Scala?

A place to discuss the implementation and style of computer programs.

Moderators: phlip, Moderators General, Prelates

User avatar
OOPMan
Posts: 314
Joined: Mon Oct 15, 2007 10:20 am UTC
Location: Cape Town, South Africa

Scala?

Postby OOPMan » Tue May 31, 2011 4:36 am UTC

Anyone else been looking at learning this?

I'm not a big fan of Java but Scala (Along with Clojure) put the JVM to a better use IMHO...
Image

Image

User avatar
MHD
Posts: 630
Joined: Fri Mar 20, 2009 8:21 pm UTC
Location: Denmark

Re: Scala?

Postby MHD » Tue May 31, 2011 1:04 pm UTC

I'm looking at possibly learning it too.

The other candidates on my list are: Erlang, SML and FORTH
EvanED wrote:be aware that when most people say "regular expression" they really mean "something that is almost, but not quite, entirely unlike a regular expression"

User avatar
Berengal
Superabacus Mystic of the First Rank
Posts: 2707
Joined: Thu May 24, 2007 5:51 am UTC
Location: Bergen, Norway
Contact:

Re: Scala?

Postby Berengal » Tue May 31, 2011 1:13 pm UTC

I personally think Clojure is better than Scala, but it's certainly an interesting language. Better than Java by far.
It is practically impossible to teach good programming to students who are motivated by money: As potential programmers they are mentally mutilated beyond hope of regeneration.

User avatar
thoughtfully
Posts: 2253
Joined: Thu Nov 01, 2007 12:25 am UTC
Location: Minneapolis, MN
Contact:

Re: Scala?

Postby thoughtfully » Tue May 31, 2011 3:09 pm UTC

MHD wrote:I'm looking at possibly learning it too.

The other candidates on my list are: Erlang, SML and FORTH

If you're considering Forth, you might want to look into a more modern stack-based language, such as Factor.
Image
Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away.
-- Antoine de Saint-Exupery

User avatar
OOPMan
Posts: 314
Joined: Mon Oct 15, 2007 10:20 am UTC
Location: Cape Town, South Africa

Re: Scala?

Postby OOPMan » Fri Jun 03, 2011 3:48 pm UTC

Berengal wrote:I personally think Clojure is better than Scala, but it's certainly an interesting language. Better than Java by far.


Well Clojure is a LISP so it figures that it's a better language :-)
Image

Image

bytbox
Posts: 56
Joined: Wed Aug 19, 2009 5:43 am UTC

Re: Scala?

Postby bytbox » Tue Jun 07, 2011 5:22 am UTC

Berengal wrote:Better than Java by far.

Oh, that's hard.

I've been looking at learning scala or erlang. (By which I mean, scala and erlang, and I haven't decided the order.) The thought of having to deal with the JVM makes me sick, though - I hope openjdk is more stable these days...

EvanED
Posts: 4331
Joined: Mon Aug 07, 2006 6:28 am UTC
Location: Madison, WI
Contact:

Re: Scala?

Postby EvanED » Tue Jun 07, 2011 5:36 am UTC

The JVM is actually a decent enough platform. With the exception of the lack of tail call support, it's pretty much the best VM out there from what I can tell.

User avatar
Berengal
Superabacus Mystic of the First Rank
Posts: 2707
Joined: Thu May 24, 2007 5:51 am UTC
Location: Bergen, Norway
Contact:

Re: Scala?

Postby Berengal » Tue Jun 07, 2011 6:41 pm UTC

