I'm a huge fan of syntactic sugar in C# - but its always there. In JavaScript, support is dependent on the environment unless you transpile and polyfill all of your code all of the time (at least for example the spread operator)
C# example (14 lines to 1 with proper linting):
public string Property { get; set; }
Is syntactic sugar for:
private string propertyField;
public string Property
{
get
{
return propertyField;
}
set
{
propertyField = value;
}
}
If I recall correctly, the C# language spec or some of Microsoft's engineers made the property syntax above as a means by which to entice VB programmers to start using the language. This was "sugar" for get_Property() and set_Property(string value) respectively, a common naming convention in Java for functions that represent properties. Great article by the way and I appreciate the positive vibes.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I'm a huge fan of syntactic sugar in C# - but its always there. In JavaScript, support is dependent on the environment unless you transpile and polyfill all of your code all of the time (at least for example the spread operator)
C# example (14 lines to 1 with proper linting):
Is syntactic sugar for:
Well I guess coffeescript is complete syntax caramel then!
That is a really clear example, thanks!
lol "complete syntax caramel"... I love it! I'm using that!
I've also used the term "syntactic saccharine" to describe bad sugar. Causes cancer of the semicolon.
I like how CoffeeScript turns this
into this
Short, sweet, and succinct. Now that is a delicious syntactic caramel!
Those are great. Included with C# 6, probably copied from coffeescript.
If I recall correctly, the C# language spec or some of Microsoft's engineers made the property syntax above as a means by which to entice VB programmers to start using the language. This was "sugar" for get_Property() and set_Property(string value) respectively, a common naming convention in Java for functions that represent properties. Great article by the way and I appreciate the positive vibes.