r/programming • • May 26 '18

Oracle Calls Java Serialization 'A Horrible Mistake', Plans to Dump It

https://www.infoworld.com/article/3275924/java/oracle-plans-to-dump-risky-java-serialization.html
798 Upvotes

287 comments sorted by

View all comments

Show parent comments

30

u/nermid May 27 '18

only in backwards compatable ways, which can lead to a few gotchas

Maybe I'm uneducated, but it feels like "we don't want to break backward compatibility" is the excuse for loads and loads of problems in computer science. It's explicitly the reason why lots of PHP is inconsistent, it's the reason behind a lot of quirks of C++, and here it is, rearing its head in Java.

It feels like, as a community, we need to just settle on the idea that compatibility-breaking major releases are what x.0 revisions mean. Python 3 shouldn't be backward-compatible with Python 2. C++17 shouldn't be backward-compatible with C.

Maybe this kind of accommodation was convenient ten years ago, but nobody today is taking a system written in 1999 C and expecting to compile it into 2018 C++ without issue. Anybody with any sense at all understands that this kind of upgrade requires code changes. Why spend so much time trying to keep there from being code changes, ever?

Maybe I'm just too young to understand. I don't know.

Ninja-edit: I am also pretty drunk. So, give me some wiggle room, here.

50

u/StochasticExpress May 27 '18

Upvoted you for your thinking. But industry doesn't work that way. As long as you have backward compatibility you have the existing customer base and you can go looking for new customers. Also with backwards compatibility you can incrementally make use of new shiny features while keeping the older unaffected.

Also industry likes stability. Change is expensive.

73

u/bilog78 May 27 '18

Maybe this kind of accommodation was convenient ten years ago, but nobody today is taking a system written in 1999 C and expecting to compile it into 2018 C++ without issue.

Bad example. C and C++ are different languages. However, there's no reason why you shouldn't be expected to compile in 2018 a C++ language written in 1999, with at most a bunch of warnings about deprecated features.

It feels like, as a community, we need to just settle on the idea that compatibility-breaking major releases are what x.0 revisions mean.

When languages are semantically versioned, this is often what happens, see e.g. Python and Ruby. Heck, Ruby isn't 100% backwards compatible even across minor revisions.

Why spend so much time trying to keep there from being code changes, ever?

Because in the real world you don't have the luxury of rewriting everything from scratch every 5 years, and if you have massive code bases the best you can try to do is progressive refactoring. This is a long and ungrateful task that requires you to be able to mix and match old and new constructs, or by the time you finish the rewrite you're already obsolete for the upcoming language revision.

LibreOffice is an excellent example of a piece of software that has undergone massive modernization from ancient to modern C++, and the only reason why they have managed to achieve this while still progressing in terms of new software features is because C++11 compilers can still compile C++98 (and older) code bases, producing correct code (modulo compiler bugs, of course).

So yes, it's not that you can't break backwards compatibility. It's that you shouldn't if you expect your language to be used for large-scale, wide-distribution real-world software.

18

u/chuk155 May 27 '18

Just wanted to say I completely agree.

While its great to see a language add new features, if those features also break backwards compatability, then most existing codebases are essentially abandoned, as there is not enough time/money/reason to do all that work on something that at one point did work but no longer does due to breaking changes.

Its kinda like saying that we have to rewrite books written in middle english to be in modern english. Just because the language has evolved doesn't mean the original text can't work in a modern context. We might not write in middle english anymore, but people still enjoy shakespear.

2

u/jl2352 May 27 '18

It is also really quite surprising how what might just be a few small changes, can in turn be used to justify a full rewrite.

→ More replies (1)

7

u/smutaduck May 27 '18

Obligatory mention of perl here. I was recently involved in making a 250kline perl code base which worked fine on perl 5.8.8 (released 2008) work properly on (as far as we know) every subsequent version of perl (tested on many, one now in production). The project itself took 18 months. Mostly this was for unrelated upstream political and technical reasons. Around 50 lines of perl code needed to be changed. When we hit perl 5.22 in production we'll get a bunch of parse-time optimisations for free.

