4 ms·
I upvoted this post (not enough IMO) when it was in the "new" page and glad that it made it to the front page, many good posts dont. A persistent peeve of mine
by srean 13y ago
I upvoted this post (not enough IMO) when it was in the "new" page and glad that it made it to the front page, many good posts dont.
A persistent peeve of mine is this vapid commentary that would invariably show up in programming language related discussions
"what's the point of this language, if one needs speed, it will be written in C".
Some would replace "C" with "assembly" in that sentence.
The point is that if a piece of code is doing something non-trivial, it is extremely hard to have confidence in the correctness of handwritten code that is written entirely at a low level. Smart compilers apply drastic, and sometimes unintuitive transformation to optimize code. To do the same manually and using low levels of abstractions would require a toure de force to pull off correctly. This simply is not going to happen often. Its precisely for speed that we need a high-level, yet optimization friendly, language so that we can delegate the job of optimizing the code to the compiler. Compilers are much better at applying large correctness preserving transformations than we humans are. The "write it in assembly" works in the small, not in the large.
- jwr 13y agoWhenever I write anything non-trivial in assembly, I always go through a series of progressively lower-level implementations in C. The last ones emulate SSE instructions with for loops and correspond very closely to the assembly code. It isn't possible for me to write a serious chunk of assembly 'just like that'.
- sillysaurus3 13y agoPlease make a video of the various stages of you doing this! Or a tutorial pointing out how the various progressions look. That's awesome, and it's extremely difficult for others to learn that process except through years of trial and error.
- nmrm 13y agoIt would be useful to watch someone (you?) step through this process.
- srean 13y agoI did not bookmark it, but there was this fun blog post about writing a number crunching HW assignment in Scheme (much against contemporary wisdom). But It ended up other implementations in C. The trick was to write it in CPS and keep hand transforming it iteratively till it was efficient assembly in a different syntax. I would still argue that that you are really writing in a high level language/abstraction and the rest is mostly tedious transliteration with special attention to keep the FPUs busy, efficient memory loading and register allocation.