Nice TWiki > Doc > LanguageComparisons > NiceVersusScala (r1.7) TWiki webs:
Dev | Doc | Main | TWiki | Sandbox
Doc . { Changes | Index | Search | Go }


Scala has many things in common with Nice: "Scala is a modern multi-paradigm programming language designed to express common programming patterns in a consise, elegant, and type-safe way. It smoothly integrates features of object-oriented and functional languages".

There are also fundamental differences: Scala has far less in common with Java (Scala targets CLR as-well-as JVM), Scala uses single dispatch, and has a different type system (nuObj).


  Unified Types Traits Mixins External Methods Inner classes Abstract Interfaces
Nice Yes Yes No Yes No Yes
Scala Yes Yes Yes No Yes No

Nice and Scala move forward OO programming in different ways. Nice addresses the problems of adding functionality to existing classes and binary methods with Multi Methods; Scala addresses the problem of implementation reuse with Traits and Mixins.


  Anonymous Functions Higher-Order Functions Currying Dynamic Dispatch Nested Functions
Nice Yes Yes Not yet (at call site) Multiple Dispatch Yes
Scala Yes Yes Yes (at definition) Single Dispatch Yes

Type Parameters

  Generic Classes Generic Methods Variant Class Type Parameters Upper Type Bounds Lower Type Bounds Multiple Bounds
Nice Yes Yes Yes(2) Yes Yes Yes
Scala Yes Yes Yes Yes Yes ?

(2) Although the typechecking isn't completely implemented yet

So wouldn't that be Not yet, or Not complete?

Java Commonality

  Use Java classes Parameterize Java classes Subclass Java classes Subclass in Java Java Statements/Operators
Nice Yes Yes Yes Yes Yes
Scala Yes ? Yes ? No

Although Scala can use Java classes (and in the future .Net classes) there's no intent to make the language familiar to Java programmers; Nice looks a little more like a Java 2.0 than an entirely new language.

Some of these differences can be seen in the following example. In Scala we use a HashMap defined in a Scala library; in Nice we parameterize the Java HashMap. In Scala we use a sequence comprehension; in Nice an extended for statement, or a Java for statement.

Scala Nice
import scala.collection.mutable.HashMap;

object hash {
  def main(args: Array[String]) = {
    val n = toPositiveInt(args);
    var count = 0;
    val table = new HashMap[String,Int]();

    for (val i <- Iterator.range(1,n+1)) 
      table += Integer.toString(i, 16) -> i;

    for (val i <- Iterator.range(1,n+1)) 
      if (table contains Integer.toString(i, 10)) 
        count = count + 1;

    Console println(count);

  private def toPositiveInt(s: Array[String]) = {
    val i = 
      try { Integer.parseInt(s(0)); } 
      catch { case e: Exception => 1 }

   if (i>0) i; else 1;


void main(String[] args){
  let n = toPositiveInt(args);
  var count = 0;
  HashMap table = new HashMap();

  for (int i : 1..n)
    table[ Integer.toString(i, 16) ] = i;

  for (int i = 1; i <= n; i++) 
    if (table.containsKey(Integer.toString(i, 10))) 


private int toPositiveInt(String[] s){
  var i = 1;
  try { i =  Integer.parseInt(s[0]); }
  catch (Exception e){ i = 1; } 

  if (i>0) return i; else return 1;


Methods Pattern Matching Local Type Inference Comprehensions Option Types User Defined Coercions Tuples
Nice Multi Methods Monomorphic (at present) No String & ?String No Yes
Scala Case classes Monomorphic, Polymorphic, Non-Recursive Functions Yes Some(String) & None Yes Library

Made a few additions -- ArjanB - 24 Jan 2004

Grateful for the help, I'll continue to add stuff too - then we can reconcile the differences and clean up. (I started off including the list of features from the Scala overview and then removed some.) -- IsaacGouy - 24 Jan 2004

Topic NiceVersusScala . { Edit | Attach | Ref-By | Printable | Diffs | r1.22 | > | r1.21 | > | r1.20 | More }
Revision r1.7 - 24 Jan 2004 - 20:20 GMT - IsaacGouy
Parents: WebHome > LanguageComparisons
Copyright © 1999-2003 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback.