4 ms·
If/else is just as made up as for loops - it’s all if/goto underneath.
by sheeshkebab 6y ago
If/else is just as made up as for loops - it’s all if/goto underneath.
- __s 6y agoUnless you compile your program with movfuscator: https://github.com/xoreaxeaxeax/movfuscator https://github.com/xoreaxeaxeax/movfuscator Or you decide to execute code on The Fungus: https://www.bedroomlan.org/hardware/fungus https://www.bedroomlan.org/hardware/fungus I also recall reading a paper that got into implementing a GC on silicon for a graph rewriting based architecture WebAssembly is if/else blocks. There's a potential future where it gets implemented directly as a CPU ISA (albeit it'd likely involve some dynamic translation, but the CPU may decide to have SSA as its internal representation) It's important to understand there's a real distinction between semantics & implementation. Otherwise you risk emulating your implementation when some new hardware comes out (say GPUs, or Quantum computers, or out of order CPUs working backwards to create something like SSA for register renaming/pipelining, or cmov) See also the debates over C code being executed in the C abstract machine for optimizers while programmers rely on implementation of the end result. But in a language without undefined / implementation-defined behavior you won't have these ways of having the program self observe its implementation
- colejohnson66 6y ago> I also recall reading a paper that got into implementing a GC on silicon for a graph rewriting based architecture Not that, but still interesting: the Intel iAPX 432[0] was a (failed) processor from 1981 designed with high level languages in mind (specifically Ada). It supported bit-level aligned, variable length instruction, but also a built in GC and type tagging system. [0]: https://en.wikipedia.org/wiki/Intel_iAPX_432 https://en.wikipedia.org/wiki/Intel_iAPX_432
- still_grokking 6y ago> I also recall reading a paper that got into implementing a GC on silicon for a graph rewriting based architecture Maybe this one: https://github.com/tommythorn/Reduceron https://github.com/tommythorn/Reduceron
- __s 6y agoThat's the one. Gets me breaking out in a solid minute of laughter imagining C code that thinks its "close to the metal" being compiled to that
- notacoward 6y agoPretty sure at least 90% of the readers here know that, but still appreciate the convenience of higher-level language constructs. That's why they're called "higher-level" after all. BTW, it's not entirely correct that it's all if/goto. ARM has conditional execution that doesn't necessarily involve a jump, and there have been other exceptions as well.
- Sharlin 6y agox86 has CMOV, for Conditional MOVe, since the Pentium Pro, and of course there are tricks employed by compilers and low-level programmers to avoid the overhead of branches, like the `a = cond·b + !cond·c` idiom.
- michaelcampbell 6y agoI remember first coming across "for"; the ... parsing of it in my brain I don't think ever did make it. I had to just accept it for what it was.
- CJefferson 6y agoInterestingly, in logic programming languages if/else sometimes turns into arithmetic, so (slightly simplifying) 'if x then y else z' becomes 'xy + (1-x)z', or 'x*(y-z)+z'