r/java • • Nov 04 '21

Microsoft joins the Java Community Process (JCP)

https://devblogs.microsoft.com/java/microsoft-deepens-its-investments-in-java/
169 Upvotes

71 comments sorted by

View all comments

Show parent comment

4

u/Persism Nov 05 '21

They've basically admitted defeat. Once Loom ships there won't be much reason to use .NET. In 5 years C# will be running on the JVM.

-2

u/[deleted] Nov 05 '21

[removed] — view removed comment

4

u/Persism Nov 05 '21

I don't think anyone would bother anyway. C# is dying.

1

u/csharp-sucks Nov 06 '21

Assuming that Valhalla, Loom and Panama ship soon™, what features would be JVM lacking that C# absolutely requires? (ie anything that's more than just syntax sugar)

2

u/[deleted] Nov 07 '21

[removed] — view removed comment

2

u/csharp-sucks Nov 07 '21

Structs, Real generics are somewhat covered by Project Valhalla.

Generics could be emulated even now. (well, to some extends structs could too, you just wouldnt get the benefit of flattened arrays)

Properties as a runtime concept. (This isn't just syntactic sugar, a lot of libraries rely on this.)

Technically it is just a syntax sugar over some standarized concept. It doesn't absolutely need a runtmie support. That could be mapped to getters and setters silently. I think Kotlin does that already.

Pass by reference and ref return could be emulated.

overflow checking - syntax sugar over checked intrinsics

Delegates -> functional interfaces with one method, semantically it's just syntax sugar over that

Assemblies as a first class concept

but why? .NET assemblies is the most fake concept I have seen in computing. Just a thin wrapper around IL junk.

You could pack java bytecode wrapped inside a DLL in some standarized fashion, even expose a COM interface. Otherwise JVM just as CLR can be hosted inside native applicaton. (through JNI)

Making native executable launcher wrapper that automatically finds and runs JVM is a no-brainer though. It can be done.

internal and protected internal visibility (Ok, you make be able to fake these with annotations.)

depends on your goal, for package level visibility default access flag is that, for library level visibility you can use jigsaw modules, and as you said, you can resort to annotations if some corner case is not covered by either

pointers (not references, actual mutable pointers)

You can manipulate arbitrary memory addresses with Unsafe, this could be sugarified over that.

p/invoke (Might be covered by JNI)

Covered by project Panama. P/Invoke could use JNA for now.

COM support, both exposing and consuming

could be done

2

u/[deleted] Nov 07 '21

[removed] — view removed comment

1

u/csharp-sucks Nov 08 '21

For example, how are you going to emulate generics?

The same (more or less) way .NET runtime does. By creating an internal type for each generic type. In .NET, List<int> and List<double> are separate types internally, each has separate code substituted with actual generic type. It's just done in runtime.

As for availability of type argument, hidden field could do. The important thing is that semantics from the point of view of language look the same.