Está en la página 1de 9

Scala, Haskell and Fantom Programming

Language

Raymark D. Dulce (200712952)

January 01, 2011

0.jar. History of Scala The design of Scala started in 2001 at the cole Polytechnique F d rale de Lausanne (EPFL) by Martin Odersky.NET libraries in the .8. Scala is a general purpose programming language designed to express common programming patterns in a concise. Scala’s operational characteristics are the same as Java’s. a programming language combining ideas from functional programming and Petri nets. As of November 2010. In fact. Scala has the same compilation model as Java and C-sharp. v2. elegant. was released in March 2006. The name Scala stands for ”scalable language”. Scala Programming Language What is Scala? Scala is a multi-paradigm programming language designed to integrate features of object-oriented programming and functional programming. so Scala code can call Java libraries (or . scala-library. A second version of the language. Platforms and License Scala runs on the Java platform(Java Virtual Machine) and is compatible with existing Java programs. is released under a BSD license.1. Scala was released late 2003 / early 2004 on the Java platform. including compiler and libraries. signifying that it is designed to grow with the demands of its users. Odersky had previously worked on Generic Java and javac. It also runs on Java Platform.NET implementation). 1 . and on the . following on from work on Funnel. The Scala compiler generates byte code that is nearly identical to that generated by the Java compiler. and type-safe way. Scala code can be decompiled to readable Java code. the latest release is version 2. It smoothly integrates features of object-oriented and functional languages. Scala code and Java code are indistinguishable. The Scala soft- ware distribution. with the exception of certain constructor operations. en- abling Java and other programmers to be more productive. To the JVM. Micro Edition Connected Limited Device Configuration. The only difference is a single extra runtime library. Sun’s Java compiler.NET platform in June 2004.

Moreover. Scala provides a lightweight syntax for defining anonymous func- tions. Scala’s case classes and its built-in support for pattern matching model algebraic types. NetBeans or Intellij for example. Scala pro- grams run on the Java VM. In particular. Scala is statically typed Scala is equipped with an expressive type system that enforces statically that abstractions are used in a safe and coherent manner. you will be at home with familiar development tools. it supports higher-order functions. the type system supports: • generic classes • variance annotations • upper and lower type bounds • inner classes and abstract types as object members 2 . the integration is seamless. all of which support Scala. Classes are extended by subclassing and a flexible mixin-based composition mechanism as a clean replacement for multiple inheritance. it allows functions to be nested. You can call Scala from Java and you can call Java from Scala.Seamless integration with JAVA Existing Java code and programmer skills are fully re-usable. Eclipse. Types and behavior of objects are described by classes and traits. are byte code compatible with Java so you can make full use of existing Java libraries or existing application code. and supports currying. Scala is object-oriented Scala is a pure object-oriented language in the sense that every value is an object. Scala is functional Scala is also a functional language in the sense that every function is a value.

world!") } } 3 . and • polymorphic methods. the development of domain-specific applications often requires domain-specific language extensions. Scala is extensible In practice. Scala provides a unique combination of language mechanisms that make it easy to smoothly add new language constructs in form of libraries: • any method may be used as an infix or postfix operator. The Hello World Program object HelloWorld { def main(args: Array[String]) { println("Hello. and closures are constructed automatically depending on the expected type (target typing). • A joint use of both features facilitates the definition of new statements without extending the syntax and without using macro-like meta pro- gramming facilities. • compound types • explicitly typed self references • views.

general-purpose purely functional programming language. a revised version was published as Haskell 98 Language and Libraries: The Revised Report. intended to specify a sta- ble. informally named Haskell’. and as a base for future extensions. This is an ongoing incremental process to revise the language definition. In particular. purely functional language. An open-source product of more than twenty years of cutting-edge research.0 The first version of Haskell (Haskell 1. correct software. the process of defining a successor to the Haskell 98 stan- dard. named Haskell 2010.0) was defined in 1990. was announced in Nov. concise. whose work in mathematical logic serves as a foundation for functional languages. It is a standardized. portable version of the language and an accompanying standard library for teaching. 2009. quite different from most other programming languages. In January 2003. hence the lambda we use as a logo. producing a new revision once per year. Haskell is based on the lambda calculus. Haskell is a computer programming language. History of Haskell Haskell 1. Haskell Prime In early 2006. lazy. In February 1999. minimal. Haskell 98 In late 1997. the series culminated in Haskell 98. it allows rapid development of robust. 4 . The language is named for Haskell Brooks Curry. the Haskell 98 language standard was originally published as The Haskell 98 Report. The first revision. Haskell Programming Language What is Haskell? Haskell is an advanced purely-functional programming language. it is a poly- morphically statically typed. was begun. with non-strict semantics and strong static typing.

