Is it worth using Assembly, C and C++ in the same program?

Asked

Viewed 164 times

2

  • 2

    In cases very, but very (but very (...)) specific compensates. In 99.9% of cases it pays to review the algorithm or the form it implemented in C++. To ensure that language is a bottleneck you need to ensure that it has been well done before. To ensure that it will no longer be a bottleneck in another language you will need to ensure that it will be well done in it. Most of the time your assembly result will not be better than the compiler, so it will be time lost.

2 answers

5


Almost everything done in Assembly is slower than in C and C++. It is possible to do it faster, but it is very difficult and it happens less than people imagine.

In fact, only naive people believe that, and they are the least likely to make Assembly go fast. It is true that this naivety will make the person produce bad codes in C or C++ as well.

To code well in these languages takes a very large domain of computing, they are not magic and anything you do makes everything fast, they can be fast because they allow to make complicated codes, difficult and that can achieve great speed if everything is right.

Some languages don’t give that much power, but it can also make some things easier. I’ve seen C# go faster than C++ and then people who wrote the code in C++ get better until they can beat the same code in C#. In C++ it took days to create slightly faster code, in C# it took minutes, and today maybe it’s faster, at the time the compiler and library of C# was very bad, C++ was good.

Often programmers have achieved more speed with C# or even Java making code simply compared to what they would do in C or C++ or more in Assembly, not to mention productivity. You won’t get good speed in languages script unless you compare it to a very bad code in C/C++, even this is not easy, you need to work hard.

2

Assembly actually, at runtime, is faster. But it is costly in development and complex in implementation / maintenance not to mention that your code gets stuck in the hardware architecture. Therefore, depending on the application, any other language, compiled or interpreted will be faster. Imagine implementing an Assembly database query?

But when it comes to digital signal processing, or driver development, Assembly can be a solution, since we wish in the middle of a C/C++ code to access a peripheral or access an instruction from the digital signal processor. However it is not every day that this type of technology is used and it is worth remembering that compilers are increasingly optimized to generate more efficient machine code than written in Assembly.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.