+1

If you're going to adopt a higher-level language, then it does seem odd that
you'd not embrace some of the best it has to offer.
Just consider other features beyond the "cleaner Java" list: partial
functions, deep function/object integration, xml literals, implicits,
higher-kinded types, extractors, by-name parameters

Some of these are clearly on the "advanced: use with caution" list, but
others you won't even know you're using, they're that well integrated.

If you thought closures were neat, try this trick:

val predicate = Map("apple" -> true, "banana" -> true, "lemon" -> false,
"orange" -> false, "pear" -> true)
val fruitList = List("apple", "apple", "pear", "orange", "pear", "lemon",
"banana")
val noCitrus = fruitList.filter(predicate)

The magic is in Predicate, which is defined as a Map.  But, and this is the
clever part, Map is a subclass of Function1.
So whenever a function from X => Boolean is called for, you can supply a
Map[X,Boolean]

All functions are objects, and any object can be a function, it's a very
powerful combination of features.


Having said all of that.  Using Scala as a clean Java is a perfect way to
start with the language.  You can then ease into the other features
gradually.




On 16 September 2010 04:42, Reinier Zwitserloot <[email protected]> wrote:

> This argumentation of "If you don't like the DSL stuff don't use it"
> isn't convincing, at least not for me.
>
> You can't just throw out half of a language. I have to look at code
> written by others. I want to use libraries that say "for Scala" (or
> even: "For JVM"). I don't want to wait for a library that says "For
> Scala, and, oh, we don't use those particular features you didn't
> like". That doesn't scale in a world where code is shared between more
> than 1 developer.
>
> Also, if you want accurate equals, hashCode, getters, and setters,
> then, use Project Lombok. Strings in Switch will be coming in the now
> accelerated JDK7 (It's one of the features already completed). Use
> guava for a nice collections library. The few places where scala does
> significantly more type inference than java are either rarely
> applicable, actively disliked (in my experience) by those who would
> like to "throw out the DSL stuff", or it's inference of generics in
> variable assignments, which is also coming in JDK7 (diamond operator
> is also finished and won't have to wait for 8). That's most of the
> features on that list covered already, without having to do anything
> as drastic as switching to an entirely new language.
>
>
> If you're going to go with scala, go whole hog. I don't see the point
> of using scala as a java with slightly more cleaned up syntax. It's
> not worth the trouble of switching if that's all you're going to do.
>
> On Sep 16, 5:12 am, Sean Griffin <[email protected]> wrote:
> > Ok, it wasn't my intention to change the subject...not sure how that
> > happened.  Also, I think I was incorrect about setters on case
> > classes...not sure you can actually do that.  It's been a few months
> > since I've actually programmed in it.  I just review everyone else's
> > code these days...
>
> --
> You received this message because you are subscribed to the Google Groups
> "The Java Posse" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<javaposse%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/javaposse?hl=en.
>
>


-- 
Kevin Wright

mail / gtalk / msn : [email protected]
pulse / skype: kev.lee.wright
twitter: @thecoda

-- 
You received this message because you are subscribed to the Google Groups "The 
Java Posse" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/javaposse?hl=en.

Reply via email to