The Artima Developer Community
Sponsored Link

Java Community News
Five Things Java (and Ruby) Developers Need to Know about Scala

9 replies on 1 page. Most recent reply: Jan 10, 2007 9:45 AM by Joao Pedrosa

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 9 replies on 1 page
Bill Venners

Posts: 2284
Nickname: bv
Registered: Jan, 2002

Five Things Java (and Ruby) Developers Need to Know about Scala Posted: Jan 5, 2007 2:52 PM
Reply to this message Reply
Summary
David Pollak recently published a blog post listing five things Java developers should know about Scala, and today published another list of five things Ruby developers should know about Scala.
Advertisement

In 5 Things a Java developer needs to know about Scala, David Pollak gives his list of the most important things for Java developers to know about Scala. In brief:

  • Scala programs are byte-code compatible with Java code.
  • Scala code is more compact and more expressive.
  • You can write code the way you used to and migrate to "functional" thinking as your brain shifts.
  • XML is an integral part of Scala.
  • Mixins/Traits are more flexible than Java's interfaces and single implementation inheritance.

In 5 Things a Ruby developer needs to know about Scala, David Pollak gives a different list, which he considers the most important things for Ruby developers to know about Scala. In brief:

  • Performance and stability.
  • Richer XML and collection classes.
  • More of a functional flavor.
  • Much better facilities for writing DSLs.
  • Static typing without getting in your face.

Do you think Scala has a chance of becoming mainstream? If so, in what areas?


Joao Pedrosa

Posts: 114
Nickname: dewd
Registered: Dec, 2005

Re: Five Things Java (and Ruby) Developers Need to Know about Scala Posted: Jan 5, 2007 6:14 PM
Reply to this message Reply
No, I don't. :-)

I think this interview with Ryan Davis should give some perspective of the Ruby side of the coin:

http://www.infoq.com/interviews/Ryan-Davis

Isaac Gouy

Posts: 527
Nickname: igouy
Registered: Jul, 2003

Re: Five Things Java (and Ruby) Developers Need to Know about Scala Posted: Jan 6, 2007 10:55 AM
Reply to this message Reply
Where does Ryan Davis mention Scala?

(Strangely he seems to think Erlang is statically type checked.)

Joao Pedrosa

Posts: 114
Nickname: dewd
Registered: Dec, 2005

Re: Five Things Java (and Ruby) Developers Need to Know about Scala Posted: Jan 6, 2007 4:20 PM
Reply to this message Reply
The idea is that he addresses many questions the way many Ruby proponents would. We are not ashamed of Ruby being dynamic typed, for instance. :-) We like it that way. To switch to another language is not an easy option, even if the language has support for type inference and is faster. :-) Why wouldn't we like to switch languages? The answer is Ruby itself, not the trouble of converting programs. For example, Ruby has very good Shell scripting support, has the integrated Regex (as mentioned by David), has only a handful of commonly used types (String, Fixnum, Float, Bignum (which works seamlessly), Hash, Array...).

I hope this helps in clarifying my position a little.

BTW, what I find hard about Scala or other growing languages in becoming mainstream is that they have lots of strong competition in the different languages that exist. Is Scala fast? Java and C# are fast as well. Does Scala want to become mainstream? Java and C# are already mainstream and will not make room for Scala to grow. What does Scala offer over Java and C#? Less verbosity? I think most Java and C# developers don't care about that. Does Scala offer more static typing support over Java and C#? Again, most Java and C# developers don't care about that. Does Scala offer support for DSL creation? Most Java and C# developers don't care about that either, because they are "application developers" too busy already to create their own programming tools. :-)

Alright, Scala maybe will not go head-to-head with the big guns, not because it lacks features, BTW. But will Scala try to go head-to-head with the "little guns", like Python, Perl, PHP, and Ruby? Then the speed, verbosity, and DSL support factors don't count as much in favor of Scala. The heavyweight of the Java libraries that Scala supports actually make it hard for the scripting languages to switch to it. XML what? :-)

Isaac Gouy

Posts: 527
Nickname: igouy
Registered: Jul, 2003

Re: Five Things Java (and Ruby) Developers Need to Know about Scala Posted: Jan 7, 2007 10:05 AM
Reply to this message Reply
We are not ashamed of Ruby being ...
That doesn't tell us whether you /should/ be ashamed or whether in fact there's nothing to be ashamed of.

James Watson

Posts: 2024
Nickname: watson
Registered: Sep, 2005

Re: Five Things Java (and Ruby) Developers Need to Know about Scala Posted: Jan 7, 2007 2:40 PM
Reply to this message Reply
> BTW, what I find hard about Scala or other growing
> languages in becoming mainstream is that they have lots of
> strong competition in the different languages that exist.
> Is Scala fast? Java and C# are fast as well. Does Scala
> want to become mainstream? Java and C# are already
> mainstream and will not make room for Scala to grow. What
> does Scala offer over Java and C#?

