Hacker News new | ask | show | jobs
by tastyminerals2 2167 days ago
Unlike 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

2 comments

It is possible in Scala: https://scastie.scala-lang.org/k7bHR6EWS7qXvaC8gIj3VA

(Unless you mean something different).

True. 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.

Thanks 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

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