On Friday, 15 June 2018 at 23:04:40 UTC, Sjoerd Nijboer wrote:
For someone coming from a C# background there is some seemingly
simple syntactic sugar missing from D.
First of all, it’s not missing but deliberately not added for
many reason, which I’m sure other folks from core team will
provide and correct me where applicable.
* The null conditional operator `?.`
Might be interesting but we need to try more principled approach
alng the line of Option!T type with nice accessors and maybe even
make non-null a default. The latter will take not a single year
though. But peppering language with more built-in magic is not
our direction, I’m pretty certain of that.
* Something like a `yield return` statement for coroutines.
That was on the radar actually, and would encode stackless
automation wrapped as InputRange. Problem is how to get it to be
say forward range (i.e. state saving would really be nice to
include). For stackfull we have std.concurrency.Generator in
library code just fine (IIRC).
T* he `async` & `await` keyword from C# make proactor pattern
async code extremely easy to reason about.
God please no. Look at Go’s popularity because of dead simple go
routines and “async i/o is transparent and looks blocking but
ain’t so”. We have at least vibe.d for that and possibly more.
Also see Java doing fibers recently, and Kotlin did them just a
year or so back. People love fibers and mostly dislike
Futers/explicit async, and plain callbacks are obvious last
resort that nobody likes.
‘async’ is viral keywords that poorly scales, I worked on Dart
core team and even they admitted this problem is not solved well.
* a good syntax for properties so there's less code bloat.
* replacing `Allocator.make()` with `new!Allocator`. After all
`new` can be concidered as just a wrapper around the standard
GC allocator. Why can't we just have a special template of it?
Is a good idea, but syntactic sugar is smallest part of this
problem if at all.
I have realized that I have become quite dependant on syntactic
sugar to the point that it severely impacts my productivity
when I work whitout. And these ones are my biggest obstacles
when I try to work with D from a C# experience.
Yeah it won’t be smooth then I could see.
I think that C# really nailed down some of these particular
examples except the last one of course.
And I also think D could do a better job of embracing
productivity through supporting syntax of common tasks and
borrow from other languages in that regard.
But the most important question is how other people feel about
that.
If people hate syntactic sugar D will never become that gem for
me that I would like it to be. But if key people want it, it
one day might.