It's a much more expressive language and I think it supports a more effective programming model than Java does. I'm constantly having to write Java code just so I can write Java code.

I agree in that I think Scala will not gain mainstream acceptance. I think it's far too academic for the average developer. Most developers are far too confident that their approaches are best. Scala takes Java and turns it on it's head. There's really no comparison. I think that Scala could be one of those languages that never really gets off the launching pad but influences the creation of one that does. But not everything will be included. I'm wagering that a good number of things in Scala will be eventually be shunned. That's what my crystal-ball says, anyway.

> Alright, Scala maybe will not go head-to-head with the big
> guns, not because it lacks features, BTW. But will Scala
> try to go head-to-head with the "little guns", like
> Python, Perl, PHP, and Ruby? Then the speed, verbosity,
> and DSL support factors don't count as much in favor of
> Scala.

Speed doesn't count? Do mean development speed or execution speed. Execution speed does matter in a lot of shops (but admittedly more than it should in many of those.)

> The heavyweight of the Java libraries that Scala
> supports actually make it hard for the scripting languages
> to switch to it.

I don't get your point here. The vast number of libraries written for Java is a big bonus to me. I use Jython (maybe not for long) and I often turn to the Java libraries for certain things over the Python versions. Not to mention, Java is supported on the platform I am using and Python isn't (I'm pretty sure.)

> XML what? :-)

I don't get this XML thing with languages. Why is everyone in such a race to make their language more like COBOL. We need good XML-Object libraries, not native support. I dread the day I start seeing stinking XML hard-coded all over the place.

Brian Rogoff

Posts: 1
Nickname: brogoff
Registered: Jan, 2007

Re: Five Things Java (and Ruby) Developers Need to Know about Scala Posted: Jan 8, 2007 10:55 AM
Reply to this message Reply
Scala has a small chance of going mainstream, but I see
Joao's point that targetting the Ruby community is likely
a waste of effort.

My guess is that Scala will find traction amongst people
who have to work in a Java environment and who mostly
like Java but find some of it's limitations frustrating.
It may also attract some programmers who are interested in
functional programming who need to fit into a Java/JVM
environment. If I were a Ruby programmer I don't think I'd
find the arguments compelling, unless I was bumping into a
performance problem (then I'd use OCaml ;-).

It's definitely early in the adoption cycle for Scala,
there are lots of things missing (e.g. combinator parsers are nice but lots of people know lex/yacc and there isn't one for Scala) but if Scala is still being used and discussed in three or four years that may all change. I
like what I've read about Scala so far, so I hope it does
become mainstream.

Joao Pedrosa

Posts: 114
Nickname: dewd
Registered: Dec, 2005

Re: Five Things Java (and Ruby) Developers Need to Know about Scala Posted: Jan 10, 2007 4:31 AM
Reply to this message Reply
"Speed doesn't count? Do mean development speed or execution speed. Execution speed does matter in a lot of shops (but admittedly more than it should in many of those.)"

Like you say, speed is relative. It certainly counts, but the algorithms, the use of external database engines, the reuse of existing fast libraries, and such, all contribute to the final speed that the user might presence. Often said as "glue languages", the scripting languages aren't known for heavy lifting anyway, but they get used all the time for many things, nonetheless. :-)

"I don't get your point here. The vast number of libraries written for Java is a big bonus to me. I use Jython (maybe not for long) and I often turn to the Java libraries for certain things over the Python versions. Not to mention, Java is supported on the platform I am using and Python isn't (I'm pretty sure.)"

My short experience with JRuby gave me a clue: interoperability. For example, you may want to implement an interface, an abstract class, and sometimes you might need it to be accessible from Java itself. To be able to override methods and provide more of the native Java functionality from another language does not seem to be that easy to get going. Also, I can read a file in Ruby with "IO.read(file_path)". In JRuby it's possible to do the same thing. But can you do it like that in BeanShell? Or in Jython? There are difference, sometimes large, because the Java libraries are not known for providing easy to consume APIs.

For instance, when I added some support for the Simple Web Framework (Java) to a JRuby prototype, I noticed that it had some helper classes in its source code. I think many Java applications and libraries recreate their own "helper classes" all the time, maybe because they want a small footprint and don't want to create a dependency on large Apache Jakarta libraries, but I am not sure. But the point is that the wheel reinvention is fulled by the uncaring core Java APIs. And a scripting language might suffer from the wheel reinvention as well, because easy to reuse APIs might not come "free". :-)

"I don't get this XML thing with languages. Why is everyone in such a race to make their language more like COBOL. We need good XML-Object libraries, not native support. I dread the day I start seeing stinking XML hard-coded all over the place. "

I have been using JSON for streaming data as of late (converted to it from YAML a few days ago). In Ruby, YAML is largely used for configuration files. I think that with the JSON popularity increasing, it will become the most popular alternative to XML.

When I am developing, I might not know yet the design of the configuration files. Sometimes you might want to store the information in the database. You could use JSON for that as well. Also, in Ruby, a separated Ruby file can be used for configuration. For example, I use one for each Web Application, I use one for each Web server. And I even use one for a Web Dispatcher I created recently.

The alternatives to XML are accumulating. With a scripting language, you might have more options at your hands. The problem is that scripting languages allow for faster development and lots of "wheel reinventions" in short periods of time (the increased productivity allows for that), and XML use becomes awkward at best.

James Watson

Posts: 2024
Nickname: watson
Registered: Sep, 2005

Re: Five Things Java (and Ruby) Developers Need to Know about Scala Posted: Jan 10, 2007 6:13 AM
Reply to this message Reply
> "Speed doesn't count? Do mean development speed or
> execution speed. Execution speed does matter in a lot of
> shops (but admittedly more than it should in many of
> those.)"
>
> Like you say, speed is relative. It certainly counts, but
> the algorithms, the use of external database engines, the
> reuse of existing fast libraries, and such, all contribute
> to the final speed that the user might presence. Often
> said as "glue languages", the scripting languages aren't
> known for heavy lifting anyway, but they get used all the
> time for many things, nonetheless. :-)

I don't argue with you here but I don't see Scala as a scripting language. You can use it in an interpreter mode IIRC but I think generally people compile it to bytecodes.

> "I don't get your point here. The vast number of libraries
> written for Java is a big bonus to me. I use Jython (maybe
> not for long) and I often turn to the Java libraries for
> certain things over the Python versions. Not to mention,
> Java is supported on the platform I am using and Python
> isn't (I'm pretty sure.)"
>
> My short experience with JRuby gave me a clue:
> interoperability. For example, you may want to implement
> an interface, an abstract class, and sometimes you might
> need it to be accessible from Java itself. To be able to
> override methods and provide more of the native Java
> functionality from another language does not seem to be
> that easy to get going. Also, I can read a file in Ruby
> with "IO.read(file_path)". In JRuby it's possible to do
> the same thing. But can you do it like that in BeanShell?
> Or in Jython? There are difference, sometimes large,
> because the Java libraries are not known for providing
> easy to consume APIs.

