4 ms·
Compare a 512 byte boot sector game [1] to a ~1Gigabyte unity 'hello world'. Until the day the compiler can smartly trim down all the unity framework to just 5
by londons_explore 7y ago
Compare a 512 byte boot sector game [1] to a ~1Gigabyte unity 'hello world'.
Until the day the compiler can smartly trim down all the unity framework to just 512 bytes because it notices I'm not using most of it, hand coding in asm will always work out smaller and faster, if one puts in enough effort.
[1]: https://www.youtube.com/watch?v=1UzTf0Qo37A https://www.youtube.com/watch?v=1UzTf0Qo37A
- Dylan16807 7y agoUnity 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.
- 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.
- jfkebwjsbx 7y agoI agree that Unity is bloated and should take way less constant storage, but that's an invalid comparison. They are not the same domains, they don't use the same APIs, the don't on the same environment, they don't talk to the same hardware, they don't have the same functionality, etc.