4 ms·
What exactly would be the benefit of this?
by Grazester 10y ago
What exactly would be the benefit of this?
- Longhanks 10y agoNo more problems with Oracle, C# features that Java is missing, such as type inference, proper generics, built in concurrency, operator overloading, first class optionals, ...
- Grazester 10y agoTheir move to Open JDK should do away with the oracle issue no?
- pjmlp 10y agoThey are just cherry picking features, check the AOSP.
- michsanders 10y agoNo more problems with Oracle, but what about Microsoft? Today we have the "cool" CEO, but that may change in the future. Remember Android started when Java was in Sun Microsystems' hands. Apart from that, C# and Java are not very different from each other. You can get many of that "features" from other Java languages, no need to move away from the JVM, so you can still benefit from the largest community.
- justin66 10y agoUsing a language not in the hands of Oracle.
- johncolanduoni 10y agoBetter support for mixed managed/native code for one. There's P/Invoke, and .NET's byte code includes instructions for low level pointer manipulation (which C# exposes). You could even compile C/C++ to CIL and obviate the need for some architecture specific binaries.
- kuschku 10y agoActually, with the JNA (not JNI), one can invoke native code from Java even easier than in C# – you just define a Java Interface containing the relevant C functions, bind the library, and get an Object implementing it.
- KMag 10y agoBut that C/C++ code you're calling still needs to be compiled to native code. The GP was referring to .NET CIL (bytecode) supporting (by design) a large subset of C/C++ semantics. The GP wants to avoid shipping N different binaries for N platforms in cases where the C/C++ code being called isn't already on the platforms. I haven't used Managed C++ and I'm fuzzy on the details, but my understanding is that a fairly large subset of C/C++ can be efficiently compiled to .NET CIL. (Of course, the class loader for untrusted security contexts will refuse to load classes that use the type-unsafe/memory-unsafe portions of .NET CIL, just like the Java classloader for untrusted applets won't load classes making arbitrary JNI calls.)
- int_19h 10y agoBased on what I know about CIL and C++, the entirety of C and C++ can be compiled to [unverifiable] CIL. The sole exception is setjmp/longjmp - this might be doable on top of CLI exceptions, but I'm not sure. And, indeed, VC++ lets you do just that. There are some bits of the standard library, mostly new stuff like threads and atomic, that had some issues, as I recall. But it's more about the amount of effort that's needed to target what's essentially a completely different platform. The thing to know about CIL is that it has: - structs; - unions; - raw data pointers, with pointer arithmetic; - raw function pointers; - dynamic stack allocation (like alloca in C); - tail calls; - exceptions with exception filters (arbitrary expression evaluation when deciding whether to transfer to a given catch-block or not) and finally blocks. I'm actually curious if there's any language that cannot be compiled down to this efficiently.
- pjmlp 10y agoDynamic languages cannot be easily mapped to CIL, which is why IronPython was the genesis of DLR extensions, later added as standard part of .NET.
- akyu 10y agoIt would be worth it just to have LINQ
- kuschku 10y agoWhy? The Java Stream API is superior to LINQ in every way, and a lot more extensible. EDIT: Instead of downvoting, please point out how LINQ is actually superior?
- kodfodrasz 10y agothe Stream API is nice, but it is not extensible. I guess you have mistaken LINQ with the SQL style LINQ queryes, but it is actually a pack of feautures, the basis of all is the Extension Methods. Every LINQ query is just syntactic sugar for composed of some extension methods to IEnumerable<T>. Without that LINQ is a bunch of extension methods giving an extensible fluent API much like the Streams API, but with true extensibility. How do you extend the the java Stream API? for LINQ you just drop in a few extra extension methods for IEnumerable<T>, IOrederedEmumerable<T>, IQueryable<T>, etc. How do you reverse a stream in java? (I know you need to evaluate the whole stream for that) You can write a utility method, but that will break the fluent readable logic. In C# you can do the very same thing, with the same method usable as an extension method keeping the readable fluent expression. Starting a stream is a PITA itself, as it differs for Iterables, Arrays, Collections... Been there, done that. Not that with some utilities these could not be overcome, but it was an inferior experience to LINQ.
- kuschku 10y ago> How do you reverse a stream in java? By calling .reverse() on it, and making it iterate the other way around? > extension methods Extension methods are something that’s really really problematic, and easy to create confusion with. That said, I’d just import the functions I want to call on the stream into my local namespace with import static.
- kodfodrasz 10y ago