Assembly language programming vs Other programming languages

Click For Summary

Discussion Overview

The discussion revolves around the performance comparison between assembly language and higher-level programming languages such as C, C++, and Python. Participants explore the reasons behind the speed differences, the implications of using assembly for programming, and the trade-offs involved in choosing different languages for coding tasks.

Discussion Character

  • Debate/contested
  • Technical explanation
  • Conceptual clarification

Main Points Raised

  • Some participants question how much faster assembly is compared to higher-level languages, suggesting that performance may not be significantly different due to compiler optimizations.
  • One participant notes that C is structured to be directly translatable into machine code, which may contribute to its performance advantages over other high-level languages.
  • Another participant argues that assembly is often overkill for most coding tasks, emphasizing the productivity benefits of using higher-level languages that leverage extensive libraries.
  • Some participants highlight that experienced assembly programmers can optimize code in ways that compilers may not, potentially leading to faster execution and reduced memory usage.
  • There is mention of the trade-offs between time and space in programming, with discussions on how different programming paradigms (compiled vs. interpreted) affect performance.
  • One participant shares an anecdote about an assembly programmer who optimized code by reusing memory areas, illustrating the potential for efficiency in assembly programming.
  • Concerns are raised about the maintenance challenges associated with assembly code, suggesting that the complexity can lead to increased costs in maintaining software.

Areas of Agreement / Disagreement

Participants express a range of views on the utility and efficiency of assembly language compared to higher-level languages. There is no clear consensus, as some advocate for the advantages of assembly in specific contexts while others emphasize the practicality of higher-level languages for most applications.

Contextual Notes

The discussion reflects varying assumptions about the capabilities of compilers, the nature of programming tasks, and the importance of maintenance in software development. There are also unresolved questions about the optimal scenarios for using assembly versus higher-level languages.

  • #121
glappkaeft said:
Edit: Note that is is considered bad practice to initialize an int with a double value.
hmm yeh, I had started it double, but then it complained with the usage of << . I changed it to integer but I forgot to remove the .0 ...

Hm, so that means the assembler code would be something like:
movl $0x6e , -0x4 (%rbp)
(sum is registered in 0x4 and moves 110 in it)
without a for loop?
Does that happen because the compiler runs the code and gets the result before producing the output?
 
Technology news on Phys.org
  • #122
ChrisVer said:
without a for loop?
Does that happen because the compiler runs the code and gets the result before producing the output?
It doesn't really run the code, but it optimizes it.

int chrisver()
{
int sum = 0;
for(int i=1; i<=10; i++)
{
sum+= 2*i;​
}​
return sum;​
0FB94090 mov eax,6Eh
}​
0FB94095 ret
 
  • #123
ChrisVer said:
Does that happen because the compiler runs the code and gets the result before producing the output?

Since it doesn't really run the code it is usually said that the compiler evaluates the code at compile time. If you are interested in these things the compiler optimization section on wikipedia is a pretty good place to start. For instance constant folding is here: https://en.wikipedia.org/wiki/Constant_folding

Added: If you want to see what the compiler does with your code in a real world scenario you need to make sure the number of times the for-loop is repeated is not known at compile time, e.g. depends on user keyboard input, data from a file or similar.
 
Last edited:

Similar threads

Replies
6
Views
3K
  • · Replies 16 ·
Replies
16
Views
5K
  • · Replies 397 ·
14
Replies
397
Views
21K
Replies
6
Views
2K
  • · Replies 29 ·
Replies
29
Views
3K
  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 4 ·
Replies
4
Views
16K
Replies
4
Views
2K
  • · Replies 5 ·
Replies
5
Views
4K
  • · Replies 2 ·
Replies
2
Views
2K