Scala吧~  - 讨论区

标题:Scala 2.9.0 final

2011年05月13日 星期五 09:32

We are happy to announce the release of the new stable release of
the Scala distribution. The new Scala 2.9.0 final is available from
our Download Page at: http://www.scala-lang.org/downloads

The Scala 2.9.0 codebase includes several additions, notably the new
Parallel Collections, but it also introduces improvements on many
existing features, and contains many bug fixes.

Scala 2.9.0 is also available in a simple, pre-integrated stack
with Akka 1.1 from Typesafe at http://typesafe.com/stack


The Scala 2.9.0 distribution
==============================


What is new?
============

The new Scala 2.9 codebase includes the following new features
and changes:

Parallel Collections
====================

Every collection may be converted into a corresponding
parallel collection with the new `par` method. Parallel
collections utilize multicore processors by implementing bulk
operations such as `foreach`, `map`, `filter` etc. in
parallel. Parallel collections are located in the package
`scala.collection.parallel`.

Depending on the collection in question, `par` may require
copying the underlying dataset to create a parallel
collection. However, specific collections share their
underlying dataset with a parallel collection, making `par` a
constant time operation.

Currently available parallel collections are:

    * parallel arrays -
        scala.collection.parallel.mutable.ParArray
    * parallel ranges -
        scala.collection.parallel.immutable.ParRange
    * parallel hash maps -
        scala.collection.parallel.mutable.ParHashMap
    * parallel hash sets -
        scala.collection.parallel.mutable.ParHashSet
    * parallel hash tries -
        scala.collection.parallel.immutable.ParHashMap
        scala.collection.parallel.immutable.ParHashSet
    * parallel vectors -
        scala.collection.parallel.immutable.ParVector

The method `seq` is used to convert from a parallel collection
to a corresponding sequential collection. This method is
always efficient (O(1)).

The App Trait
=============

The App trait is a safer, more powerful alternative to the
previous Application trait, which has now been deprecated. The
new recommended way to write a top-level application is like this:

   object Echo extends App {
     println("Echo" + (args mkString " "))
   }

Objects inheriting from the old Application trait were almost as
convenient to write,  but were not thread-safe and were often not
optimized by the VM, since the application�s body was execited as
part of of the object�s initialization sequence. Objects inheriting
the App trait instead make use of Scala 2.9�s delayed initialization
feature to execute the whole body as part of an inherited main
method.

Another new feature of the App scheme is that command line arguments
are now accessible via the args value (which is inherited from trait
App)

The DelayedInit Trait
=====================

The DelayedInit trait provides another tool to customize
initialization sequences of classes and objects. If a class or
object inherits from this trait, all its initialization code is
packed in a closure and forwarded as an argument to a method named
delayedInit which is defined as an abstract method in trait
DelayedInit.

Implementations of delayedInit have thus full freedom when to
execute the initialization code. For instance, Scala�s new App trait
stores all initialization sequences in an internal buffer and
executes them when the object�s main method is called. Note that
only initialization code contained in classes and objects is passed
to DelayedInit; initialization code contained in traits is not
affected.

Repl Improvements
=================

Improvements in jline, the repl input handler.  More robust cursor
handling, bash-style ctrl-R history search, new commands like
:imports, :implicits, :keybindings.  On platforms with the necessary
runtime support, :javap will disassemble any class including
repl-defined ones.  A long-running repl command can now be
interrupted via ctrl-C without terminating the repl session.
Improved programmability: the repl classloader exposes repl-defined
classes via their given names.

Scala Runner
============

Scala code can now be executed in any of the following ways:

- scala <jarfile> will run the main class, similar to java -jar
- scala <classname> will run the main method of that class
- scala <sourcefile> will run the script contents as a scala script
- scala <sourcefile> will, if the contents are not a script, find a
   single main method in a top level object and run that.  This
   allows the same file to be used with scalac and to be run directly.
- scala -save <sourcefile> will create a jar file with the compiled
   source, which is then reusable and can be run as scala <jarfile>

Java Interop
============

The @strictfp annotation is now supported.
Various fixes in JavaConverters and JavaConversions for smoother
interoperation. Primitive types and their boxed versions are now
implicitly converted bidirectionally.

Other features
==============

     * Generalized try-catch-finally:

       try body
       catch handler
       finally cleanup

       Here, body and cleanup can be arbitrary expressions, and
       handler can be any expression which evaluates to a valid
       exception handler (which is: PartialFunction[Throwable, T]).

     * New packages:
       scala.sys and scala.sys.process which are imported from
       sbt.Proces

     * New trait:
       App, a safer and more performant alternative to Application.
       It now allows to access command line arguments. It relies
       on another new trait, DelayedInit, which lets one capture
       class initialization code in a closure.

     * New methods in collections:
       collectFirst, maxBy, minBy, span, inits, tails,
       permutations, combinations, subsets

     * AnyRef specialization:
       It�s now possible to specialize on type parameters for subtypes of
       AnyRef (class Foo[@specialize(AnyRef) T](arr: Array[T]) {...}),
       which allows for more efficient array indexing and updates.

And a large number of bugfixes and performance improvements.

Please note: an incorrect version of the binaries appeared for a
brief time on the Maven repositories only. If you fetched 2.9.0
final from Maven prior to this announcement, you may have to clean
your local cache in order to fetch the correct version.

如下红色区域有误,请重新填写。

    你的回复:

    请 登录 后回复。还没有在Zeuux哲思注册吗?现在 注册 !

    Zeuux © 2024

    京ICP备05028076号