Live data from Hacker News

Removal of Unsafe in Java 9 – A disaster in the making

blog.dripstat.com

121–130 of 142 posts

Re: Removal of Unsafe in Java 9 – A disaster in the making

#121

Once again, The Platonic Engineer gazes hatefully at the gronky, ugly and awkward things that make things work in real life, rub his hands together and says... "Burn it to the ground."

Yeah, I don't get it either. Even the Lisp Machines had unsafe subprimitives you could call if you needed to and knew what you were doing.

Re: Removal of Unsafe in Java 9 – A disaster in the making

#122

This is related and unrelated and maybe even meta to some degree: There are a couple of companies that are guilty of using their free software update mechanism to try and trick people into installing crap they don't want (and might even mess-up their systems): Sun and Adobe. I almost happened to me last night as I updated Flash on a test system and some bullshit anti-virus crap-ware was going to be installed because…

You understand of course that Sun has been out of business for a very long time right?

Sorry, brain fart, I meant Oracle

Re: Removal of Unsafe in Java 9 – A disaster in the making

#123

This is related and unrelated and maybe even meta to some degree: There are a couple of companies that are guilty of using their free software update mechanism to try and trick people into installing crap they don't want (and might even mess-up their systems): Sun and Adobe. I almost happened to me last night as I updated Flash on a test system and some bullshit anti-virus crap-ware was going to be installed because…

java hasnt been bundled with crapware since oracle bought it

Some installations I've seen have crapware pre-selected. I haven't looked at it lately, maybe they changed this.

Re: Removal of Unsafe in Java 9 – A disaster in the making

#124

Earlier quoted context omitted.

You forgot to explain what the "right thing" that they should be doing is? Even according to most articles on the topic there is very to any pleasant alternatives that are cross platform e.g. https://dzone.com/articles/understanding-sunmiscunsafe

jni, and don't tell me now that c isn't portable.

C isn't portable.

You cannot write it once and run it everywhere, each platform needs a bunch of macros and flags. Plus you'll now either be delivering it in binary form (which may or may not work due to bitness, OS incompatibilities, and so on) or you'll be delivering it as code (which may or may not work due to compiler incompatibilities, build system components available, and missing libraries).

C is only portable in the sense that "every platform ever made has a C compiler." But if you've ever written a C application which is just meant to run on Windows, OS X, and Linux you'll know that it is a painful experience (double that if they're meant to compile it themselves).

Re: Removal of Unsafe in Java 9 – A disaster in the making

#125

Earlier quoted context omitted.

It's part of the OpenJDK/Oracle VM implementation, not an official part of the Java standard library. It allows for all sorts of fun stuff like native compare and swap operations (used for concurrent collections iirc), object allocation without calling the constructor, accessing blocks of memory directly without object references, and other things. The reason it's called unsafe is because it allows developers to bypa…

Why remove it though? What harm is being caused?

I haven't seen anything official about it, but I imagine it's been planned for some time. Sun/Oracle have explicitly warned against its use for a while. It seems less necessary when GC improvements in the last two releases have meant it's much easier to get great speed and latency with idiomatic and documented implementations. Further, what performance improvements are offered by Unsafe are obtained by breaking a variety of Java's guarantees, and I imagine that it is tiresome as an OpenJDK dev to hear about bugs "caused by the JVM" in libraries that depend on an unsupported undocumented API.

Just speculation, of course.

Re: Removal of Unsafe in Java 9 – A disaster in the making

#126
post #120
post #104

Earlier quoted context omitted.

Oracle did a survey last year exactly as input for what to do.

Good, that seems like a smart move. It is of course possible for them to still ignore the results of that survey, or to game the results, or that a majority of respondents don't care or understand the issue anyhow. My point is that if this feature is important enough to people, they can take real action and don't have to kiss the ring and beg at the feet of power in order to achieve the result that they want.

They are not ignoring the result, and are doing exactly what the author wants them to do, except they started doing it before this hysterical piece was written.

Re: Removal of Unsafe in Java 9 – A disaster in the making

#127

Earlier quoted context omitted.

jni, and don't tell me now that c isn't portable.

C isn't portable. You cannot write it once and run it everywhere, each platform needs a bunch of macros and flags. Plus you'll now either be delivering it in binary form (which may or may not work due to bitness, OS incompatibilities, and so on) or you'll be delivering it as code (which may or may not work due to compiler incompatibilities, build system components available, and missing libraries). C is only portable…

*bad C isn't portable. and you can pack as many platform as you wish in your binary distribution, so single download still works everywhere (everywhere you built beforehand).

Re: Removal of Unsafe in Java 9 – A disaster in the making

#128
post #49

Earlier quoted context omitted.

[deleted]

If you are using Unsafe in your code you have already decided that you know what jvm you are deploying to.

That's not necessarily true. What about for projects which are used across a wide array of platforms such as Spring or Gson? Those frameworks are meant to be deployed independently of platform.

Re: Removal of Unsafe in Java 9 – A disaster in the making

#129

Earlier quoted context omitted.

C isn't portable. You cannot write it once and run it everywhere, each platform needs a bunch of macros and flags. Plus you'll now either be delivering it in binary form (which may or may not work due to bitness, OS incompatibilities, and so on) or you'll be delivering it as code (which may or may not work due to compiler incompatibilities, build system components available, and missing libraries). C is only portable…

*bad C isn't portable. and you can pack as many platform as you wish in your binary distribution, so single download still works everywhere (everywhere you built beforehand).

I think the issue is a disagreement over what portability means. To me, portability doesn't mean write once, run everywhere, it just means you can make it run on a different platform with a bit of effort.

In a C/C++ program, if you're careful, you can isolate the platform-independent parts so that you only have to write them once. VM languages abstract further by creating a new language for these platform-independent parts. However, the platform-dependent parts are still going to be written in C/C++, or assembly, or generated by a JIT compiler written in C/C++ (there are rare exceptions).

So if anything, I would say that C/C++ enables portability, simply because there aren't any other viable choices besides assembly when it comes to generating platform-specific machine code.

Re: Removal of Unsafe in Java 9 – A disaster in the making

#130
post #120
post #104

Earlier quoted context omitted.

Oracle did a survey last year exactly as input for what to do.

Good, that seems like a smart move. It is of course possible for them to still ignore the results of that survey, or to game the results, or that a majority of respondents don't care or understand the issue anyhow. My point is that if this feature is important enough to people, they can take real action and don't have to kiss the ring and beg at the feet of power in order to achieve the result that they want.

Here, Java ONE 2014, one year ago!

"Safety Not Guaranteed: sun.misc.Unsafe and the Quest for Safe Alternatives"

https://www.parleys.com/tutorial/safety-not-guaranteed-sun-m...

Every Java developer worth its salt knows about Java ONE.

Post reply on HN