You usually can’t have them all.
Most comp sci majors today learn how to program with languages like Java and Python. These are great, extremely flexible languages. They run on any processor and any operating system. The programmer doesn’t need to know anything about the hardware.
Java’s like a luxury SUV. You get in, turn it on, and drive. It goes anywhere and you already know how to operate it.
Most embedded code is written in C and C++. These are still somewhat flexible languages, but since you must compile them for a specific processor within a specific system, you must understand the hardware on which it is meant to run.
C/C++ is like a sports car with a manual transmission. It still goes anywhere, but requires some skill on your part to work well.
If you want the most efficient code, you write it in assembly language. Assembly code is specific to the processor, its peripherals, and its physical memory. It’s not portable to a different system.
Assembly is like a Formula 1 race car. It only drives on racetrack, and you definitely need skills to drive it.
If you need even better performance, you can optimize your assembly code. Optimization, though, requires deep knowledge of both the hardware and the inputs you’re giving it. The optimized code has zero flexibility. If you change one of the inputs, you will have to rewrite the code.
Optimized assembly is like a rocket car built to break the land speed record on the salt flats. It drives in one specific place, requires highly specific skills, and can break at any moment for a million little reasons.
The Java code might take an hour to develop.
The C code might take half a day.
The assembly code maybe all day.
Optimized assembly might take 2 weeks.
Don’t build a rocket car to drive to the grocery store. Also, you’ll never hit the land speed record in a cookie-cutter luxury SUV.
What are you trying to build? Who’s it for? What matters?
Discover more from johnmaconline
Subscribe to get the latest posts sent to your email.