r/java • • Mar 26 '26

Carrier Classes & Discussing Syntax with Brian Goetz - Inside Java Podcast 52

https://www.youtube.com/watch?v=b6cXuA84c9g
86 Upvotes

25 comments sorted by

View all comments

Show parent comment

2

u/supersmola Mar 27 '26

So this?

var a := a + 1;

12

u/brian_goetz Mar 27 '26

There are good reasons that Pascal and its ancestors picked this syntax, and its not only "looks like an equation but isn't." If you use `=` for assignment, you have stolen the best syntax for the comparison operator. (After 50 years of C, we're now used to `==` as the equality comparison operator, but it was decidedly weird at the time.) Other contemporaneous languages picked backarrow for the same reasons.

But of course the power move is to do what functional languages do; rather than picking a different syntax for assignment, they went the other way, by ensuring that `a = exp` is a statement of equality, making the problem moot.

2

u/vytah Mar 30 '26

If you use = for assignment, you have stolen the best syntax for the comparison operator.

There are languages that use = for both assignment and comparison, and they work fine.

0

u/supersmola Mar 28 '26

I think Ada authors and Wirth were not hardcore programmers and didn't consider the amount of time you'll spend writing associations.

With that said, when I switched from Pascal to Java I needed a quite amount of time to stop typing the colon. On the other side I had not problem ditching the "begin..end".

-3

u/[deleted] Mar 27 '26

[removed] — view removed comment

20

u/brian_goetz Mar 27 '26

Thanks, I'm new at this programming thing

3

u/Gleethos Mar 27 '26

Yeah, and also, the JDK team decided that the == operator is deprecated and will be removed soon.

They also decided that besides hashCode and equals every Object and even null will inherit the assignTo(T) method so that they can also deprecate and remove the = operator shortly afterwards.

1

u/supersmola Mar 28 '26

Abomination.