Jython is just a version of Python with some extra features. You can read a file by calling open(). What I generally do is make helper modules to simplify access to the Java functionality.

> For instance, when I added some support for the Simple Web
> Framework (Java) to a JRuby prototype, I noticed that it
> had some helper classes in its source code. I think many
> Java applications and libraries recreate their own "helper
> classes" all the time, maybe because they want a small
> footprint and don't want to create a dependency on large
> Apache Jakarta libraries, but I am not sure. But the point
> is that the wheel reinvention is fulled by the uncaring
> core Java APIs. And a scripting language might suffer from
> the wheel reinvention as well, because easy to reuse APIs
> might not come "free". :-)

I'm not really talking about reinventing the wheel. There are a lot of libraries in Java all over the place. Not all of them are open source. Many shops have millions of lines of critical applications written in Java. If they've written them well, they may be able to use them from a language like Jython or Scala. They can then avoid the huge risks of the 'big rewrite'.

> "I don't get this XML thing with languages. Why is
> everyone in such a race to make their language more like
> COBOL. We need good XML-Object libraries, not native
> support. I dread the day I start seeing stinking XML
> hard-coded all over the place. "
>
> I have been using JSON for streaming data as of late
> (converted to it from YAML a few days ago). In Ruby, YAML
> is largely used for configuration files. I think that with
> the JSON popularity increasing, it will become the most
> popular alternative to XML.
>
> When I am developing, I might not know yet the design of
> the configuration files. Sometimes you might want to store
> the information in the database. You could use JSON for
> that as well. Also, in Ruby, a separated Ruby file can be
> used for configuration. For example, I use one for each
> Web Application, I use one for each Web server. And I even
> use one for a Web Dispatcher I created recently.
>
> The alternatives to XML are accumulating. With a scripting
> language, you might have more options at your hands. The
> problem is that scripting languages allow for faster
> development and lots of "wheel reinventions" in short
> periods of time (the increased productivity allows for
> that), and XML use becomes awkward at best.

I've heard or JSON but I need to look into it more. I was really thinking something else here. I don't see why we need to make serialization formats part of general programming language. We need better approaches for serializing Object graphs into different formats. For example lets say JSON does become the dominate format, then we'll still be stuck with XML because it's all through the code. From a more general standpoint, we shouldn't be hardcoding serialization structures. Making this part of the language is just going to encourage people to do this and I can't see how that's good.