EvanED wrote:The JVM is actually a decent enough platform. With the exception of the lack of tail call support, it's pretty much the best VM out there from what I can tell.
I think that both the CLR and Dalvik are better VMs. The JVM is actually rather primitive. What's good about it are the various highly mature, highly optimized implementations, although these vary from platform to platform as well. For example, I don't think there's any JVM implementation that beats Dalvik on the platforms that it runs natively on. I've yet to see a comparison between any JVM and the microsoft CLR implementation, but Mono is about half the speed of hotspot (comparing Java and C# programs) and I suspect microsoft's implementation is better while hotspot may be slower on windows than on linux.
It is practically impossible to teach good programming to students who are motivated by money: As potential programmers they are mentally mutilated beyond hope of regeneration.

korona
Posts: 495
Joined: Sun Jul 04, 2010 8:40 pm UTC

Re: Scala?

Postby korona » Tue Jun 07, 2011 7:37 pm UTC

Berengal wrote:
EvanED wrote:The JVM is actually a decent enough platform. With the exception of the lack of tail call support, it's pretty much the best VM out there from what I can tell.
I think that both the CLR and Dalvik are better VMs. The JVM is actually rather primitive. What's good about it are the various highly mature, highly optimized implementations, although these vary from platform to platform as well. For example, I don't think there's any JVM implementation that beats Dalvik on the platforms that it runs natively on. I've yet to see a comparison between any JVM and the microsoft CLR implementation, but Mono is about half the speed of hotspot (comparing Java and C# programs) and I suspect microsoft's implementation is better while hotspot may be slower on windows than on linux.

CLR has almost the same architecture as the JVM. It's also stack based. The only difference I can think of is that it supports unsigned integers and interaction with native code. EDIT: IIRC CLR supports stack allocated objects. Hotspot is very good at dealing with short lived objects; newer versions of Hotspot also support escape analysis. (Personally I don't like the CLR assembly file format and its embedding into PE as the spec is _very_ complex)

Hotspot has a much better JIT and garbage collector than Dalvik. Dalvik obviously shares the JVM's type system. The only reason that Google uses Dalvik is that Hotspot has a huge memory footprint. Could you state any reasons why you think that Dalvik and CLR are better virtual machines?

User avatar
Berengal
Superabacus Mystic of the First Rank
Posts: 2707
Joined: Thu May 24, 2007 5:51 am UTC
Location: Bergen, Norway
Contact:

Re: Scala?

Postby Berengal » Tue Jun 07, 2011 8:58 pm UTC

The CLR has stack-allocated objects and parameterized types. Dalvik is a register machine, which is just nicer to work with overall. Also, Dalvik's executable format is supperior to the JVMs.

korona wrote:Hotspot has a much better JIT and garbage collector than Dalvik.
Do you have any benchmarks for that? I've been looking for some, but I haven't even found any indication that they both run on the same hardware yet.
It is practically impossible to teach good programming to students who are motivated by money: As potential programmers they are mentally mutilated beyond hope of regeneration.

EvanED
Posts: 4331
Joined: Mon Aug 07, 2006 6:28 am UTC
Location: Madison, WI
Contact:

Re: Scala?

Postby EvanED » Tue Jun 07, 2011 10:31 pm UTC

Berengal wrote:The CLR has stack-allocated objects and parameterized types. Dalvik is a register machine, which is just nicer to work with overall. Also, Dalvik's executable format is supperior to the JVMs.

korona wrote:Hotspot has a much better JIT and garbage collector than Dalvik.
Do you have any benchmarks for that? I've been looking for some, but I haven't even found any indication that they both run on the same hardware yet.

I haven't seen comparisons of the actual .Net VM and the JVM, but I suspect that even if the CLR is better in theory (because of those benefits you mention, though I'm not sure that stack-allocated objects count) the actual implementation wouldn't measure up.

Maybe I'll try to do some experiments some time. Any suggestions for benchmarks to try?

korona
Posts: 495
Joined: Sun Jul 04, 2010 8:40 pm UTC

Re: Scala?

Postby korona » Thu Jun 09, 2011 7:50 pm UTC

Hotspot has much greater optimizations than Dalvik; I don't know any research papers on this topic but you can look at the code & documentation of both vms. Dalvik's compiler is still _very_ young. (There is a comparisons of Mono, Dalvik and Hotspot (ie. modified versions of Mono and Hotspot that run on mobile phones). It seems that Mono is pretty fast among those vms but I don't think anyone actually verified the results of that author. The author also uses an outdated version of Dalvik with no compiler. Here is the link: http://www.koushikdutta.com/2009/01/dalvik-vs-mono.html)

Dalvik is optimized for low memory footprint and not for great performance optimizations; so is its bytecode file format.
I don't think that register based vms have advantages over stack based ones; being register based does not free the compiler to do actual register allocation; it does not even make it easier. (It don't recall how it CLR restricts the usage of the operand stack but the JVM puts constraints on the types that are pushed on the stack ie. the type of values passed to basic blocks must be equal at each branch refering to this block) Almost all "heavy" optimizations will need a data flow graph that can be easily be obtained from both representations. In particular Dalviks 4 bit register index format sucks and forces it to move data between registers regulary just to keep the file size low.


Return to “Coding”

Who is online

Users browsing this forum: No registered users and 13 guests