Skip to main content

Scala. Bridging The .NET and Java EE Worlds.

Posted by lifemichael on September 12, 2010 at 3:40 PM PDT

Scala is an object oriented and a functional programming language. If you already know Java or C# you will find Scala an easy to learn and a powerful one. Most of the new features that were added in C# (comparing with Java) exist as well, and apart of enjoying the power of OOP you will also get to enjoy the power of Functional Programming.

There are many advantages for using Scala. However, the one I find as the most interesting one from a business perspective is the ability to compile code written in Scala either into intermediate language code or into java byte code. Companies, that maintain two versions for their products, one for the .NET platform and one for the Java EE platform, can use Scala for maintaining the core modules of their products in one version. The Scala version. Given the scalability related unique adavantages of Scala (comparing with Java and .NET), doing so can also assist with implementing the required changes set by the dynamic business environment in which we operate.

Comments

.NET Interoperability?

While it is safe to make the statement that there is a Scala compiler which compiles to IL for the CLR, it does not seem safe to assume that Scala code written with the JVM in mind is 100% compatible with targeting for the CLR or vice-versa.
I'm no expert on Scala by any means, but there does seem to be a considerable amount of stale-ness associated with the CLR compiler for Scala. "Scala on .NET: quirks" was last updated in July of 2008, and covers Scala 1.4(Scala is currently at 2.8).
However, the SVN repository does show some recent activity in the /src/msil directory, so they may be doing some work updating things after all.

Interoperability at component level with IIOP.NET

Instead of having both C# and Java programmers develop in a language they don't know (Scala), it might be better to interoperate with middleware: http://iiop-net.sourceforge.net/ Let Java developers use their EJBs and their appservers and have .Net call the EJBs. Of course, you should not do a middleware call for each method invokation, but reuse should be done component level, anyway.

Scala is Simple!

I admit that I don't know IIOP and therefore I cannot say if that option is indeed simpler. I do know Scala... and based on my experience with teaching Scala (students that already know Java)... it takes no time. Reuse on the component level is IMHO usually the best approach.. and I certainly recommend it when using Scala for bridging the two worlds. 

there r limits

it isn't that u can take a scala code and have it automatically portable both for .net and java... there are limits... u need to understand how scala works in order to know those limits. yet, within the scope of those limits i believe there is a place for a practical usage of scala in many cases.

What about graphics?

Does Scala offer graphics that run on either .Net or Java?

scala doesn't include graphics u can use both on java and .net

 u can use java swing classes within your scala code without any problem... u won't be able to get that swing class on .net... there are limits... u need to understand the scala language and the way it works in order to know its limits.