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.
Now that I work as half data engineer and half infra (cloud). I do have a few hobby projects using C/C++ (e.g. embedded for C and game programming for C++), but nothing really completed and polished. How do I convince someone to give me a job to work on low level systems, even as a junior?
Should I continue working on low level projects and hopefully they are good enough, or there are other approaches?
TBH I'm willing to do free part-time work on sys programming if given the chance, but industry doesn't work like this.
>Should I continue working on low level projects and hopefully they are good enough, or there are other approaches?
The way i had done this in the past was to really learn the language well (today you will also have a GitHub repo of projects to show), practice algorithms/data structures/interview questions in C/C++ and finally, understand the tight coupling between C/C++ and underlying OS i.e. "Systems Programming". This is the preparation phase.
In the execution phase, you contact companies/recruiters/friends/anybody at all with suitable openings and make it very clear that you really really want the job even if it means taking a pay cut i.e. Salary/Money should not be the goal. Make it clear and open that you are looking for a break into that domain and you are willing to put in any Time and Effort reqd. Finally, try smaller companies rather than big ones at first; their requirements are less strict.
HTH
If you can, buy the 3rd edition (this is one of the few books worth its price) and then pickup the 1st edition for cheap/free from somewhere. Try for Used/Secondhand copies to save money.
There is a lot to learn from the book; all of them necessary for a beginner to connect the dots and get the full picture. So don't get stuck on any one chapter/problem but make sure to cover all the chapters in sequence skipping over unnecessary details in the first couple of passes. As an example you don't need to know the nitty-gritty of PIC/GOTs/PLTs/Assembly minutiae etc. in the beginning but just understand the concepts of Relocatable code and Executable vs. Shared Object files.
Note also that there are two versions of the third edition: the standard edition (colorfully striped shape on the cover) and the international edition (globe made of circuit boards on the cover) which is quite a bit cheaper. The contents of the chapters are the same, but the exercises at the ends of the chapters have been rewritten, by the publisher's lackeys, not by the original authors, for the international edition, very poorly by all accounts.
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.
I completely disagree that C is no long relevant. The amount of new C code written today across the world dwarfs the amount of new Rust, D, or Nim code combined.
It is quite clear from the post that the author had heard of some "low level concepts" but does not have a clear idea of what they mean much less understand them. This is NOT a "XY Problem" as your response seems to suggest. They are basically exploring in the dark and need guidance. As many have pointed out, "C" is the answer since those concepts are "natural" in that language and moreover is the "lingua franca" of low-level programming.
FWIW, I doubt anyone was suggesting "large scale applications programming in C"..Just the nuts & bolts & basic vocabulary..the way a program/process interacts with an OS, etc. in the very simple cases/scenarios. The main (but not only) way people use Nim is through the C backend. { The code generated by the Nim compiler is not that easy to read or intended to be so, of course. } There are also OS books to consider like The Design of The Unix OS or Advanced Programming in the Unix Environment. These also use very minimal little C examples. Everyone learns differently, though. I think more delineated goals and background level would yield better advice for @budafish.
Teaching has also evolved over the decades. Teaching of C was/is more "hand in hand" with the ideas the poster was asking about. For example, the K&R C book walks you through writing both stack allocators and heap allocators on top of raw memory.