3 ms·
It has been decades since I was tempted to "goto". This not because of dogma or "drinking the kool-aid". It is because I use an expressive language that has con
by ncmncm 8y ago
It has been decades since I was tempted to "goto". This not because of dogma or "drinking the kool-aid". It is because I use an expressive language that has constructs that mean what I mean, so don't need to be cobbled up out of such fragmentary primitives.
That so much C code is littered with them just demonstrates a deep weakness in C, and not any kind of fundamental principle. I admit surprise that C# turns out similarly weak.
- asveikau 8y agoWould you also consider the assembly code that is generated by your high level language to be so "littered" with jmp instructions, arising from a "deep weakness"? It's one thing to prefer to work with another abstraction, but this is awfully judgmental phrasing that denies or unfairly maligns a usefulness and necessary ubiquity at a different level.
- ncmncm 8y agoMachine instructions are the archetype of fragmentary primitives. We use better languages for good reasons.
- AnimalMuppet 8y agoYes, assembly language is a language of deep weakness. There's a reason we don't use it unless we have to - it's too hard to write anything in assembler. In fact, assembler weaker than C - in C, you can usually avoid goto if you want to bad enough, but in assembly, it's impossible.
- asveikau 8y ago> it's too hard to write anything in assembler. And yet, everything you run is written in it. (By a compiler or a JIT, sure.) The goto is a useful abstraction for its layer. It doesn't have to be your favorite layer, but it's there, and ubiquitous. I feel like discussions around memory safety are similar. I can't get a lot of people around here to admit that in order to be blessed with memory safety at one layer it needs to not exist somewhere else, and that's OK.
- AnimalMuppet 8y agoYou seem to be having a different discussion than most of the rest of us. You're claiming that it's fine for its layer, and the rest of us are saying that we don't want to work at that layer. Yes, jmp is useful at the assembly layer. Yes, everything eventually gets run on assembly (on the way to microcode, and then transistors, and then quantum mechanics). That doesn't mean most of us want to work there, though. And goto is the same. Having seen that we don't have to work in that way, we don't want to work in that way. We can work with larger abstractions so that we don't have to deal with that kind of detail.
- asveikau 8y ago> You're claiming that it's fine for its layer, and the rest of us are saying that we don't want to work at that layer. Correct. This is what I said all along. Glad to see you're up to speed. Meanwhile, every time you write an if statement ... May you think, acknowledge, appreciate: "I'm adding a goto!" Or possibly several of them. [I am pretty sure I have had discussions with people who say they are also against if statements, but I don't think that's quite as common.]
- ncmncm 8y agoEveryone is always perfectly and completely aware of the jmp instructions that implement their if and while statements. Talking about them does not make you cleverer than anyone else. What you are missing, and is the fundamental essence of the whole discussion, is that these jmp instructions don't just jump to any old place, like a goto. They jump to only very specific places corresponding to the boundaries of our if and while statements. The compiler will never generate an undisciplined branch, absent an actual goto in the source. Beneath the jmp instructions there are register transfer machines, and beneath them are logic gates, and beneath them are transistors and wires, and beneath them are charge carriers and fields, and beneath those are atoms and crystalline structure. At each level you can find the correspondence with structures in the next level above and below. In no case does the lower level violate the structural rules of the next level up, despite that in principle, it could. That is how we get systems that can be understood, and work.
- timwaagh 8y agoC# is one of the very few modern languages that has kept goto. A similar comparison in most other modern languages does not make sense because you cannot even use it.
- wool_gather 8y agoSwift, for example, has a nice construct called `defer` that runs some code immediately after the current scope exits -- no matter the means of exit. This is pretty much all I would want to use `goto` for. I sort of disagree that C is "weak" -- I think its simplicity, which even includes `goto`, is a strength. But I agree that other languages can certainly, within their own contexts, come up with nice things.