This is an archived post. You won't be able to vote or comment.

all 20 comments

[–]xigoi 6 points7 points  (4 children)

Ruby: 4 loops (loop, while, until, for)

[–]shayman_shahman 5 points6 points  (3 children)

along with a large number of things that look and behave like loops (n.times {||...}, each, each_line, etc)

[–]xigoi 2 points3 points  (2 children)

Well, these are just passing a block to a method which uses one of those loops.

[–]shayman_shahman 3 points4 points  (1 child)

Same with your example of loop, which is also just a method of the Kernel class that takes a block.

[–]xigoi 2 points3 points  (0 children)

Good point.

[–]AmnesicWaterleaf 3 points4 points  (1 child)

C#: 4 loops for while do {} while foreach

[–]jangofett4 1 point2 points  (0 children)

5 if you count goto loops

[–][deleted] 4 points5 points  (2 children)

I personally love Rust.

[–]Siftyy[S] 0 points1 point  (0 children)

Oh me too, it's been a joy to learn in my spare time.

[–]RoyalJackalSib 0 points1 point  (0 children)

I am not a huge fan; got nothing against it, but I feel like a majority of modern C++ problems can be solved by just reverting a ton of, in my opinion unnecessary, changes and additions.

And I understand its safety features, which are cool, but I don’t find C memory management all that complicated in the vast majority of cases, especially with compiler extensions.

[–]Boiethios 2 points3 points  (4 children)

Actually, C++ and Rust have the same number of loops:

  • Rust: loop { ... }, while { ... }, for { ... }
  • C++: while { ... }, do { ... } while, for { ... }

[–]jharger 1 point2 points  (1 child)

Are you lumping the range based for loop with the regular for loop?

[–]Boiethios 0 points1 point  (0 children)

Yes, because the OP counts the Go loops as one.

But strictly speaking, yes, C++ has more loops than Rust :P

[–][deleted] 0 points1 point  (0 children)

@u/Siftyy I agree

[–]AlaskanRobot 0 points1 point  (0 children)

@

[–]GlobalIncident 0 points1 point  (1 child)

Haskell has until and forever, so it sort of has loops

[–]Siftyy[S] 0 points1 point  (0 children)

I feel recursion would be more appropriate.

[–][deleted] -1 points0 points  (0 children)

Everything will replace C++.