Mike Levin SEO

Future-proof your technology-skills with Linux, Python, vim & git... and me!

What are the advantages of the programming language you select?

by Mike Levin SEO & Datamaster, 09/11/2013

Note: This article is heady stuff for the wanna-be-programmer. So, turn back now for your sanity and to avoid a barely graspable discussion of C-like languages versus LISP, and how all roads lead to both Python and JavaScript (sorry, Ruby/PHP). Please pass this article onto somebody you know that is trying to learn to program.

If you have a few years to spare and would like a computer science degree at the end, I will give you the complete answer to the reasonable boundaries of human knowledge. But since you probably want the answer in an easily consumed paragraph, distilling the wisdom of the ages down into pill concentrate form, I will disappoint you merely with this article, which states:

1. Your programming language choice makes a difference. It makes a BIG difference in how it predisposes you to methods, techniques, and in all manner of nuanced ways how you break down and tackle a problem. It effects how obvious the solutions to your problem may be. It effects the range of problems you can effectively tackle, and how efficient the code that gets executed is, and whether that code requires, or indeed can even be subject-to, pre-optimization by a compiler to ensure fast and safe constant execution.

  1. You absolutely can not make the perfectly correct choice for your particular situation. The reason is that right now in the state of programming, there are “flavors” of programming that give you mutually exclusive benefits, and you have to choose one or the other, or something in between that compromises on both ends. See, you may of heard of how the C-language and most of its cousins like C++, C# (c-sharp), Objective-C and the like, get “compiled”. Well, getting compiled is a desirable thing for games, hardware drivers, and operating system components.

Given Items #1 & 2 above, the best you can do is satisfy the 80/20 rule with your programming language choice: getting 80% of the benefit you’re looking for in learning to program, giving up the 20% of stuff you don’t need—but which is absolutely critical and makes all the difference to someone else with their particular (and probably very different) problem. Are you planning to program games or robust learning and self-correcting control systems? Are you planning on programming the Mobile Apps themselves or the information-shuttling API’s they connect to? These types of programming problems are actually at quite opposite ends of the spectrum. You’d use a C-like language for the former, and a rapidly update-able meta-ish language for the other.

