Google-programming Considered Harmful

Sun, 06 Dec 2020 00:57:43 -0800

Tags: technical, education


Perl has been my to go language for scripts that need to be written fast and only executed once. I have become very effective writing Perl one liners that do things such as computing the most frequent URLs in Wikipedia:

bzcat enwiki-20180901-pages-articles-multistream.xml.bz2 | \
  perl -ne '@a=split(/http\s?\:\/\//,$_);@a=map{s/\/.*//;s/\|.*//;$_}@a;shift@a;print join("\n",@a)."\n" if@a'| \
  sort|uniq -c|sort -n|head

(Using a parallel implementation of BZip2, that takes about 5', the most popular websites are factfinder from, BBC and, in case you were curious.)

But that wasn't always the case. The thing with Perl is that I remember very well when and how I learned it. It was the year 1999, I had just started my PhD. The topic was information extraction on biomedical texts using statistical techniques. We were processing ten years of the journal from the European Molecular Biology association. Coming from my undergraduate thesis using Haskell for parsing Spanish texts, I started doing detagging using Haskell. That didn't work fast enough. My other choice was Java but by then I was behind on the work. I needed something fast to code and show results. My advisor at that time, Dr. Hatzivassiloglou (which was actually my second advisor and not my thesis advisor, I think that deserves another post in some moment) was very keen on Perl so I decided to learn the language of the camel.

To learn it, I got two books: Learn Perl in 24 hours and Effective Perl Programming. One was the quick intro to get going while the other deal with more obscure advanced topics. With the basic book, I was hacking Perl furiously by the end of the week and with the advanced book I managed to write more complex integration scripts. By the end of my PhD I had put the 10,000 hours and was very proficient in the language, a skill that remains to this day.

The path Book => Practice => Mastering has been with me ever since, for the few new languages I picked since then (Scala, Python, Elm, node.js).

These days, I'm learning Go and I'm trying to avoid the problem that has plagged my Python learning (I also started learning Python by reading a book but things went south from there).

It has to do with Google-programming, the practice of doing web search upon web search to build the code. This is way of programming works and gets the job done. But I find it ineffective. This post discusses my thoughts on the topic.

Why I find it ineffective?

  • It involves a mindset change, going from "speaking programming in my head" to "speaking English in my head", that gets me out of "the flow".

  • The example code found online needs adaption to the codebase I'm writing. This adaptation can be quite onerous, again taking the concentration away from what I'm coding.

  • Example code in the Web might have security and/or stability issues introduced by the very nature of simplifying the code to fit an example.

  • Leaving the IDE into the Web browser exposes you to be ambused by well trained algorithms intent of stealing your attention away. Those advertisements you will see will be very relevant to you and might derail your thought process for a long time.

  • This is a minor issue for most people buy it leaks information to the world and uses a lot of traffic and resources, both at Google and the target websites such as Stack Overflow.

  • Most importantly, the learning doesn't happen in the form of "programming need -> code structure" but instead in the form of "programming need -> Google query". This is not a minor issue. Google-programming makes you dependent on using Google over and over again. It makes programming off-line impossible, which is something desireable for a variety of reasons (long travel, living in areas with spottin internet, going off-the-grid to concentrate in a complex piece of code).

As such, for Golang, I'm trying something else. I again, started with two books (Go in Action and The Go Programming Language, great books, highly recommend them). Then I'm using Google-programming to bootstrap working examples (you can see one here) and then stopping the temptation of Google-programming new code but instead searching on my existing code base for working examples (that originated from google programming).

By the way, I'm not saying that searching in Google is bad for learning to program or that there is no space within the programming craft for doing web searches. The consensus seems to be clear that you are not a bad programmer if you do. My points here might also be a generational issue. Other people seem to be fine with Googling (but I wonder how that author would have behaved to having to program a second Netty server). There is a quote in there attributed to Albert Einstein 'Never memorize something that you can look up'. I don't think that applies to what we are talking about here. Einstein used some heavy tensor mathematics in relativity. I don't think he would advocate to people not taking such tools as innate. But as everything in life, YMMV!


Your name:

URL (optional):

Your e-mail (optional, won't be displayed):

Something funny using the word 'elephant' (spam filter):

Your comment: