P. 1
scala, haskell and fantom programming language

scala, haskell and fantom programming language

|Views: 521|Likes:
Publicado porChristie Morota

More info:

Published by: Christie Morota on Feb 01, 2011
Copyright:Attribution Non-commercial


Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less





Scala, Haskell and Fantom Programming Language

Raymark D. Dulce (200712952) January 01, 2011

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

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

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. world!") } } 3 . • A joint use of both features facilitates the definition of new statements without extending the syntax and without using macro-like meta programming facilities. and • polymorphic methods. and closures are constructed automatically depending on the expected type (target typing). Scala is extensible In practice. the development of domain-specific applications often requires domain-specific language extensions.• compound types • explicitly typed self references • views. The Hello World Program object HelloWorld { def main(args: Array[String]) { println("Hello.

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

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

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

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

Closures are a key feature of the language. Declarative Programming Fantom incorporates declarative programming right into the language. 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. Fantom also includes a text serialization syntax which is human readable and writable. uris.Funtional Programming Fantom was designed from the ground up to support functions as first class objects. ranges. The serialization syntax is a clean subset of the programming language . Fantom supports a literal syntax for lists. World!") } } 8 . and all the APIs are written to use functions and closures where appropriate. and durations. Functions and closures are baked in. maps.so you can paste a serialization file right into your source code as an expression.

You're Reading a Free Preview

/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->