Scala Language

Designed by MartinOdersky, Scala is a modern MultiParadigmProgrammingLanguage designed to express common programming patterns in a concise, elegant, and TypeSafe way. It smoothly integrates features of ObjectOrientedProgramming and FunctionalProgramming languages.

Monads and Arrows have been implemented in ScalaLanguage - see

Book: ProgrammingScala Wampler and Payne ( OreillyAndAssociates )
For a discussion on the nature of ScalaLanguage see
20101003 ChrisGarrod tried to put this into HelloWorldInManyProgrammingLanguages, but that page kept being reverted by What a deterrent to editing! In my ten years at this wiki, this is the first time my changes been attacked by a robot. RecentChanges discourages me from participation here.

HelloWorld in Scala is discussed in several steps on this page:
 println("Hello, world, from a script!")

BridJay (BridJ) is a way for JavaLanguage and ScalaLanguage to make calls to CeeLanguage or CeePlusPlus code.
Scala, it seems to me, is about making Java cleaner, while adding some functional concepts in the process. For example, instead of static methods on a class, you define a singleton object for the class.

    object HelloWorld {
      def main : Unit = println("Hello, world!") // This is a method, not a variable.  Variables are introduced with var.

This is different from the static-method-on-class model because it makes an actual, first-class object.

    class MyList?[+T](first : T, rest : MyList?[T]) {// Constructors look like ordinary closures.  Very clean!  Even C++ doesn't have initialization this clean!
      //         ^---------- Note: type variance of T is covariant.
      def foreach(op : T => Unit) : Unit = { // Higher-order foreach function.
                                      // Just like HaskelLanguage?s a -> ().  Foreach's type in Haskel would be written as ml a -> (a -> ()) -> ().
    // The above is not actually the important part, otherwise I would have introduced a lot more features there.
    object MyNil? extends MyList?[Nothing] { // Nothing is the BottomType.
      override def foreach(op : Any => Unit) = () // Do nothing at last list instance.
                                                  // (Oh, Any is the TopType.)
    /* Roughly equivalent to:
    val MyNil? = new MyList?[Nothing] {
      override def foreach(op : Any => Unit) = ()
    However, you can declare objects which are also classes, to get static members.
    Also, you can make those objects-of-classes functor objects.
    This means you can use the factory pattern without actually appearing to use it!
    MyList?(1, MyList?(2, MyList?(3, Nil))) foreach print // Demonstration of Scala's flexible syntax: infix methods.
                                                       // Operators like +, -, *, and / are actually parsed as infix methods.
                                                       // Oh, and functions are first-class.

CategoryProgrammingLanguage CategoryFunctionalProgramming CategoryMultiparadigm

EditText of this page (last edited November 7, 2010) or FindPage with title or text search