What are the practical benefits of teaching Assembly?

Most people believe that training assembly is important, it is important to know the basic operation of a computer, etc. But what I'm looking for are some practical suggestions that will do everything possible to assimilate the Assembly.

What are your suggestions? What am I missing by not studying assembly and pointers / memory management in general?

+6
assembly pointers
source share
14 answers

I think the main practical advantage of learning low-level things, such as assembly language, pointers, and memory management, is that when you write or review high-level code, you can instinctively or subconsciously identify performance problems or other pitfalls.

An average developer might write a simple loop and think: “This code iterates over a set of integers and writes each to the console.”

An expert developer can write the same loop and think: “This code iterates over a set of integers and must put each element to call the ToString method, and ToString must format the string in base 10, trivially, and then the integer in piece the packaging, and the formatted string will soon have the right to garbage collection, because the links will not remain, and the first time you run this method it should be JIT'ed ... ", etc.

9 times out of 10, it does not matter. But this is 1 time out of 10, an expert developer will probably notice a problem with the code that the average developer would never have thought to consider.

+7
source share

You need to learn how to read the assembly so that you can understand what went wrong when a complex operator bombed. The CPU debug window should not be a mysterious place.

+5
source share

Pointers / memory management are more general than assembly language. You should also understand them for C and C ++, which you might need if you need to save code written in C.

For assembly language, it is sometimes useful to read the assembler code that the C compiler generates to find out if it generates the correct and efficient code.

+4
source share

I think it's good to learn new languages. It opens my mind. Some languages ​​are more intelligent than others. I would say that the collector is one of those. It makes you think of things like a call stack and a command pointer. And that will make you more valuable languages ​​of a higher level. Another interesting language to learn is PostScript.

+3
source share

I don’t think you need to learn how to build for something practical. However, this will provide you with an understanding of the real roots of what you are doing as a developer. Essentially, assembly programming is a discipline for learning the logic and architecture of chips. I have not programmed the assembly for more than two decades, but still informs about the options that I do when programming C #.

+3
source share

This is one of those questions that will always be asked: "Why should I know something." etc. Well, maybe you could do something other than create the next general CRUD application or something similar. If you want to engage in any system development, then knowledge of the assembly is very useful, if not important. How much you “miss”, perhaps you lose sight of knowing how computers work. Some consider this to be desirable. Some people do not. Some people create processors. Some people growl ditches. It all depends on personal preferences :)

+2
source share

But what I'm looking for are some practical suggestions that will do everything possible to study the Assembly.

Find out what assembly is. Actually learn to read (and understand) small fragments: how to walk / go through it in your mind. Perhaps also by going through some of them with a debugger (including looking at memory and registers that are changing). Ideally find some annotated build.

But don't bother to learn how to write an assembly: instead, learning to write C or C ++ is probably "low" for most practical purposes.

+1
source share

Pointers and memory management are really a different issue than assembly. If you want to do C / C ++, you need to learn pointers and memory management because they are part of the language. But even if you plan on using nothing but (say) Java all your life, you have to learn something about memory management to avoid writing a memory leak despite the GC, and pointers are just the difference between atomic types and references to objects. You need concepts or you will write programs that do not work!

Practical reasons for learning collection: debugging and optimization. Even if you are not recording any assembly, one of these days you may need to optimize the C / C ++ code for performance. In this case, you will need to read the assembly for your inner loop, even if you do not need to write another line.

Ultimately, I think your distinction between “knowing the basic actions of your computer” and “practical suggestions that will make an attempt to learn the assembly worthy” is false. Ignorance does not pay. Learning how your computer works is a practical suggestion that deserves attention!

I have a prophecy: someday soon your program will work too slowly to be practical, and periodically go astray. That day, a clear screaming concern that you don’t know what the hell is happening or where to start looking to fix it will return your karmic debt with interest ...

+1
source share

These days, many assembler languages ​​are actually quite high-level.

And it has always been that if you learn “C,” it's close enough to collecting to get most of the benefits of learning.

edit: thinking about this a bit more, in Knut's books he describes an idealized assembler language. You will not be mistaken in learning about this and reading these books.

0
source share

Another practical reason I can think of is to reverse engineer the application code to modify it for educational purposes only, as it is widely used by crackers to bypass third-party applications such as time limits or serial numbers.

An application like win32Dasm can convert executable files into assembly code, which can later be modified using a Hex editor such as hiew. You can learn a lot about program flow.

0
source share

Well, at a practical level, I made a class in assembler 6502 when I first learned how to code the early 80s. I also made the assembler 8088. This has been used from time to time for many years, but I can’t say that he ever really got out of the pit in more than one or two cases after 25 years. Crashing C at a fairly fundamental level is much more useful. YMMV and it is certainly useful as a background, but how is the direct practical benefit? Marginal indeed.

Perversely, although one thing that has proven useful is at an even lower level. I made a class on chip design (NAND gates, etc.), and as part of this course, formal logic logic was studied at a certain depth. Since then it has been very useful - surprisingly, the number of coders who really don't know what they are doing with ands, ors and nots :-)

0
source share

I think that the study of computer architecture in conjunction with the assembly will open your mind a little.

This will help to explain many performance problems - for example, the parser is slow because there are many branches and the pipeline is dumped very easily, the industry predictor cannot compensate for everything.

In addition, different architectures have their own characteristics. Someone was talking about assembling an assembly to replace 2 registers, including xor's. It works, and it works great for the execution kernel in order (the most recent example may be Intel Atom and Via C7 in netbooks), but not so large in non-ordering kernels.

Knowing that this will help you detect poorly compiled code by checking it in the assembly and possibly be able to write code in a higher level language to circumvent the imperfections of compiler optimizers. I am not trying to weaken them, but they simply cannot be fully tuned.

0
source share

I have some practical examples of why you need to know what is under the hood. Some useful links you might find useful in this context are

Assembly and debugging art

Debugging - changing code at runtime

0
source share

The biggest practical benefit of Assembly training is performance. You can optimize to perfection when necessary.

0
source share

All Articles