5 ms·
This is why C is a high level language (and portable)
by uticus 3y ago
This is why C is a high level language (and portable)
- flohofwoe 3y agoA good macro assembler allows to write code on an abstraction level that's not much different from C though ;) What actually makes C a high-level language isn't the language, but the optimizer passes in modern C compilers.
- themerone 3y agoWhat macro assembler allows you to write a single code for multiple architectures?
- c-linkage 3y agoWASM? :D
- pyinstallwoes 3y agoFAsM
- ternaryoperator 3y agogo's assembler enables this.
- fluoridation 3y agoOptimizations are enabled by the semantics of the language. If the language mandated that generated code must conform exactly to specific sequences of operations dictated by the source code, instead of merely respecting the observable behavior of the abstract machine, it would be impossible to optimize C code in the same way that it's impossible to optimize Assembly code.
- mordechai9000 3y agoI was thinking it might be feasible to tackle Advent of Code in assembler if you started out with a good set of macros and a library for handling common data structures and memory operations. I personally would not be able to do that and keep up with the daily problems, but it might be fun.
- b5n 3y agoYou can get pretty far just by linking libc :)
- fluoridation 3y agoYou'd probably be better off with TCC or with GCC with -O0. Assembly can only outrun C when the programmer uses context-aware optimizations. If you're just using generic macros everywhere to piece together a solution you may as well just use a high-level language.
- mordechai9000 3y agoOh, I wasn't thinking of optimized code. It just sounds kind of fun. And it would still probably still beat anything that doesn't target machine code. But yeah, the compiler is going to produce better code than I can in most cases.
- fluoridation 3y agoIf it's for fun then sure, why not. What I meant was that you weren't really gaining any technical advantage by using Assembly like that.
- uticus 3y agoI would love to see a side-by-side example of C and assembly to demonstrate what you're claiming here.
- pjmlp 3y agoTI has an Assembly language for DSPs that looks like C written in SSA form. Macro Assemblers like MASM, TASM, NASM, YASM et al, provide directives to define structs, strings and such, alongside macros for most common control structures.
- aidenn0 3y ago> What actually makes C a high-level language isn't the language, but the optimizer passes in modern C compilers. I don't think so because that would imply that a language would be low-level until someone writes an optimizing compiler for it. The "levelness" of a language shouldn't depend on implementation details.