Hi HN<p>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.<p>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?
Learn C. Despite all the slander, it remains the easiest to learn and most widely applicable Systems language. I personally recommend this book (wish it was available when I learnt it): <a href="https://www.amazon.com/Effective-Introduction-Professional-Robert-Seacord/dp/1718501048" rel="nofollow">https://www.amazon.com/Effective-Introduction-Professional-R...</a>
As other have noted, pick up a copy of this book <a href="https://en.wikipedia.org/wiki/The_C_Programming_Language" rel="nofollow">https://en.wikipedia.org/wiki/The_C_Programming_Language</a> 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 <a href="https://www.stroustrup.com/books.html" rel="nofollow">https://www.stroustrup.com/books.html</a> all that are pretty decent.<p>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.
Two recommendations:<p><pre><code> 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"
</code></pre>
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.<p>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.
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 <i>that</i> dramatically, but your best bet today will probably be to learn the used subset of C and Nim analogues at the same time.<p>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.<p>There is also <a href="https://ssalewski.de/nimprogramming.html" rel="nofollow">https://ssalewski.de/nimprogramming.html</a> which has some material on what you are asking about.
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.<p>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)<p>You can also refer to Stanford CS107 lectures taught be Jerry Cain when you are somewhat comfortable with C.
Start with the basics. It will give you a basic foundation to appreciate how computers work.<p><a href="https://www.nand2tetris.org/" rel="nofollow">https://www.nand2tetris.org/</a><p><a href="https://nandgame.com/" rel="nofollow">https://nandgame.com/</a><p>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<p>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.<p><a href="https://eli.thegreenplace.net/tag/linkers-and-loaders" rel="nofollow">https://eli.thegreenplace.net/tag/linkers-and-loaders</a>.<p>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
C snobs don't like this book, but it's free and fun: <a href="https://buildyourownlisp.com/" rel="nofollow">https://buildyourownlisp.com/</a><p>I ended up expanding the project pretty far: <a href="https://github.com/willcipriano/Connery" rel="nofollow">https://github.com/willcipriano/Connery</a>
Sure, C is the original low-level language and any low-level discussion should start with it.<p>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.<p>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".<p>Then there's a brilliant "Expert C Programming: Deep C Secrets" explaining subtle details of the language.<p>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.
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.<p>[1] - <a href="https://godbolt.org/" rel="nofollow">https://godbolt.org/</a>
My own introduction to this, and to understanding programming rather than writing a few scripts for calculations, was the book "C Programming: A Modern Approach." It covers reasonably up-to-date C, assumes no previous expertise and teaches not just the language itself but practices for structuring programs, how to optimize, etc. I picked it up in 2020 so it should still be useful.<p>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.
"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.<p>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.
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.<p>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 :)
<a href="https://www.goodreads.com/en/book/show/910789.The_Elements_of_Computing_Systems" rel="nofollow">https://www.goodreads.com/en/book/show/910789.The_Elements_o...</a><p>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.
I hope you go through fundamentals first. You can't understand C without them[0].<p>Nothing explains systems programming like C[1], including Rust. Godspeed.<p>[0] Introduction to Computing Systems: From Bits & Gates to C/C++ & Beyond 3rd Edition
by Yale Patt (Author), Sanjay Patel (Author)<p>[1] Books by Robert C. Seacord and/or Noam Nisan
Folks recommending C are doing you a disservice, C is just one example of a systems programming language. And that example is now outmoded, Rust or Dlang would be fine first systems languages, I haven't looked at Nim in years, so I can't comment on that.<p>Someone else mentioned The Compiler Explorer, which is a great resource. I would second that.<p>Questions I would ask yourself are<p>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?<p>2) What are the qualities you are solving for? Latency, predictable performance, memory bandwidth, IPC (instructions per clock cycle), etc?<p>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.