Scripting Languages on JVM

Initially JVM was designed to support only Java.Later with the growing needs and technology many scripting languages are developed which can run on JVM.

Scala,Clojure and Jython are the top 3 scripting languages among many that can run on JVM.

Let us see main features and advantages of each of it.

1.Scala

Scala is a object oriented and functional programming language, a dynamic language that is often used in scripting and testing which runs on JVM.
Scala introduces new concepts such as,
  1. Functions as values
    • Functions can be treated as value.That is, a function can be assigned to val or var,or even returned from another function.
  2. A compiler to infer the types of variables and return types of functions.for example
    • val Pi = 3.14
    • val radius = 100
    • Here variables type is not declared.Compiler will infer the types of Pi as float and radius as int.
  3. Ability to build highly scable system with the use of Immutable objects.
    • Immutable objects can be shared freely between different executing threads without needto provide synchronization or locks,simply because the values cannot change.
    • Case classes and core data structures of scala libraries are immutable.

You can download scala from the offical website at http://www.scala-lang.org/download/

2.Clojure

Clojure is a Lisp family language,high level, functional programming language. and has compilers that run on both Java and .Net runtime environment.
  • It has very powerful libraries for Clojure framework.
  • Data structures are immutable.
  • It has REPL so you can try out the things quickly and interactively.
  • Multi-core enabled (parallelism and concurrency by being thread-safe)

The number of potential bugs will be reduced drastically once you write a such high code in clojure.

3.Jython

Jython is just a Python implementation written in Java and runs on the JVM and it is successor of JPython.

  • It allows Python code to script Java applications slower and less robust than CPython.
  • It consists of Java classes that compile Python source code to Java bytecode and then route the resulting bytecode to the JVM web applets and servlets, build Java-based GUIs.
  • It is targeted for integration with the Java programming language which is downloadable from http://jython.org.

Some of the main advantage of Jython,

  • Easy interactions with existing java libraries and classes.
  • All native Java libraries can be used with Jython which is very helpful for Java developers.
  • The advantages of python are added to this. Such as  very clear syntax, object-oriented programming model which makes it a natural fit for Java’s OO design.