Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Articles like this I guess. If these are the 'lovable' features I'd hate to see the 'meh' features.

Automatic constructors - You only have to write the 'make me a box of two apples' code and not 'this is how two apples go into a box'! This is as revolutionary as 'automatic function calls', where you don't have to manually push the instruction pointer to pop it back off later.

Parenthesis omission!

If I were to parody this I'd talk about how good Scala is - in addition to classes, you can also declare objects, saving you the effort of typing out the static keyword on each member.

Sell me something nice! Millions of threads on a node. Structured concurrency. Hygienic macros. Homoiconicity. Higher-kinded types. Decent type inference. Pure functions. Transactions.



D has pure functions:

https://dlang.org/spec/function.html#pure-functions

D's pure functions are quite strict. It can be a challenge to write a function that passes strict purity guarantees - but the result is worth it!


compile time function evaluation is "nice" in the same way those features are, isn't it?


What's interesting is that other languages have since adopted CTFE, but they missed the point and did it wrong. The usual mistake is to add a keyword necessary to trigger it. D triggers it when an expression appears where a "const-expression" appears in the grammar. I.e:

    int x = f(); // f() is run at run time
    enum y = f(); // f() is run at compile time




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

Search: