3 ms·
"If you get any of this wrong, even in an edge case, the user is presented with non-working code for a valid program, and the compiler writer has failed at his
by rlpb 11y ago
"If you get any of this wrong, even in an edge case, the user is presented with non-working code for a valid program, and the compiler writer has failed at his or her one task."
Perhaps languages could be designed so as to make this task easier?
In language design we end up torn between making things easier for the programmer and making things easier for the compiler-designed-for-performance. Doing both things well is perhaps something that language design will be able to improve upon in the future.
- dkopi 11y agoLanguages and compilers actually do have constructs for programmers to make things easier for the compiler. "inline" and "register" are two very known examples. Other examples are function attributes in gcc: https://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html https://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html
- nkurz 11y agoI presume you're aware that you've chosen two controversial examples? "register" has been formally deprecated in C++, and has been ignored by (almost?) all C compilers for decades: http://stackoverflow.com/questions/20618008/replacement-for-deprecated-register-keyword-c-11 http://stackoverflow.com/questions/20618008/replacement-for-... And most current wisdom is that "inline" no longer serves as a useful performance suggestion to the compiler, but instead should only be used as a linkage directive to allow multiple declarations of the same function: http://stackoverflow.com/questions/29796264/is-there-still-a-use-for-inline http://stackoverflow.com/questions/29796264/is-there-still-a...
- dkopi 11y agoGreat points. As compilers evolve, optimizers are even more knowledgeable of what should be put in a register or inline that the programmer. But those are still 2 well known features that were added intentionally to help improve performance.
- 0x07c0 11y agorestrict is probably a better example! https://en.wikipedia.org/wiki/Restrict https://en.wikipedia.org/wiki/Restrict
- dkopi 11y agogreat example
- akkartik 11y agoA degenerate case is my project, which makes people write assembly, but in a very safe way that it can check. You lose the expressivity of conventional HLLs, but still get their safety benefits. https://github.com/akkartik/mu https://github.com/akkartik/mu
- jcr 11y agoAfter reading the mu link you posted, I was going to ask you to submit it as a "Show HN" post... but it seems I'm about a month too late: https://news.ycombinator.com/item?id=11092067 https://news.ycombinator.com/item?id=11092067 It's great reading. thanks.
- carussell 11y agoSee also: http://cr.yp.to/qhasm/literature.html http://cr.yp.to/qhasm/literature.html > The programmer using such a system will write his beautifully-structured, but possibly inefficient, program P; then he will interactively specify transformations that make it efficient.
- bijection 11y agoHalide is a neat example of this approach in an image processing context [1] [2] [1] http://halide-lang.org/ http://halide-lang.org/ [2] https://people.csail.mit.edu/jrk/jrkthesis.pdf https://people.csail.mit.edu/jrk/jrkthesis.pdf "Decoupling Algorithms from the Organization of Computation for High Performance Image Processing"