4 ms·
Anonymous lambdas instead of comprehensions, delegates instead of closures. D does not have decorators in the sense Python does, well function attributes might
by tastyminerals2 6y ago
Anonymous lambdas instead of comprehensions, delegates instead of closures. D does not have decorators in the sense Python does, well function attributes might come close. What I do enjoy in D syntax-wise is UFCS: https://tour.dlang.org/tour/en/gems/uniform-function-call-syntax-ufcs https://tour.dlang.org/tour/en/gems/uniform-function-call-sy...
Array slicing, ranges, compile-time execution. Probably the most succinct and easy-to-read syntax out of many compiled languages. It's an investment (as with any other language) but the learning curve is not steep if you get scared away by C++ or Rust for that matter. Julia comes to mind too in terms of syntax but no UFCS and its interoperability with C++/C looks like a lot of work compared to D.
- ttymck 6y agoUFCS is awesome, I had no idea it existed! Implicit classes are my favorite feature of scala[1], I agree .chain syntax is infinitely more readable. [1] https://riptutorial.com/scala/example/7538/implicit-classes https://riptutorial.com/scala/example/7538/implicit-classes
- tastyminerals2 6y agoUnlike in Scala, you can chain your custom methods in D. For example, seqOfChars.map!(a => a.toLower).filterIfNotDigitChar.sort.uniq; is simply not possible in Scala. Here is a great presentation about fp in D: http://beza1e1.tuxen.de/stuff/FunctionalD.pdf http://beza1e1.tuxen.de/stuff/FunctionalD.pdf
- rbonvall 6y agoIt is possible in Scala: https://scastie.scala-lang.org/k7bHR6EWS7qXvaC8gIj3VA https://scastie.scala-lang.org/k7bHR6EWS7qXvaC8gIj3VA (Unless you mean something different).
- tastyminerals2 6y agoTrue. I forgot about implicits (because I try not to use them :). Unfortunately it looks more like a kludge tbo. Sort and uniq get also hidden in a class which can be tucked away from your eyes and this is never good.
- qznc 6y agoThanks for calling my presentation "great". I don't design my slides to work without me talking though. The official tour has a short page about FP as well: https://tour.dlang.org/tour/en/gems/functional-programming https://tour.dlang.org/tour/en/gems/functional-programming Anyways, since Walter is probably reading this: Any new insights around this quote five years later? > I know a lot of the programming community is sold on exclusive constraints (C++ concepts, Rust traits) rather than inclusive ones (D constraints). What I don't see is a lot of experience actually using them long term. They may not turn out so well. –Walter Bright
- hellofunk 6y agoIt would seem that D and Nim have many similar goals and features.
- tastyminerals2 6y agoYes, they are frequently compared. If you like style-insensitive (case insensitivity, underscore ignored) languages with hacker mentality, Nim is for you. This is simply a no-go for me. I briefly tried Nim before even knowing about D and it never stuck with me due to awkward syntax (subjective). Later I learnt that Nim (being a younger language) frequently breaks backward compatibility. Maybe it changed now but all the above was enough to pass it and move on.
- pjmlp 6y agoWhat I dislike is the {. .} annotations, Active Oberon also followed that path and I don't find it that great.
- throwaway_pdp09 6y agoSome context would be nice - can you say a little more on that annotation please.
- pjmlp 6y agoThat is how Nim does pragmas, https://nim-lang.org/docs/manual.html#pragmas https://nim-lang.org/docs/manual.html#pragmas And Active Oberon as well (here called flags), http://cas.inf.ethz.ch/projects/a2/repository/raw/trunk/LanguageReport/OberonLanguageReport.pdf http://cas.inf.ethz.ch/projects/a2/repository/raw/trunk/Lang...