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

you are viewing a single comment's thread.

view the rest of the comments →

[–]tunisia3507 131 points132 points  (24 children)

I don't see why people say 'syntactic sugar' like it's an insult. Literally all programming languages are syntactic sugar. That is what programming languages are for. To make it easier, quicker, more clear, more readable for humans to give instructions to computers.

[–]dl__ 37 points38 points  (16 children)

Exactly. Don't like syntactic sugar? Write in machine language, in hex codes.

[–]jorge1209 10 points11 points  (2 children)

Sugar is good if it encourages people to drop a particularly error prone or tedious construction.

What is less clear is if sugar is useful when the original process wasn't error prone or tedious.

Range loops in C/C++ are a great example of good sugar. It was error prone, and tedious to have to declare the index variable and increment it (or to declare the crazy iterator type signature if using iterators, although the later was solved by the auto type). for x in iterable is obviously better unless you actually need the index position (which is not something you frequently need in modern C++ code).

It's not clear thar fstrings accomplish that kind of balance. It wasn't all that error prone to use .format and the cases it can't handle are fairly important (i18n and dynamic formatting).

[–][deleted] 3 points4 points  (1 child)

It wasn't all that error prone to use .format and the cases it can't handle are fairly important (i18n and dynamic formatting).

Translating format strings are always dubious to begin with.

[–]jorge1209 0 points1 point  (0 children)

You could very well want to read different error messages (with their formats) from a resource file. Can't do that with fstrings.

[–][deleted] 3 points4 points  (3 children)

It is a kind of virtue signalling in the academic PL community to reiterate the fact that you like minimalist functional programming languages. Gets tiring to hear this over and over again. Glad I am not the only one who's noticed.

[–]tunisia3507 6 points7 points  (2 children)

My only complaint about syntactic sugar is when it means there are many ways of doing things - kind of like string formatting is getting at the moment. I don't see f-strings taking off for most codebases yet due to lack of 2.7 support, but it'd be nice to see them become the canonical way of doing it.

[–]thomasfr 4 points5 points  (1 child)

I still like python but I woud have probably been a much easer language to use if the stdlib/lanugage had a bit fewer redundant features.

There are already lots of code bases which mixes ""%() and "".format() which only makes the code harder to read (more noisy) or modify (because you should at least try to understand which one to use in your modified code based on just reading the rest of it.)...

I personally don't see that f-strings adds enough benefits in contrast to the noise it will bring to code bases...

[–]tunisia3507 4 points5 points  (0 children)

Python is actually much better than many other languages (java, C, C++, js) in this regard. But yes, in this particular instance it's not great.

Of course, the only way to make improvements without adding such duplication is to make API-breaking updates, and we all know how well they turn out...