World Applied Programming, Vol (2), Issue (5), May 2012. 300-307 Special section for proceeding of International E-Conference on Information Technology and Applications (IECITA) 2012 ISSN: 2222-2510 ©2011 WAP journal. www.waprogramming.com 300 Optimization and Performance Analysis of Scala over Java Compiler Deepali Rai Himan Bayan Gaurav Sharma M Rajasekhara Babu* School of Computing Science and Engineering VIT University Vellore, India School of Computing Science and Engineering VIT University Vellore, India School of Computing Science and Engineering VIT University Vellore, India School of Computing Science and Engineering VIT University Vellore, India rai.deepali07@gmail.com bayanhiman@gmail.com gaurav0886@yahoo.com rajababu.m1@gmail.com Abstract: Scala a programming language combines the feature of object oriented and functional programming language. It provides greater flexibility to programmers by allowing them to grow the language through libraries. Scala implements the concept of class, and sees everything in terms of object. In terms functional programming, it brings in algebraic data types, pattern matching, functions and closures. Optimization is an important concept in compiler design to reduce the cost, code size, reduction of design complexity, thereby internal execution time and increasing the performance of the compiler. Benchmark programs have been used to show the improvement in these language features and to compare the efficiency of scala program and their java equivalents. Key word: JVM, Compiler, Scala, Java, Closures, Performance, Phases I. INTRODUCTION Optimization of scala compiler is done to reduce the execution time and code size of scala code running on JVM. Our focus is on compiling the scala code having various higherorder functions and find out the execution time so as to optimize it and thereby increasing the performance. Larger programs need some way to divide them into smaller and flexible piece of code. For dividing up the control flow, Scala provides functions. Scala offers several ways to define functions that are not present in Java. Besides methods, which are member functions of some object, there are also nested functions, function literals, and function values. Scala has some features where you can write very expressive code in a few lines. This means that new abstractions can be provided as libraries but you can have the look and feel of built in language features which is ideal feature for building Domain Specific Language (DSLs).Scala is good basis for parallel programming because of its strong support for functional programming. Twitter has replaced their Ruby-based back-end services with Scala. Using actors, they have scale their concurrent message queue system to a larger number of users. The next section gives brief description on the related work. Section 3 describes about design and algorithm used for analyzing various phases of compiler. In section 4 performance of java and scala code is measured and the result is analyzed. And the last section concludes and gives direction for future work. II. RELATED WORK Iulian Drago et al. have presented a set of micro-benchmarks to measure the effectiveness of compiler optimization and specialization. He has seen how the performance of code can be improved by using high-level constructs, like higher order functions and generic container classes. They have showed that specialization has achieved speedup of 2 and 3 on generic code operating at primitive types. Shown that optimizer are giving very high gains when it can remove boxing and closure creation up to 5 to 6 times speedup ,but when the structure of the code become too involved when it failed to give the high gain [1]. Scala relies on libraries for language extension which gives an elegant solution for growing the language, but at the same time performance penalty is high incurred by call-by-name parameters, boxing and anonymous functions [6].They have shown that inlining alone is not only the solution to remove this overhead. For the solution it is required to combine the decompilation of library code with inlining, dead code elimination, and copy propagation. They have shown the improvements of up to 45% by evaluating their approach on two language extensions asserts for for loop on Java and C [2].