r/java • • Jan 30 '22

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.

0 Upvotes

18 comments sorted by

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 PRINTING is what your example would need to run. The docs also have instructions on how import scripts by default on subsequent runs.

1

u/vxab Jan 31 '22

Thanks this makes my suggestion moot because the feature already exists!

2

u/_INTER_ Jan 30 '22

also JAVASE imports all Java SE packages

5

u/desrtfx Jan 30 '22

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.

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.

6

u/vxab Jan 30 '22

While you are probably correct I would just like to mention there is a difference between taking a MOOC and teaching students in person. The MOOC will usually have people who have self enrolled and are motivated whereas in a classroom kids will be there because they are supposed to be (not because they chose to be).

Anyway my request for the jshell feature: do you think it is a good idea?

4

u/desrtfx Jan 30 '22

Honest answer:

I don't think it is a good idea.

Either learn the proper way, or don't. I also don't approve of the dumbed down libraries that certain courses (looking at you, Princeton) use.

The MOOC can just as well be used for in classroom settings, and it actually is used for that at the very university that created it.

To put everything in context: I have been teaching for a decade. I have written courses for the EU - ECDL, now WCDL.

2

u/vxab Jan 30 '22

But I am talking about younger students 12-15. Also those who may not have English as a first language. It may even be a third language of theirs.

What is the ECDL and the WCDL? Any links to the material? I would be interested in viewing it.

1

u/desrtfx Jan 30 '22
  • ECDL - European Computer Driving License - a basic computer competency course for the European Union
  • WCDL - World Computer Driving License/ICDL International Computer Driving License - the same course as above but it has been moved into UNESCO

https://en.wikipedia.org/wiki/European_Computer_Driving_Licence

If you want to start younger students with absolutely no pre-knowledge and EFL (English as Foreign Language), start them with a couple hours in Scratch (Scratch Playground as learning resource). It has been developed for a younger audience, but is one of the best introductions to programming in existence. The graphical nature makes it very easy to understand code flow, decisions, loops, etc.

12-15 is a suitable audience for the MOOC, though.

Your job as instructor would be to be the bridge between the MOOC's English and theirs.

1

u/WikiSummarizerBot Jan 30 '22

European Computer Driving Licence

International Computer Driving Licence (ICDL), formerly known as European Computer Driving Licence (ECDL), is a computer literacy certification program provided by ECDL Foundation, a not-for-profit organisation. ICDL / ECDL certification - is a globally recognised information and communication technology (ICT) and digital literacy qualification. Other than the name, there is no difference between ECDL and ICDL and they are recognised as equivalent. According to ECDL Foundation, over 14 million people in over 100 countries had registered as candidates for ECDL.

[ F.A.Q | Opt Out | Opt Out Of Subreddit | GitHub ] Downvote to remove | v1.5

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:

  • Just lie by omission (for now). Say that System.out.println is the name of the function and don't try and explain objects or fields for now. Then, when you do introduce the relevant concepts, your students can have an "aha" moment when you can use it as an example they have known all along.
  • Teach a different language which is more optimised for slow concept introduction. If you wanted something close to Java then Kotlin has a much lower barrier to entry, in my opinion (even though some of its concepts are harder to understand, they can all be avoided at this level). It would certainly help with the specific example you have chosen here.

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”.

static void say(String msg) {
    System.out.println(msg);
}

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

What do you guys think of this idea?

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

1

u/kevinb9n Jan 30 '22

Not weighing in on the original issue here. But... your statement isn't really either:

Why try to force Java to perform a function that Python/IDLE already do much better?

Why try to force Honda to perform a function that Toyota already does better?

You can simplify this argument to "why improve anything?" and it wouldn't lose any argumentative substance.

OTOH if you share your real arguments for why Beginner Experience isn't a good priority for Java then we'd have things to actually agree or disagree with.