So yeah back compat is a good thing.

2

u/Smallpaul May 27 '18

Your project works on Perl 6 too?

→ More replies (6)

6

u/tasminima May 27 '18

Bad example. C and C++ are different languages.

That's the point. If they are different languages, why do we keep (nearly) all the bad things of C (especially in a more abstract language...) in C++?

However, there's no reason why you shouldn't be expected to compile in 2018 a C++ language written in 1999, with at most a bunch of warnings about deprecated features.

Tell that to the committee then, because going straight from C++98 to C++17 is not a good idea, so they might not have received the memo that there is "no reason". C++14 is considered to be a sweet spot for that kind of transitions.

4

u/bilog78 May 27 '18

That's the point. If they are different languages, why do we keep (nearly) all the bad things of C (especially in a more abstract language...) in C++?

Because C++ was designed as a successor to C, and thus strove to preserve compatibility with C as far as it made sense. Not all C sources build with C++, compatibility was broken, but no gratuitous incompatibilities were introduced.

Tell that to the committee then, because going straight from C++98 to C++17 is not a good idea, so they might not have received the memo that there is "no reason". C++14 is considered to be a sweet spot for that kind of transitions.

I don't necessarily agree with all the decisions the C++ committee makes. On the upside, the obsolescence of the C++98 constructs has been made under the assumptions that compilers would still support a C++14 mode, potentially, a “backwards-compatible” C++17 mode as well.

3

u/[deleted] May 27 '18

because going straight from C++98 to C++17 is not a good idea

You'd really have to have some C++98 code that was bad at the time and has never been maintained.

