Announcement

Collapse
No announcement yet.

Is Assembly Still Relevant To Most Linux Software?

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Is Assembly Still Relevant To Most Linux Software?

    Phoronix: Is Assembly Still Relevant To Most Linux Software?

    Steve McIntyre and the Linaro Enterprise Group recently analyzed Ubuntu and Fedora software packages to see what software was still relying upon hand-written Assembly code. This was done to see how much real Assembly is being used, to see what the code was used for, and whether it was worth porting to 64-bit ARM / AArch64 / ARMv8...

    http://www.phoronix.com/vr.php?view=MTM0MDk

  • #2
    Assembly is overrated...

    This is not surprising at all. There is a myth that programming in assembly produces faster executable code, but this is not always the case. It enterily depends on the programmer's ability. Many times a compiler produces better executables than hand written assembly, and is less prone to errors, not to mention developing in assembly takes ages...

    There is absolutely no point in using it today, except for corner cases.

    In fact, we are rapidly approaching an age where almost all programs will be written in managed languages like Java and C#. Virtual machines have come a long way in speed, and with multicores now the norm, managed code can be as fast or sometimes even more than unmanaged code.

    Comment


    • #3
      Originally posted by TemplarGR View Post
      This is not surprising at all. There is a myth that programming in assembly produces faster executable code, but this is not always the case. It enterily depends on the programmer's ability. Many times a compiler produces better executables than hand written assembly, and is less prone to errors, not to mention developing in assembly takes ages...

      There is absolutely no point in using it today, except for corner cases.

      In fact, we are rapidly approaching an age where almost all programs will be written in managed languages like Java and C#. Virtual machines have come a long way in speed, and with multicores now the norm, managed code can be as fast or sometimes even more than unmanaged code.
      What? This isn't about managed vs unmanaged, and if anything the Linux development space is trending towards Qt, which is C++ and native, since Java is a slow boring piece of crap, and C# (mainly Xamarin) has been disowning the Linux developer scene hardcore. Neither are supported across mobile platforms either, which is key, and something that Qt actually has going for it as well, and as GTK and Gnome get its act together it remains a competitor. Maybe language binds for native toolkits, like pyside, but even that won't support mobile platforms like native will.

      I'm honestly surprised 6% of packages have assembly. I mean, that is slightly more than 1 in 20 packages using assembly. When you factor in how many of those are written in Python / Java / C# / etc, you know, the managed languages, it means a quantifiable number of C/C++ packages use platform dependent hand written assembly still.

      Comment


      • #4
        I'm actually kind of tired of reading comments from people regurgitating how "it is a myth that coding assembly produces faster code" or that it is overrated. These people obviously have no clue what they are talking about.

        One "problem" with writing software in assembly is that you end up doing quite a few high-level function calls so the question ends up with; how much is low-level assembly really when most of the execution time of the program takes place in libraries (that most likely are not coded in assembly) rather than the program itself.

        A person who decides to write particular routines in assembly knows what he is doing and in most cases hand-written code will be more optimized than code that is compiled from high-level. Sure, some cases may be debatable and you might find that e.g. Intel's c compiler sometimes generates really good code that is close to what one would have achieved with hand-written assembly.

        But still in general, an experienced assembly programmer writes more optimized code than any high-level compiler in existence.

        Comment


        • #5
          Originally posted by axero View Post
          But still in general, an experienced assembly programmer writes more optimized code than any high-level compiler in existence.
          If you are responding to TemplarGR, I think you are saying the same thing. TemplarGR said, "but this is not always the case. It enterily depends on the programmer's ability." (emphasis added)

          Comment


          • #6
            SIMD, kernel

            AFAIK compilers don't produce optimized assembly using SIMD instructions, which is the only "corner case" that comes to my mind for using assembly along with writing kernel code that directly interfaces with the hardware.

            Comment


            • #7
              It's partially true that it's up to the programmer's skill on how small and fast he can make his code. But there's different limits for each programming language and assembly is the one you can make your executable most fastest and/or smallest possible compared to C, C++, java etc. because you are given more control over how memory is managed.

              But because of advances in CPU power, such refinements and sleekness are not needed for most apps you use today. However, part of the Linux kernel is still in assembly while the rest is in C. So assembly is still important but not used as much. There's still however, one use of assembly in "Applications". Creating Worms and Viruses. These things need to be slick and small enough to easily get on computers. They need to manage memory properly and efficiently as well to stay hidden to such a point that only assembly provides the means to produce a program which achieves that.

              So if you're a malicious cracker (and all crackers use Linux because they would have learned that Linux is the safest), assembly and assemblers like nasm are still relevant to you for creating viruses to infect Windows and BSD machines.

              BSDs are so insecurity that you probability only need to write your code in C, C++ or even shell to be successful.

              Comment


              • #8
                It's partially true that it's up to the programmer's skill on how small and fast he can make his code. But there's different limits for each programming language and assembly is the one you can make your executable most fastest and/or smallest possible compared to C, C++, java etc. because you are given more control over how memory is managed.

                But because of advances in CPU power, such refinements and sleekness are not needed for most apps you use today. However, part of the Linux kernel is still in assembly while the rest is in C. So assembly is still important but not used as much. There's still however, one use of assembly in "Applications". Creating Worms and Viruses. These things need to be slick and small enough to easily get on computers. They need to manage memory properly and efficiently as well to stay hidden to such a point that only assembly provides the means to produce a program which achieves that.

                So if you're a malicious cracker (and all crackers use Linux because they would have learned that Linux is the safest), assembly and assemblers like nasm are still relevant to you for creating viruses to infect Windows and BSD machines.

                BSDs are so insecurity that you probability only need to write your code in C, C++ or even shell to be successful.

                Comment


                • #9
                  Linux kernel, some assembly required :P

                  Comment


                  • #10
                    Saying hand optimized asm isn't faster than any lang is flat out bullshit, negating stack pushes (values as well as sp's), redundant/unnecessary register stores and swaps, jump zero flags instead of cmp's,etc...

                    Now is it necessary (other than CPU probing and other hardware)? I stopped writing in ASM ~2002 for a reason. Still I am glad that you can insert _asm into a c project... too bad it's AT&T (yeah I know you can flag it to Intel) syntax.

                    Edit: man was it fun stuffing all the code in the .data section for obfuscation. Too bad anti viruses flagged the crap out those programs.
                    Last edited by nightmarex; 04-02-2013, 07:58 AM.

                    Comment


                    • #11
                      Originally posted by lesterchester View Post
                      BSDs are so insecurity that you probability only need to write your code in C, C++ or even shell to be successful.
                      zomg, so is SLOWlaris. just moving a mouse breaks that shit. Thank Linus for Linux.

                      Comment


                      • #12
                        Originally posted by lesterchester View Post
                        But because of advances in CPU power, such refinements and sleekness are not needed for most apps you use today.
                        Man, how fast could our machines be when this wouldn't be the dominant opinion: Optimizing code? What for, get more RAM and a faster CPU!

                        Comment


                        • #13
                          xls? *sigh*

                          While not surprising, extremly disappointing is this little bit:
                          Raw results

                          The raw results from my analysis are stored in Google Docs at

                          http://goo.gl/6z2C8

                          for anybody else who might be interested. The raw data there works OK, but with limited success. The spreadsheet stored there is already quite slow, plus the many extra cells used to help with analysis did not work at all - maybe I overstepped the limits of Google Docs. Given that, an extra copy in a better format is also attached here for reference.
                          The disappointing bit of course is that it is in excel, or at least saved to an xls file. I would have expected that the 'better format' where an ods (Open Document Spreadsheet). But then again, while Linaro is a linux group, for linux on arm, I'm pretty sure most just use Windows, Office and just play with Linux via a VM.

                          Comment


                          • #14
                            Originally posted by TemplarGR View Post
                            This is not surprising at all. There is a myth that programming in assembly produces faster executable code, but this is not always the case. It enterily depends on the programmer's ability. Many times a compiler produces better executables than hand written assembly, and is less prone to errors, not to mention developing in assembly takes ages...

                            There is absolutely no point in using it today, except for corner cases.
                            I agree with you, though as others pointed out you'd have a pain convincing your compiler to generate good code for SIMD instructions, and that's why FFmpeg still uses a lot of hand-optimized asm code.

                            There's another indirect use of asm which the Linaro guy didn't mention: runtime code generation, such as JIT. An example is Google v8 Javascript engine.

                            Comment


                            • #15
                              Embedded Systems

                              Even embedded-systems-developers are almost entirely using C instead of ASM.
                              For professionals however, knowing ASM is essential to write efficient C-programs, as you know how it works behind the scenes, are able to check the compiler-output and know about certain tweaks to write better and faster code. Apart from that, it has actually lost much relevance in real applications, but will never be surpassed by C when it comes to certain functionality (fixed point arithmetic, ...) which just isn't expressable simply in higher-level-languages.
                              I am glad to see most software is still written in C and not C++, because non-OO software comes closest to what the CPU actually handles and thus you might not be encouraged to write inefficient code, even though by today's standards, the bottlenecks are almost always too small to be even noticed.

                              The big power of compilers is that they can apply architecture-specific tweaks to the written code which the normal programmer would only know after having read hundreds of pages of documentation.
                              Especially today, as we have so many different architectures, writing portable code is essential. And even though I personally am a big fan of ASM, as the programs are nice and small, the readability and portability of a well-written C-program is hard to beat.

                              Comment

                              Working...
                              X