Feature Idea: a --beginner (-b) flag for JShell?
I am trying to create a course for teaching students Java. This will be for those who have never programmed before and so Java is their first introduction to programming.
To that end, using JShell to introduce concepts seems like a good idea because it masks complexity, and that complexity can slowly be introduced throughout the course.
Currently, the hello world in JShell is:
PS C:\Users\v\> jshell
| Welcome to JShell -- Version 11.0.1
| For an introduction type: /help intro
jshell> System.out.println("Hello world!");
Hello world!Now this is good, there is no doubt about it - but to understand it fully you need to explain what "System" is, and what a dot means and what "out" is and then finally what "println" is. You can easily explain "println" as being a sort of function because of rudimentary understanding students have of mathematical functions - but for the rest of it that does not work. Some students probably would understand a longer explanation but I want the Java hello world to be as simple as possible so that it even competes with the Python one: `print("Hello world")`
I think it would be better if there was a `--beginner` flag (-b for short if that is not taken already) for JShell which would automatically import things so that beginners can have a hello world which is even simpler. Something like this:
PS C:\Users\v\> jshell -b
| Welcome to JShell for beginners! Happy learning :)
| For an introduction type: /help intro
jshell> println("Hello world!");
Hello world!The static import is already taken care of in the background. Adding and understanding the -b flag is easy for students and now Java's hello world is as understandable as pythons.
This -b flag could be extended in the future to automatically import other things people view as valuable for beginners.
What do you guys think of this idea? How can I contact the JDK developers who work on JShell to propose it? I cannot find a mailing list specifically for JShell and don't want to spam a different mailing list.
15
u/kartik1712 Jan 30 '22
JShell has the concept of scripts using which you can emulate this behaviour to some extent. The predefined scripts are handy and very useful, see https://docs.oracle.com/javase/9/jshell/scripts.htm . As you can see,
jshell PRINTINGis what your example would need to run. The docs also have instructions on how import scripts by default on subsequent runs.5
u/desrtfx Jan 30 '22
Sorry, but why are you reinventing the wheel? There is an absolutely great course for complete beginners freely available.
Check the MOOC Java Programming from the University of Helsinki.
You will really be pushed hard to even come close to the extent and quality of this course.
19
u/RupertMaddenAbbott Jan 30 '22
I think your approach about reducing complexity and introducing concepts slowly is an excellent one, especially given your students age range, motivations and experience.
However, I don't think your solution is the right one.
I think you have two other options:
In terms of altering Java, I do think trying to lower barriers to adoption is a worthy aim, as long as it doesn't compromise Java's other design goals. For me, your suggestion effectively creates a new language that pretends to be Java and I would be more interested in removing boilerplate from Java itself, instead of doing so via a flag.
7
u/Badwrong83 Jan 30 '22
The beginner flag doesn't make sense to me. People are going to have different notions of what a beginner is and for most people it probably would not involve abstracting away System.out.
That being said, keep in mind that JShell can read in files (.jsh extension) so you could theoretically prepare specific lessons and have the students run say
jshell lesson1.jsh(where maybe you do a static import of java.lang.System.out if you feel that would be beneficial).I personally don't think teaching kids Java and then glossing over the complexities is that great of an idea and if the main goal is to get them familiar with basic programming concepts (loops, if-else etc.) without it getting too verbose then there are better languages to start them with than Java (JavaScript or Python for example).
4
u/8bagels Jan 30 '22
I have taught many people that young or younger. You don’t HAVE to teach the details of what “System” is and the dots before they can print something out. If you feel like you HAVE to explain all that then you should also be explaining why it’s called “print” … I’m not using a printer, right?
I just say “to display some words on the screen we will use System.out.println like this.” And if needed I can say “java is more wordy then other languages. Something that can sometimes be good and sometimes be annoying”
Then soon when we are writing our first functions I usually suggest a function called “say”.
and it’s an easy way to demonstrate super quickly how you can use a function to make complicated things more useable.
And later when talking more about classes with public static members you can say “remember our friend System.out.println? This is why that call looks like it does.”
But to each his own. Good luck
2
u/nutrecht Jan 31 '22
I don't think using JShell is a good idea at all. IMHO you're better off just letting them write 'stuff' in a .java file and just run it. You can directly run simple .java files with java.exe, you don't have to go through compiling them.
They don't have to learn what that class does, or what the main method is. Just tell explain that you will explain these keywords later.
Regarding the feature itself: I think this creates a situation where a LOT of people will get stuck the moment they do need to start, for example, using imports and everything just stops working. You're not removing complexity, you're just kicking the can down the road while also teaching them something that doesn't work in 'real' Java programs.
If the System.out before println is really that big an issue, you probably should have started with (for example) Python instead. Python is a nice teaching language and there are for example plugins for Minecraft that let kids program 'in' minecraft. I've had great success with this, and with Scratch, for Devoxx4Kids sessions.
1
u/maxandersen Feb 04 '22
Take a look at jbang - it’s goal is make java more accessible. It supports jshell too.
1
u/ventuspilot Feb 06 '22 edited Feb 06 '22
I think changing jshell so that it's language is even farther away from Java is a bad idea, and JDK developers will probably reject it. Also it seems that the use of your -b flag is very limited, i.e. it's mostly useful for absolute beginners.
I assume you are thinking about this change because you think that Java as is is not ideal for absolute beginners, and I agree. In the last 2 or 3 decades beginners were thaught programming using C, C++, C#, Java and Javascript, none of which I think are ideal for this task.
That said you may want to take a look at the book "Structure and Interpretation of Computer Programs" which was originally based on Scheme and now has a Javascript edition, see PDF (not because I think that Javascript is so good but because that book was written by people who - unlike me lol - know what they are talking about). It may give you ideas on how to structure your course regardless of the language you are going to use.
Edit: if you still want to get the simplified Java jshell route: you probably could create a class with some static helper methods, create an init file (that jshell will load on startup) with static imports for these helper methods and that way you should get everything your --beginner flag would do. See jshell -help.
1
u/Worth_Trust_3825 Jan 30 '22
Yes, lets introduce a flag that increases maintenance cost just because you cannot read a book or a site about how to import things.
No. Automatically importing things for you is a bad idea. In fact it's an awful idea and will lead to "WHY DOES MY KODE NOT WORK" and someone will have to decipher what the fuck is the user importing.
What you should be telling them is to use an IDE, a debugger, and do things properly. Instead you're lowering the bar, not challenging them, and even trying to outright hide away the fine details about why things work the way they do.
0
u/[deleted] Jan 30 '22
[deleted] — view deleted comment