Paving the on-ramp

Brian Goetz brian.goetz at oracle.com
Wed Sep 28 20:56:06 UTC 2022


> - You can declare a main() on other things that a class, on an 
> interface, on an enum or a record.
>   Being able to declare the "main" without to have to declare it 
> static is nice, but the semantics you propose creates new issues,
>   because the auto-instantiation does not work if the container is an 
> interface or a record with components.
>   This feels too magical to me, and as a teacher i will have to 
> explain it at some point.

Perhaps, but not on the first day.

> - At the begining, teaching records is easier than teaching classes 
> because you can do too much with a class while records have a simple 
> syntax and a simple semantics.

I agree teaching records first is a good teaching strategy; I have a lot 
to say about curriculum design, but I'd like to keep that a separate 
discussion.  Suffiice it to say that an important secondary goal here is 
unconstraining the order in which things must be taught.

>   In a dream world, we should be able to declare records inside a 
> classless class, but i do not see how the compiler will not see a top 
> level record instead of a classless class containing records.
>

Hoping to make this dream possible.
> - At my uni, we start by teaching Python and JavaScript, then C then 
> Java. We do not teach ipython because the semantics is slightly 
> different from python.
>   For the same reason, we do not use jshell for undergraduates because 
> the semantics is sligthly different than java.
>   For the same reason, if the semantics of a classless class is 
> different from the semantics of a regular class , we will not use it too.

Agree, and this was a strong driving motivation.  This is why we have 
avoided trying to create a "safe subset for beginners", and instead 
focus on allowing unnecessary wrapping to be elided.

> - I don't hink we can add an auto static import without causing source 
> backward compatibility issues, because you can not have several import 
> static using the same last identitfier.
>   By example, if an existing class declare
>     import static foo.A.println;
>
>   this class will now fail to compile.
>   That's why no auto static import was added in Java 5.

There is some complexity here, but it does not seem insurmountable.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/amber-spec-experts/attachments/20220928/07ec7d80/attachment.htm>


More information about the amber-spec-experts mailing list