logoalt Hacker News

kittoesyesterday at 2:42 PM3 repliesview on HN

Interesting take, how is optional functionality annoying? Isn't the fact that it's just sugar a huge benefit? Us old timers can simply stick to what we're familiar with.


Replies

fourseventyyesterday at 2:49 PM

Because unless you are the only person maintaining your codebase other people in your organization will start using the cool new syntax sugar and optional functionality. So you will be forced to deal with it as it starts showing up in your codebase.

pjc50yesterday at 2:44 PM

I don't get this either. You can even lock the language level if you really don't want it, or you can just ignore it.

hirvi74yesterday at 6:47 PM

(GP here)

> Isn't the fact that it's just sugar a huge benefit?

My main gripe is that I cannot remember what is allowed and not allowed between multiple versions of the same language. On a daily basis I hop between apps versioned in .NET Framework 4.8 all the way to .NET 10. I have to constant remember, are nullable types allowed here? What about 'new(); vs. new Object();', new collection syntax, new switch syntax, new extensions syntax, etc..

Plus, I just find it obnoxious that the same thing can be written so many different ways. I can think of 7 ways to assign a new empty List<T>.

List<T> foo = new List<T>();

var foo = new List<T>();

List<T> foo = new();

List<T> foo = new List<T> { };

var foo = new List<T> { };

List<T> foo = [];

var foo = (List<T>)[];

There are probably more that I am forgetting. What irks me most is Java is older than C#, and from what I can remember, it is not nearly this ridiculous in terms of syntactical sugar. So, what is the true benefit behind all this sugar? It hardly saves any keystrokes in the age of autocomplete in IDEs.

I am inclined to believe most of the sugar is an attempt to make the language appeal to a newer generations of programmers. But I would argue features are more attractive than syntactical sugar. I believe Rust is truly impressive language. In my opinion, its syntax is uglier than sin, but that does not seem to deter many from using Rust.

show 1 reply