How I do my ComputingHow I do my Computingwww.stallman.orgProgramming languages

  • The most powerful programming language is Lisp. If you don't know Lisp (or its variant, Scheme), you don't know what it means for a programming language to be powerful and elegant. Once you learn Lisp, you will see what is lacking in most other languages.

    Unlike most languages today, which are focused on defining specialized data types, Lisp provides a few data types which are general. Instead of defining specific types, you build structures from these types. Thus, rather than offering a way to define a list-of-this type and a list-of-that type, Lisp has one type of lists which can hold any sort of data.

    Where other languages allow you to define a function to search a list-of-this, and sometimes a way to define a generic list-search function that you can instantiate for list-of-this, Lisp makes it easy to write a function that will search any list — and provides a range of such functions.

    In addition, functions and expressions in Lisp are represented as data in a way that makes it easy to operate on them.

    When you start a Lisp system, it enters a read-eval-print loop. Most other languages have nothing comparable to `read', nothing comparable to `eval', and nothing comparable to `print'. What gaping deficiencies!

    I skimmed documentation of Python after people told me it was fundamentally similar to Lisp. My conclusion is that that is not so. `read', `eval', and `print' are all missing in Python.

    Some fans of Clojure say it is a variant of Lisp. I disagree, because it lacks one of the fundamental features of Lisp: cons cells, out of which we construct lists.

While I love the power of Lisp, I am not a devotee of functional programming. I see nothing bad about side effects and I do not make efforts to avoid them unless there is a practical reason. There is code that is natural to write in a functional way, and code that is more natural with side effects, and I am not a partisan of either way. I limit my campaigning to issues of freedom and justice, such as the injustice of nonfree software.

Lisp is no harder to understand than other languages. So if you have never learned to program, and you want to start, start with Lisp. If you learn to edit with Emacs, you can learn Lisp by writing editing commands for Emacs. You can use the An Introduction to Programming in Emacs Lisp to learn with: it is free as in freedom, and you can order printed copies from the FSF.

You can learn Scheme (and a lot of deep ideas about programming) from Structure and Interpretation of Computer Programs by Abelson and Sussman. That book is now free/libre although the printed copies do not say so.

Please don't buy books (or anything) from Amazon!



  • My favorite programming languages are Lisp and C. However, since around 1992 I have worked mainly on free software activism, which means I am too busy to do much programming. Around 2008 I stopped doing programming projects. As a result, I have not had time or occasion to learn newer languages such as Perl, Python, PHP, Ruby, Lua, Go, Scala, Rust, and so on. Therefore, I don't have an opinion about them as languages.

    If I were not so overloaded with responsibilities and work that is important to me, I would study them out of curiosity. But that is not likely to ever happen.

    If you want to learn C, but you already know how to program in some other language, I recommend you try my GNU C Language Introduction and Reference Manual.

    I read a book about Java, and found it an elegant further development from C. But I have never used it.

    I did write some code in Java once, but the code was in C and Lisp (I simply happened to be in Java at the time ;-).

  • By contrast, I find C++ quite ugly.

    The flaws of C++, as I recall from when I studied the matter around 1990, include syntax and semantics. As for syntax, its grammar is ambiguous, and it is gratuitously incompatible with C, which blocks the smooth upgrade path from C to C++.

    As for semantics, the abstract object facility of C++ is designed around the case where the real type of an object is known at compile time. However, in that case, abstract objects are equivalent to a naming convention for functions to call. The case where abstract objects add real power to a language is when the type is not known until run time. C++ does handle that, but it seems to be an afterthought, a poor relation.

    I suspect that I would find plenty of ugliness in the template library, but I don't know. That was added to C++ after I studied it.

How to learn programming

First, read a textbook about programming in some language, then manuals for several programming languages including Lisp. If they make natural intuitive sense to you, that indicates your mind is well-adapted towards programming.

If they don't make intuitive sense to you, I suggest you do something other than programming. You might be able to do programming to some degree with a struggle, but if you find it a struggle you won't be very good at it and you won't enjoy it. What's the point of programming if it is a struggle instead of a fascination? It's your choice -- if your brain is better suited to some other activity, you could choose that instead.

After that, you need to read the source code of real programs (or parts of them) and figure out what they do. Then start writing changes in them, to add features, or fix bugs if you can find out about specific bugs to fix. Ask some good programmers who are familiar with the code of those programs to read and critique your changes.

If you fix bugs in a free program that others are developing, the developers are likely to be glad to get fixes from you and will tell you the way to write them to make them good to install. Look at their TODO list for features they would like to add, and implement some. You will find it is a great satisfaction when the developers incorporate your changes.

Do this over and over and you will become good at developing software.

Please use your programming capability only for good, not for evil. Don't develop nonfree software, or Service as a Software Substitute. Design systems not to collect personal information, and to allow anonymous use.



  • I find it bizarre that people now use the term "coding" to mean programming. For decades, we used the word "coding" for the work of low-level staff in a business programming team. The designer would write a detailed flow chart, then the "coders" would write code to implement the flow chart. This is quite different from what we did and do in the hacker community -- with us, one person designs the program and writes its code as a single activity. When I developed GNU programs, that was programming, but it was definitely not coding.

    Since I don't think the recent fad for "coding" is an improvement, I have decided not to adopt it. I don't use the term "coding", unless I am talking about a business programming team which has coders.

  • Why I coined the name POSIX.