java-repl
java-repl copied to clipboard
Static typing?
I just found this project, very nice work! Have you considered using a more strict type system in the REPL? In the current version, data types for variables can change during the session, and variables can be created without being declared. For example:
java> int a = 3;
int a = 3
java> a = 42.0;
java.lang.Double a = 42.0
java> b = 15;
java.lang.Integer b = 15
I'd love to use this project for teaching Java, however, this "dynamic typing" makes it poorly suited for education. When teaching about data types, students need to understand that a variable's type does not change after it is declared, and that all variables must be declared.
Have you considered adding a mode that strictly follows Java rules for types/declarations?
:+1:
Agreed :+1:
I wouldn't necessarily agree with making stricter because that's how JShell (Java9+) works too. Of course, your point that beginners will construe this behavior as if Java does Dynamic typing is accurate.