Tuesday, 4 October 2016

Every coder should experience ASSEMBLER


In this modern world of fantastically beautiful user interfaces and Object oriented programming, a coder might think that knowing assembler is not as important. While you may never need to design system software or embedded systems throughout your programming career some knowledge of assembler is important.




Many 'App' programmers are completely oblivious to the inner workings of the computer. Why this knowledge would never need to be explicitly called upon during one's career, experiencing the low level world of Assembler will give you profound insight into the fundamental workings of the computer.
You might have done some course on the Design and Analysis of computer programs and some Discrete maths and if you really understood what you were learning you might have some flipping confidence about your ability to design efficient programs. But in reality nothing prepares you for the gruesome world of assembler. When you actually see how program instructions are specified at such a low level, you will see that the computer is actually something deeper that what all your functions and classes present to you.
When you see what clock cycles for the execution of instructions are you will learn to be more efficient in how you write code trying as much as possible to use optimal structures throughout your programming.
In my own experience I was stunned when I got down to assembler, I realized the power of abstraction and the core knowledge that everything from the bottom up in computer science is one bag of tricks inserted into a larger bag of tricks.
An Enlightening experience I discovered when I delved into the depths of Assembler is the core fundamental idea of computation. Assembler is just a level above the machine code, and if you are using a good simulator you will be able to inspect the machine code generated. When you see that everything in a computer, data and code is expressed uniformly as binary patterns you will be greatly awed, I hope you would because this was how I felt.
It might seem obvious that everything in a computer is just 1 and 0, but seeing the machine code generated by some assembler will give you a real gutsy experience of this fact and you might have some deep understanding of the computer that can make you a better programmer for life.
When I first ventured out into programming, I thought that statements like the If, Do and While statements were something natural to programming and that there could be some circuit within the computer that does explicitly does conditionals, but when I saw that what you could do in a typical computer was mainly stuff like JMP (to move the program counter), MOV (to move data to and fro) ,AND etc. I was stunned because I did not see If, Else, While, etc. This other statements that you use in everyday programming were invented by combining these low-level almost primitive instructions that did not have any direct connection with the upper layers. Even things like function calls that you take as a given, is done with some elaborate stack management. Infact I would say that assembler is awesome. You might never need to code in it, but if you want to have some nerdy kinda fun you should take a deep dive you will definitely come out a better programmer, frowning when you see lesser than thou peers write endless FOR loops for stuff that could be efficient if you vectorize it (lol)!

(The image above is some simple assembly language program that does multiplication! How elaborate. Obtained from google search)

No comments:

Post a Comment