5 ms·
This decompiled output shows a very nice example where C can really be no more than "glorified assembly". (Anyone help me with proper attribution for the quote?
by yuvadam 16y ago
This decompiled output shows a very nice example where C can really be no more than "glorified assembly". (Anyone help me with proper attribution for the quote?)
- udp 16y agoThat's a bit inaccurate: http://james-iry.blogspot.com/2010/09/moron-why-c-is-not-assembly.html http://james-iry.blogspot.com/2010/09/moron-why-c-is-not-ass...
- tedunangst 16y agoWhat do you suppose a decompiled chunk of optimized Haskell would look like?
- eru 16y agoWithout a very clever decompiler, I'd say `ugly'.
- jerf 16y agoHeck, you don't even need that. Put this in a file named "Hello.hs": module Hello where main = print "Hello world!" and run "ghc -fvia-C -keep-hc-files Hello.hs". Compilation may fail with linker errors, but today we don't care about that. We just want to look at the resulting Hello.hc file, which is the C representation of the Haskell, and generally looks like: II_(rhG_closure); II_(si4_closure); FN_(Hello_main_entry) { FB_ if ((W_)(((W_)Sp - 0x10UL) < (W_)SpLim)) goto _cip; Hp=Hp+2; if ((W_)((W_)Hp > (W_)HpLim)) goto _cip; Hp[-1] = (W_)&stg_CAF_BLACKHOLE_info; ;EF_(newCAF); {void (*ghcFunPtr)(void *); and so on for quite a while longer. Passing this through a compile and decompile step might actually clean it up a bit....
- btrask 16y agoOn the contrary, I think the decompiled output highlights the difference between C and assembly, because it looks nothing like typical C code.