Lurker News
Tired of the hype on the web/js (every week new library to learn about), I am thinking to switch career in the next 1-2 years, and move lower in the stack. I am into Rust in the last 3-4 months and I really enjoy it, but I would like to learn more, what would you consider essential books/papers/resources that a system's programmer should know?

Comments (226) 63 threads

Earlier comments
k4ch0w1 reply#
I would say learning a bit about the security implications involved. You don't have certain things given to you like other languages.

You have to watch what compiler flags you use, like someone turning off stack cookies, not using clang's sanitizers. Check out https://clang.llvm.org/docs/AddressSanitizer.html it would have prevented the Heartbleed vulnerability if it existed at the time.
You need proper bounds checking everywhere! You should fuzz your code with something like AFL and if you don't have the time to setup test cases for it, just send your program random junk and see if you can get it to seg. fault.
Multithreading is hard, and detecting multithreaded bugs is even harder. Random monkey testing can sometime's help find these, but they are very hard indeed. Monkey testing is just literally if a monkey was smashing your keyboard and your program was open, what would happen?
Know the most vulnerable function calls by taking a look at banned.h from Microsoft's SDL. It looks like it's no longer on the official website, but the author put it up here Take a look at https://github.com/x509cert/banned/blob/master/banned.h. Sometimes you can't avoid using these functions but know why they can be considered bad.
A proper Makefile is your team's best friend. The same can be said with one build machine for your whole team. It is easier now than ever to build and distribute it between your team with Docker. This is just a personal opinion, but I think downloading all the exact library versions you need once and putting them in a Docker image will save your team some pain in the future.

sebcat#
> You have to watch what compiler flags you use, like someone turning off stack cookies, not using clang's sanitizers. Check out https://clang.llvm.org/docs/AddressSanitizer.html it would have prevented the Heartbleed vulnerability if it existed at the time.

If that was true, then so would Valgrind have, and Valgrind was in wide use at the time.
It was however more complicated than that. If my memory serves me right - OpenSSL had its own memory management.

drablyechoes#
Topics to study should include: Unix IPC, signals and syscalls, filesystem and kernel implementation details, and network/socket programming.

Being able to read and write C programs goes a really long way.
Beej's guides are a good resource. I learned a lot from them.
Guide to network programming: https://beej.us/guide/bgnet/html/multi/index.html
Guide to Unix IPC: https://beej.us/guide/bgipc/
The Unix Programming Environment (Kernighan & Pike) is also very good.
http://files.catwell.info/misc/mirror/the-unix-programming-e...
A good exercise would be to write a simple IRC-like chat server and client in C.

roland351 reply#
One important thing for an embedded engineer (just like any software engineer!) to know is how to select an appropriate solution for a given problem. This includes both hardware and software, and do it yourself vs off the shelf.

I think it can be summed up with some questions to ask at different points in a project:
- Should I use a microcontroller or a processor? If a microcontroller should I use a simple 8 bit or more featured 32 bit?
- Do I need an operating system like Linux, RTOS like FreeRTOS, or bare metal?
- Are there existing code modules out there to help kick start the project? Like SD card libraries, ethernet middleware, etc
- Should I design a custom PCB or look at development kits, or off the shelf electronics?
- Where should I design in flexibility in the project? What requirements can be solidified to simplify the design?
Knowing about what is out there helps pick appropriate solutions to problems, which will save the most time in the future.

jamesadevine3 replies#
In your opinion is 8-bit even a realistic choice anymore? Many ARM CPUs offer way more bang for your buck nowadays (unless i'm looking in the wrong place).
ianhowson#
Depends on your cost/power/space budget. There's plenty of new 8-bit work being done today.
roland35#
Yes 8 bit is absolutely a good choice. ARM comes in less than a dollar for the cortex m0 core (maybe others now?) but sometimes that is more than you need in both size and capabilities.

Also sometimes you may have existing expertise, tooling, or firmware already for a processor such as a PIC, AVR, or STM8, so why reinvent?
Some examples may be things like a custom serial to input/output expander, small motor controller, power controller, data logger, or other small and simple machines.

AnimalMuppet#
What do you want? Do you want a system to play with for your own learning? Or do you want to build a shipping product?

If for your own learning, do you want a full-powered environment? Or do you want a simple system that you can learn all of, even if it's more of a toy?
If it's a shipping product, do you care more about ease of development, or about total parts cost? (The difference is often quantity that you expect to ship - 10 cents in part costs matters if you expect to make 100 million of them.)

flipnotic4 replies#
In embedded and systems-level programming, something I find indispensable is knowing what values fit in what types (for example, an 8-bit type can represent a maximum of 256 values; a 16-bit type can represent 65536 values).

This comes up incredibly frequently, and having it be second nature will benefit you.
A lot of the time, this gives you a starting place for how your inputs and outputs should look, what your method signatures should be. For example, if your data can can fit in a uint8_t, why waste bytes on a uint32_t?
This isn't the be all and end all, especially since modern architectures use larger word sizes/RAM is plentiful/bandwidth is cheap, but it can be a helpful way to frame the conversation when you're architecting software (especially network protocols).

sreeramvenkat1 reply#
IMO the book "Computer systems : a programmer's perspective [Randal E Bryant; David R O'Hallaron]" provides a good foundation on this and other lower level system details.
dannas#
I second this. Make sure that you do the labs that are available from the books web page.
m-ee2 replies#
Also the ability to understand and check the performance impact of these choices. For example at a old job on an embedded motor controller the previous engineer had learned 'floats are slow never use them on a microcontroller' and went and removed them from the code wherever he found them. However in the motor control update loop this meant using longs (or possibly even long longs, I don't remember) in a couple calculations. A quick check with a pin toggle showed this was significantly slower than just using floats.

I'm an ME who went into embedded systems, so I'm not sure what qualifies as low level for a web developer and if checking timing using an oscilloscope or saleae is feasible for the type of work OP wants to do. But even just looking at the assembly would have made things obvious in my example.
EDIT- This made me realize that a rudimentary understanding of the assembly language for your architecture will be very valuable. Doesn't have to be enough to actually write any code in it, but it's great to be able to take a look at what was generated when things are acting weird.

londons_explore#
Some of the bigger microcontrollers have native hardware support for floats, and in that case they are very performant.

Without that though, performance is really really bad. The inner loop of a motor controller is no place for them...

zozbot1231 reply#
Fixpoint arithmetic is going to be significantly more efficient than floating point in many cases, except where you need to use relatively-uncommon operations/functions (which are hardware-accelerated in the FPU), or in cases where the same value might span multiple orders of magnitude (i.e. a direct win for the floating point representation). The inner loop of a microcontroller is not generally one of these cases, though exceptions might be out there.
m-ee#
I was surprised it was faster, from what I remember to avoid floating point operations several large values had to be multiplied together then divided which required using a long long to avoid overflow. The division operation was quite slow. Thinking back I'm not 100% sure it was in the inner control loop but at the very least it was required to generate the new motor position.

Anyway a bit toggle tells all, and if you're making speed optimizations you should be checking that things actually got faster.

C1sc0cat#
All nonfront end programmers should know this and arguably the front end ones should to.
roland35#
RAM is plentiful even on many microcontrollers now, but it becomes much less plentiful when you start storing thousands of data points and need to start bit packing boolean flags and reducing the integer size to squeeze as much as you can in the data structure! Or you need to stream as much of that data over a serial link as possible as quickly as possible!

So I agree, knowing how data is stored is critical.

Load more comments