Beyond Javascript: 5 Programming Languages That Will Rewire Your Brain (Part 1/5: C)

Manuel Odendahl - Apr 27 '22 - - Dev Community

So you know Javascript, and maybe Typescript, and you wonder what's next. You might ask yourself: how can people write these elegant frameworks, how do they come up with the idea to build Node, how can they understand networks and distributed systems so well? Often, it comes from knowing many different paradigms and fundamental concepts of computer science, and combining them in new ways to make them work for the web.

There is no better way to learn new paradigms than being fully immersed in them because they are at the core of the language you express yourself in. There is a lot of speculation that language shapes the way you think. While it might be true for human languages, it definitely is true for programming languages.

Here is a list of the languages that I have learned over the years. Some I have used extensively, some are things I picked up but never used professionally, but they all significantly changed the way I think about programming.

Please note that each of these languages takes a long time to really be proficient with. Don't just do 2-3 tutorials and think that that was enough to rewire your brain. You need to dive into the unknown, do a chunky project without guidance, hit your head against the wall a few times in order to really make those new neuron connections. For each language, I will give a short list of project ideas that I think are both fun and instructive.

C

C is getting a lot of flack about being insecure, but it is a marvelous language to learn.

CPU - courtesy wikimedia

Learn C, it's great!

Why do I think that C is a great language to learn next:

  • it is close in syntax to Javascript
  • it is available on literally every platform, from a 1 kB of memory microcontroller to the biggest supercomputer
  • it teaches you a very useful abstraction of the hardware
  • it is the glue of every operating system and shared library.
  • it is small and fast. Often, it is the benchmark every other language runs up against
  • you will understand how many exploits and security bugs work
  • you can use it to program microcontrollers and build physical devices

Get close to the CPU and the operating system

In C, you have full control of the memory, and a fairly close mapping of the code you write to what the CPU is actually going to execute. Furthermore, the way you call functions in C is the way any programming language has to call functions that are not written in the language itself, like operating system functions. For example, node's magic comes from how it binds javascript to operating system functionality, in C. Similarly, the linux kernel is written in C. Learning C will get you half of the way to programming your own system tools, shared libraries and kernel drivers.

Why C and not Rust?

I think C is a much better systems language to learn after Javascript than Rust, even though Rust has many more interesting ideas and addresses a lot of shortcomings of C. It however makes it much harder to understand how your program and the resulting binary relate to the CPU and operating system. Once you know C, so much of Rust will make a lot of sense, and you can focus on the features that make Rust great.

Resources to learn C:

Timeless Books - CC/A Lin Kristensen - Wikimedia

I learnt C in the 90ies on a small linux computer (486 with 8 MB of RAM), and it taught me a lot about unix, network programming, memory layout, linkers, compilers. C has changed a lot since then, with the newer C99 and C11 standards. I recommend learning C in combination with the following language (assembly) by using a site like godbolt which allows you to see how your C code compiles down to assembly (we will come back to that in the next post in this series).

While I don't have a list of good resources to learn modern C (there are quite a few books out there, I have never been disappointed by Manning: Modern C. The resources that shaped my own way to C were: Advanced Programming in the Unix Environment and Unix Network Programming. And then much more importantly, and shaping my aesthetics until today: C Interfaces and Implementations and DJB's software. I can't stress the latter one enough, as it shows you how much of C's unsafety comes from bad API design, more so than the language itself.

Project ideas in C:

  • Build a robot with an arduino, and control a lamp by pressing on a switch
  • Build a little web server with no external library
  • Build a tool that decompiles a shared library, showing the assembly for each function (start with an easy CPU, not x86. I recommend atmel 8-bit CPUs)
  • Build a little calculator

What's next?

The next part of this series is going to be about learning assembly. Scary yet? Don't fear, assembly is tremendous fun, and very relevant to the web these days.

Which languages did you learn that changed the way you think? Comment below!

. . . . . . . . . . . . . . . . . . . . . . .