We can't find the internet
Attempting to reconnect
Something went wrong!
Attempting to reconnect
Analysis Summary
Worth Noting
Positive elements
- This video provides a practical demonstration of how JEP 445/512 (Flexible Main Methods) and JShell can be used to simplify the Java learning curve for absolute beginners.
Be Aware
Cautionary elements
- The presenter frames a pedagogical preference (bottom-up vs. top-down) as a logical necessity rather than one of several valid teaching philosophies.
Influence Dimensions
How are these scored?About this analysis
Knowing about these techniques makes them visible, not powerless. The ones that work best on you are the ones that match beliefs you already hold.
This analysis is a tool for your own thinking — what you do with it is up to you.
Related content covering similar topics.
Transcript
Since Java 25, hello world has become much more approachable to beginners. In particular, they are no longer confronted with keywords that simply don't make sense at that stage. But I think that doesn't go far enough. For example, void doesn't really make sense without a type system. And void is a very special type and main doesn't really make sense if you don't know functions. And main is a very special function. So why don't we start with statements? Why can't we just execute this one line and get hello world? Or going even further, why isn't hello world itself something that makes sense and can be evaluated and then we see the result of hello world is hello world of type string. Yeah. So the idea is start with expressions, work your way up to statements, then functions and then classes. What can we do as with expressions? For example, we can see the math that we know from school also works on computers, right? Computers can compute these math formulas and the result is a whole number. Then we can see that multiplication takes precedence over addition. And if you don't want that, you can use parenthesis just like you would expect. Okay. Then if you add very large numbers, the result can overflow into negative numbers. Why is that the case? there is a maximum value of int and if you add one to that then you get a negative value. So the integers are not even a straight line from minimum to maximum but um they form a circle if you will. Are there other uh things that start with m in integer? Yeah, there's also min value. You could also use that directly. Okay. Then if you divide 9 by two, maybe unexpectedly you get four because we are still in the int realm. The rest of the division would be one. But if you want a number like 4.5, you can't use int. You have to use double. Double comes with its own surprises. So 0.1 and 0.2 is not exactly 0.3. Why is that the case? Because computers don't really like dividing by 10. behind the decimal point. You can see 0.1 is almost 0.1 but not quite. But for example, 0.5 is exactly 0.5 because computers love dividing by two. Okay? So instead of adding 0.1 and 0.2, you're much better off adding 10 cents and 20 cents. Right? Then there are mathematical constants like a math pi um which are quite useful in math examples. You also have functions you put in an argument and you get a result. That's a quite useful concept in general and you can use or form formulate arbitrary complex expressions. For example here for the golden ratio we would like to compute phi. Okay. So this function takes one argument. This function takes two arguments. If you're an audio nerd, you can probably guess what I'm trying to compute here. I leave that up as an exercise for you. And then you would use much more uh of these expressions. Um, of course, right? There are also functions that take zero arguments and every time you call them, they give you a different result. That would be our first contact with side effects. This you could use this for tossing coins for example. So if the number between zero and one uh is smaller than 0.5 uh you get true and in other times you would get false right and if you want literally want let's say heads or tails then you can use the conditional operator for that. And that would be our first contact with strings also. Cool. Now at some point we want to move on to statements. What can we do with statements? Of course we want to introduce variables and then we can use this for example to compute the collards number sequence. Right? That's a very interesting sequence that spans over very many integer numbers if you start with the number 27. Okay. Or we could compute Fibonacci numbers. So start with two values zero and one and then compute uh the next two neighbors then the next two neighbors then the next two neighbors and so on. And then you should see the Fibonacci sequence emerging. And this is a point where we would say well it's probably better to have a loop. Maybe we want to execute this a 100 times or something. And maybe we want to execute this until x reaches one. while loops and for loops that would be quite useful. We can also implement a guessing game just with statements. So let's guess or make a random number then we guess the number is 50 and then the computer tells us that 50 is too big. So then we would reassign it to let's say 25. Execute that and let's see that number is um still too big. let's say 12 that's too small and so on right and of course here you also wouldn't want to manually switch between those lines that would be a good idea to use loops and then of course stuff like print line and read line then we would go on to functions um so we know functions from math right I would I would start writing functions like in math so everybody understands line 87 square of x is x squ not everybody is familiar with this type notation from math. So we map from the real numbered numbers to the real numbers and we simply have a different notation for these two lines in programming which looks like this. And you could then talk about that in detail. Okay. And then we would call this function. The square of three is nine. The square of four is 16. And you can of course combine those results. Right. So I think it's very important uh to understand that return doesn't print to the terminal but instead it gives us a value and then we can uh uh compute further with the returned value. Many beginners are extremely confused between the difference uh return versus print line, right? And it can get arbitrarily complex of course. And then you would say, "Dear student, uh here's a function. Here's a math expression that computes the distance from the origin to 3 4. Why don't you make this a function where you can choose the x and the ycoordinate?" Right? And then we would make lots of more functions until students understands what functions are. Okay. And I think then you can talk about the very special main function. You can talk about the void data type um and so on. So this tool uh that I wrote uses the JShell API. You may be familiar with the JShell tool itself, but it also has an API which you can call from Java. It's about 300 lines of codes, not counting blank lines, and you can do it in a weekend. So, this this is not an advertisement of my own little tool here. I would expect that in the last 8 years since the JS APA existed, dozens, if not hundreds of tools like this have been developed by teachers, maybe in private or maybe open source, I don't know. But I think it's worth discussing. Should we start with classes and then work our way down or should we start with expressions and then work our way up? And since I'm very fond of ripples and functional programming languages like Closure, of course, I love to start with the expressions and then work myself up.
Video description
https://docs.oracle.com/en/java/javase/25/docs/api/jdk.jshell/jdk/jshell/package-summary.html 0:00 Intro 0:50 Expressions 4:00 Statements 5:39 Functions 7:02 Outro Java 25 public static void main JEP 512