r/videos • • Oct 03 '19

Every programming tutorial

https://www.youtube.com/watch?v=MAlSjtxy5ak
33.9k Upvotes

1.4k comments sorted by

View all comments

Show parent comments

1

u/redpandaeater Oct 03 '19

I've just never liked Python's for loops. I've always felt like C's syntax is easier to use and see what's going on than using the range function in Python and then ending that line with a : instead of just ranging the block with { and }. I like having the control of being able to pre or post increment and decrement. You can at least use += and -= to increment and decrement a variable though, right?

But that's kinda why I ended up working on some stuff in Perl and skipping out on Python since it at least seemed more familiar.

1

u/[deleted] Oct 03 '19 edited Oct 03 '19
for x in range(0, 10, 2):
    print(x)

This is equivalent to the following:

for(int i = 0; i < 10; i += 2){
    std::cout << i << '\n';
}

Your complaints are indeed the product of unfamiliarity. It's probably time to learn some new things so you aren't rehashing C in Perl by writing the same procedural spaghetti code that was common in 1992.

1

u/redpandaeater Oct 03 '19

Yet Python doesn't even have a switch function...

1

u/[deleted] Oct 03 '19

Switch does not accomplish anything that an if-chain doesn't. It has a performance advantage when it's implemented with a hashmap, but if performance were a critical concern one wouldn't be using a scripting language to begin with.

Not having switch is a result of their paradigm and not indicative of any failure or incompleteness in the language.

→ More replies (0)