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?
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.
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.
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.
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.
After this, start learning C. There will be a bunch of semantics to learn, which are all important, however with every small program that you write , you should generate the assembly code with gdb, and aim to understand what the assembly is doing (calling convention for functions, registers, syscalls, e.t.c). This will
Then, figure out how linking and loading works (i.e turning assembly code into the shape of an executable understood by the OS). Objdump and readelf are going to be your friends, as well as getting familiar with gdb debugger.
https://eli.thegreenplace.net/tag/linkers-and-loaders.
This will give you a good foundation for low level development. You can then branch off to other areas like CUDA/OpenCL/AVX programming, microcontroller programming, kernel development, e.t.c
I ended up expanding the project pretty far: https://github.com/willcipriano/Connery
There is problem with the classic introductory book though. "The C Programming Language" is a classic and ppl mention it all the time. But it's horribly outdated and doesn't cover the living language at all. It's more like a description of a language authors wanted C to be, not the real thing.
Take "C Programming: A Modern Approach" or something along the same lines. Go through it, get a hang of the language then follow up with something like "Effective C" or "Modern C", which are good recent mid-level books on the language. I also like "The C Puzzle Book".
Then there's a brilliant "Expert C Programming: Deep C Secrets" explaining subtle details of the language.
One thing that is missing from the books is POSIX. The language itself is very barebones so in practise people are always coding against some Linux/*nix/POSIX or equivalent APIs. These serve as a std library of sorts as otherwise even moderately involved projects become prohibitively big.
[1] - https://godbolt.org/
I personally am dissapointed by people recommending "The C Programming Language." It's a terse book that doesn't go into the detail I found helpful when starting.
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.
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 :)
Also Google from and to Tetris as there are courses using the book called this. In fact that's what they were going to call the book.
Nothing explains systems programming like C[1], including Rust. Godspeed.
[0] Introduction to Computing Systems: From Bits & Gates to C/C++ & Beyond 3rd Edition by Yale Patt (Author), Sanjay Patel (Author)
[1] Books by Robert C. Seacord and/or Noam Nisan
Someone else mentioned The Compiler Explorer, which is a great resource. I would second that.
Questions I would ask yourself are
1) How is a low level language different than the languages you are coming from? What do they solve for you vs what do you have to solve yourself?
2) What are the qualities you are solving for? Latency, predictable performance, memory bandwidth, IPC (instructions per clock cycle), etc?
All of the issues you would like to learn about can be learned directly in Python. So you have to figure out what exactly you want to learn and then learn that thing. Just learning about lower level compiled languages is like learning about rakes and shovels if you are a gardener.