The two best programming languages that nobody uses

A language that doesn’t affect the way you think about programming, is not worth knowing.

Alan Perlis, “Epigrams on Programming”

Today I want to talk about two underdogs of programming languages. If you have only ever worked with object-oriented, C-family languages like Java, C# or JavaScript, these will definitely change the way you think about code.

LISP

Any sufficiently complicated C or Fortran program contains an ad hoc, informally-specified, bug-ridden, slow implementation of half of Common Lisp.

Philip Greenspun

LISP is the second oldest high-level programming language. It was designed by John McCarthy in 1958 to prove that a Turing-complete language could be built using a few simple elements based on a mathematical model of computation. Garbage collection was invented for LISP.

What’s so great about it?

The syntax. It’s simple and minimalist. Once you learn the very few syntax rules, you can forget about syntax forever and save your brainpower for learning the functions and libraries that you need to do stuff.

A hello world web service looks like this (copy and paste in DrRacket):

#lang racket
(require web-server/servlet
         web-server/servlet-env)
 
(define (start req)
  (response/full
   200
   #"OK"
   (current-seconds)
   #"text/plain"
   empty
   (list #"Hello world")))
 
(serve/servlet start)

Everything is functions calling functions. The fundamental data structure is the list. Lists go between parenthesis and by default they are evaluated as function calls, where the first element is the function name and the rest are the arguments. Code is also represented as lists so LISP can read and generate code as data.

Then why nobody uses it?

Saying that nobody uses LISP is a bit of a troll. Lots of people use it and love it, but it’s far from mainstream. The 2022 Stack Overflow Survey has Clojure as the most popular dialect at the 32th position, with only 1.51% of developers reporting to use it.

The syntax is LISP’s main advantage and often it’s downfall. It can be too minimalist and you can get too smart with it. For example, here’s one Fibonacci implementation in Racket. Can you immediately tell how it works?

#lang racket

(define (fib n)
  (car (foldl (lambda (y x)
                (let ((a (car x)) (b (cdr x)))
                  (cons b (+ a b)))) (cons 0 1) (range n))))
The letters are Elvish, of an ancient mode, but the language is that of Mordor, which I will not utter here.

The parenthesis are off-putting for a lot of people. You’ll be reaching for that Shift key a lot and it’s easy to get lost in them. Comments, code formatting and a good IDE can help.

Where can I start?

If you want something production-ready, go with Clojure. It runs on the JVM, so it’s fast and has access to the vast Java ecosystem, besides its own quality libraries. Robert Martin is a big fan. It is used in some big corporations like Apple and Netflix, and while there might not be as many jobs as with Python, Clojure is the top paying language in 2022. For learning head to https://www.braveclojure.com (but feel free to skip EMACS, instead use Visual Studio Code with the Calva extension).

You can also check out Racket. It is very nice. John Carmack has spoken highly of it and even taught his son to program Racket. But while some people have used it for production stuff, it’s more geared towards education, research and small applications.

Smalltalk

I made up the term “Object-Oriented”, and I can tell you I did not have C++ in mind.

Alan Kay, OOPSLA 1997

Smalltalk is the original gangster of object oriented programming and one of the most influential languages in history. It pioneered the use of virtual machines, graphical IDEs, design patterns—MVC was invented in Smalltalk—agile methodologies and test driven development.

When Steve Jobs and a team of Apple engineers visited Xerox PARC in 1979 to steal ideas get inspiration, and they saw a GUI that blew their minds and revealed them the future of personal computing, that GUI was Smalltalk.

What’s so great about it?

The syntax. It’s simple and minimalist. And easy to understand! It was in part designed for children.

A hello world web service looks like this (copy and paste in a Pharo Playground):

(ZnServer startDefaultOn: 8080)
	onRequestRespond: [ :request |
		ZnResponse ok: (ZnEntity text: 'Hello World') ].

In Smalltalk everything is objects communicating via messages. In fact the big idea is messages: every object is like a mini computer that can only communicate with others through messages. There is no public, protected, internal, protected internal or private protected madness in Smalltalk.

This elegant model has been praised by a lot of people. Some studies have shown that Smalltalk is one of the most productive programming languages, and even functional programming stalwarts like Scott Wlaschin have a soft spot for object oriented Smalltalk.

Then why nobody uses it?

Smalltalk was actually popular in the early 90s. It became the second most popular language behind C++, and IBM bet the future of the Internet on it. But while there are still some big users, today it really is a niche language. It doesn’t appear in the 2022 Stack Overflow survey and you will hardly find any jobs.

The problems with Smalltalk were various. In the past performance was an issue, but that didn’t stop Python from becoming popular. I would say the biggest problem today is the lack of commercial support which has resulted in poor environments with bugs, no hardware acceleration, green threads, poor integration and a lack of libraries.

Smalltalk is also a virtual machine, development environment, operating system and an entirely alternate vision of computing developed by Alan Kay, Dan Ingalls, Adele Goldberg and others at Xerox PARC. This model is alien to most developers today.

Where can I start?

Check out Squeak. It’s a direct descendant of Smalltalk-80 first developed at Apple Computer in the 90s.

There is also Pharo, with the stated goal of enabling commercial and mission critical applications. But after three major versions it still doesn’t properly support HiDPI, everything looks blurry in my screen. For that reason alone I can’t recommend it.

Turtles all the way down

The common theme to LISP and Smalltalk is the uniform application of a small set of simple and elegant concepts to build a complex system. Don’t let this simplicity fool you into thinking that these are primitive, old languages: they are very high level, even more that Python.

There are no for loops or if-else statements in LISP. You call functions which call other functions.

In Smalltalk you send a message to a number or boolean object. Smalltalk has six reserved words. Six. And with this everything is achieved. Compare that to most languages today which have hundreds of reserved words and operators, and thousands of syntactic rules, and you will wonder when things went off the rails.

Published by Orlando Ramírez

Software Engineer. Munich, Germany. https://www.linkedin.com/in/orlandoramirez1

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: