Is assembly the only low level programming language, and if not is it the most widely used?

12,486

Solution 1

Writing assembly was appropriate in simpler times. Back when the code generator in a C compiler wasn't very smart yet and it was simple to predict the execution time of machine code.

That's over and done with, a human can't beat neither the smarts built into a modern code generator nor its relentless attention to detail. The kind of detail required to know exactly when you insert a cache prefetch so the data is available at exactly the right time. And how reordering instructions just right gets you the best super-scalability. And inserting nops just right so jump targets are aligned. And how to unroll loops mechanically. And how to take advantage of auto-parallelizing provided by SIMD. Etcetera. And to do this not just once, but over and over again as the code changes.

Solution 2

Well, "assembly" is more of a collection of different varieties, actually. It's dependent on the architecture you're programming for. For example, assembly for x86 could (and will) greatly differ from assembly for ARM, or MIPS, or any architecture you can think of. This is caused by the fact that assembly is a one-to-one translation of the binary code the processor runs. As different architectures have different instruction sets, their assembly language differs too.

So really, assembly is the lowest you can go without writing plain binary code. But, it is not a specific language, rather than a group of languages. So, if you are talking about, for example, x86 assembly, and you compare that to another language of an equal low level, you would find that that other language would also be some variety of assembly. Then again, it would be for another architecture, so it wouldn't be very useful too.

Solution 3

compilers of higher level languages are getting smarter each day. In the past assembler tricks could increase the performance a lot. Nowadays, compilers implement a lot of these tricks themselves.

Examples are: shifting instead of dividing, manipulating the program counter in a jump-table for a switch/case, inlining functions if they are only used once, etc.

There still is room for optimalisation, but the performance gain will be so low that it is better to use a higher level language and to go for maintainability.

Share:
12,486
kjh
Author by

kjh

Updated on June 15, 2022

Comments

  • kjh
    kjh almost 2 years

    I've started learning assembly recently and as I've looked across the internet I see more and more people saying that assembly is not useless, but it's also not worth the time to program things in a language that requires such time and effort compared to high level languages. Is the efficiency between a high level language program and a low level one really not even noticeable enough to pay attention to nowadays, and is there another low level language like assembly that is more widely used?