5 ms·
Unity isn't.. what? And the problem there is using an ill-suited framework, not the language. If you compile hello world in C, it's not going to be very big e
by Dylan16807 7y ago
Unity isn't.. what? And the problem there is using an ill-suited framework, not the language.
If you compile hello world in C, it's not going to be very big either.
> if one puts in enough effort
"enough effort" is a cheat. I can replace almost any program with a smaller javascript version, if I put in "enough effort". It's not a reasonable way to compare anything.
- snvzz 7y ago>If you compile hello world in C, it's not going to be very big either. You should actually try that, and compare sizes with the asm hello world.
- SomeoneFromCA 7y agoThe problem not in the language per se, but in the linker settings. By tweaking it, you can achieve almost same size as the assembler version has.
- BubRoss 7y agoYou say that, but I still haven't seen any compilers link in only parts of libc. Use any of it and it all comes in. Hello world in C becomes anywhere from 120KB to 1.2MB even if just using puts. Even setting the entry point to a function with no arguments doesn't help. A tiny hello world ends up needing to ignore the standard library and use a console output function from the OS.
- SomeoneFromCA 7y agoJust checked on a Ubuntu machine. Hello world takes 6Kb. Uses printf.
- BubRoss 7y agoThat's because it links dynamically to the standard library.
- Dylan16807 7y agoIs that a problem? It's there whether you use it or not, and it's not like the asm is running in a vacuum either. If you go to an embedded point of view where there is nothing already supplied, you can get a hello world, even with a basic printf, down to that size.
- snvzz 7y agoEspecially since you use external libraries to do the bulk of the work, 6KB is a lot. It is an order of magnitude bigger than the assembly version.
- deleted 7y ago[deleted]
- SomeoneFromCA 7y agoAfter some manipulations with the linker, I was able to cut the size down to 750 bytes. You cannot go below this, without hacking the ELF file format.
- snvzz 7y agoI got my asm one down to 268 without even trying. It prints (via write syscall) "hello world.\n" and then calls exit(0). Assembled with fasm, linked with ld -n, then stripped.
- SomeoneFromCA 7y agoOk fine, I've used the tool called sstrip from a suite called ELFKickers. Now my hello_world.cpp (yes, c++) is 380 bytes long. I could not make it any shorter, so yeah, it is 120 bytes (50%) bigger than yours.
- 7thaccount 7y ago95KB using MinGW's GCC on Windows using default compilation. When I tell it to emit the assembly with "-S" I get 28 lines of code when I have a feeling assembly is much shorter.