3 ms·
> What is this post supposed to prove? It proves that the compilers for many programming languages emit a lot of instructions and a lot of system calls they co
by einpoklum 7y ago
> What is this post supposed to prove?
It proves that the compilers for many programming languages emit a lot of instructions and a lot of system calls they could have optimized away theoretically.
This is particularly true when there are lots of "startup routines". When the program to be run is known, almost all of that startup can be found out to not be necessary, and stripped from the final executable.
> Your users are not going to wait shorter for your program because you and your team are taking another year to write, test, and debug it in assembly.
They might, if your program is interactive and is used often enough. Now, writing assembly is not very realistic, but considering a different language with less overhead - is.
- phoe-krk 7y ago> they could have optimized away theoretically. For a hello-world program, this is true, you do not need any of the features that usually come in the language runtime - no garbage collection, no runtime memory safety, no runtime introspection, et cetera. This stems directly from the fact that many of these languages have borrowed features from Lisp, which has the whole language (GC, compiler, debug functions, etc..) always available for the code. And that, considering your point of view, might be a feature, not a bug - especially if your program, having a runtime of its own, actually produces its own stacktrace, allows you to interactively inspect values of variables throughout the stack, and - in case of some runtimes - is capable of opening up its own debugger for you to perform introspection and issue analyzing in.
- saagarjha 7y ago> This stems directly from the fact that many of these languages have borrowed features from Lisp, which has the whole language (GC, compiler, debug functions, etc..) always available for the code. Right, I think the point was that this isn't always necessary, in which case it becomes extra baggage that you have to carry around.
- hokumguru 7y agoFor all the daily articles that pop up here on HN concerning premature optimization I find it surprising to see this thread and all the sentiment of language choice mattering. It’s far easier to work in and translate thoughts to more feature rich languages. The vast majority of the time it’s not the language itself that will be an optimization issue down the line but rather the written code.
- overgard 7y agoHere's the problem, your language isn't the optimization issue... until it is. You optimize all the hot-spots on your profile, and then... all the sudden you're looking at a very big samey chart of everything taking slightly-too-long even though you've optimized every possible thing and there's nothing that particularly sticks and and there's nothing you can do about it. And then you're totally fucked, because you're looking at a rewrite at that point; probably in a language your team doesn't know and doesn't like. Sometimes language matters! Not always, but frequently!
- saagarjha 7y ago> you're looking at a rewrite at that point; probably in a language your team doesn't know and doesn't like Or you commit atrocities like rip the garbage collector out of Python. I’m not joking; Instagram did this: https://instagram-engineering.com/dismissing-python-garbage-collection-at-instagram-4dca40b29172 https://instagram-engineering.com/dismissing-python-garbage-...
- overgard 7y agoHeh! That is fantastic!
- lasagnaphil 7y agoThat’s actually a pretty clever (and crazy) idea, because when you disable the gc in Python the reference counting still works and only the cycle detection part is vanished. So you are just dealing with reference semantics the same as C++’s shared_ptr or Swift’s references, which isn’t that hard to use if you are careful about cyclic refs. And if the memory leak exceeds a certain amount they can just restart the process.
- Aeolun 7y agoI think it would be interesting to make a slightly more complex program involving maybe a few hello worlds, and then see how much the size of all these languages increases.
- MisterTea 7y ago> Now, writing assembly is not very realistic, but considering a different language with less overhead - is. https://en.wikipedia.org/wiki/RollerCoaster_Tycoon_(video_game) https://en.wikipedia.org/wiki/RollerCoaster_Tycoon_(video_ga... "Sawyer wrote 99% of the code for RollerCoaster Tycoon in x86 assembly language, with the remaining one percent written in C."
- einpoklum 7y agoI didn't say "impossible" or "completely unrealistic"... I wonder how that code gets maintained. Also - that game absolutely needs better resolution to do the coasters justice.
- MisterTea 7y agoIt's quite an old game now, released in 1999. Runs beautifully under wine and one of my favorite games of all time. I recommend giving it a go if sim games are your thing. Hard to believe it was all written in assembler and I too would love to know how Chris managed his code.