Updated on May 1, 2015
Basic Introduction to Scala Part 1
Scala’s name comes from the idea of a scalable language, its ambition is to be a language that can scale to solve a more diverse set of programming problems more easily than General purpose programs (GPL). Scala is similar to a scripting language and supports full functional programming. Through compiler inference, Scala’s syntax can often be very concise. These attributes of Scala evolved from criticisms of General Purpose programming languages just as Java.
Preliminary work on Scala was undertaken by Martin Odersky in 2001 at École Polytechnique Fédérale de Lausanne. Martin Odersky is responsible for designing Scala and Generic java and he currently serves as chairman and chief architect.Martins aim was to incorporate functional and object-orientated programming but without the normal constraints of standard GPLs such as Java. Scala evolved from a research endeavor to develop better language support for component software. It utilized ideas from his previous research on a minimalist research language based on functional nets called Funnel. Before proceeding I should say that Functional nets are out the scope of this post, but I may write a post specific about them at a later date. The basic idea is that functional nets combine fundamental ideas from Petri nets and functional programming to produce a general programming notation. Funnel was a good idea but it proved to be too complex for non-expert users. Scala emerged from ideas of Funnel and an aspiration to make it interoperable with other standard systems.
Scala is designed to interact with standard languages such as Java and C#. It utilizes a large amount of the syntax and type systems from these languages but with some fundamental changes to work around some of the restrictions of those languages. This includes Scala not being a superset of java, excluding and re-implementing some of the features to aid in the goal of improved uniformity of objects. In addition, Scala is object orientated and shares most of the basic operators, data types, and control structures with standard GPLs.
Scala source code is designed to be compiled to Java bytecode. The implication of this is that Scala can run on a diverse set of systems and be extremely portable. Furthermore there is no performance penalty from the bytecode compiled from Scala as opposed to java, although peak performance of bytecode can be significantly less than native C/C++ compiled programs. Scala’s ability to compile straight to java bytecode allows for Scala and Java to utilize each other’s plethora of libraries. This has the effect of achieving higher language interoperability, which is one of the main features of the language.
Scala isn’t a traditional object oriented language or a functional language, it’s something quite new. Object oriented programming was invented in the 1960’s, and it has become the mainstream paradigm since the 1980’s. This was partly due to the growing importance of GUI’s in the 1980’s, which object oriented programming suited aptly. But in today’s world, other important features such as good techniques for concurrent programming are becoming more prominent. Therefore even though the idea of functional programming is old, it’s starting to break out into the limelight. Before proceeding, it’s important to note that functional programming is based strongly on functions in the mathematical context. For example in mathematics functions are pure, such that no global state of any kind will be modified internally by it. In addition, the function will always return the same result given the same arguments. Furthermore, variables in functional programming they are immutable, as opposed to procedural programming where they are mutable. Consequently, this gives functional programming a large benefit over object orientated programming when it comes to concurrency. To elaborate, in object orientated a lot of issues arise in synchronizing access to shared and mutable states. Due to functional languages not allowing mutable variables, this becomes much less of an issue. Although, Scala is not just a functional language but more of a hybrid between functional and object orientated. As such, Scala does not require variables to be imputable or functions to be pure, but it is strongly encouraged to write your code in a functional style.
Scala is a very versatile language, aiming to be concise. It can achieve this through type inference as well as cutting down on the boilerplate code that plagues Java. One of the ways it achieves this is though optional use of semi-colons. Although, semi-colons are normally not used. A good example of how concise Scala can be when compared to Java is a class constructor.
The syntax of the class constructor for Scala is significantly more concise than the Java implementation. When the Scala compiler comes across this code, it will output a class that has two private instance variables and assign the name and datatype to what is described in the brackets. Therefore, the Scala syntax allows the code to be faster to write, as well as being less likely to contain errors due to size of the code.
In conclusion, the aim of this post was to explain what Scala is and why is differs from traditional programming languages. My next post will be expanding upon this, and move on to programming in Scala.
 – http://www.scala-lang.org/what-is-scala.html
 – http://en.wikipedia.org/wiki/Scala_(programming_language)
 – Odersky, Martin. “Functional nets.” Programming Languages and Systems. Springer Berlin Heidelberg, 2000. 1-25.
 – http://www.artima.com/weblogs/viewpost.jsp?thread=163733
 – Odersky, Martin, Lex Spoon, and Bill Venners. Programming in scala. Artima Inc, 2008.
 – http://en.wikipedia.org/wiki/Martin_Odersky
 – Odersky, Martin, et al. An overview of the Scala programming language. No. LAMP-REPORT-2004-006. 2004.
 – http://www.scala-lang.org/old/node/239.html
 – https://en.wikipedia.org/wiki/Java_virtual_machine
 – Wampler, Dean, and Alex Payne. Programming Scala: Scalability= Functional Programming+ Objects. ” O’Reilly Media, Inc.”, 2009.
 – http://en.wikipedia.org/wiki/Pure_function
 – http://www.sitepoint.com/functional-programming-pure-functions/