The Artima Developer Community
Sponsored Link

Weblogs Forum
Is Scala really more complicated than Java?

54 replies on 4 pages. Most recent reply: Nov 11, 2009 11:45 AM by Danny Lagrouw

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 54 replies on 4 pages [ « | 1 2 3 4 ]
Darren Cruse

Posts: 1
Nickname: dcruse
Registered: Apr, 2004

Re: Is Scala really more complicated than Java? Posted: Sep 30, 2009 3:45 PM
Reply to this message Reply
Advertisement
Good article. Ignoring the details, I think the real point is that people will always be biased toward calling something different/new "complicated". It's human nature. I think the article's example illustrates that generally, getting comfortable with a language like Scala requires thinking less imperatively (the computer does this then this then this) and more declaratively/logically and trusting that if the logic is right the outcome will be right. Similar e.g. to teaching recursion to someone who's only known looping. They'll say recursion is more complicated as they mentally try and step thru what the computer is doing until they stop that and just think logically about whether they've logically covered the cases. I see this as similar to this article. Scala can be more abstract and more declarative while the java gives choices that on the whole are less abstract and more imperative.

Tiago Motta

Posts: 2
Nickname: timotta
Registered: Sep, 2009

Re: Is Scala really more complicated than Java? Posted: Sep 30, 2009 3:55 PM
Reply to this message Reply
To print:

4.times { |i| puts "Happy Birthday #{ i==3 ? 'Dear XXX' : 'To You' }" }

To create an array:

(1..4).collect { |i| "Happy Birthday #{ i==3 ? 'Dear XXX' : 'To You' }" }

Tiago Motta

Posts: 2
Nickname: timotta
Registered: Sep, 2009

Re: Is Scala really more complicated than Java? Posted: Sep 30, 2009 3:56 PM
Reply to this message Reply
Ruby :)

Ayman Saleem

Posts: 4
Nickname: ayman
Registered: Dec, 2005

Re: Is Scala really more complicated than Java? Posted: Oct 2, 2009 9:23 AM
Reply to this message Reply
Hi Vassil,

For me, your conclusion and examples are very interesting; they don't contradict with my point when I said "I don't think that two great languages can be compared using single and compacted lines (which are not recommended anyhow) especially when we recall that a scientific comparison would consider the coding context and purpose". (That's to say, even English-like syntax depends on the coding context even if the language addresses semantics sufficiently)


Obviously, Scala introduces many features (some sound to be magical too) and it employs many of the lessons learned in using older languages as it was the case with C#, Java, and others when those languages addressed certain issues in C, C++, ...etc

Here, I think the issue is not about generalizations since context, purpose, and other factors are critical in software development where each solution (or language) would target more areas than others and each programming language would have its pros and cons when these factors are considered (for instance, the variation of your examples is evident on this fact). In short, there is no silver bullet.

Vassil Dichev

Posts: 6
Nickname: 53870
Registered: Feb, 2008

Re: Is Scala really more complicated than Java? Posted: Oct 2, 2009 1:25 PM
Reply to this message Reply
Ayman,

Certainly, you're right that my intent wasn't to contradict your point. And if the last decades have taught us anything about software engineering, it's that there really is no silver bullet.

The idea I wanted to convey is that Scala is very good in isolating complexity from one layer to another. Writing software is inherently complex, so it's not possible to eliminate it entirely. But the least we can do is not force it upon developers who don't need to deal with it. It's the same with garbage collection- it doesn't eliminate memory leaks altogether, but it certainly simplifies memory management a whole lot.

As for Scala, it's not the perfect language, and I don't think there is one. Minimal languages like the Lisp-based Clojure, or other dynamic languages like Ruby or Python all have their appeal.

I must say that Dick did a great job in giving an example that is both fairly simple to understand, but still showing enough of the new paradigms that Scala offers. It's hard to showcase a programming language in just a couple of minutes of one's attention span, but Dick also has the experience of the Scripting Bowl from the last Java One, where Scala finished second. The fact that this thread started a life of its own really shows that he struck a nerve.

