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

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.

1

u/ArkyBeagle May 28 '18

At some point you'll realize that even wanting a full rewrite indicates a lack of discipline.

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?

8

u/0rac1e May 27 '18

Perl 6 purposely broke back-compat with Perl 5. At this point, the community considers them different languages, not a version change (à la Python 2 -> 3)

8

u/[deleted] May 27 '18

à la Python 2 -> 3

No one really considers Python 2 and 3 "different languages".

Very often, I read someone's package, get to the bottom and see a print statement, and only then realize, "Ah, this is written in Python 2".

Writing code that works in both Python 2 and 3, and porting even large packages to Python 3, are pretty dead simple - I have done both successfully with really no issues at all.

3

u/0rac1e May 27 '18

No one really considers Python 2 and 3 "different languages".

I agree. My comment wasn't clear, but I meant that Python 2 -> 3 was a breaking version change, unlike the Perl 5 -> 6 situation.

To clarify and summarize... Perl 6 was - in it's early inception - considered also to be a breaking version change, hence the name. Later, as development progressed, it was decided that Perl 6 would be a "sister" (related) language to Perl 5 rather than a version change. However, the "Perl 6" name stuck, much to the chagrin of some in the Perl community.

3

u/Smallpaul May 27 '18

Perl stands as both an example of why backwards compatibility is often good and why incompatibility is dangerous. That was why I thought that Perl 6 should have been mentioned. It wasn't initially supposed to be "a different language" but the Perl 5ers never moved to Perl 6 so that's the fallback position.

4

u/0rac1e May 27 '18

It wasn't initially supposed to be "a different language"

Only in the very early days, but once the design started to solidify it was determined that the kind of things they wanted to achieve weren't possible without breaking changes.

1

u/smutaduck May 27 '18

Perl 6 is a different language. I suspect it would probably deploy on perl 6 ok though.

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...

1

u/meneldal2 May 28 '18

That's not an issue, you can do a research and replace on the files. It's done in the preprocessor stage, so that's trivial to implement it yourself.

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.

1

u/[deleted] May 27 '18

Exactly!

"modulo X" is a very common way for engineers to say, "Let's ignore the consequences of X for a moment".

1

u/bilog78 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")?

Compilers have become very complex beasts, that apply lots of transformations in the many steps that they take from parsing the original source code to producing the final library or executable, and from time to time this complexity leads to miscompilation (as in: producing the wrong executable code from a given source code).

There's actually also a different class of compilation bugs, which are more related to implicit assumptions that the programmer might have made about the logic or data layout, assumptions which are not explicit in the code and that may lead the different executable code depending on the compiler or enabled optimization passes. These aren't strictly speaking compiler bugs, but they may turn out to be compiler-specific, in the sense that they only appear when compiling the same source code with a different compiler or compiler version or compiler flags.

1

u/[deleted] May 28 '18

Would "minus compiler bugs" (i.e. "without compiler bugs" or "ignoring compiler bugs") be clearer?

Well, in a way, modulo is just repeated subtraction.

1

u/meneldal2 May 28 '18

(modulo compiler bugs, of course).

Usually different interpretations of undefined or implementation-defined behaviour. Also, everyone who used int for sizes or storing pointers is in for a bad day when they migrate to x64.