Hacker News new | past | comments | ask | show | jobs | submit login

I like swift's conditionals without brackets, OTOH the syntax for string interpolation is ugly



Ugh, I know it's something that literally every programmer on earth can and often does bikeshed, but Swift just got string interpolation syntax wrong. Parentheses are something that are often part of the interpolated expression... they shouldn't be part of the interpolation syntax itself.


Yes, agreed. IMO, curly braces would have made much more sense. It's not even bikesheding, really. It's just a fact that curly braces are less used in most written languages. I would also argue that curly braces are a better signal to the programmer that "something programmatic is happening here", due to their prevalence as scope delimiters in most popular languages.

Swift's string interpolation doesn't catch my eye like, say, Ruby's does: `#{my_var}`. It's very easy to gloss over `\(something_like_this)`. I suspect they were going for a more "elegant" syntax at the cost of pragmatism.


I definitely think a general guideline for language designers could be "when in doubt, make it look like Ruby". The language has its issues, sure, but damn if it didn't get syntax just right.


I think we will have to agree to disagree on this. Personally, Ruby code is only marginally better than Perl in terms of line noise I can't read, a dubious distinction.


> but damn if it didn't get syntax just right.

Yeah, like the symmetry of `do` / `end`! /s


I don't see why that matters if they're always balanced.

  "blah blah \(f(g(42)))"
Seems fine to me.


> they shouldn't be part of the interpolation syntax itself.

Why not? It's not like there's any conflict. You can use parens inside the interpolated expression just fine.


I agree. I prefer ES6 and Kotlin's interpolation syntax. Ruby is ok too.


It's so pretty but that's really disappointing. That puts a damper on even trying it but to be fair it could be a lot worse.


>That puts a damper on even trying it

Hyperbole much?


Yes, that seems like a fair criticism. Just being honest even at the expense of looking ridiculous.


Opinionated, I suspect, but not hyperbole.


There is such a thing as a hyperbolic opinion or reaction.

Not trying a language because one dislikes the syntax for one of 2000 features it has, and not even the most important one, looks hyperbolic to me.


It doesn't look hyperbolic to me. If I dislike the syntax of a language, I can probably find a better one with the syntax I prefer. Maybe this is a negative side-effect of having too many options, but I don't think it's unreasonable to pass up on something for purely stylistic choices.




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: