Live data from Hacker News

Ask HN: How do I start learning about lower level compiled languages?

news.ycombinator.com

1–10 of 34 posts

Ask HN: How do I start learning about lower level compiled languages?

#1
Hi HN

I work quite a lot with Python and JS, and some other higher level languages, but have recently wanted to get involved in lower level languages, particularly NIM. I have already started coding with it, but it comes with a whole range of new topics that are semi-unknown to me, heaps, stacks, memory management, pointers, compilers, debugging compiled applications, garbage collection, etc. Does anyone know of any material that can help demystify those topics and any other that come up.

I know the common answer will be to start coding and learn it as you go along. But I was curious to understand if there was any supplementary material that can support my introduction to this new works of coding?

Re: Ask HN: How do I start learning about lower level compiled languages?

#2
I don't know anyhting about NIM in particular, but you touch on points with which I'm right at home, and I suggest you have a look at programming in C, it's a simple and small language, and its syntax is less intimidating than C++, while at the same time introducing you to the concepts you mention.

The nice thing about C in your case, is that you won't get very far before being introduced to things like pointers, and allocating memory on the heap :)

Re: Ask HN: How do I start learning about lower level compiled languages?

#3
As someone who is currently learning Rust, which is lower level than Java (used at work). Having studied C and using some portion of C++ at university has been immensely helpful.

I would recommend learning C, as it is a relatively small language; and focusing on understanding the underlying assembly which is generated by the compilers. (Compiler Explorer gotbolt.org)

You can also refer to Stanford CS107 lectures taught be Jerry Cain when you are somewhat comfortable with C.

Re: Ask HN: How do I start learning about lower level compiled languages?

#4
If you want to understand how things work at the lower level, I think the Compiler Explorer[1] might be a good place to start. You can enter a program in a while variety of languages, and see the code that results. Python and Nim are both supported, along with a wide variety of other languages.

[1] - https://godbolt.org/

Re: Ask HN: How do I start learning about lower level compiled languages?

#5
"Memory as a Programming Concept in C and C++" was a helpful book for me. I'd stick to C as C++ is kinda kludgy syntactically with higher level constructs and they're not key to lower-level stuff anyway.

After that, you might look into Rust. I don't have any particular recommendations; there was/is an introductory text online by the original Rust developer I found helpful. Rust is sort of hyped the last few years, but there's good reason for it, and its approach to memory builds well on classic C-like ideas.

Re: Ask HN: How do I start learning about lower level compiled languages?

#7
Two recommendations:

  1. Switch to a team (or company) where they are developing in the language you want to learn. 
  2. Work through the book "Computer Systems: A programmer's perspective"
Nothing beats daily programming in said language on a daily basis. Similar to yourself, I was predominately writing in higher level interpreted languages. Although I did teach myself C by working through books, writing programs and more, it was not until I started writing C on the job that really accelerated my learning. Very quickly, hit my fair share of segfaults ... discovered that we never called malloc (i.e. allocating memory on the heap) during runtime, stepped through our mark-and-sweep algorithm.

As for the book recommendation, it will cover all the above topics you are interested in such as heaps, stacks, memory management, etc. There are lots of other books that I studied during my CS education but self studying "Computing Systems: A programmer's perspective" really switched a light bulb on in my head.

Re: Ask HN: How do I start learning about lower level compiled languages?

#8
As other have noted, pick up a copy of this book https://en.wikipedia.org/wiki/The_C_Programming_Language it was written by the two guys that created C (and also contributed quite a bit to UNIX). Its perhaps one of the truly "original" programing textbooks (and it does not have some wacky animal on the front). The creator of C++ also has written many books on the topic https://www.stroustrup.com/books.html all that are pretty decent.

If you want to lean by doing my advice is to get an arduino and try and build stuff. The arduino has a C like language (and will also accept C code) which is a great way to learn the language with fun projects. More importantly it will force you to learn C in a very restricted environment where you actually have to think about clock speed, memory management and code efficiency due to the micro controllers limited resources.

Re: Ask HN: How do I start learning about lower level compiled languages?

#9
Most well vetted material you will find on this will use regular old C, not Nim, like that Bryant & O'Halloran Computer Systems from a Programmer's Perspective mentioned in a sibling comment. It probably won't rely on C that dramatically, but your best bet today will probably be to learn the used subset of C and Nim analogues at the same time.

Your questions are a bit all over/vague. The Nim forum (forum.nim-lang.org) is generally very helpful and if you ask more specific questions then you can get better answers.

There is also https://ssalewski.de/nimprogramming.html which has some material on what you are asking about.

Re: Ask HN: How do I start learning about lower level compiled languages?

#10

Two recommendations: 1. Switch to a team (or company) where they are developing in the language you want to learn. 2. Work through the book "Computer Systems: A programmer's perspective" Nothing beats daily programming in said language on a daily basis. Similar to yourself, I was predominately writing in higher level interpreted languages. Although I did teach myself C by working through books, writing programs and m…

Can get my hands on the 2nd edition for cheap, or is the 3rd edition required? It's quite expensive.
Post reply on HN