For me, that's a mission accomplished- not to convince that Scala is the best language, but that there is more beyond Java, and you can use it now- it's not so difficult. I wouldn't go so far to say that Scala is superior to Ruby, Python, etc., but you can still learn something from Scala.

Benjamin James

Posts: 7
Nickname: bmjames
Registered: Oct, 2009

Re: Is Scala really more complicated than Java? Posted: Oct 12, 2009 3:46 AM
Reply to this message Reply
I much prefer the first Scala example without all the parentheses and dots:

1 to 4 map { i => "Happy Birthday %s" format (if (i==3) "Dear XXX" else "To You") } foreach println

Some might see this as overuse or even abuse of the special syntax case for infix operators.

But to me, especially when chaining maps, filters, foreaches etc. on an interator, it makes the whole statement look almost like a sentence rather than just a line of code.

Benjamin James

Posts: 7
Nickname: bmjames
Registered: Oct, 2009

Re: Is Scala really more complicated than Java? Posted: Oct 12, 2009 4:15 AM
Reply to this message Reply
Also I find foreach println to be far more readable than foreach { println(_) }. If you're still using the latter you're really not taking advantage of the brevity Scala allows for this very common situation (of calling a unary function with foreach).

craig bordelon

Posts: 2
Nickname: cbordelo
Registered: Jan, 2008

Re: Is Scala really more complicated than Java? Posted: Oct 16, 2009 6:36 AM
Reply to this message Reply
Anybody besides me think to use xml detour to get the "string interpolation" that earlier commenter pointed out was missing from scala:

scala> val name = "Dick Wall"
scala> println(<a>
| Happy Birthday to you
| Happy Birthday to you
| Happy Birthday dear {name}
| Happy Birthday to you
| </a>.text)

Happy Birthday to you
Happy Birthday to you
Happy Birthday dear Dick Wall
Happy Birthday to you

As to the subject matter at hand.
Of course Scala is more :) complicated than Java.
Java is like having a pack of 16 crayons to color with where Scala is like having a 64 pack.

Thomas Knierim

Posts: 3
Nickname: 58330
Registered: Sep, 2008

Re: Is Scala really more complicated than Java? Posted: Oct 16, 2009 6:48 PM
Reply to this message Reply
The initial post suggests that you can tell complexity by code length or code structure. I don't think that is the case. Scala code is typically more concise than Java code (the posted example may be an exception), but I doubt it is therefore easier to read or understand.

Conciseness is good, because it relieves programmers from having to type boilerplate code. It reduces typos and speeds up development cycle. But it only works to your advantage if you master the language.

I think it is obvious that Scala is more complicated than Java. In addition to understanding OOP, you also need to understand FP. Plus Scala has a richer type system. So, yes, there's a learning curve... but you get a more powerful programming arsenal.

Cheers, Thomas

Danny Lagrouw

Posts: 1
Nickname: dlagrouw
Registered: Jan, 2006

Re: Is Scala really more complicated than Java? Posted: Nov 11, 2009 11:45 AM
Reply to this message Reply
> Anybody besides me think to use xml detour to get the "string interpolation" that earlier commenter pointed out was missing from scala:

In that case, we can match the Ruby examples:


(1 to 4).foreach {i => println(<a>Happy Birthday {if (i == 3) "Dear " + name else "To You"}</a>.text)}


and


(1 to 4).map {i => <a>Happy Birthday {if (i == 3) "Dear " + name else "To You"}</a>.text}

Flat View: This topic has 54 replies on 4 pages [ « | 1  2  3  4 ]
Topic: What are Your JUnit Pain Points, Really? Previous Topic   Next Topic Topic: Abstract Type Members versus Generic Type Parameters in Scala

Sponsored Links



Google
  Web Artima.com   

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