5 ms·
One of the primary problems with this is generics (java/JVM uses type erasure, CLR/C# keeps type information) and value types (CLR/C# has them, JVM does not);
by zastrowm 12y ago
One of the primary problems with this is generics (java/JVM uses type erasure, CLR/C# keeps type information) and value types (CLR/C# has them, JVM does not); That's why you can implement the JVM on the CLR (see IKVM.NET[1]), but not the other way around.
[1]: http://en.wikipedia.org/wiki/IKVM.NET http://en.wikipedia.org/wiki/IKVM.NET
- meddlepal 12y agoI'm not a vm or compiler expert by any means but Gosu and Ceylon have implemented reified generics on the JVM somehow. It seems possible, but I don't know what the performance impact would be.
- gsnedders 12y agoWell it's obviously doable — both the JVM and CLR are equivalent to Turing machines, so it follows that they can run the same set of programs. It just, uh, might be non-trivial. :)
- meddlepal 12y agoFwiw, when Gavin King (Ceylon) did a AMA on Reddit a while back I asked about how they implemented reified generics on the JVM: https://www.reddit.com/r/programming/comments/2iszra/ceylon_11_is_now_available/cl5vp6x https://www.reddit.com/r/programming/comments/2iszra/ceylon_...
- Gurkenmaster 12y agoCeylon is a great language in my opinion. I would rather programm in Ceylon than in C#.
- meddlepal 12y agoThat's good to hear! I haven't played with it yet beyond flipping through the docs. Have you built any production ready apps or libraries in it? How was the transition from writing Java? Did anything cause you pain or surprise?
- Gurkenmaster 12y agoThe Eclipse IDE plugin works but is pretty slow. I wouldn't use it if I wasn't so used to autocompletion + documentation in my IDE. The module system can use the central maven repository but it doesn't accept dashes in the name like jackson-core unless you put it in quotes. (Took me a while to figure out). Ceylon doesn't have enums but you can emulate them like this: http://ceylon-lang.org/documentation/1.1/tour/types#enumerated_instances http://ceylon-lang.org/documentation/1.1/tour/types#enumerat... Otherwise it's fairly straightforward to translate java into ceylon. I love immutability by default. Only 10% of my variables/fields are actually mutable. I could reduce that percentage further if the jvm had TCO.
- pron 12y agoJava is getting value types and replied generics.
- meddlepal 12y agoPotentially. Value types seem like a lock for 10, but reified generics have only been suggested as a research topic in Project Valhalla.
- gagege 12y agoSomehow F# uses type erasure. I'm not sure how it works, but I know that it does.
- seanmcdirmid 12y agoType erasure on the CLR is exactly as it is on the JVM. Generics are needed for interop with generic libraries (which aren't used that much beyond collections anyways in core libraries). Erasure is necessary when the type system is differently expressive from C#, which I beleive F# is.
- kvb 12y agoTaken at face value I think this is misleading - a typical F# generic type will be represented as a normal .NET generic type at the IL level. However, it is true that some types are erased, like unit-of-measure type arguments or types surfaced by type providers.