How to begin

What first programming language should learn a wannabe programmer?

When I was a beginner, we were supposed to build our computers ourselves: layout and make the board, buy the chips, solder them on the board, test and debug the hardware, organize a ROM with some operating system… When we were ready, we could turn on the PC and have two possibilities to develop anything on it: either entering machine codes, or use the built-in BASIC. So, these were the two programming languages I’ve learned first, in parallel.

My first commercial software was a teaching aid for physics lessons and was written on BASIC. I’ve sold it 20 years ago, in 1992, for 50 roubles. The very cool aspect of BASIC was the ability to program something in a reasonable time frame, and immediately see how the program works line after line of typing, which has a reinforcing effect on the motivation of a beginner programmer. On the other side, the cool aspect of machine codes was the fun of working with electronics. I can’t explain it reasonably, but at that times I had enormous fun manipulating bytes and bits in some CPU registers, and observing some effect (such as lightning of a LED) in the hardware. This was something magical. The advanced high technology, staying directly here, on my old table in an otherwise very low-tech room. There was an understanding gap though: I didn’t know how the BASIC statements exactly relate to the machine codes. I know BASIC eventually ends up being machine codes, but didn’t exactly know how and believed it is so complicated I can’t learn it in a reasonable time.

Later, times changed (as they were continuiously changing every couple of years or so), and I’ve learned and used the Clipper programming language to write various enterprise information systems. That was quite a cool language: it had code blocks (also known as closures), untyped arrays aka structs (ala modern JavaScript) allowing to have some basic OOP, and a very beautiful syntax. To program a text box in a form with validation, you’d just write

@ row, col SAY "FirstName:" GET firstname VALID !empty(firstname)

You won’t get it shorter and prettier with any modern mainstream UI language. Clipper also had statements to work with a NoSQL database as first-class concept, and supported multiple styles of programming (ala Perl and Python), so that it is pity it is so completely dead today. In fact, I’m very lucky that this was my third language, because it has gently introduced me to structural programming, to functional programming (code blocks!) and basics of OOP, without looking like “rocket science”. Unlike the modern functional languages who hit you with a hammer by speaking about type systems, monads and other useless academic stuff, Clipper was able to introduce me practical advantages of using these approaches.

Clipper has died, because it didn’t support the new graphical user interface Windows 95 has introduced at those times to the wide public. I had to switch, and my next language was Delphi. For some reason beyond of understanding, at those times I had enormous fun dragging and dropping UI components such as buttons and text boxes onto forms and so visually programming the modern GUIs. I didn’t understand much about user experience at that time, so that wasn’t the joy I feel today when creating a new wireframe or mock-up. The very notion of visual programming was fun. It was so high-level, so rapid software development comparing with the manual coding of forms on Clipper, that it felt as if I were on a roller-coaster. Delphi has introduced me to basic Windows concepts, and because this time that was a slightly more complicated enterprise information system, I’ve used a SQL database, so I could learn the world of relational databases and SQL in particular.

This was the time when I’ve graduated and started my first “freelance” projects. Delphi was a limiting factor though, because it was almost always used only in enterprise information systems. So I’ve switched to C++Builder, which had the same framework (GUI, collections, databases, etc), but was based on C++. With C++ knowledge, I’ve figured out that I could find the way to all kinds of projects and escape from the world of enterprise software. I’ve had hard times making C++ to work for me though. This is exactly the sort of language I didn’t get very well, having syntax so unlogical you could think it is sort of a natural human language, pretending to allow for abstraction level but failing and leaking from all its abstractions, the only language I know whose fans don’t find the very existance of Sutter and Alexandresku with their books and lessons strange. From my current perspective, I would prefer using GLib Object System, if I were for some reason fancy using OOP in a performance-critical app. Nevertheless, I don’t regret learning C++, because it has made me think (for the first time) about programming language designs, and it made me so desperate that I went ahead and tried other programming languages. A whole lot of them. In a merely half a year, I’ve checked out Prolog, ML, Ocaml, Clean, Scheme, Haskell, Eiffel, Perl, Erlang, VB6, Java, and Smalltalk. The latter I loved almost instantly, because it was almost the full opposite of C++ — extremely simple and beautiful syntax, real abstractions, very safe and user-friendly, allowing multi-paradigm, and relatively slow (still quicker than the modern JavaScript though).

I was fortunate to find a job on Smalltalk, and learn from a Smalltalk guru and coincidentally one of the best programmers I’ve ever met, and this experience has changed me forever. Not only I grasped OOP (which was almost destroyed in me by its C++ version), I also understood how OOP fits in the landscape, and what software architecture is all about. Smalltalk is the only programming language I know that is so fun to use and to type. It is like hearing a song that gives you creeps. Or meeting with a guru.

Later I’ve switched to .NET web development, which is basically C#, MSSQL, HTML, and JavaScript. The C# in .NET 1.1 seemed to me quite under-developed (especially after having experienced Smalltalk), but was improving rapidly, and peaked in .NET 4 to be enjoyable and quite productive language. Too bad Microsoft has almost decided to dump it in favor of the horrific C++. Coincidentally, I’ve started to develop myself away from programming, so that I didn’t care that much about the language and the frameworks.

Currently, when I program, I use pure C in an embedded environment. This is fun on its own. My typical task is to understand, how exactly

var mystring = "abc";

in JavaScript gets first allocated in the WebKit’s JavaScriptCore VM, and if VM needs to call FastAlloc to get this memory, how it is represented in its managed space, and if FastAlloc must bump sbrk or use mmap to get more memory from Linux, how exactly Linux would book keep this additional virtual memory, and if this virtual memory will be in fact used, how exactly Linux is going to handle the minor page fault to allocate physical memory, and if free physical memory pages are scarce, how exactly Linux would use kswapd to free up the memory by swaping out least used pages into the swap. This has almost nothing to do with what I did in the last 20 years, and even though it is not like learning a new programming language, it is still learning new concepts and software designs. And this is sort of a filling the gap between BASIC and machine codes, the gap I’ve mentioned at the beginning of this long post.

Learning. This is what you are going to do as computer programmer. Like, not learning two or three languages and be happy forever. This won’t happen to you. Well, I mean, hopefully not. You want to be more than just a computer programmer, don’t you?

So, does it matter then, what first language should be learned by beginners? Well I think yes, in fact it does matter. I believe, you need to start learning with two languages at the same time. The one language should be low-level, bit and byte manipulation on hardware or OS level. It will save you from embarrasment of not understanding how pointers work, or what a variable declaration in high-level languages in fact does behind the scenes. I’d say this language should be an Assember or C, and not C++. The other language should be very high-level, allowing you to quickly unlock your first achievements. But it also should be multi-paradigm and able to demonstrate you various styles of programming. I’d said it should be Smalltalk if it wasn’t so inpractical in the current situation. Well, perhaps JavaScript (including Node.js) is what you’re looking for… Yes, this combination is crazy enough to work out. Start with C and JavaScript, and be on the lookout for your next languages you’re going to learn (hint: it shouldn’t be C++ either. C++ will eventually find and kill you and eat your mind anyways, so don’t be a fool and don’t seek for the meeting yourself).

Leave a Reply

Categories

Archive