5 ms·
High-performance Java is indeed basically writing C in Java, including using you own byte array for memory. It's amazingly un-idiomatic though, and you'll get (
by dtech 5y ago
High-performance Java is indeed basically writing C in Java, including using you own byte array for memory. It's amazingly un-idiomatic though, and you'll get (rightly) roasted by fellow Java developers for doing it without a clear and compelling need.
In other words, you've missed the whole point of the article. Just because you can do it, doesn't mean you'll end up doing it.
- cerved 5y agoYou can do it for fun :P
- bullen 5y agoClear and compelling need? Isn't $1/KWh enough for you? I don't think you understand that real electricity prices can never go down! Combine that with peak computer hardware performance/efficiency and you have a time bomb that will leave nobody out of harm! Java can do atomic parallel things on multiple cores you are hard pressed to build a VM with GC to get working in C. WASM tried only VM and Go tried only GC, both failed compared to Java on the server. Servers that crash are not an option.
- coldtea 5y ago>Clear and compelling need? Isn't $1/KWh enough for you? I don't think you understand that real electricity prices can never go down! So? It's not like the electricity bill is a major concern for 99% of companies with servers. It's usually less than what they pay to stock the fridge with water bottles...
- bullen 5y agoMany small things is the way big things form, all collapses happen this way because humans don't understand compounded exponential changes and react too late. Right now not a single company is making any profit, the margin calls are filling with debt at a rate that nobody can comprehend. Just a question of time, it's inevitable, what goes up must come down.
- coldtea 5y ago>Right now not a single company is making any profit I'm pretty sure this is not factually correct. Also, not related to server electricity costs.
- noctune 5y ago>High-performance Java is indeed basically writing C in Java, including using you own byte array for memory. Oh, I wish. For example, in C you can easily return multiple values through pointers. In Java, you have no such luxury without allocating so it's even less flexible if you can't allocate.
- kaba0 5y agoI’m not sure what you have in mind but returning pointer to a value on the stack may very well be a huge error.
- tempodox 5y agoOf course it's a huge error, which is why you should never do that. Instead, you pass the addresses of local stack variables to that function as pointer arguments and let that function write its outputs there. Voilà, multiple return values without heap allocations.
- kaba0 5y agoOr you pass `this` and set a field of that in a function, which is equivalent.
- AmpsterMan 5y agoThat's a bit of a stretch using the word 'return' there. Forgive my exactness, but return implies, well, returning a value from a function. I'd say that Java has similar semantics to C. One can easily pass object references to a function that sets their data. That looks and behaves almost exactly like C. The fact that the references are allocated on the heap is an implementation detail. Let me be clear, a pointer to a struct on the stack in C is obviously not the same as a reference to an object allocated on the heap in Java. The point is that from the point of view of what the language induces you to do, Java and C are similar. Anyone that has used older libraries in Java can attest to this; they look and feel remarkably like C.
- guavaNinja 5y ago