News for hackers. Stuff that matters.
Re:Garnet – A new remote cache-store from Microsoft Research by blackoil on Tuesday March 19, 2024 @01:11AM (#39753132)
The investment in optimization in CLR or JVM can be huge as they impact millions of applications. While each C / C++ code will have to be hand optimized.

Also limits on number of people in given time who can write optimal C code vs C# will also make managed code better.

Re:Garnet – A new remote cache-store from Microsoft Research by theLiminator on Tuesday March 19, 2024 @03:23AM (#39753614)
Couldn't you just replace the CLR and JVM with llvm and gcc and then replace C with assembly and arrive at the same conclusion.
Re:Garnet – A new remote cache-store from Microsoft Research by blackoil on Tuesday March 19, 2024 @04:05AM (#39753782)
Now commenting beyond my expertise, I understand both ecosystems have developed orthogonally, C#/Java assumes code to be higher level and "dumb" and optimization are in library/CLR/JVM. While C/C++ are developed with code at lower level and developer making sure code is optimized.

Now, I could be talking out of ass, haven't done enough C/C++ coding in over a decade.

Re:Garnet – A new remote cache-store from Microsoft Research by balls187 on Tuesday March 19, 2024 @09:50AM (#39755721)
You can write poorly optimized C#.

And the intel C++ compiler has provided significant performance for decades via optimization without needing to optimize by hand.

Re:Garnet – A new remote cache-store from Microsoft Research by Dumble on Tuesday March 19, 2024 @03:42AM (#39753703)
I'm not the person you are replying too, but I believe that of course, the pattern holds if you keep shifting it down. I.E. using a faster CPU will speed up all programs running on it, each (already optimized) ASIC has to be optimized further individually.
Re:Garnet – A new remote cache-store from Microsoft Research by astral303 on Tuesday March 19, 2024 @10:40PM (#39762421)
I don’t think so, because it is the runtime JIT (Just-In-Time) optimizer that is the critical speed advantage that allows the CLR and JVM to beat C and C++.

The inlining of virtual calls is the critical optimization that enables this. Because C/C++ is optimized statically and never at runtime, it is unable to optimize results of function pointer lookups (in C, and thus also virtual calls in C++). However, the JITs can inline through function pointer lookups.

In sufficiently complex programs, where polymorphism is used (i.e. old code that calls new code without knowing about it), this yields an unsurpassed speed advantage. Polymorphism is critical to managing complexity as an application evolves (even the Linux kernel, written in C, uses polymorphism, e.g. see struct file_operations).

Re:Garnet – A new remote cache-store from Microsoft Research by rfoo on Tuesday March 19, 2024 @01:59AM (#39753317)
Plus that it's easier to have unmanaged code in C# than in Java.
Re:Garnet – A new remote cache-store from Microsoft Research by larodi on Tuesday March 19, 2024 @02:49AM (#39753477)
Is it possible to have unmanaged code in Java at all… or you mean linking libs and exposing them through Java API in the lang?
Re:Garnet – A new remote cache-store from Microsoft Research by rfoo on Tuesday March 19, 2024 @03:29AM (#39753637)
Ah, I meant Java code manipulating off-heap memory. For Java I don't think there's a way to mix managed and unmanaged code like you do in C#/C++ CLR.
Re:Garnet – A new remote cache-store from Microsoft Research by neonsunset on Tuesday March 19, 2024 @03:36AM (#39753676)
In C# you usually don't want to mix in C++. Manipulating off-heap memory is indeed easy - nowadays pointers to both object interiors, stack and unmanaged memory can be represented as `ref T` where T is byte, int, etc.

These are then subsequently wrapped by `Span<T>` and `ReadOnlySpan<T>` respectively. This way a span can be a slice of memory that can have any origin:

    var fromStack1 = (stackalloc byte[32]);
    var fromStack2 = (Span<byte>)[0x20, 0x20, 0x20, 0x20];
    var fromHeap = new byte[32].AsSpan();
    unsafe
    {
        var ptr = NativeMemory.Alloc(32);
        var fromMalloc = new Span<byte>(ptr, 32);
        // Don't forget to free :)
    }
Re:Garnet – A new remote cache-store from Microsoft Research by pjmlp on Tuesday March 19, 2024 @05:20AM (#39754051)
Panama has helped into that direction, it isn't like C# though, for feature parity we will eventually need Valhalla, which since they want to keep existing JARs working, it is taking its time.

Ignoring the type systems from Eiffel, Objective-C, Oberon and Modula-3 linage, even though they were inspirations for Java, has been shown to have been a bad decision in hindsight.

Re:Garnet – A new remote cache-store from Microsoft Research by pjmlp on Tuesday March 19, 2024 @05:11AM (#39754009)
True, I still look forward to have Valhala, eventually.