Reconsider Learning Python First

Don’t Mess Up Your Brain

Rob Muhlestein
5 min readJul 27, 2018

After teaching and advocating Python as a first language for the last five years, I’ve decided to drop it for beginners. My students will literally shake their head and mutter something under their breath. Here’s my justification.

Languages Shape Your Thinking

In the movie Arrival the hero, a linguist, saves the day by being so good at languages that her brain gets rewired, so to speak. I won’t spoil the rest except to say that by learning the alien language she literally gains an unexpected superpower. This appeals to me having learned both French and Russian (my major) and teaching these languages to others as well as teaching computer programming languages. I fully believe an aptitude for syntax and prose, be it spoken or code applies equally.

Python Gives You a 90s Brain

Look, I coded most of my professional life with a 90s brain. I was raised on imperative and later object-oriented programming. Hell, I gave presentations about the “new” Java language to packed auditoriums of hungry programmers wanting to see the new thing that would change their programmer lives. That is why I can tell you going through the transformation to modern 2020 thinking is so important and relevant.

Modern programming requires functional, event-driven thinking preferably combined with an understanding of when object-oriented, imperative, and procedural paradigms can serve you as well.

This is also why it is so crucial to always be learning new languages, even esoteric ones, to maintain your programmer brain fresh and relevant over the course of your career.

The 90s Called, It Wants Its Paradigms Back

Everyone was coding using imperative paradigms and the new hottest idea in the world: object-oriented programming—specifically using strong, single-inheritance such as that still required by Java (and the completely out-dated AP Computer Science exam).

Python was created during the 90s at the height of this imperative and object-oriented craze. Python had OO tacked onto it covering the use of simple dictionaries underneath (exactly like Perl, just more elegantly). Python is NOT an OO language at the core despite what all the textbooks say, not in the way that C++ or Java or Objective-C at least.

Brendan Eich’s Revenge

From my perspective the only people doing functional programming in the 90s where MIT Scheme and LISP programmers. They were in a universe all their own and—although they were ahead of their time—were definitely not mainstream. Brendan Eich was one of them.

It really didn’t seem like any practical usage for functional programming paradigms existed except in very isolated cases. I suppose this was because computers where still single CPU and not a lot of multi-threaded code would actually provide any solid benefit because it still had to use a single CPU.

Around that time Brendan Eich released LiveScript to the world while on the Payroll of Netscape corporation. Later, for marketing reasons, an executive made him change it to (the completely stupid) JavaScript.

Brendan was one of the first modern programmers to face a serious concurrency requirement while being constrained to a single CPU, doing a bunch of things at the same time. Because of this, LiveScript, from the first day, was better suited to the needs of modern computing with 4 or more CPUS, threads, coroutines, asynchronous patterns and more.

You could say LiveScript (that we all hated because of how stupid it was for what it was used for then) was the first modern mainstream language. (And yes, my younger self would have laughed hysterically at my current self for saying so.)

Looks like Brendan get’s the last laugh. His creation has become arguably the most important language in the world today and for the foreseeable future.

Objects, Cloning Over Classes

Every language has some notion of objects, even if they are not called that or are limited to primitive objects that are built into the language (like strings, which are composed of characters, which are composed of bytes, which are composed of bits).

One of the most novel things about JavaScript from the first day it was released is the idea of objects being hashes, associative arrays, maps or whatever moniker you prefer. The idea that every hash is automatically an object was consistent with Perl and Python at the time as well. JavaScript’s notion persisted, however.

Python covered over the simple hashes with a bunch of syntax sugar making it really object-oriented, but specifically class-based. I believe that was one of the biggest mistakes of Python (and we see it repeated somewhat in the ES6 class keyword addition in JavaScript today).

Java and C++ warped our brains with the idea that objects must have a class specification, like you can’t have cookies without a cookie cutter, or you can’t have a construction without a blueprint and “constructor.” But in requiring classes you add an immense amount of wasted, bloated required syntax. More importantly, however, you codify the notion that things cannot exist unless a plan for their existence is first laid out in stone, never to be changed. This is not how the world works. Nor is it how the future of programming will work.

Dynamically Changing Methods of Functionality

Our natural world is based on the idea of objects learning and changing their methods of doing the same thing. It follows that any programming paradigm reflect this ability—particularly with the present and future AI needs.

Class object-oriented ideas impose a static limitation on the code that behavior shall NOT change. In Python you actually can have a property be a reference to a function, but it is not immediately evident.

“Monkey patching” as allowed easily in JavaScript has been accused of being a horrible thing because the behavior of a method may change over time. Critics are usually biased with OO class-based encapsulated thinking.

In a functional world, swapping out the function that returns the same type of thing is not only ok, it is encouraged. Changing the implementation of that function can happen freely and frequently, it can even be dynamically generated allowing AI to detect better methods, even create them on the fly, and change the method of the function as needed by the usage of the program.

That is huge. In fact, it is the basis of all modern and future computer science where things that were static before are fluid and constantly adapting and improving.

Python Lacks Multi-Line Anonymous Functions

The single biggest fail of the Python language is the lack of truly anonymous functions. It forces class abuse and singletons just to implement dynamic methods.

This is inadequate to do modern programming. In fact, this one fail is enough almost entirely for me to throw out the whole language for beginners. It completely blocks learning the concept of first-class functions by forcing every function to be defined using the def keyword.

When a student sees a JavaScript function assignment they automatically understand that it can be treated just like any other thing that can be assigned to a variable or a constant—including the notion that a given operation can have its method (function) reassigned to something else.

Based on this I’ve decided to teach JavaScript and Go first then Python when they are ready (and willing) to learn data structures, algorithms, data science, and systems monitoring and automation. I wonder if this is the same reason Harvard chose to teach C before Python in the same CS50 course.

--

--