• A smaller semantic gap between the programmer and the language. allow- ing for bindings to other programming languages. Pattern- Guards. NoNPlusKPatterns. definitions of the form fak (n+1) = (n+1) * fak n are no longer allowed.Haskell 2010 Haskell 2010 adds the Foreign Function Interface (FFI) to Haskell. World!" OR putStrLn "Hello World" OR main = putStrLn "Hello. and more maintainable code. Why use Haskell? Haskell offers you: • Substantially increased programmer productivity • Shorter. that is. The names of the extensions introduced in Haskell 2010 are DoAndIfThenElse. clearer. RelaxedDependencyAnalysis. LineCommentSyntax. • Fewer errors. FixityResolution. EmptyDataDeclarations. • Shorter lead times. HierarchicalModules. fixes some syntax issues (changes in the formal grammar) and bans so-called n-plus-k-patterns. higher reliability. World!" 5 . ForeignFunctionInterface. LanguagePragma. The Hello World Program "Hello. It introduces the Language-Pragma-Syntax-Extension which allows for des- ignating a haskell source as Haskell 2010 or requiring certain Extensions to the Haskell Language.

Erlang etc. History of Fantom The original name of the Fantom programming language was Fan. Fantom takes a middle of the road approach to its type system.NET. .NET CLR. In November 2009. Fantom uses a curly brace syntax. blend- ing together aspects of both static and dynamic typing. and Func. Fantom Programming Language What is Fantom? Fantom is a general purpose object-oriented programming language that runs on the JRE. Fantom is designed as a practical programming language to make it easy and fun to get real work done. The language supports func- tional programming through closures and concurrency through the Actor model. named after the neighborhood where the creators live in Richmond. the name of the project was officially changed from Fan to Fantom. It borrows it’s Syntax from Java but also adds many features and syntactic sugar created or borrowed from . members of the community raised concerns about the searchability of the name. Fantom has an easy to use reflection API and metaprogramming capabilities. It is familiar to a Java / .Net programmer but is much less painful to use (no boilerplate).Python. Typing Fantom’s type system is simple by design. Fantom is an exciting new language that targets the Java VM and the CLR. Like C-sharp and Java. and Javascript. but it does have a set of built-in generic types: List. Map. After gaining some popularity. Virginia.Groovy. All variables are statically typed. as they are in C-sharp and Java. Fantom rejects generic types due to their complexity. Fantom can also take on the feel of a dynamically typed language through dynamic calls and automatic downcasting. 6 .

Object Oriented Fantom follows the . These types have all the same performance characteristics of using boolean. Elegant APIs Quite obsessive about providing all the key features required for a stan- dard library. The reality is that many software organiza- tions are committed to one or the other of these platforms. Portability Fantom is created to write software that can seamlessly run on both the Java VM and the .NET. and Float are value types which are implemented as primitives in Java and value types in . and modules.NET model of value types. Unlike Java these types cleanly subclass from Obj to create a unified class hier- archy. Pods take on the role of namespaces. but with much less surface area than the APIs found in Java or . The compiler automatically implements boxing and unboxing when necessary. packages. fwt::Widget is distinct from webapp::Widget. and double in Java or C-sharp. long. Int. Even dynamic languages like Python and Ruby are getting hosted on one of these VMs. the documentation. The three special types Bool. Familiar Syntax Java and C-sharp programmers will feel at home with Fantom’s evolu- tionary syntax. then it can be executed on the command line with:fan ¡podName¿ The Fantom build system can package a set of Pods into a Jar archive through build::JarDist. which are zip files containing the FCode (the Fantom bytecode). If a pod contains a type named Main. A pod name fully qualifies a type name. the unit of deployment is called a pod. For example.NET. and resource files necessary to run the pod.NET CLR. A pod can define any number of types for use in other libraries and applications. They are stored as . 7 .pod files.Pods In Fantom.

Closures are a key feature of the language.so you can paste a serialization file right into your source code as an expression. maps. uris. Concurrency Fantom tackles concurrency using a couple techniques: • Immutability is built into the language (thread safe classes) • Static fields must be immutable (no shared mutable state) • Actors model for message passing (Erlang style concurrency) The Hello World Program class HelloWorld { static Void main() { echo("Hello. The serialization syntax is a clean subset of the programming language . and durations. Declarative Programming Fantom incorporates declarative programming right into the language. ranges.Funtional Programming Fantom was designed from the ground up to support functions as first class objects. Functions and closures are baked in. Fantom also includes a text serialization syntax which is human readable and writable. Fantom supports a literal syntax for lists. World!") } } 8 . and all the APIs are written to use functions and closures where appropriate.