www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Scala collections

reply bearophile <bearophileHUGS lycos.com> writes:
A nice video with readable slides, mostly about Scala collections:
http://www.parleys.com/#id=2184&sl=71&st=5

Martin Odersky looks like a very intelligent person (about as Hongwei Xi,
author of ATS language).

Scala collections look very integrated with each other and with
functional-style programming. And they look good for parallelism too.

A flatMap() sounds useful in Phobos. It means flat(map()) where map returns a
small collection, and flat flattens them all in a single result. There is a
similar function in Haskell too.

Scala partition returns a 2-tuple. I'd like a similar functional function in
Phobos too, that doesn't touch the input range.

Bye,
bearophile
Jun 17 2011
parent reply Timon Gehr <timon.gehr gmx.ch> writes:
bearophile wrote:
 A nice video with readable slides, mostly about Scala collections:
 http://www.parleys.com/#id=2184&sl=71&st=5

 Martin Odersky looks like a very intelligent person (about as Hongwei Xi,
 author of ATS language).

 Scala collections look very integrated with each other and with
 functional-style programming. And they look good for parallelism too.

 A flatMap() sounds useful in Phobos. It means flat(map()) where map returns
 a small collection, and flat flattens them all in a single result. There is
 a similar function in Haskell too.

 Scala partition returns a 2-tuple. I'd like a similar functional function
 in Phobos too, that doesn't touch the input range.

 Bye,
 bearophile
Wow, neat. Thanks for sharing. I'm hardly halfway through, but I think we need to steal some Scala features sometime! =) It makes even D feel verbose. What I especially like: "var"/"val" are very short names for often used keywords. (not too descriptive though) Scala's way of doing the equivalent of inline delegates. (_.age < 18) vs (at least) (a){return a.age < 18;} or unaryFun!"a.age<18". List comprehensions. Is it maybe possible to get equivalent functionality and conciseness in a library solution? auto-return of last statement / def foo():Type=result for short function definitions. Infix functions and custom operators. Simple pattern matching (bearophile's well-known tuple unpacking sugar) Tuples. Tuples. Tuples. Cheers, Timon
Jun 17 2011
parent reply bearophile <bearophileHUGS lycos.com> writes:
Timon Gehr:

 I'm hardly halfway through, but I think we need to steal some Scala features
 sometime! =)
The most important features of Scala are in its refined type system. The things you underline aren't the most important ones.
 "var"/"val" are very short names for often used keywords. (not too descriptive
though)
In origin it was "invariant", then we have asked for "immutable", but now I like val better because it's shorter. I have seen D code use more "const" maybe just because "immutable" is a longer word.
 List comprehensions. Is it maybe possible to get equivalent functionality and
 conciseness in a library solution?
List comps are good to improve psychological chunking. In dlibs1 I have a select that apes them, but we are not there.
 Simple pattern matching (bearophile's well-known tuple unpacking sugar)
Scala pattern matching is far more than just unpacking tuples. But currently I don't miss it a lot. Bye, bearophile
Jun 17 2011
next sibling parent Timon Gehr <timon.gehr gmx.ch> writes:
bearophile wrote:
 Timon Gehr:

 I'm hardly halfway through, but I think we need to steal some Scala features
 sometime! =)
The most important features of Scala are in its refined type system. The things
you underline aren't the most important ones. I just underlined features I am somewhat missing from D. I think templates and CTFE can be used to build complex systems more easily than by using the caps of a refined type system. But I am definitely going to look into it. Apparently, it provides VERY nice means to define beautiful syntax in a library!
 "var"/"val" are very short names for often used keywords. (not too descriptive
though)
 In origin it was "invariant", then we have asked for "immutable", but now I
like
val better because it's shorter. I have seen D code use more "const" maybe just because
 "immutable" is a longer word.
=(. Well, definition blocks help somewhat: immutable{ int a=8383,b=foo(); bool c=true; }
 List comprehensions. Is it maybe possible to get equivalent functionality and
 conciseness in a library solution?
List comps are good to improve psychological chunking. In dlibs1 I have a select
that apes them, but we are not there.
 Simple pattern matching (bearophile's well-known tuple unpacking sugar)
Scala pattern matching is far more than just unpacking tuples. But currently I
don't miss it a lot. Yes, I only miss the most basic features too.
 Bye,
 bearophile
Cheers, - Timon
Jun 17 2011
prev sibling parent Russel Winder <russel russel.org.uk> writes:
On Fri, 2011-06-17 at 21:12 -0400, bearophile wrote:
[ . . . ]
 "var"/"val" are very short names for often used keywords. (not too desc=
riptive though)
=20
 In origin it was "invariant", then we have asked for "immutable", but now=
I like val better because it's shorter. I have seen D code use more "const= " maybe just because "immutable" is a longer word. [ . . . ] Groovy folk debated this one a few days ago, and the consensus was that val and var are far too similar to have such huge differences of semantics. In the Java context, to which Groovy is intimately tied, using def and final seems to be winning the day. =20 --=20 Russel. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D Dr Russel Winder t: +44 20 7585 2200 voip: sip:russel.winder ekiga.n= et 41 Buckmaster Road m: +44 7770 465 077 xmpp: russel russel.org.uk London SW11 1EN, UK w: www.russel.org.uk skype: russel_winder
Jun 18 2011