java-repl icon indicating copy to clipboard operation
java-repl copied to clipboard

Static typing?

Open daw42 opened this issue 9 years ago • 3 comments

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?

daw42 avatar Jul 12 '15 00:07 daw42

:+1:

ioistired avatar Oct 05 '15 16:10 ioistired

Agreed :+1:

bmaca avatar Dec 17 '15 08:12 bmaca

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.

asgs avatar Jan 25 '17 12:01 asgs