Slashdot Mirror


Is Assembly Programming Still Relevant, Today?

intelinsight asks: "Consider the following question given the current software development needs, and also the claims of the Assembly lovers for it being a language that gives one insights of the internal working of a computer. How relevant or useful is it to learn Assembly programming language in the current era? "

22 of 676 comments (clear)

  1. Isn't it the root of all programming languages?? by madhatter256 · · Score: 4, Insightful

    Isn't knowledge of assembly language for microprocessors required to create a higher level programming language?

    --
    Previewing comments are for sissies!
  2. You should not learn it.. by QuantumG · · Score: 5, Insightful

    Please remain ignorant of all lowlevel details of your deployment and development platforms.
    Please continue to treat both computers and the tools you use to program as magic black boxes.
    That way old dogs like me will still have a job.

    --
    How we know is more important than what we know.
    1. Re:You should not learn it.. by MenTaLguY · · Score: 5, Insightful

      Um, I know you were being facetious, but that's not a bad idea at all, actually. A comprehensive knowledge of those fields isn't normally worth it for most things, but basic literacy in all the areas you mention is actually very helpful at times.

      --

      DNA just wants to be free...
  3. For most programmers, no. by CosmeticLobotamy · · Score: 5, Insightful

    For good programmers, yes.

    1. Re:For most programmers, no. by Bogtha · · Score: 5, Insightful

      I don't think that's the case. It really depends on what you want to do. Typical desktop applications don't need any assembly language, nor in-depth knowledge of how the CPU works. In fact, it's probably a bad thing to worry about things like this — premature optimisation being the root of all evil and all that. You don't want to put a lot of work into making your application 1% faster and then realise you've ruined your portability.

      In fact, these days, there's a case for even doing away with languages like C for a lot of desktop applications. With the speed of today's computers, if you can write your application quicker in a scripting language, it's a worthwhile trade-off for many organisations.

      Sure, if you want to work with operating systems or things like games where performance is critical, then knowing assembly will make you a better developer even if you don't end up using it. But most of the software industry is working at a level far higher than that, and if you are at that level and making your decisions based on what instructions the CPU is getting, then you're probably doing a worse job than somebody who is entirely ignorant of assembly.

      --
      Bogtha Bogtha Bogtha
  4. Very relavent by Forrest+Kyle · · Score: 5, Insightful

    Well, given that the world runs on embedded systems, and will probably become more reliant on even greater numbers of even more complex embedded systems, I'd say assembler will be around for quite a while. However, in terms of game programming or something, it's probably not amazingly useful any more. It is my understanding that most of the API calls to advanced graphics libraries are about as optimized as they are going to get. Clearly you don't need it to write a medical billing application.

    I would not encourage universities to start pumping out CS graduates who have never seen assembly laguage, and don't expect it to phased out of the average Electrical Engineering curriculum any time soon.

    Frankly, I don't think it's a very good question. It's sort of like saying, "Given that we now have calculators and computer algebra systems that will do the math for us, is it really worth it to waste students' time learning the nuts and bolts of mathematics?" It has been my (limited) experience in software engineering that knowing how something works on a deeper level will almost always be an asset, and at the worst have no effect at all.

  5. Yes by Starji · · Score: 4, Insightful

    Do you write drivers? Or do you need highly optimized algorithms? What about really low level firmware stuff?

    In other words, yes, there are good reasons for knowing assembly. Whether or not you'll actually use it is another matter entirely. Just depends on what you're working on.

    Actually I wouldn't be surprised if in about 10-15 years assembly programmers are in higher demand since none of the CS schools these days ever teach assembly anymore.

  6. Re:Isn't it the root of all programming languages? by KokorHekkus · · Score: 5, Insightful

    Isn't knowledge of assembly language for microprocessors required to create a higher level programming language?
    To create - yes. To use as a programmer - no. You can still be a good programmer if you know the cost (in terms of resources) for the operations you choose to make use of. A higher level language will most likely give you a wider range of ways to solve a problem within the given limitations. But only if you actually know the computational characteristics of the system (as a whole) that you are using. Simply put you need to realise which operations are expensive and which are cheap from a total perspective.
  7. Re:Assembly _programming_? by dgatwood · · Score: 4, Insightful

    That's a pretty fine line there. If you can understand asm well enough to debug such issues, I would argue that you also probably know enough to write it, or at least very nearly so.

    I would say that you need to know how to program in assembly language, though it doesn't really matter much which ISA you use---MIPS, x86, PPC, ARM, whatever. What matters is the ability to understand what's really happening at a low level so that you don't do stupid things in high level code that cause your machine to have a seizure.

    For example, once you understand that your CPU only has a limited number of registers, you'll understand why (on some CPU architectures) it is a good idea to limit the number of function arguments so that they can be passed via registers, and that you should put the arguments that you are most likely to use at the beginning of your prototype so that they have the best chance of already being in a register.

    --

    Check out my sci-fi/humor trilogy at PatriotsBooks.

  8. Re:All's quiet by Anonymous Coward · · Score: 5, Insightful
    • Vertex Shader
    • Pixel Shader
  9. Re:Yes. by Lehk228 · · Score: 4, Insightful

    i agree that everyone should have decent understanding of what's going on behind the curtain, though rather than focus on the what, i would prefer to see more experience with limited environments.

    as in your example, too many people code like the only platform is the multi-GHz PC.


    even a year doing tools in Graphing calculator basic will teach appreciation for not wasting cycles doing everything the lazy way, 'cause sure, you usiung strcat doesn't slow the system in a noticable way, but when half the processes running are using it, and using it in "hotspots" suddenly you need a new machine because it's just not fast enough.

    --
    Snowden and Manning are heroes.
  10. Re:Yes. by Dachannien · · Score: 5, Insightful

    I don't think that's a very apt analogy (though few analogies ever are apt). Driving a car to and from work is more akin to using Word (or OpenOffice) on your computer. You don't really need to understand the nuts and bolts of how either one works, but you do need to know what the controls do.

    Programming in a high-level language is more like doing basic maintenance on said car. You definitely need to know something about how the car works, and the more you know, the more work you can do on that car yourself. Programming in assembly is sort of like taking the engine out and repairing or modding it. You may never need or want to do that, but knowing how an engine works on a detailed level can help you diagnose and remedy things that don't actually require going to those lengths. Similarly, knowing how a microprocessor works can help you understand more about what you're doing when you program in a high-level language.

    It also gets you into a mindset where you're thinking about this sort of thing, which is why assembly should still be required teaching in an undergraduate computer science curriculum.

  11. Re:Yes. by smallpaul · · Score: 5, Insightful

    My philosophy is that you should know the layer beneath the layer you program on. Let's say you're working on Groovy code which is half-interpreted and half-compiled on a JVM which is written in C, perhaps using JIT or perhaps not, running on a CPU. Nothing that you can possibly known about how registers work or how jumps work will help you to understand the performance of your program several layers up -- especially given that your program will run on several different runtimes optimized in several different ways on several different CPUs.

    But if you're going to program in Groovy then you should know Java and perhaps JVM IL. If you're going to program in C then you should know assembly. If you're programming in assembly then you should know about how CPUs will reorder your instructions etc. If you're building a CPU, then you'd better know physics.

    I really don't think that if you're writing an app in Rails/Javascript/SQL you are going to achieve any performance or debugging benefits by understanding assembly language. It's just knee-jerk to say that every programmer, no matter what they do day-to-day should be knowledgeable about assembly. The same effort expended learning about the layer UNDER your development environment would have a much better payoff. E.g. a Javascript programmer reading the Firefox source code (or at least benchmarking FireFox and IE on important operations). With each level deeper you go, you achieve quickly diminishing returns.

  12. Re:Yes. by thecheatah · · Score: 5, Insightful

    Wow, the first programming language I learned was z80 assembly :-). I use to make games for the ti86.

    here is a side scroller i made written all in assembly (includes animated screen shot)

    http://www.ticalc.org/archives/files/fileinfo/232/ 23280.html

    The things I learned:
    1. 4mhz processor is REALLY fast!
    2. How the stack works.
    3. How absolute and relative jumps work.
    4. How to create "objects" and implement "methods"
    5. How the smallest variable, the register works.

    I have to say that after making games in assembly, I am actually disappointed in how well the current consoles handle them. I would expect them to be able to crazy things with the hardware they are given. That is also why I am interested in the ps3, it forces programmers to understand the underlying hardware.

  13. Still relevant, but... by pinkfloydhomer · · Score: 5, Insightful

    Hmm. Assembly is still relevant and useful for certain tasks, of course.

    But two things come to mind:

    1: Handcoders can code better than good compilers?

    Yeah, in some cases after a lot of refining. But it is not as easy as it once was.

    Compilers have gotten much better and processors have gotten a lot more complex. It's not just "how many clock cycles does this instruction use?", you also have to take various forms of micro-parallelism (pipelining, branch prediction, etc.) and cache hierachy issues into account.

    2: It's good to know what goes on under the hood, sure.

    But in many, many software developer tasks, early optimization is the root of all evil.

    I would actually much rather recommend a top-down approach for most problems, abstracting away low-level details, rather than going bottom-up. The teaching approach of the great "Accelerated C++" comes to mind.

    A lot of developers that know a little or a lot about low-level programming write less than excellent code in other regards (algorithmic complexity, design, re-use, etc.) and they can't seem to stop focusing on performance throughout the process.

    For most problems, performance isn't critical, and even when it is, it might be better to look for algorithmic enhancements (lowering complexity) rather than do low-level fiddling. /David

  14. Re:All's quiet by doti · · Score: 4, Insightful

    Those bastards make you study it in one of your college courses. That is justified by all your previous points.

    I see it this way: assembly is still used today, but only in a smaller niche. But that's not the only reason it's relevant. I think it's a good knowledge to have, even if you'll never use in practice, but it's concepts help you understand the whole. Much like Math, or basic Physics.
    --
    factor 966971: 966971
  15. Answer to "What's hard about pointers?"... by tlambert · · Score: 4, Insightful

    Answer to "What's hard about pointers?"...

    There are people who cannot grasp the difference between "a thing" and "a respresentation of a thing". In fact, there was an entire century where almost the entire school of French philosophers were unable to grasp that there was a difference.

    For pointers, it comes down to realizing that a pointer to memory is not the memory, it's a representation, and the real memory lives somewhere else: at the dereference of the pointer. And at that location it takes up real space. And so does the representation (but it's comparatively tiny).

    The ability to make this disctinction comes naturally when you've written assembly code of any complexity, since you've had to manage the memory yourself. But if you've never done that, or, worse, you've only ever programmed in languages which eschew pointers and try to pretend that their own internal implementations don't use them, even if they won't let you use them, well, then, you've got a conceptual problem. An that conceptual problem is going to be very hard for you to overcome.

    It also makes it very, very hard for someone to understand row-major vs. column major languages, or how you would link a program in one against a library in another, and be able to usefully communicate your data between the two. Or it makes it hard to understand the difference between "call by value" and "call by reference.

    If I'm interviewing someone, and it becomes clear that they need a "code interview" because some things don't add up between their banter and their resume, the first thing I whip out is a pointer problem.

    -- Terry

  16. Re:Here's another by countach · · Score: 4, Insightful

    Maybe, except that not many assembly programmers can make faster code than a C compiler anyway. It's no use being a mediocre assembly programmer.

  17. Yes, learn it in context. by nadador · · Score: 5, Insightful

    As a marketable skill, assembly won't get you anywhere. There are a handful of places were knowing a specific assembly language is a prerequisite (boot loaders, deeply embedded applications, etc.) but these are just a fraction of the overall job-space for software engineers. Most software engineers never mess with assembly; they are, in fact, afraid of it and think that it's evil.

    Given all of that, assembly language *is* the hardware/software boundary. It's where all of the fancy abstractions from CS dissertations meet reality. Understanding computer architecture is a huge asset as a software engineer, and to properly understand how software and hardware interact, you have to learn at least one assembly language. There is no alternative. For most people, it is an unpleasant experience, but the payoff is enormous. The learning process that you undergo while learning assembly will change the way that you see your software and will help you understand why your code is so slow and how to make it fast by design.

    I have one last point. When you tell a potential employer about the low-level stuff that you know or work that you've done, your assembly skills are a proxy for understanding how hardware works (at least to interviewers with half a brain). If their software needs to run fast, they'll be happy that you understand the deep magic of hardware.

    (Incidentally, I think that the fraction of software jobs that require an understanding of hardware and knowledge of assembly languages, linker internals, etc., are the only fun ones and the only ones worth having. So I learned MIPS, ARM, PowerPC, and TMS320C6 assembly, and they have all served me very well because I don't have to refactor C# for a living.)

    --

    Outside of a dog, a book is a man's best friend. Inside a dog, its too dark to read.
  18. Efficiency sometimes irrelevant by davidwr · · Score: 5, Insightful
    In most programs, easy-to-read, easy-to-maintain code is worth a size and speed penalty of up to several times that of hand-optimized assembly code, and it's almost always worth a 0-50% penalty.

    This is particularly true for programs that
    • don't need to be shoehorned into memory or onto disk
    • spend most of their time waiting, not running

    --
    Knowledge is how to play a game, intelligence is how to win, wisdom is knowing what game to play.
  19. Re:Here's another by Anonymous Coward · · Score: 4, Insightful

    To consistently beat a C compiler: Write your code in C with inline assembly if required, then compile through Assembler to get assembler source code. Next, hand tweak the assembler code and add C as comments. Pretty soon you will start to think like a compiler and your C code will get better too!

  20. Would you trust these professionals? by mikehoskins · · Score: 5, Insightful

    The original post asks if Assembly is still relevant today. I'll ask some rhetorical questions (the only kind in a blog) and see how they apply:

    * Would you want an astronaut to understand physics and math?
    * Would you want a doctor to understand chemistry and biology?
    * Should somebody studying to be a Literature teacher take their full set of liberal arts courses, including history?
    * Should somebody earning a business degree take music appreciation?

    Most of us probably said, "Yes" to most or all of those above. Even if the study seems irrelevant or too "low-level" or too "high-level" at the time, there are areas of coursework that help us understand things better.

    I see a lot of dead wood in the IT industry. There are enormous numbers of people who either have no passion or who do not have a deep-enough or broad-enough knowledge of computer science to do their daily data processing job well. They are dependent on others around them for everything, even though they may be very skilled in one area.

    By having both a broader and a deeper knowledge, people are necessarily better at troubleshooting and at understanding the areas outside their particular specialty. It makes them be better at all of IT and helps them do their specific role.

    You should learn IT two ways -- deeply and broadly. You should deeply learn specific skills (Java/C#/Linux/Windows/scripting in Ruby/whatever) and you should learn broad skills (computing theory/relational databases/networking/troubleshooting/programming/a nalysis/architecture/whatever). The difference is training vs. education.

    There is an enormous difference between training and education. Training is learning specific skills for specific tasks (narrow/specific), while education is broader and teaches you how to think, understand, and apply (broad/general).

    While taking Assembly may not seem relevant at the time and you may never directly use it again, for every programming task, having a strong background in all of computing theory (including how the CPU handles its low-level instructions) educates you and gives you a deeper understanding. (Don't just be trained, be educated!)

    My recommendation is the book My Job Went to India (And All I Got was this Lousy Book). If you can't afford it, read the sample chapters, especially the "Being a Generalist" and "Being a specialist" chapters at http://www.pragmaticprogrammer.com/titles/mjwti/in dex.html.

    Personally, unless you need the specific class/training, I'd say that FORTRAN or COBOL ought to be abolished as required material in all colleges and shouldn't be in the degree program. Those should be electives only. Assembly, on the other hand, should remain required, for a deeper and broader education. (Don't settle for a dumbed-down program).

    The difference, again, is training (specific/skill-oriented/task-oriented) vs. education (general/broad/understanding-oriented). Education and being a generalist will reap large rewards, long term. So stick with it and take that class. Assembly is a very important foundation class that educates you, long-term....

    Another rhetorical question I have is this: "Are you passionate for IT or is it just a high-paying (presumably) job?" If it isn't a passion of yours, find you passion and do it well. If it is, take Assembly and like it -- it'll help you appreciate IT, your computer, your high-level language, and give you a more educated view of the "soul" of your computer.

    (They don't make you take Assembly at many/most schools for their health. It would be a crying shame to remove it from the required courses).