Java's Hello World Is About To Change Forever

Поделиться
HTML-код
  • Опубликовано: 27 окт 2024

Комментарии • 603

  • @CodingWithJohn
    @CodingWithJohn  Год назад +116

    There's about a 7-second part of this video that I had to re-record since I found while I was editing that I had totally flubbed a line. Thing is I had already trimmed my beard a little, so if you look closely it's definitely not a seamless transition. Let me know if you can see where it is.
    And let me know if you'd like to hear more about this kind of thing, new features in newer Java versions!

    • @whiteraven9544
      @whiteraven9544 Год назад +23

      it's 1:47

    • @aaf2011
      @aaf2011 Год назад +2

      2:06

    • @CodingWithJohn
      @CodingWithJohn  Год назад +3

      @@whiteraven9544 🏆

    • @cleitonsantoia
      @cleitonsantoia Год назад +2

      Well, sooo old school that looks like C

    • @MarkSmith-vo1vn
      @MarkSmith-vo1vn Год назад +1

      @@CodingWithJohn Can you do streams in java. And its methods like flatMap, etc. There is not too many videos on it and I think it wil be cool

  • @panic_seller
    @panic_seller Год назад +122

    Java was my first language, then I moved to C#. it's fascinating to learn that C# was inspired by Java, C# implemented the changes and now Java is learning from it's apprentice

    • @nightowl9467
      @nightowl9467 Год назад

      They are copying kotlin since they are getting replaced by it.

    • @jm.101
      @jm.101 Год назад

      As someone who is learning Java as my first strongly typed language, I don’t mind the extra words. Most ides will autocomplete is for you anyway. Just type psvm and then tab in IntelliJ and vs code. It’s also useful as a learner to see and expect the same structure everywhere.

    • @kam1234554321
      @kam1234554321 Год назад +2

      ​@@sagnaik They didn't break the compatibility, it's just a new way to define the main method. I wish they actually broken the compatibility once in few years (mark the language features as depracated, let you fix it with new implementation, test with old tests, then rewrite tests) because keeping all of these old features of the language makes it harder to maintain and making sure it works - which makes development of the language slower and more buggy. The same way you are forced to fix all the issues when upgrading to a new major version of the library, they should force people to rewrite their implementations if they want to upgrade to a newer version. Unfortunately the core feature of java is that it's compatible ~25 years back so you only need to bump the version and start mixing your 20years old implementation with a new, fancy stuff.
      I want to see the face of 80 years old company in the future supporting their code writteen 80 years ago with a code of 3 human generations. It's would be like you had to maintain COBOL code while writing Java now.
      They will die due to lack of developers working for them when they have to fix an issue that their grandpa writte 70 years ago. Even now it's hard to find someone who wants to work with Java 6/7

    • @falklumo
      @falklumo 11 месяцев назад

      @@kam1234554321Java is used for serious projects with millions loc. A world you don‘t seem to know but where Java rules.

    • @toby9999
      @toby9999 2 месяца назад

      Microsoft wanted to improve Java by adding and/or modifying features and incorporating the language into the Visual Studio suite. But they hit a legal brick wall, which ultimately led to the development of C# and .NET. Both are better than their Java counterparts in my opinion.

  • @mikes333
    @mikes333 Год назад +305

    As an experienced java programmer looking at this new main() method from the point of view of when I first started out, the first thing that comes to mind is "What took them so long???"
    However, looking at this new main() method from the point of view of an experienced java programmer my first thought would be, "Meh, I've been doing it this way for all these years, and I've got all my project templates that I've built up over time, I'll just keep doing it old school!"

    • @kaustubhkale6598
      @kaustubhkale6598 Год назад

      I choose Java over Python is it right move in 2023

    • @mikes333
      @mikes333 Год назад +12

      @@kaustubhkale6598 Personally I feel that whichever language you choose to start learning from, it's the 'basics' of understanding programming overall that's the important thing (functions, loops, conditionals, data types etc...) as you can then learn many of the other different languages as required depending on what problem you have to solve. Although Python, might be the 'new' and 'flashy' thing to learn just because it's new (and again depending on the problem being solved may be the better choice) there are still a large number of Java backend servers out there that require Java programmers to maintain.

    • @experiment0003
      @experiment0003 Год назад +5

      @@mikes333 Agreed! If you understand the fundamentals, they're all pretty much the same. I can switch to a new language in a day or two! I started with R and python for statistics and Machine learning. In my first semester of grad school, I had to learn Java... besides having to get used to classes, psvm, and types, it took me hours to make that switch. C took the longest with wrapping my head around memory allocation and pointers. Even that only took about a few weeks, and I was writing systems-level scripts in Linux. Javascript took me 10 minutes to make the switch!

    • @jan5504
      @jan5504 Год назад

      ​@@kaustubhkale6598depends but i have a news for you. There's a new comer programming language that uses the syntax of python but the performance is 10x faster than python so yeah maybe you want to know it.

    • @TimeConvolution
      @TimeConvolution Год назад

      @@jan5504if you are talking about codon, that is not going to be free for professional use, so it might not be the killer recommendation you think it is

  • @glaze4629
    @glaze4629 Год назад +256

    Java 21 is a new reason for companies to stay at Java 8 xD

    • @JW-jd6sn
      @JW-jd6sn Год назад +22

      yea, when they start using it in 20 years. Most big banks still use Java 8.

    • @glaze4629
      @glaze4629 Год назад +9

      @@JW-jd6sn I really like Java and Spring boot, but this is really sad to be honest

    • @Gandhi_Physique
      @Gandhi_Physique Год назад +16

      Why? I can't see how this is bad. As said, it will still check for the typical main method first so how is this a problem?

    • @boy_deploy
      @boy_deploy Год назад +1

      Same with IDEs also. You must have a backup of your 10 yr old IDE installer.

    • @AnthonyBerlin
      @AnthonyBerlin Год назад +5

      ​@@Gandhi_Physique My guess is something along the lines of "it isnt proper OOP".

  • @archiewood4610
    @archiewood4610 Год назад +17

    For me, as I have been using Java for years, the "unnecessary" keywords are a comfort. They make me feel reassured that the code i have written will work exactly how I intend it to. By removing these I feel it may make the code seem more ambiguous. That being said it does feel like a step in the right direction for Java as the language's complexity normally turns beginners away and this will help more people get to grips with the basics before moving on to the more complicated side - hopefully increasing Java's popularity. I also appreciate it is not a requirement to use the new layout so I can't complain. It seems overall to be a positive change for Java :)

  • @RobRoss
    @RobRoss Год назад +73

    I’m not sure this one change is going to really make Java an easier language for a beginner to learn programming with. I’m a Java developer and I think it’s a fantastic language. But when people who have never programmed before ask me if they should “learn Java”, I tell them, if you really want to become a software developer, I highly recommend you start with Python first and learn some basic programming concepts there. As far as all the boiler plate in the traditional “Hello World” Java program, I actually think it’s a great teaching opportunity. It took me a very long time as a programmer to be comfortable with not knowing things. It happens to all of us, all the time. Whether it’s a new project in an unfamiliar domain, or a new library or framework, when you are starting out with it there are many things you’re not going to understand and a few things you will. That can be frustrating and stressful. Part of being a successful developer is learning to be comfortable with not knowing everything and trusting that the knowledge will come in time. I think teaching that concept to a new developer by explaining that they can ignore all the boilerplate and it will eventually become clear later on is a vital skill for them to learn.

    • @mikeoxlongdnb
      @mikeoxlongdnb Год назад +18

      May i disagree regarding python? I observe my friend switching from python to java as a beginner. python oversiplyfies so many concepts that when people are trying to switch they are basically have to learn the same stuff again. Even if they'd prefer to stick with python, they will need to learn these more complex concepts anyway. If someone with no programming or even simple computer science knowledge wants to learn how to java i'd rather recommend to write simple procedures on some kind of BASIC or pascal just to get the understanding of simple procedures and then start to learn java. The only reason to learn python imo is when you want/need to use it.

    • @marktheunknown1829
      @marktheunknown1829 Год назад +4

      I was 9 years old when I discovered Java through Minecraft mod creating videos. After I started watching Java tutorials and even though I didn't understand anything, I liked the language. It helped to have a basic computational and object oriented thinking. Moreover, I couldn't even touch python because that is just disgusting for me. I don't say it's a bad language, it is just something I cannot get used to. I am now 19, currently taking an IT course but beside that I am working on React projects, and recently I switched to TypeScript instead of JavaScript to get back Java-like features.
      I agree with you that it is important to be comfortable with not knowing everything. It took me a while to develop this, because I was scared of the amount of stuff I don't know, but as I am learning and I look back, that hey 3 months ago I didn't even know what this stuff was, and now I am able to build these things it is awesome!

    • @Christobanistan
      @Christobanistan Год назад

      @@mikeoxlongdnb I agree. I started with BASIC, then QuickBasic, Pascal, then C++, then C#. Each one of these languages built on the last. Python is a full featured language, but it does things in a really oddball way that doesn't let you build knowledge incrementally.
      Even internally, Python is built on the very foolish and outdated idea that everything is built into the language itself instead of the libraries. This leads to multiple, inconsistent ways of doing things that are confusing and hard to learn after the first few months.

    • @matthewwheeler469
      @matthewwheeler469 Год назад

      Very well said. This was a big thing for me to come to terms with when I was learning Java. You don't have to understand everything immediately. The Hello World program is a great example of this.

  • @LuneAgent
    @LuneAgent Год назад +72

    it sure looks better, but it was such a good reminder that the main method is public and static, and that you can pass arguments as strings that you can use right in the main method, I always liked that the entire code is detailed and self-explanatory, but it will be hidden from the beginners now, making it hard for them to grasp the basics of the language functionality

    • @sanjayKumar-sx5bv
      @sanjayKumar-sx5bv Год назад +10

      At first it might seem overwhelming if you're a newbie
      But that's syntax makes allot of sense

    • @georgeshalvashvili6270
      @georgeshalvashvili6270 Год назад +8

      Your comment contains so much boilerplate

    • @_caracalla_
      @_caracalla_ Год назад +6

      quite the contrary, i think it will make much more easier for beginners to learn the language. they don't have to think about intermediate topics like functions being static or something, they will learn variables, operators etc first. this is an advantage.

    • @LuneAgent
      @LuneAgent Год назад +5

      @@_caracalla_ what if a newbie sees an error like "cannot use non-static variables in a static context" in void main() and breaks his head over why is it working like this and why main is static if it isn't even declared as static

    • @Andrew-ss7jd
      @Andrew-ss7jd Год назад +5

      ​@@LuneAgentIf they have any hope of becoming a programmer they will immediately google the issue and find out what's happening, overwise they were probably a lost cause anyways 😂

  • @duxa03
    @duxa03 Год назад +182

    Java slightly morths into Kotlin

  • @sooxpix
    @sooxpix Год назад +52

    I am a one year old java student and I like the old java way because it is precise. no ambiguity.

    • @gerdsfargen6687
      @gerdsfargen6687 Год назад +26

      Gees I tell you they're starting earlier in life now 😮

    • @vikingthedude
      @vikingthedude Год назад +4

      Damn i started when i was 2 and i thought i was ambitious

    • @KhoaNguyen96
      @KhoaNguyen96 Год назад +6

      All hail the boilerplate driven language designed for writing verbose object oriented instant legacy code.
      Repeat after me:
      public static void main string args
      public static void main string args
      public static void main string args

    • @depressedsoul7487
      @depressedsoul7487 Год назад +3

      ​@@vikingthedudenaah dude, programmers nowadays start practicing when they're still in the womb

    • @akosbalazs7208
      @akosbalazs7208 Год назад

      @@KhoaNguyen96 for (int i = 0; i

  • @tombenjamin2164
    @tombenjamin2164 Год назад +9

    As an experienced engineer, I'd still like to have the blueprint of the object defined just for the sake of clarity of how objects manifests itself in Java and it's nice to know that the devs left the class definition as an option. The pros for me is in the memory usage as this could potentially save a lot of disk space especially while I'm noticing there is a popular trend in Java's relatively new functional paradigms. I can imagine myself writing a rest API with just a few lines using the function utility package and I think that would be phenomenal. At the same I also love Java's syntax being verbal enough to justify the behavior of it's statements.

    • @FABGIO1
      @FABGIO1 Год назад +2

      I would at least preserve the class construct. It actually is the basic building block of Java

    • @conorcleary733
      @conorcleary733 Год назад

      @@FABGIO1 All of the plumbing is still there and inferred by the compiler. Its just that it can be hidden now when working on single file java programs, a concept long present in modern java. Class contruct and everything is going nowhere, it all only applies to the basic use case such as this.

  • @darksalmon
    @darksalmon Год назад +11

    This will be a big help in whiteboarding leetcode during interviews!

  • @philippetrov4881
    @philippetrov4881 Год назад +8

    This should be discussed from didactics point of view for future introductory programming classes. This is clearly a feature for learners and not for professionals. I would be happy to discuss this with other professors.

  • @phoenixflames6019
    @phoenixflames6019 Год назад +2

    4:42 to 5:44
    Golden...
    Probably unrelated, but thank you SO MUCH for explaining what "setting an environment variable" means! I've been coding for a few years now, and this was NEVER explained! Most tutorials for downloading any software just say "do this and this" and I followed them helplessly...

  • @nicoleta8964
    @nicoleta8964 Год назад +3

    Dude... Public static void main (String [] args) was the hug at the start of what could be a hell of an algorithm...

  • @rubens_cube
    @rubens_cube Год назад +34

    Oh that is really interesting. I definitely remember being overly curious about what the whole "public static void main" thing meant when first learning Java (and I specifically remember the frustration when everyone told me to just forget about it for now haha)
    I have a question though, since the main method no longer needs to be static, does that mean we can do things that we previously couldn't do? Or does it just automatically treat it as being static?

    • @Zalaniar
      @Zalaniar Год назад +2

      I was wondering the same!

    • @iCybqr
      @iCybqr Год назад +1

      Technically, it can’t be static now, since it doesn’t belong to a class, right? If there’s a class being created anyway behind the scenes that contains this main method, I’d assume the main method is statically being called since it cannot be called by the user from other files.

    • @elohimalves
      @elohimalves Год назад +14

      @@iCybqr In Kotlin you can write code without using classes, but behind the scenes if you inspect the .class files you'll see that the JVM treat the name of the file as the main class. The same will happen with Java to maintain interoperability with legacy code. So even if we don't see, behind the scenes the code will be there.

    • @iCybqr
      @iCybqr Год назад

      @@elohimalves ah, thanks for the clarification.

    • @vinterskugge907
      @vinterskugge907 Год назад +2

      It doesn't treat it as being static, what happens is that the JVM will construct an instance of the class, and then call the main method on that instance.

  • @gabucarneiro
    @gabucarneiro Год назад +12

    John, you're amazing! The way you explain Java makes it way easier. By the way, it never bothered me since VSCode always filled that line for me! 😂

  • @rodrigomarques1633
    @rodrigomarques1633 Год назад +23

    I've been a java programmer for 5 months and studying this language been 1 year. My honestly opinion is that this changes are amazing, there allow you to know better how Java works and when you don't know nothing about versions like 1.8, 11, 15, 17, 19 and 20, force you to begin with this new version to understand easily how the things work. This doesn't mean that you don't gonna need to know this things later, it's only to be more friendly when you are learning or showing Java to other people.

    • @Ewig_Luftenglanz
      @Ewig_Luftenglanz 11 месяцев назад

      ​@@sagnaikit's the propuse of a teacher to teach and not to scare students.
      Also kotlin allows this and none can say that it's a garbage language meant to write small few lines of code software.
      Being easier and less boilerplate doesn't mean less powerful, simpler sintax doesn't mean more limitations.
      Hiding things you are not using doesn't mean those things don't exist anymore.

  • @elohimalves
    @elohimalves Год назад +34

    This feature will make the interoperability with Kotlin devs easier.

  • @DerSchakal523
    @DerSchakal523 Год назад +2

    That's a good idea to provide the option to omit the class declaration because in the most cases, it's always the same: class is public, the name matches the file name, no extensions/implementations. I can only say: go ahead! 👍🏼

  • @chiter200
    @chiter200 Год назад +4

    That is what Python for, if people want to it easy, Python to go. I went from Python and now learning Java and sure, it is hard if you compare two but that is for every different language. It was a huge curve when I understood that Python is dynamically typed and Java is statically typed but then again both have ups and downs.
    Anyway I will be most likely doing it the way I learned it in the books because this does not really speed anything up as most IDE will automatically write all these for you in the .java file anyway

  • @Kiyuja
    @Kiyuja Год назад +1

    I started programming with Java 4 years ago. These days I commonly use C# as it often used in the industry. In C# there are multiple ways of declaring your main method depending on what you want and I like that. However Java still has some edges over C# in friendliness, for example in C# you dont have a wrapper class for Strings that checks for isDigit or isLetter, Java has that be part of the String class. Printing and command input loops are "easier" in Java and so is debugging. Java is a very nice beginner language and this very advantage will get stronger with the shorter main method. Tho I personally would always teach new students the full version so they get a feeling for how methods work in general

  • @juvi925
    @juvi925 Год назад +4

    Wasn't aware of these new upcoming features. thanks for the updates John! awesome content as usual.

  • @restagner99
    @restagner99 Год назад +1

    Nice!! Java is finally catching up with Groovy. The syntax you demonstrated is valid syntax for Groovy.

  • @chigozie123
    @chigozie123 Год назад +1

    It's like deja vu.
    I distinctly remember that Microsoft's version of C++ supports a void main with no args as well, and when I started coding in C++, everyone said not to use it, lol. It is nice to see it become mainstream in a non-C++ environment.

  • @WhereMyTeeth
    @WhereMyTeeth Год назад +3

    This is a great addition and glad to see Java is modernizing the language.

  • @pdlbackup
    @pdlbackup Год назад +2

    Oh wow this is really interesting, when I started out it did confuse but I don't think it made me give up straight away (I gave up later though, but then got back into it after a few years).
    Changes like these are super welcome though! I bet it'll clear up some confusion for people starting out.

  • @skyknight2011
    @skyknight2011 Год назад +2

    Huge. I loved this new feature. But I would like even more if we could also get rid of the 'System.out.[...]'. I started learning java sometime ago, but stopped when I realized I could write much less code in other languages. It felt like I spent more time typing the code than actually thinking about the program logic

  • @Yunyopern
    @Yunyopern Год назад +5

    I never learned the main method syntax by memory I always use auto complete but I think this is great.

  • @Amitkumar-dv1kk
    @Amitkumar-dv1kk Год назад

    It was overwhelming at first... But apparently over the years I've grown so much love for Java, I only ever code in it and everything else difficult to learn, c, c++, even python I didn't bother to learn... Rust is the only one that has peaked my interest in recent days, will be trying it out more.

  • @Crusader4633
    @Crusader4633 Год назад +5

    The complaints about boilerplate in Java are kind of silly, IMO - usually slung about by "fanboys" of other languages. When is the last time, as a professional programmer, you actually wrote, I mean hand-wrote boilerplate code? Yeah I'm guessing "I can't remember." Modern IDEs write all the boilerplate for us. But it is there to remind us that things are being done/defined/etc by said boilerplate - and we can change these things.

    • @new_moon1728
      @new_moon1728 Год назад +1

      we write all of this by hand in college. ALL.
      public class Test {} ... and so on.

    • @wilmarbarrick3194
      @wilmarbarrick3194 Год назад

      @@new_moon1728 go to a different college. IDEs have been doing the mundane for over 20 years now. You're better off understanding the declarations and why they're there rather than have magic code that works behind the scenes.

    • @andrewhinson4323
      @andrewhinson4323 Год назад +2

      this change isnt for experienced "professional" programmers to benefit from, directly. Its for the new programmers, or wanting-to-be programmers. That way you dont end up being the only guy out there coding, even if you tend to be more of the leading-edge, hard-charging type. You benefit indirectly by having a more ready force of "support" programmers who are.. well lets say more "cautious" learners. When boilerplate doesn't inhibit or outright prevent their growth, they gain confidence, and pick up the material better which creates a positive feedback look. Some people need that. Others, like your self I presume, operate differently. In my experience, however, they often slip into the error of assuming that things they dont find challenging are not.

  • @tonywayne29
    @tonywayne29 Год назад +2

    Good for beginners. But enterprise code wants to be more verbose. IDEs handle this anyways. Just write main and space+alt and we get a main method. Does not make a huge difference. Also there is just one mainethod in a huge application. So nothing huge.

  • @doncrandalljr1425
    @doncrandalljr1425 Год назад +1

    For many, this change may seem a good thing. The problem now is those who do the single file simple program will likely forget how a Java class is actually structured, leading to other potential learning difficulties. That said, I also believe the use of the shortened main method signature is likely the best part. For example, String arguments are rarely used for desktop apps, and the static keyword has often thrown me for a loop (no pun intended), especially when adding methods after main in the same file.

  • @thomi100
    @thomi100 Год назад +4

    I think it's good that they are making (bigger) changes. Especially for beginners this looks great. I don't think it makes a huge difference to experienced developers, especially if your'e working with IDE's like IntelliJ or Visual Studio (Code), those structures are automatically generated.

  • @armajroy
    @armajroy Год назад +1

    Hi John, love your videos. I have seen many developers used a functional approach to solve programming questions with relatively low lines of code so I also started learning functional programming in Java but it is overwhelming. So in future could you release any Java functional programming videos for better understanding?

  • @joshjackson5274
    @joshjackson5274 Год назад +2

    In the financial sector, Java 8 and spring/spring boot are used loads and it doesn’t seem to be going anywhere. Java’s lifeline for the future from my perspective is making it easier and more beneficial to switch to newer Java versions rather than these long standing Java 8 systems being migrated to another language entirely. Either way, these big systems still have little to no incentive to stop using Java 8 for the near future.

    • @prodevcafe
      @prodevcafe Год назад

      Most of fintechs I know are now using 11.

  • @SteveRowe
    @SteveRowe Год назад +2

    Personally, having everything in a class has never bothered me, and public static void main(String args[]) is muscle-memory. So yeah, I will probably never use this feature.

  • @kumar29nov
    @kumar29nov Год назад +3

    I don't like how Java has evolved following populist opinions, despite its verbosity it had a explicit structure that you can debug, now you need to know a lot of things and are implicit, and can't just reference

  • @marcom.
    @marcom. Год назад +1

    Wow. If that really makes the difference as to whether a beginner can cope with Java, then maybe he'd better look for another job.
    But I'm pretty sure that Java 21 will also have far more exciting innovations on board.

  • @anuragbisht1200
    @anuragbisht1200 9 месяцев назад

    I am new to Java and this looks really cool. Makes the learning process much easier. I am wondering what is going on behind the scenes esp. with "Everything in java is a class". Does in the compile stage , compiler automagically adds a class to the code ?

  • @nathanyao3525
    @nathanyao3525 Год назад +2

    Personally not a fan of this change. Does it imply existing programs can be refactored in some minute way to become simpler (better)? It also confuses me because it introduces non-object-oriented features into Java, which is the king of OOP. When I was first taught java with hello world, the instructor told us to focus on "main" and forget everything else because it would all make sense later, and it surely did. And it was a joy to see all these keywords come together down the road.

    • @oliver_twistor
      @oliver_twistor Год назад +1

      I agree. In fact, I wish Java were even more focused on OOP than it is. For example, I don't really care for the primitive types. That's what I like with Python, that's everything is an object. C# doesn't have primitive types, so why does Java? I know that I could use Integer, Boolean etc. instead of int and boolean, but why are there non-OOP constructs in a language that's supposed to be all about OOP?

  • @mariobisignani4477
    @mariobisignani4477 Год назад +2

    Don't really understand the big advantage... so we can save a couple of lines of code?

  • @troeteimarsch
    @troeteimarsch Год назад +11

    When I was introduced to Java I hated it so much I quit programming. Then Python got me hooked again and now I'm programming mainly in Java for a living. :)

  • @bluebon5228
    @bluebon5228 Год назад +7

    What , i just started learning it

    • @Metanabolix
      @Metanabolix Год назад +5

      you should stick to java 17 for now

    • @fredcomms_
      @fredcomms_ Год назад

      Same wth man

    • @Anathrax
      @Anathrax Год назад +3

      That's fine, larger applications will actually still use the older syntax. It's just to keep beginners from getting overwhelmed with java boilerplate code

  • @humphreychiu
    @humphreychiu Год назад +2

    As a very experienced Java dev, this is of no value to me. However I can see it being less intimidating for total newbies. But anyone serious about learning the language will soon have to understand things like static.

  • @idontknowanygoodnames1498
    @idontknowanygoodnames1498 Год назад +1

    they did the same thing for c# a while back... i still use the old method, and i feel a lot of people who already use java will probably continue to do it the old way as well

  • @goobies_channel
    @goobies_channel Год назад

    It looks so much better, I love it! Thank God they did something with that "string args"! Good video :D

  • @redcrafterlppa303
    @redcrafterlppa303 Год назад

    The problem is that most teachers and textbooks are stuck at java 8 and the new programmers will still learn the old school way. Like we still learn to write
    List l = new ArrayList();
    Even though the second Long is completely unnecessary since a long time.

    • @ioannischristou2362
      @ioannischristou2362 Год назад +1

      This is about generics, which were introduced in JDK5, not 8. Also, the second Long became unnecessary in JDK7 (if not earlier), not 8. Personally, I haven't seen any book with the example you mention; if a book had this example, I'm sure the author would put it there only for "pedantic" reasons, thinking it makes it easier for his audience to understand the statement.

    • @redcrafterlppa303
      @redcrafterlppa303 Год назад

      @@ioannischristou2362 yes, but I talk about 8 as it's the most widespread version even today (wich is terrible).
      I also said the Long was unnecessary for a long time, not since Java 8.
      Hack the reference solution in our statewide exams declare variables in functions all at the top of the function. Which was never a requirement in Java and is not a requirement anymore since I think C98.

  • @AliImtiazKhan
    @AliImtiazKhan Год назад +6

    Are there any new and exciting topics like this to run in java 17, I recently switched to records and I am a spring developer so new topics kinda excite me.

    • @CodingWithJohn
      @CodingWithJohn  Год назад +1

      I'll check out the stuff specifically in 17 and see if anything looks good!

  • @StephenSheridanOnline
    @StephenSheridanOnline Год назад +1

    Reading back through some of the other comments is interesting. I teach semester 1 Java in an imperative way first, Objects come later for me. If you teach Objects early than this change may not make much sense.

  • @Der_Yoloist
    @Der_Yoloist Год назад +1

    Not sure if I like it.. I made my OCA Course half a year ago and I know the compiler decentely well. Java hides lots of stuff that happens and makes the language unclear to beginners. My point is that this so called "easier" method hides even more and makes the language even more unclear.
    What do you think of my point?

    • @oliver_twistor
      @oliver_twistor Год назад +1

      I think you are correct. Since newbies will eventually have to create classes, public and static methods sooner or later anyway, learning something only to have to "relearn" it another way later rarely makes things easier. I'm a huge fan of learning something the proper way directly, so I don't have to remember when to use what.
      I remember in school I had trouble learning short division so I stuck with doing long division, which I thought was far easier (I was born with a memory problem, so not having to keep numbers in my head helped me tremendously). When I later was learning polynomial division, I had an easier time than my classmates that had relied on short division and never bothered learning long division, because now they had to also learn a new division algorithm on top of learning the concept of polynomial division. Why use two different algorithms instead of one that works with everything?

  • @12MrRetro
    @12MrRetro Год назад +1

    I have one question. Why?
    At that moment, when you realize all disadvantages of static methods you start using only classes, or sigltones. And those unnamed class, seems, just create hiden static class, with static method, just like in kotlin. And you, just, will be again, create classes and methods, as usual...
    If you don't whant create classes, you need to change language to rust, or some functional (as i see, in go you will need classes, to, for best practices))

  • @FrostSpike
    @FrostSpike Год назад

    I've been using Groovy, in its various incarnations, for over a decade, and you don't even have to have a main() method, it just runs wraps your code in a pseudo class and puts it into a main() method all transparently. It's very nice and I recommend it all Java programmers. Here's the Groovy version:
    println "Hello world!"

    • @inakiarias7465
      @inakiarias7465 Год назад

      Same on C#, surprised they didn't go all the way and kept the void main

  • @Fractal227
    @Fractal227 Год назад

    the thing that makes java great is the "boiler plate" as people call it, and instead of stuff being implicit it is explicit.
    it gives clarify, precision, makes errors visible and this is one of java's great strength in my opinion, while being syntatically fluid, insanely well structured and a lot of other stuff.
    I am not a fan of this at all, and cant imagine myself be using this "feature", if Java would ever enforce this on me i would ditch Java after being almost exclusive with it... 7+ years, as soon as i could.

  • @livingcodex9878
    @livingcodex9878 Год назад +2

    Imo, omitting public and static doesn't feel right since these keywords actually described what the main function is. I don't think the gain of omitting two keywords is enough to convince me that this change was necessary. I do quite like the option to omit the String[] args though. It feels natural when you don't care about the arguments.
    Having a classless function feels really out of order. In Kotlin that's fine because it's a completely different language and it can do some things differently, but having this change after so long in Java just feels weird. Also, what exactly is the benefit besides saving a total of two lines in a project? Templates exist and the main class and function are usually auto-generated by an IDE. A simple class definition takes only five seconds to write, so there isn't really a significant time difference either.
    It can be a nice gimmick for beginners, but nothing more than that imo.

  • @ThaggeydheyLaa
    @ThaggeydheyLaa Год назад

    For vs for each
    Static vs instance
    Static methods
    Multi threading
    Getters ,setters
    Please explain these concepts 🥺

  • @MetalLegacy34
    @MetalLegacy34 10 месяцев назад

    I think the real victory here is the “String[] args” being optional. When I see an argument in a method declaration, I assume that argument serves a purpose and will be used. That has never been the case for me with the String[] args argument, I don’t think I’ve ever used it. Even if the argument could still be passed in, it not being in the method declaration tells someone reading the code it won’t be used. There’s an actual practical benefit to not including the “String[] args” compared to the rest which just abstracts fundamental Java concepts

  • @ioannischristou2362
    @ioannischristou2362 Год назад +1

    if there is something in the hello-world program that I would like to see changed, that would be the "System.out.println()" statement, which is simply too long to write, and is something you need to write all the time, no matter how many years of experience you have (I have been programming in Java since 1999). True, the IDEs have their own short-cuts for writing it, but the clutter is always there, not just in the hello-world, but in all programs' source. You can try to import the method statically from System.out, but it's still an ugly import line, and you have to do it yourself in every class you write and uses it. In my opinion, it would have been much better if the search for the appropriate "main" were a search for the appropriate "println" instead.

  • @renatzkigab2616
    @renatzkigab2616 Год назад

    Well this is a very good news John its getting back near to his grandfather's (C Language) syntax setup. Nice info John and please do tutorial playlist for beginners using this new Java 21 version. Thanks for the info John.

  • @TheBitKrieger
    @TheBitKrieger Год назад +1

    I get the idea but making stuff easier just caters to having programmers who have no clue about what they are doing... if you want to learn java, then you have to understand OOP... java is OOP from start to finish, so once you learn just a tiny bit of java you will know what a class is and why the method is static - and if you are too lazy or feel it is too cumbersome to type the boilerplate: literally every text editor for coding has snippets... get up a "main" snippet and press one keycombo and you get all the text presented to you

  • @wisnu6374
    @wisnu6374 Год назад +1

    I think it's great, they make the code become short, when the first time i learn about Java it's make me confuse because the code is very long compare to Phyton

  • @kayintong
    @kayintong Год назад

    It would be great if you can explain how to run different JDK versions without deleting the path in the environment variables. For now, I have different projects with different JDK versions, I am deleting and editing the JDK path everytime for the project I am running.

  • @realtorozan
    @realtorozan Год назад +1

    Hi John, Are there any other changes coming with this new version and if you are planning to share a video of the new features?

  • @bobothecryptohobo8513
    @bobothecryptohobo8513 Год назад

    I'm split. Traditionally, I've use "main" as an icebreaker to Jr. Devs, or even kids, who don't really know OO/Java. It provides the jumping off point for access modifiers, classes, static vs instance, return types, IDE class generation/packages and the JVM all in one line/generation without having to do anything but generate a class with main in it. It also is a good point to explain what boiler plate code is and how to get around having to pound out thousands of repetitive lines, which with me etched it all into my brain as I started in 1.4. The easier and quicker things get, the more things can be misused and the underlying practices are never learned.
    I guess the ultimate question would be, if you take it all out will the new generations still understand what it does when they run across the older style. That being said, I'm all for making it cleaner, more readable, and reduce keystrokes but when IDE's already give you the option to add a main (like Eclipse) what's really the benefit other than tech debt? It seems like languages are trying to become everything they aren't the last 10 or so yrs and though it's brought amazing things to Java, it's also bred some abhorrent coding practices and abuse trying to take shortcuts. I can always use other examples to teach, but I know when I first picked Java up at my first job figuring "main" out did a lot for me personally. But that's all based off not playing with it and first look so I may change my mind once I deal with 21.

  • @andrewdecatus5172
    @andrewdecatus5172 Год назад +2

    As a python and R programmer thanks for this video. Java has always been intimidating to me because of the syntax

  • @Expung3d_
    @Expung3d_ Год назад +1

    This one small change is just a drop in the bucket, won't really make the language much more beginner friendly. However, at a glance it definitely is

  • @69k_gold
    @69k_gold Год назад +2

    If there are multiple ways to declare the main method, and we use two or more main methods in the same file, each with a different way, what would happen?

  • @libertyimobi8313
    @libertyimobi8313 Год назад +1

    Awesome content John. Its an eye opener. The Truth is lots of experience Java developer as myself will still want to stick to the old ways lolzz

    • @ndchunter5516
      @ndchunter5516 Год назад

      Eh, most frameworks abstracted most of it away already anyway

  • @simonrozendal7542
    @simonrozendal7542 Год назад

    But all of it let say the class and main method declaration is already autmaticly be done when you click in you IDE new class > "give it a name" > select generate main method? I used that always. Works the same as generate automatic getters and setters for your variables.

  • @dans.8198
    @dans.8198 Год назад +1

    Nice. Slowly getting there. In Java-99 they’ll finally realize pointers can actually be useful in a programming language.

  • @ertugrulghazi334
    @ertugrulghazi334 Год назад +2

    Java needs a functional ONLY structure. OOP should be optional. Also, please just give us a smaller print method 😭😭 and a easier way to read input.

    • @itzdm0r3
      @itzdm0r3 11 месяцев назад

      You can just type "sysout" and then tab complete the rest in most IDE's with auto complete.

    • @ertugrulghazi334
      @ertugrulghazi334 11 месяцев назад

      @itzdm0r3 Yeah, true. I don't use Java anymore, I'm just complaining from way back 😂

  • @SalivatingSteve
    @SalivatingSteve Год назад

    I think this is a good change. Simplified syntax will allow Java to better compete with other modern languages like Swift, which was designed to replace the archaic Objective-C.

  • @haltsmaul.
    @haltsmaul. Год назад +1

    I approve of those changes.
    Though i will rarely benefit from this feature nowadays, i remember feeling overwhelmed when i was confronted with a Hello World program for the first time during a lecture.
    I wonder if Java could make methods be void by default and allow you to ommit the return type (or rather the lack thereof) or if this would lead to too many bugs.

    • @oliver_twistor
      @oliver_twistor Год назад

      I hope that Java won't ever let people omit the void return type. That would be terrible, because as you say it would lead to bugs and misunderstandings. Newbies would then have to remember two ways to write methods, one way if it doesn't return anything (other than void) and another way if it does. At least in my own experience, I have had a far more difficult time learning dynamically typed languages than statically typed languages, precisely because I can never be really sure whether a function shouldn't return something or if it's just that someone forgot to add it to the signature.

  • @mericet39
    @mericet39 Год назад

    Since the main method isn't in a class any more, it is perfectly logical to remove the words 'public static' because they only make sense in classes.
    What if you have another method alongside main()? Can main() call it?
    I have mixed feelings. With the old way, you were forced to learn immediately about classes, which are the fundamental building blocks of any java application.
    With the new way, the essential lesson of classes is just deferred by a few minutes.

  • @antoniushka
    @antoniushka Год назад

    Amazing update is coming! Just now when I've started to learn Java 😅😎👍 Great video! Keep it up 💪

  • @mohsenkarimi572
    @mohsenkarimi572 Год назад

    You don't even need to compile java files separately. You can run a single file with compile the java code on the memoty

  • @appleturdpie
    @appleturdpie Год назад

    I think this is a great change for beginners. Me encountering the old hello world syntax is part of the reason, while still to this day, I do not write any Java. Along side other issues with Java; interpreted languages being annoying and heavily forcing OOP. RUclips says I'm making the 256th comment, How humorous.

  • @jabuci
    @jabuci Год назад +2

    Hello World is simpler, but compiling/running is so complicated that I will stick to the class version. Thank you, Java!

    • @Grovion
      @Grovion Год назад +1

      It won't be once it's no longer in preview

  • @SXsoft99
    @SXsoft99 Год назад

    As a person that has been prpgraming in scripting languages for 8 years and have been fiddleing with kotlin, c#, go i just cant get how peple can be so enthusiastic about Java changes especially when most java developers dont invest into upgrading versions

  • @a7mdbest15
    @a7mdbest15 8 месяцев назад

    Hey honestly, its good, specially for running small programs or trying stuff, I just remembered the old days knowing nothing of those keywords it scared me a lot😂.
    But of course once you learn all of those concepts it just makes sense what they mean and why they are there

  • @techwizpc4484
    @techwizpc4484 Год назад +1

    Now Java really needs to have a decent GUI editor like Visual Studio.

  • @TJ-hs1qm
    @TJ-hs1qm Год назад

    Of course Scala had this long before Java and C#. But for the most part it doesn't matter, the number of main methods in business shop code tends to be 0.
    ADTs with real pattern matching is much more important.

    • @ahdog8
      @ahdog8 Год назад

      This feature is not intended for business shop code though, it is mostly intended for students learning Java, and people who write smaller scripts (I don't imagine there are many people who use Java for this though, heh).

  • @dario-viva
    @dario-viva Год назад +1

    kinda cool. But why did they not get completly rid of method declaration. would have been even easier. js, python and probably a lot of other programming languages allow you to do this.

  • @siddu41
    @siddu41 Год назад +1

    @CodingWithJohn the course fee for Java is too high for Indian students. See if you can have customized pricing based on country.

  • @martinpayne2934
    @martinpayne2934 Год назад

    I wonder why they stopped at that point. If the aim was to make the entry point for an application minimal, why even require a main function? The code could just go at the top level and your hello world example would be one line.

  • @dalonsogz
    @dalonsogz Год назад

    Nice video, thanks, really interesting. I didn't know about this change.... Well, I have been coding in Java for more than 20 years and in my humble opinion, this is one step more towards an even more ambiguous coding in Java. More different ways of doing the same things writing less. The old sintaxis is there fore a reason. What is going behind the scenes really is there, and new developers will be unaware of that in the day basis. Sadly, being concise nowadays is confused with being brief. Well, I guess we expericenced programmers should not complain, and instead of that hail the new 'improvements'.

  • @marianpelmus
    @marianpelmus Год назад

    I would like to see more futures that removes the bloatware, something similar to lombok but embedded into jdk with official support

  • @Utub-qc2cz
    @Utub-qc2cz Год назад

    public static void main() is what makes Java worth of learn and work with.

  • @theidanking
    @theidanking Год назад

    Thank you for the information, but why 10 mins of video if you can summarise it to 1 min?

  • @mesonofgib
    @mesonofgib Год назад

    Why didn't they go the whole hog, do what C# did, and just allow you to write statements directly in a file without even needing the `main` method?

  • @stefumies
    @stefumies 5 месяцев назад

    The Graal and Oracle JVM 22 compilers still complain this is a preview feature, so even with 22 this has to be set as a preview feature

  • @user-tk2jy8xr8b
    @user-tk2jy8xr8b Год назад

    Looks somewhat similar to the top-level statements appeared in C# a year ago. The only difference is in C# you don't even need a function, just write your code into the file, like one would do in Python. The features like that are useful only for some small script-like or PoC programs. From the high-level design perspective such syntactic sugar is just an unnecessary overcomplication of the language spec

  • @raylopez99
    @raylopez99 Год назад +1

    Didn't they do the same thing in C# console mode? I think a few years ago they did and sure enough I see there's a new convention for C#.

  • @DoFliesCallUsWalks
    @DoFliesCallUsWalks 7 месяцев назад +1

    OMG Isaac's binding.

  • @_caracalla_
    @_caracalla_ Год назад

    these changes will make java much more simpler to learn. amazing!

  • @atlgansahinulasan4031
    @atlgansahinulasan4031 Год назад

    Hi!
    Thanks for this amazing video. The new version makes me think of the usage of interfaces and abstract classes as well as the extension and implementation features. If you could tell us about these features, I would be grateful :)

  • @kushalshukla12
    @kushalshukla12 Год назад +1

    Is there a way to decompile this Java class? To see if the compiler is adding the class and other attributes during compilation? How does it actually internally work

    • @r6playaray
      @r6playaray Год назад +1

      Intellij can show you "decompiled" java class files. I believe that is the default behavior if you try to "open" a class file with that IDE.

  • @EdwinRebolledo
    @EdwinRebolledo Год назад

    Hey @CodingWithJohn could you please talk about Garbage collector and how works, thanks for your videos!

  • @StephenSheridanOnline
    @StephenSheridanOnline Год назад +1

    That is a welcome development from a semester 1 teaching perspective. I would have liked to see them go a step further with System.out....... I guess that could be cleaned up even further with a static import.
    import static java.lang.System.out;
    void main(){
    out.println("Hello World!");
    }

  • @micleh
    @micleh Год назад +1

    I'm not certain yet whether getting rid of the boilerplate will be beneficial or detrimental to my students in Years 10 to 13 (age 16-18/19). IntelliJ does so much of the heavy lifting. I don't see my students struggling with instantiating a class and writing a main method. Understanding the concept of classes and the main method will be essential later on, and Java 21 takes a crucial concept of object-oriented programming away from my students.

  • @endermwatts
    @endermwatts Год назад +1

    Is this really that big of a change. First how often do you actually have to actually write that initial bit of code? Most every IDE will auto generate it when you first create a new project. And as far as it being a lot of concepts it’s a good place to start explaining what some of those concepts and ideas are.
    I don’t see this alone as really being that big of a deal.