3 ms·
Kotlin has a lot useless syntax sugar, for example @decorators are less powerful than the @decorators in python. And How do you say the opposite of sugar synta
by mdtrooper 3y ago
Kotlin has a lot useless syntax sugar, for example @decorators are less powerful than the @decorators in python.
And How do you say the opposite of sugar syntax in English? Because my lovely rustlang has a lot of sigil chars as old Perl, it makes me sad.
- adql 3y ago> And How do you say the opposite of sugar syntax in English? Syntax spice ? It burns when you eat/read and it burns when you write/poo > Because my lovely rustlang has a lot of sigil chars as old Perl, it makes me sad. I unironically prefer Perl mess, at least you don't have macros and annotations generating who-knows-what at random parts of code. I mean, not that you couldn't in Perl, there is plenty of horrid things you can do using some more obscure Perl's features (my favourite so far was modifying other package's package-scoped variables), but most code in Perl doesn't.
- valvar 3y agoBoilerplate
- throwaway17_17 3y agoI’ve thought I had usually seen syntax salt be used as the opposite of sugar. I know there is some university’s PL Theory lecture guides that use it, just can’t think of where it is. edit —- I just checked, and salt is ‘name dropped’ in the Wikipedia article for syntax sugar, and there were a few more links making me think it is relatively common.
- aragonite 3y agosyntactic broccoli. The idea behind 'sugar' is 'tasty but inessential', so the strict opposite would be something essential but not so tasty. But maybe 'syntactic thorns' correspond better to the sense you intend to express.
- matsemann 3y ago> Kotlin has a lot useless syntax sugar, for example @decorators are less powerful than the @decorators in python. I think you're comparing two different things. Kotlin has "annotations", not decorators. It's because of it's java inheritance, where that is the way it's done. It's two different concepts. With a decorator, your code is replaced with a function call with the function itself as a parameter. With an annotation, you're just adding metadata and an annotation processor or static analysis tool etc can do whatever it wants with it. Like aspect oriented programming. You mark your code as having certain properties, and then other code can find it and react to those. I don't know of much other useless syntactic sugar in Kotlin? I think most of it is quite nice, for instance how you can put the lambda outside parenthesis or create infix operator for more readable code. I also like the implicit `it` parameter in lambdas, better than what this article shows. Doesn't support multiple arguments, though.
- TrianguloY 3y agoDoesn't support multiple arguments by itself, because "it" will always refer to the "group". But with destructing you can name yourself as many arguments as you want: listOf(1,2,3).let { (a, b, c) -> a * b + c } Which I think it's a good compromise
- cout 3y agoSweet is usually contrasted with savory. I think "savory syntax" rolls off the tongue well.