3 ms·
Do you mean for all imperative languages? Functional or declarative languages can do away with loops and jumps. Not trying to nitpick, perhaps you had some furt
by killingtime74 5y ago
Do you mean for all imperative languages? Functional or declarative languages can do away with loops and jumps. Not trying to nitpick, perhaps you had some further insights when creating this
- dahfizz 5y agoOP said > primitive and fundamental concepts do not go away even if things are abstracted by high level features in high-level languages. Loops do not go away in fp. They are just hidden under layers of abstraction.
- bawolff 5y agoMost fp loop-like things are recursion. Traditional iterative loops are abstractions over goto. Arguably a function call is an abstraction of goto (JMP)+stack manipulation. So they are both abstractions over goto, but i would say they are sibling abstractions not parent/child.
- lelanthran 5y ago> Do you mean for all imperative languages? Functional or declarative languages can do away with loops and jumps. At the programmer interface, sure. At the implementation level ("underlying"), all that abstraction is being turned into loops and jumps.
- FrancoisBosun 5y agoThe functional language does do away with loops, but when the rubber nets the road, you don’t have any choice: somewhere, something will execute the equivalent of “for(int i = 0; i <= 10; i++) {}”. When I implemented Mindcode, I realized that “while” is the basic construct and that all enumerations and looping compiled down into goto. Mindcode is a Ruby-like language for the Mindustry game. Mindustry has an assembly-like language with a visual editor in-game. Mindcode has a more traditional text-based flow.
- ModernMech 5y ago> somewhere, something will execute the equivalent of “for(int i = 0; i <= 10; i++) Not necessarily; depending on what's going in in the loop, you can compile the code into parallel non-looping instructions that execute on multiple cores or threads. No loops needed.
- throw10920 5y agoThat's a very specific special case. For instance, if you have more iterations than cores or processors, you'll still need to do looping somewhere. In the general case, the statement is still true.
- ModernMech 5y agoIt's a specific case but not a very specific case, and one that is becoming more common as core counts are exploding. And anyway, even if it were a very specific case it's still an existence proof that disproves the assertions that "all that abstraction is being turned into loops and jumps." as one other poster put it. The replies here are speaking in very absolute terms ("you don’t have any choice", "loops and jumps cannot ever go away regardless of the higher level abstractions"), which are not true in an absolute sense. The OP said: > Do you mean for all imperative languages? Functional or declarative languages can do away with loops and jumps And everyone here is answering them so far from the perspective of imperative languages. But depending on the program, it's not necessarily the general case in declarative languages, where we have much more freedom to compile things as we want, including without loops where they would be used in an imperative language. Since this is a thread about language design and we're talking about alternative paradigms and how things get compiled to instructions, it's absolutely true that if our problem can be parallelized we don't have to loop at all. This is not a special case, but something that is generally applicable to many kinds of situations. Now that we're entering a world of potentially 1000s of cores available on consumer CPUs in the near future, what I'm saying is going to become the general case more and more.
- jstimpfle 5y ago
- digitalsankhara 5y agoTotally reductionist on my part, but when you've written assembly by hand you realise that loops and jumps cannot ever go away regardless of the higher level abstractions. At least I'm not aware of any CPUs that are not imperative in operation.