I was just in a meeting yesterday where we have to write a file to the government and they have changed the file structure every year for the last five years. The program is written in RPG and the file structure is hardcoded and compiled into the program. Every year someone has to go in and modify the program and recompile it instead of just adding or modifying a configuration that defines how the data is output to the file. Sure you might need to modify the program anyway but not for every little change. This makes me want to scream because it's as if no one else sees this as a problem and we are headed full-steam into this same situation with XML.

Joao Pedrosa

Posts: 114
Nickname: dewd
Registered: Dec, 2005

Re: Five Things Java (and Ruby) Developers Need to Know about Scala Posted: Jan 10, 2007 9:45 AM
Reply to this message Reply
"I don't argue with you here but I don't see Scala as a scripting language. You can use it in an interpreter mode IIRC but I think generally people compile it to bytecodes."

Oh, I wasn't referring to any language in particular. Maybe to the languages people consider "slow", though. :-)

"Jython is just a version of Python with some extra features. You can read a file by calling open(). What I generally do is make helper modules to simplify access to the Java functionality."

:-) I remember when NIO was launched, and I tried to use it. It was very hard, and inappropriate for me, actually. But it was supposed to be fast! And I wanted that! (At the time. hehe)

I make my own "helper modules" in Ruby as well, even though Ruby provides a lot of concentrated and easy to use APIs. The point is that the fewer "helper modules", the merrier. :-)

"I'm not really talking about reinventing the wheel. There are a lot of libraries in Java all over the place. Not all of them are open source. Many shops have millions of lines of critical applications written in Java. If they've written them well, they may be able to use them from a language like Jython or Scala. They can then avoid the huge risks of the 'big rewrite'."

I'm writing this most to give you feedback on this. I certainly support the avoidance of "big rewrites". That's why I have been trying to choose my libraries carefully, even though they are in Ruby. I really want to try to avoid rewriting things every few years. When I started in Ruby, I was disillusioned with the Java/.NET state of affairs, which would split the community (which they did).

I really didn't want to aim low and have to rewrite things every now and then. Think about the .NET's "big rewrite" with WPF and the other goodies of Windows Vista! Also, at the time the Java Swing had some problems with accented characters on Linux, which I needed as a Portuguese speaker.

When I wrote my first Ruby-GTK+ application, it didn't have any problem of accented character on Linux, and on top of it, it used much less memory than the Java Swing applications (I had one which I had converted from Java/Swing to Ruby/(GTK+|Fox-Toolkit)). At the time, Rails was still a dream in DHH's head.

My point for this is two-fold:
1) Dream your own dream, make your own choices, and things might turn out OK in the end;
2) Sometimes we just need to go with the flow, in which case, just try to enjoy it (for instance, the Java to .NET conversions);

Given that, I am all for the "no rewrites". :-)

"I've heard or JSON but I need to look into it more. I was really thinking something else here. I don't see why we need to make serialization formats part of general programming language. We need better approaches for serializing Object graphs into different formats. For example lets say JSON does become the dominate format, then we'll still be stuck with XML because it's all through the code. From a more general standpoint, we shouldn't be hardcoding serialization structures. Making this part of the language is just going to encourage people to do this and I can't see how that's good."

"I was just in a meeting yesterday where we have to write a file to the government and they have changed the file structure every year for the last five years. The program is written in RPG and the file structure is hardcoded and compiled into the program. Every year someone has to go in and modify the program and recompile it instead of just adding or modifying a configuration that defines how the data is output to the file. Sure you might need to modify the program anyway but not for every little change. This makes me want to scream because it's as if no one else sees this as a problem and we are headed full-steam into this same situation with XML."

Your worries are well-founded, but as said by a Brazilian politician by free-form translation to English: "He who worries doesn't hurry." Actually the literal translation would have been: "He who worries doesn't get busy." (pt_BR: Aquele que se preocupa não se ocupa.) (Which rhymes in Portuguese, like I tried to do in my first English translation.)

All that said, I think JRuby has a chance of revolutionizing the Java languages portfolio. The "Jython/Scala/Groovy" safe-bets might become a little obsolete once JRuby becomes stable and fully interoperable with Java. One of the killer JRuby features, pushed by Ruby itself, might be a very good support for "Shell scripting" for the JVM! Also, their support of Rails will give them instant access to a large pool of enthusiasts which will keep the ball rolling no matter what.

Remember! No "big rewrites". Bet wisely. Wait a little if you need to.

Flat View: This topic has 9 replies on 1 page
Topic: Adobe Ships FlexBuilder for the Mac Previous Topic   Next Topic Topic: Martin Fowler on Role Interfaces

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use