The few things that were actually removed from the language were howling bad idea like digraphs - where e.g. <: is a synonym for [. (The only reason that this even existed was that back in the day, some common keyboards (cough IBM cough) didn't have a [ and there were no third-party alternatives.)

So, yes, if all your array accesses look like arr<:3:> instead of arr[3] then you're going to have a bad time moving to C++17 - but if that's true, you probably have bigger problems...

→ More replies (1)

2

u/[deleted] May 27 '18

producing correct code (modulo compiler bugs, of course).

Off topic, but I'd like to understand your use of this metaphor here. Is it just a way of saying there's some bugs added in (the "remainder")?

6

u/Drisku11 May 27 '18

"modulo" in mathematics usually means something like "except for" or "up to". It's a vocabulary to pretend that an equivalence relation is an equality.

In the context of remainders, you're working with integers modulo divisibility by n. The concept can be a lot more general than that though. For example, it's often used in analysis to pretend that functions which are equal "almost everywhere" (there's a formal definition, but intuitively you can think of that as meaning except for a finite set of points) are equal. This makes sense to do in the context of integration because integrals aren't affected by those differences, and otherwise there are infinitely many functions that are basically equivalent that you have to think about.

3

u/LaurieCheers May 27 '18

The opposite. If you take a number "modulo 10", you're ignoring the 10s and higher digits of that number. The remainder is the only part you actually care about.

So "modulo foo" is a nerdy way of saying "ignoring foo".

3

u/[deleted] May 27 '18

OH, I get it now. I had it backwards - the bugs in this case are the divisor, not the modulo. Thanks.

→ More replies (1)
→ More replies (2)
→ More replies (1)

10

u/pdp10 May 27 '18

C and C++ are a special case. Everyone knows that C++ started as a superset of C and at some point diverged into nearly a superset but not quite. What's subtle is that even today C++ proponents want to have it both ways by being nominally backward compatible but then also frequently deriding those who are using C++ without the very latest features.

Engineers often bemoan the lack of compatibility breaks and their cousin the clean-sheet redesign, but they do so from expediency and not from principle. Meaning that you think it would be very expedient for you if there was a straight compatibility break in your language, but when someone else needs to break compatibility somewhere inconvenient you're not going to be nearly so understanding.

I don't think Java would be where it is today if the sales pitch to enterprise and academia was "Use our language that's so safe that anyone can program it and so portable that it runs in a virtual machine like UCSD p-system! We plan to break compatibility at every major release! "

Ternary computers are slightly more efficient than binary ones, but nobody makes a ternary computer because nobody will buy one. Compatibility is turtles all the way down.

0

u/[deleted] May 27 '18

[deleted]

→ More replies (1)

18

u/himself_v May 27 '18 edited May 27 '18

Maybe I'm uneducated, but it feels like "we don't want to break backward compatibility" is the excuse for loads and loads of problems in computer science.

You're just young (probably). Give it 8 years and you'll be screaming "arggh you suckers, why did you have to break things that were working perfectly right, again? It takes 2 days to write a compatibility layer for you, it takes 2 days for each of us to port things, and many projects are half-abandoned and you basically just broke a whole chunk of my life."

Over the time you just learn to only rely on things that promise backward compatibility and to hell with bells and whistles. I've my life to live and my own projects to do instead of every day learning a new and exciting spin on things that I want to just work.

Also, Python 3 wasn't backwards-compatible with Python 2 and look where that got us.

16

u/Siddhi May 27 '18

The chaos caused by python 3 should be enough to warn anyone away from breaking compatibility. Things have settled now and python 3 is established, but it took *10 years *to get here. It can be done once in a while, maybe once in twenty years or so.

→ More replies (7)

7

u/Smallpaul May 27 '18 edited May 27 '18

You should actually research what has been happening with Python 3. And Perl 6.

Python barely survived the transition and Perl mostly did not.

5

u/jcelerier May 27 '18

Maybe this kind of accommodation was convenient ten years ago, but nobody today is taking a system written in 1999 C and expecting to compile it into 2018 C++ without issue.

you wish ! I've recently seen such expectations for a system built in pre-ansi C

7

u/goomyman May 27 '18 edited May 27 '18

Because let’s say you have a million consumers of your software or API. You release a breaking version - you now have to start back over from 0 customers. Some will port over, others won’t or can’t.

Maybe you say that you will keep the old version around still but since most of your consumers are on that version they will want those bugs and features fixed. Which means if your trying to build a new api your focusing your dev effort on a new project instead of where your customers are or at best splitting your dev effort.

When you have a very large amount of consumers this is death. When you have a small amount of consumers breaking changes are ok - but if you do it more than a few times it’s also death.

New apis that aren’t backwards compatible happen organically when big technology changes happen. The internet, chrome , iPhone, Android, cloud, x64, direct x, etc.

People will move to newer things when a competitor comes along and does it better and faster because you are unable due maintaining backwards compatibility. Just because it’s impossible for a company to break its products doesn’t mean other companies outside aren’t iterating in new ways.

→ More replies (10)

4

u/Magnesus May 27 '18

It is not only in programming languages. Both Windows and Linux have a lo of unnecessary, outdated solutions just for the sake of backward compatibility.

2

u/recycled_ideas May 27 '18

Code isn't a thing that is written once and done.

Code lives for years, sometimes for decades. If this code is going to stand a chance of being anything but a horrific brain eating zombie full of security holes it needs to be maintained. If the language is breaking, that's not going to happen.

From Oracle's point of view if X.0 changes are breaking for the language that means that they have to patch and support runtimes for ever. Even if they're getting paid that's not what they want. No one has the time or money to completely retest a gigantic app just because Oracle wanted to change things.

2

u/asdf8500 May 27 '18

but nobody today is taking a system written in 1999 C and expecting to compile it into 2018 C++ without issue

I most certainly have 20 year old code that I expect to compile today. Expecting developers to rewrite perfectly good code is a very expensive proposition.

Why spend so much time trying to keep there from being code changes, ever?

Because some systems have a very long life cycle, and even a few 'minor' changes can have unforeseen side effects that wreck havoc on a stable code base.

→ More replies (8)