This inability to make exactly the right programming language choice due to mutually exclusive programming language features (point #2 above) requires a ton of intellectual gymnastics to appreciate—that takes you from the “always-works” world of computers embedded into car dashboards to the “crashing on unexpected input” world of emotionally sensitive robots. In other words, I will take you from C to LISP, and land you at the end somewhere in-between (Python).

Compiled languages like C are very attractive for certain problems, because all the various ways they may run have been pre-investigated and all (most) computer-crashing contingencies accounted-for. They run ultra-fast and well—close to the maximum capacity of the hardware. Speedsters rejoice! But the flip-side of all this speed is that very little self-modifying code is possible—the sort of code-that-writes-code from where self-improving systems and emergent life-like behavior arise. So, if you’re writing in a C-like language (really, BCPL-derived languages), you’re unlikely to accidentally give rise to HAL or SkyNet. Rest assured, your C-based language programs will never have to face an ethical dilemma. But they can sure keep airplanes from crashing if you can keep the bugs out. If not, there’s Ada (more on that, later).

Okay, the flip-side of C-like compiled code? That would include all manner of systems requiring some level of introspection, or knowledge of self-state. Compiled-code advocates would tell you that you can just turn everything into program-parameters that you had previously thought-of and taken into account. This is not true. Being able to have your program write extensions to itself “from scratch” is MUCH more powerful.

In fact, the introspective ability of a programming language is so potentially dangerous and profound that it has its own programming category-name, known as meta-programming. You’ve heard of meta-data, right? Well, in a meta programming language, the difference between the instructions that your processor is to follow, and the data upon which it is to process are very similar. In the case of LISP in fact, they are identical. And you could therefore possibly even wire-up a human brain (or at least the Cerebral Cortex) from scratch, given the right type of processor nodes and the LISP programming language. Pursuing the avenue of pure meta programming is much like contemplating your own navel.

At this point, you should probably go read LISP’s champion proponent, Paul Graham, ramble on about the “blub paradox” under which you will suffer util you learn LISP. Okay? Get it? LISP and C define the opposite ends of the programming spectrum: interpreted languages versus compiled. However, the discussion becomes a bit more complex, and gives you the first inkling of the blub paradox: while LISP sits on the interpreted side of the scale in comparing computer languages, it is ALSO on the highly optimize-able and compiled side of the scale. Yes, it’s true. And if that even makes sense to you, then LISP may be for you… but you’re on your own! Oh, maybe you’ll have Paul Graham on your side.

Got it? Hold those two ends of the spectrum in your head for a moment. C for the know-it-all speedster, and LISP for the head-in-the-clouds dreamer. C for techno-dweebs to keep space shuttles from crashing, versus LISP for trying to actually raise the robot-brains to pilot future unmanned space probes. Both sides are quite hardcore, and hardly for the casual programmer, feint of heart, or hopeful sojourner through the secret knowledge of tech. For you, there is JavaScript, PHP, Ruby and Python.

…but mostly Python.

Why? In a nutshell, it goes like this:

1. Your choice of primary programming language will predispose your actions, behaviors, capabilities, and job opportunities… likely, for the rest of your life. Once you “speak” a computer language, it is very hard to change. The same single-language-speaking limitations exist in machine languages as do in the spoken word. So, choose carefully.

2. We have already established that no programming language is perfect, and that the strongest way to categorize programming languages and their relative traits are by pre-compiled versus interpreted. The line of demarcation is not totally clear between the two, and there is a spectrum of choices in between.

3. In the middle of the spectrum between C and LISP, Python is the least least perfect. It will not leave you alienated as either a bit-twiddling C-tech or a LISPy ziggurat of progressively more abstract languages that only you will understand. Python will help you make friends and influence people on a reasonable timeframe, as far as learning programming languages go… weeks to be truly productive instead of years.

Looking between both ends of the spectrum, you will also find a whole slew of other perfectly viable language choices that compete with Python. Probably the strongest, sexiest and most obvious is JavaScript—which offers a nice balance of C-like and LISP-like characteristics—and is like pee in the pool, thanks to the Web browser and Web standards. Web, web, web. It’s not always about the web. Sometimes it’s also about the Internet, or the most awesome and optimized library ever written for your particular problem, time-tested and ready to download (for free). In defense of JavaScript, sure HTML5-driven touch tablets MIGHT inherit the earth—but it just as likely you will be conversing with nearly Turing-test-passing intelligent agents within the next 10 years. And for THAT future, you don’t want yourself limited by the precepts of a [temporarily?] web-oriented world and desktop and mobile GUIs. You want to be thinking in terms of pure information i/o—more like back-end systems programming. And even though JavaScript now has node.js on the back-end, that choice is still not necessarily JavaScript. Now admittedly, JavaScript does have its good parts, and if you do choose JavaScript over Python, your prototypes and non-blocking event handling learnings will be super-useful programming models in the future. However, I believe that many other things about JavaScript (more-so than with Python) will be a liability—especially due to library dependency hell, and eventual paralysis and a forced perishable-by date on all code. ‘Dem’s fighting words, I know. But I tried both JavaScript and Python, and I have only come to truly love the later.

Okay, so what about Ruby? After getting through all the pro-arguments of forced-object-orientedness and gem-riches, and all the stupid one-liners that sell Ruby, you just find something profoundly similar to Python but more restrictive, and fewer time-tested optimized specialized problem-domain libraries (like NumPy and SciPy) at your fingertips.

PHP, then! Everyone knows WordPress and Facebook were written in PHP, right? So it must be awesome, right? Instead of telling you why this isn’t so, I’ll tell you that Java isn’t all it’s cracked up to be either, and if you’re not SPECIFICALLY taking up Android app development, steer clear! Oh, and don’t even get me started on Microsoft finally finding religion and making the awesome platform of .NET, then making it useless in the world of instantiating thousands of node instances due to it’s massive footprint, monetary cost, and licensing requirements. As viable as .NET may be, costly proprietary and licensing restrictions are not.

Finally, then we must look at the sexiest thing of all: Objective-C and the Angry Birds / Instagram billionaire lottery of the App Store… and get past it. Then, and only then, will you stop to contemplate the humble but critically awesome offerings of little ol’ Python.

So what-the-F is it about Python, then? Although it is interpreted, it clearly falls on the compiled-C side of the spectrum, with extreme  predictability and clarity of how a program is likely to run. Emphasize UNDERSTAND-ABILITY—a trait equally appealing to the beginner and advanced programmer alike. How is Python compiled if you never run a compiler? Like many other pseudo-compiled languages with intermediary “p-code” for virtual machines (more on that later), upon first execution the Python code gets examined and compiled, and the compiled version actually dropped into the same directory as your original un-compiled source code text file. From that point forward, calls to that program will instead of being interpreted, execute in a compiled fashion—unless of course, Python detects that the source code has been modified, in which case it will re-compile. That’s nice about Python, but is far from unique to Python. The unique stuff is in the code formatting.

Python’s imposed code formatting requirements (which I’ll describe in a moment) makes it uniquely humanly readable, compared to C-like languages. So, Python is very C-compiled-like, but in the actual programming process… the workflow… the typing into a text editor and immediately running the program with no compiling step… feels VERY MUCH like an interpreted language, and therefore feels more understandable and accessible than C. This is SO IMPORTANT for a beginner. When you actially sit down to write some Python code, you can slam out a Hello World program in about 2 seconds without the mental gymnastics of EITHER end of the spectrum (Hello World is harder in both C and LISP than Python).

So, what about the LISP-like meta capabilities of Python? Python slips in some meta-introspection tricks that will serve you well through your career, and let you do things that would be enormously difficult for the C-folk… but old hat to LISPers. In other words, while Python allows fairly powerful introspection and anonymous functions to achieve both functional programming advantages (with lamda functions if you REALLY want them), and machine-learning-like code execution with the eval statement and other tricks when you want them. So, Python favors easy, stable-systems without entirely shutting you out of the meta-fun. So, if you want to learn a C-based language, but don’t really want to learn a C-based language, then you want to learn Python.

Then the main things you need to know about Python, is that it has the ease-of-use of a beginner programming language. It is not littered up with syntactic candy, like {curly-braces} and code-blocks (the logical grouping of lines of code) is achieved with INDENTING—which flies totally in the face of all modern programming convention… and makes all the difference. There are tiny other differences between Python and other languages… like the forced elimination of anything mysterious, due to how its clever tenant of “convention-over-verbosity” combines with its equally clever tenant of “verbosity-over-ambiguity”. The result is beautiful, readable, write-able, understandable, share-able code that everyone who REALLY looks at it eventually admits to loving—and which can be hot-spot optimized at will and over time… in C!

This all makes it the perfect language for 3 categories of people:

  1. Beginners
  2. Advanced programmers
  3. Teams of either or both of the above

For the rest of my opinion on Python, just Google python advantages. I’m usually at-or-near the top.