Welcome to Questionaries, where you can ask questions and receive answers from other members of the community.

Let us know at info@questionaries.org

Why aren’t programs written in Assembly more often?

11 like 3 dislike
Hi Guys

It seems to be a mainstream opinion that assembly programming takes longer and is more difficult to program in than a higher level language such as C. Therefore it seems to be recommend or assumed that it is better to write in a higher level language for these reasons and for the reason of better portability.

Recently I've been writing in x86 assembly and it has dawned on me that perhaps these reasons are not really true, except perhaps portability. Perhaps it is more of a matter of familiarity and knowing how to write assembly well. I also noticed that programming in assembly is quite different than programming in an HLL. Perhaps a good and experienced assembly programmer could write programs just as easily and as quickly as an experienced C programmer writing in C.

Perhaps it is because assembly programming is quite different than HLLs, and so requires different thinking, methods and ways, which makes it seem very awkward to program in for the unfamiliar, and so gives it its bad name for writing programs in.

If portability isn't an issue, then really, what would C have over a good assembler such as NASM?

Edit: Just to point out. When you are writing in assembly, you don't have to write just in instruction codes. You can use macros and procedures and your own conventions to make various abstractions to make programs more modular, more maintainable and easier to read. This is where being familiar with how to write good assembly comes in.
asked 2 years ago by william (91,210 points)

3 Answers

3 like 0 dislike
 
Best answer
Hello I am a compiler.

I just scanned thousands lines of code while you were reading this sentence. I browsed through millions of possibilities of optimizing single line of yours using hundreds of different optimization techniques based on vast number of academical research that you would spend years getting at. I won't feel any embarassment not even a slight ick when I convert a three lines of loop code to a thousands of instructions just to make it faster. I have no shame to go great lengths of optimization, do the dirtiest tricks. And if you don't want me to, maybe for a day or two, I'll behave and do it the way you like. I can transform the methods I'm using whenever you want, without even changing any single line of your code. I can even show you how your code would look in assembly, on different processor architectures and different operating systems and in different assembly conventions if you'd like. Yes all in seconds. Because, you know, I can; and you know, you can't.

P.S. Oh by the way you weren't using half of the code you wrote, I made you a favor and threw them away.
answered 2 years ago by pollard (41,990 points)
5 like 0 dislike
I've written shedloads of assembler for the 6502, Z80, 6809 and 8086 chips. I stopped doing so as soon as C compilers became available for the platforms I was addressing, and immediately became at least 10x more productive. Most good programmers use the tools they use for rational reasons.
answered 2 years ago by biswaskeran (70,430 points)
0 like 0 dislike
hi,
I'm sure there are many reasons, but two quick reasons I can think of are

   1. Assembly code is definitely harder to read (I'm positive its more time-consuming to write as well)
   2. When you have a huge team of developers working on a product, it is helpful to have your code divided into logical blocks and protected by interfaces.
answered 2 years ago by biswaskeran (70,430 points)

Related questions

11 like 0 dislike
0 answers
4 like 0 dislike
1 answer
asked 1 year ago by marck_don (191,010 points)
8 like 0 dislike
1 answer
12 like 0 dislike
1 answer
11 like 0 dislike
1 answer