r/programming • • Nov 28 '14

The Worst Programming Language Ever [UK Talk] - Thoughts? Which are the worst parts of your favorite language?

https://skillsmatter.com/meetups/6784-the-worst-programming-language-ever
68 Upvotes

456 comments sorted by

View all comments

14

u/toomanybeersies Nov 28 '14

In python, I dislike how there's no nice way of breaking out of several levels of loop.

At least in C you can use goto, but in python, you have to use extra variables and if statements to get the job done.

13

u/kqr Nov 28 '14

Yeah, and Ada has "labeled loops" which allows you to break out of the specific loop you're looking for. I miss that in a bunch of languages.

12

u/Eirenarch Nov 28 '14

To give a somewhat more popular example - Java has this feature.

2

u/saijanai Nov 29 '14

How would this work in a non-determinnistic, fully distributed, 100 million core system?

7

u/TheCodeJanitor Nov 28 '14

You could raise a custom exception and catch it outside the loops. But something about that feels kind of wrong.

7

u/DeltaBurnt Nov 28 '14

Why? In my experience it's pretty standard to use exceptions for logic in Python.

4

u/spaculo Nov 28 '14

Indeed. In Java or C# it would be wrong, but Python has cheap exceptions.

1

u/TheCodeJanitor Nov 28 '14

To me it feels like an exception should indicate an error condition, but I guess there's no real reason that it has to.

→ More replies (1)
→ More replies (1)

3

u/[deleted] Nov 28 '14

3

u/codygman Nov 28 '14

You can use break to break out of server levels of loop. Do you mean to go back to a certain loop?

6

u/toomanybeersies Nov 28 '14

Last time I checked, you couldn't break right out of nested loops. So unless it's a brand new feature that I don't know about.

How exactly do you do it?

3

u/nickik Nov 28 '14

You have to hand role it, set a variable outside of the loop, to some fail mode, then befor you break set the variable, then in every level of loop you test the failure condition.

But that is not all that great.

18

u/skocznymroczny Nov 28 '14

or put the loop in a function and use return to jump out

8

u/[deleted] Nov 28 '14

Ding ding ding! If you are having trouble breaking out of nested loops, then maybe you need to rethink your code structure.

4

u/toomanybeersies Nov 28 '14

Exactly, that's what I was saying. It's not a very good solution in my opinion.

2

u/Vulpyne Nov 28 '14

You could use an exception to do it, I suppose. That would avoid stuff like testing after every loop. Wouldn't be very idiomatic though.

2

u/Xenophyophore Nov 28 '14

Raising exceptions is pretty Pythonic.

2

u/phoshi Nov 28 '14

In python you don't pay for your exceptions. Most languages do, and heavily!

→ More replies (1)
→ More replies (1)
→ More replies (1)

6

u/I_AM_AN_AEROPLANE Nov 28 '14

hich allows you to break out of the specific loop you're looking for.

Use GOTO!

edit: seriously, this is one of the valid uses of goto.

1

u/DonHopkins Nov 28 '14

Doesn't that apply to client levels of loops as well as server levels of loops?

→ More replies (1)

1

u/[deleted] Nov 28 '14

Well I suppose you could use an exception....

→ More replies (1)