News for hackers. Stuff that matters.
Re:Google joins .NET Foundation as Samsung brings .NET suppo... by Grazester on Wednesday November 16, 2016 @10:50AM (#12968012)
What exactly would be the benefit of this?
Re:Google joins .NET Foundation as Samsung brings .NET suppo... by Longhanks on Wednesday November 16, 2016 @11:03AM (#12968201)
No more problems with Oracle, C# features that Java is missing, such as type inference, proper generics, built in concurrency, operator overloading, first class optionals, ...
Re:Google joins .NET Foundation as Samsung brings .NET suppo... by michsanders on Wednesday November 16, 2016 @05:07PM (#12972028)
No 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.

Re:Google joins .NET Foundation as Samsung brings .NET suppo... by Grazester on Wednesday November 16, 2016 @11:47AM (#12968761)
Their move to Open JDK should do away with the oracle issue no?
Re:Google joins .NET Foundation as Samsung brings .NET suppo... by pjmlp on Friday November 18, 2016 @12:36PM (#12988437)
They are just cherry picking features, check the AOSP.
Re:Google joins .NET Foundation as Samsung brings .NET suppo... by johncolanduoni on Wednesday November 16, 2016 @11:08AM (#12968276)
Better 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.

Re:Google joins .NET Foundation as Samsung brings .NET suppo... by kuschku on Wednesday November 16, 2016 @11:48AM (#12968765)
Actually, 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.
Re:Google joins .NET Foundation as Samsung brings .NET suppo... by KMag on Wednesday November 16, 2016 @12:40PM (#12969336)
But 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.)

Re:Google joins .NET Foundation as Samsung brings .NET suppo... by int_19h on Wednesday November 16, 2016 @08:16PM (#12973315)
Based 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.

Re:Google joins .NET Foundation as Samsung brings .NET suppo... by pjmlp on Friday November 18, 2016 @12:38PM (#12988456)
Dynamic languages cannot be easily mapped to CIL, which is why IronPython was the genesis of DLR extensions, later added as standard part of .NET.
Re:Google joins .NET Foundation as Samsung brings .NET suppo... by int_19h on Friday November 18, 2016 @09:04PM (#12991594)
Dynamic languages typically aren't compiled, though. So either a language would have some kind of VM of its own (which is typically implemented in C, and hence can be implemented in CIL), or else they have some form of JIT compilation, which can use CIL as a target.
Re:Google joins .NET Foundation as Samsung brings .NET suppo... by pjmlp on Saturday November 19, 2016 @09:34AM (#12993635)
Those are scripting languages.

If you bothered to read why DLR was created, you will see why CIL wasn't enough.

Or why Java following the same linr of thought had to follow DLR changes to the CLR and introduce invokedynamic byte code and its related infrastructure.

Re:Google joins .NET Foundation as Samsung brings .NET suppo... by int_19h on Saturday November 19, 2016 @05:27PM (#12996062)
I know why DLR was created. I work on a team that has one of the guys who was working on it, and specifically on IronPython.

My point is that they are two different layers in the stack. CIL and JVM are lower level. DLR is a higher level layer. Said higher level can be implemented on any kind of lower level that's powerful enough - for example, you could have a kind of DLR directly on top of native code. All that matters for the lower level is that it's flexible enough to permit something like DLR to be implemented on top of it. CIL is undeniably flexible enough for that.

Re:Google joins .NET Foundation as Samsung brings .NET suppo... by pjmlp on Sunday November 20, 2016 @04:03PM (#13001210)
I remember reading some articles that justified DLR as CIL not having enough semantics that allowed to properly implement optimization algorithms commonly used in dynamic languages, like method lookup and call site caches.

Then again, maybe I understood it wrongly back then and I surely don't have the knowledge of your team.

Re:Google joins .NET Foundation as Samsung brings .NET suppo... by int_19h on Tuesday November 22, 2016 @09:01PM (#13019354)
Yes, that's right. But it's kinda what I meant. CIL is really roughly the level of C, plus some strongly typed object oriented stuff on top. It doesn't really offer anything useful for a dynamic language directly. But you can use it to implement a dynamic language VM with all those optimizations - just like C was used to write Parrot VM. DLR is to CLR as Parrot is to native code.
Re:Google joins .NET Foundation as Samsung brings .NET suppo... by int_19h on Wednesday November 16, 2016 @08:12PM (#12973287)
With C#, you can implement an IUnknown-derived interface completely in C++ (with `class` etc), and then define it in C#, and it transparently does all the mapping of members for you.

Yes, it's COM. People assume that makes it non-cross-platform, but there's nothing Windows-specific about COM, it's just a slightly higher-level ABI than C. So Mono supports it on Linux in the same manner. Not sure what the story is in .NET Core.

Re:Google joins .NET Foundation as Samsung brings .NET suppo... by akyu on Wednesday November 16, 2016 @11:12AM (#12968329)
It would be worth it just to have LINQ
Re:Google joins .NET Foundation as Samsung brings .NET suppo... by JustSomeNobody on Wednesday November 16, 2016 @12:08PM (#12969020)
LINQ is cool and all, but it takes a lot of code to make that cool, so I would love to see how it affects battery life.
Re:Google joins .NET Foundation as Samsung brings .NET suppo... by Grazester on Wednesday November 16, 2016 @11:51AM (#12968818)
LINQ and Lambda expressions had me liking C# a lot back when I used it for an Entity Framework project I was on(well java got Lambda expression not too long ago though)
Re:Google joins .NET Foundation as Samsung brings .NET suppo... by kuschku on Wednesday November 16, 2016 @11:48AM (#12968777)
Why? 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?

Re:Google joins .NET Foundation as Samsung brings .NET suppo... by kodfodrasz on Wednesday November 16, 2016 @03:40PM (#12971280)
the 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.

Re:Google joins .NET Foundation as Samsung brings .NET suppo... by kuschku on Wednesday November 16, 2016 @04:23PM (#12971690)
> 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.

Re:Google joins .NET Foundation as Samsung brings .NET suppo... by kodfodrasz on Thursday November 17, 2016 @02:13AM (#12975116)
When i last used the stream api i don't remember it had a reverse functionality. Still that was an example only.

Edit: Just checked: https://docs.oracle.com/javase/8/docs/api/java/util/stream/S... no reverse().

Fyi for 1 year I have been working on a Stream API heavy app. Now working on a C# project with quite some LINQ. I know both sides to some extent...

Re:Google joins .NET Foundation as Samsung brings .NET suppo... by adgasf on Thursday November 17, 2016 @09:11AM (#12977548)
How is stream superior? I cringe every time I move between Integer and int.
Re:Google joins .NET Foundation as Samsung brings .NET suppo... by serge2k on Wednesday November 16, 2016 @05:52PM (#12972372)
You made the bold statement, why don't you say something to support it.
Re:Google joins .NET Foundation as Samsung brings .NET suppo... by justin66 on Wednesday November 16, 2016 @11:06AM (#12968233)
Using a language not in the hands of Oracle.