Scala is a wonderful language, but I wonder how could be improved if it had it's own runtime?
I.e. what design choices were made because of JVM choice?
Scala runs on the Java Virtual Machine Scala is compiled into Java Byte Code which is executed by the Java Virtual Machine (JVM). This means that Scala and Java have a common runtime platform.
The Scala compiler ( scalac ) produces JVM bytecode ( . class files), as much as the Java compiler ( javac ). To execute these files you need a JVM.
Can I run my scala program without JVM using scala-native? Yes, the goal of Scala Native is to support compilation of Scala programs without any kind of VM.
Scala runs on the Java platform (Java virtual machine) and is compatible with existing Java programs.
The two most important compromises I know about are:
new scheme of handling arrays in Scala 2.8. Instead of boxing/unboxing and other compiler magic the scheme relies on implicit conversions and manifests to integrate arrays
Those are the two main JVM limitations, when it comes to manage generic type (with bounds): The Java JVM does not keep the exact type use in a generic object, and it has "primitive" types.
But you could also consider:
@tailrec
annotation)@proxy
) In order to cover as many possibilities as possible, Scala provides:
- Conventional class types,
- Value class types,
- Nonnullable types,
- Monad types,
- Trait types,
- Singleton object types (procedural modules, utility classes, etc.),
- Compound types,
- Functional types,
- Case classes,
- Path-dependent types,
- Anonymous types,
- Self types,
- Type aliases,
- Generic types,
- Covariant generic types,
- Contravariant generic types,
- Bounded generic types,
- Abstract types,
- Existential types,
- Implicit types,
- Augmented types,
- View bounded types, and
- Structural types which allow a form of duck typing when all else fails
This article is a discussion with Martin Odersky (Scala's creator) and includes the compromises that were made in Scala for compatibility with Java. The article mentions:
null
pointers.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With