> Interestingly, Scala can declare a thrown exception that Java will force you
> to catch, via the @throws annotation
> But it'll never force you to catch them at a time that's inconvenient for
> you.

Or tell you about it.  That said, you might be able to write some
bytecode processor that produces a report for all your bytecode that
hides checked exceptions.  Though I imagine you'll still lose some in
the Function traits.

> Imagine performing an operation in parallel on an array of 100 elements, and
> 2 of those invocations throw.
> Checked exceptions state that you *must* catch a checked exception (though
> we all know that remoting and threads can break this)
> Unchecked exceptions, you can bundle together in an aggregate, but how could
> the enforced catch behaviour best be handled?

Ideally when you read the results you'll see the exceptions.  That's
how SwingWorker works now, and I think it's how Future works.

> Compare
>   HashMap<Shape, Pair<String, String>> shapeInfo = makeInfo()
> to
>   val shapeInfo: HashMap[Shape, (String, String)] = makeInfo()

HashMap[Shape, Pair[String, String]] shapeInfo = makeInfo()

I personally find this very readable (the (String, String) sugar is
nice too).  It's the angle brackets in the Java version that make it
harder to read, especially in a proportional font like the one I'm
reading these emails in.

> Plus, you have the ability to invoke methods on any Int (primitives don't do
> this)
> So `2.toString` is a valid Scala operation.

The same in C#, though there it's spelled 2.ToString() Because That's
What C# Looks Like.  And int is a primitive in C#.  And you can do
List<int> in C#.  The syntax differences between primitive and
reference types are just a Javaism, and nothing inherent about
primitive types.

> val tags = for {
>   page <- site.pages
>   tag <- page.tags
>   ucTag = tag.toUpperCase
> } yield ucTag
> and that's just a short example, not even using a filter.  The difference
> between <- and : helps indicate that this construct really isn't a loop.

Why do you need to indicate that it's not really a loop?  yield
already does that.  And if you didn't have yield it would really be a
loop.
> Scala's grammar is approximately 1/3 of Java's.  When counting
> non-whitespace lines from the respective BNF descriptions of the two
> languages, as taken from the official specifications.

Is Scala's BNF up to date?

-- 
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