Professor Beekums Blog


Follow Professor Beekums
follow professor beekums on twitter add the professor beekums rss feed

User Experience in Programming Languages

When we talk about UX, we often refer to the UX of the products we build and use. We want our products to be easy to use. Interactions should be quick. Mistakes should be easy to recover from. These things are also good to have in the tools we use to build software, especially programming languages.

I’ve worked in a fair number of languages: Java for almost 15 years, PHP for 8, Javascript for 8, and dabbled in a few others like C# and Go. By far my favorite language is Python, which I’ve only used for the past couple of years.

The reason is that Python simply provides a superior user experience for the programmer. When I write code in Python, I fight programming problems alone. I’m not also fighting the language (hello Java/PHP).

The first point is that the syntax is a lot clearer.

	for item in myListOfThings:
is just much more readable than

	for( let item in myListOfThings ) {
or:

	for( Item item : myListOfThings ) {

Another example:

	if isThisTrue or isThisOtherThingTrue:

is more readable than

	if ( isThisTrue || isThisOtherThingTrue ) {

There is of course a bias in people who speak English in this advantage of Python. Yet, reading and writing is something most people have been doing since a very young age, usually much earlier than when they learned to code. Cutting down on symbols not used in everyday communication and replacing them with words makes it much easier to read what the code is doing.

The next point is the dynamic typing in Python. I used to be very skeptical of dynamic typing being “dangerous” (Java was my first language), but it does make writing code a lot faster. While typing out types like

	boolean someFlag = true

isn’t a big deal, trying to get a nested map in Java will usually result in something extremely difficult to read:

	Map<String, Map<String, List<String>>> 
		myNestedMap = new HashMap<>()

Go only makes this marginally better:

	var myNestedMap = 
		map[string]map[string]string{}

This is also compounded by the fact that so much of what I do involves JSON. Decoding/encoding JSON in Python/PHP/Javascript takes seconds. Doing the same in Java/C#/Go takes a hell of a lot longer, and it only gets worse if you need to refactor.

Granted, static typing does allow for more optimizations, but I personally don’t work with software that actually needs those optimizations. It’s often more sensible to throw money at the problem instead of spending development time.

Yet, like all good UX, Python reduces the costs of one of the most common mistakes made in dynamically typed languages: adding things.

In PHP/Javascript, 1 + 1 could easily be 11 or 2. Each dynamically typed language has their own rules for handling this and you could learn those rules to work around it. Or you could just remember to cast things as strings or ints to force the behavior you want. Or you could be tired one day and forget, creating an opportunity for a hard to find bug.

Python will remind you that you’re doing something ambiguous. Attempts to add a string and an integer result in an error. You’re forced to make a conscious decision in the one case where you almost always want to make that decision anyway, eliminating a simple but very easy mistake to make.

Another phenomenal feature are keyed parameters. For example, this is a function call in PHP:

	someFunction($param1, $param2)

I can tell you from painful experience that many PHP libraries/frameworks like to refactor the order of things. You have to go through and find every function call and make sure the order is correct when you update those libraries. Forgetting even a single instance produces really confusing bugs.

Python provides the option to name your parameters when calling them:

	someFunction(param1=param1, param2=param2)
You can change the order of those parameters in the function definition all you want, the calling code will still work as intended.

This not only makes updating easier, it makes refactoring your own code easier AND it provides some nifty documentation as well. When reading other people’s code you don’t have to go to the function definition to see what parameter is in what place. It’s all listed for you.

I don’t think any single one of these features is unique to Python. What is unique is the combination of all of these features into a single language with a great experience (and there are definitely other great things about Python). With Python I spend more time solving interesting problems and less time banging my head with frustrating ones. I’ve never built software as fast and with as few bugs as I do with Python.

P.S. I know I’m about to get a bunch of hate from Python programmers going “You’re not using PEP8 in your examples! You suck as a Python programmer!”

Consistency is important in cross language examples.

P.P.S. I actually hate Python’s documentation and the docs for most Python libraries. It’s simply abysmal. It’s written like no one is actually expected to look at them. Just read the source!

Java probably still has the best documentation out of every language I’ve used.

share on twitter share on linked in share on reddit share on facebook
Hi there! I hope you enjoyed this post.

I keep this blog around for posterity, but have since moved on. An explanation can be found here

I still write though and if you'd like to read my more recent work, feel free to subscribe to my substack.