Java is slow and verbose (or so they say)

Поделиться
HTML-код
  • Опубликовано: 5 мар 2024
  • In this tutorial we will take a look at the misguided claims that Java is slow and verbose.
    🔗Resources & Links mentioned in this video:
    GitHub Repo: github.com/danvega/java-verbo...
    👋🏻Connect with me:
    Website: www.danvega.dev
    Twitter: / therealdanvega
    Github: github.com/danvega
    LinkedIn: / danvega
    Newsletter: www.danvega.dev/newsletter
    SUBSCRIBE TO MY CHANNEL: bit.ly/2re4GH0 ❤️
  • НаукаНаука

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

  • @oskar9136
    @oskar9136 3 месяца назад +18

    In my opinion the verbosity of Java makes it more understandable, at least in the beginning when you are learning Java.
    Sure writing out getters and setters and constructors may be a lot of code.
    But seeing that getUsername is just a method that returns a field from the class and doesn't take a parameter (unless you want it to) made it so I could see patterns and understand the syntax better.
    When you improve and understand the language even further then I think you can take shortcuts. It's always a trade off of course. That's just my two cents.

    • @jazzycoder
      @jazzycoder 3 месяца назад +1

      And no one actually writes getter and setters ... just generate them with the IDE 😁

    • @GreatTaiwan
      @GreatTaiwan 3 месяца назад +1

      @@jazzycoder lombok or not even those spring got it in the framework

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

      @@GreatTaiwan you can add lombark manually though

    • @lufenmartofilia5804
      @lufenmartofilia5804 2 месяца назад +1

      Who uses lombok and type getters and setters in 2024... any ide can generate them for you in a single click or shortcut. At least intellij, vscode, eclipse can.

  • @zombi1034
    @zombi1034 3 месяца назад +5

    Java is by far my favorite language. I just love how many things you can do with Java, be it writing a web service or a desktop app and it is even cross platform thanks to the incredible JVM. Also the vast amount of great frameworks and tools that we have at our disposal really helps a lot in building good and reliable software.

  • @asdrubalzp
    @asdrubalzp 3 месяца назад +3

    Great demo Dan! Greetings from Ecuador

  • @NetImperia
    @NetImperia 3 месяца назад +9

    From my experience. Projects where Java was slow. There were errors in the architecture. And choosing the wrong libraries. In almost all such projects, there were a lot of abstractions and widespread use of Hibernate where it was not needed...
    Java itself is very fast. But different libraries slow it down very much.

  • @fredericolivier7896
    @fredericolivier7896 3 месяца назад +25

    I still prefer writing the types I never use var.

    • @HandledToaster2
      @HandledToaster2 3 месяца назад +6

      Same, but I like using it in unit tests to keep things simpler.

    • @railroadman2k
      @railroadman2k 3 месяца назад

      Well look if it obvious type not generic just simple type why not use ir

    • @deeplife9654
      @deeplife9654 3 месяца назад +3

      Me too , why we need to make everything super easy ? 😢. Modern java is cool and enough

    • @illyam689
      @illyam689 3 месяца назад +1

      Also, var can be dangerous

    • @user-qm2uo6ht5l
      @user-qm2uo6ht5l 3 месяца назад

      @@illyam689it can never be dangerous

  • @jazzycoder
    @jazzycoder 3 месяца назад

    I love this video! Someone has needed to make this video for a long while and you are the man to get the business done... thank you!

  • @lifeisgoodoutdoors2680
    @lifeisgoodoutdoors2680 Месяц назад +1

    New to Java here. Excited! What flavor of Java are people using? Amazon Correto? Microsoft build of Java?

  • @RondellKB
    @RondellKB 3 месяца назад +3

    I was going to post this before watching the video, but you said it while I was posting lol.
    The only people who say Java is verbose are people who: 1. Have not touched or followed the language in years. Or 2. Have never or barely used the language but read regurgitated nonsense online and then decide they hate the language.

    • @Noam-Bahar
      @Noam-Bahar 3 месяца назад +1

      So far I've only encountered Java and C# when I learned programming and computer science. In hindsight they were both the best languages for me as a beginner. Both high level languages like JS and Python, and low level langs like C, are too confusing for beginners like me.

    • @RondellKB
      @RondellKB 3 месяца назад +1

      @@Noam-BaharThe thing about languauges like Python is you can learn it fast, but it hides a lot of stuff, whereas C forces you to do everything on your own. I think languages like Java and C# are the sweet spot.

    • @illyam689
      @illyam689 3 месяца назад +1

      These individuals are also known for composing nonsensical one-liners in Scala and labeling them as 'clean code'.

    • @RondellKB
      @RondellKB 3 месяца назад +1

      @@illyam689This is exactly the sort of thing I'm talking about. Concise != more readable.

  • @KangoV
    @KangoV 19 дней назад

    Records can also be declared inside a method

  • @haroldpepete
    @haroldpepete 3 месяца назад +3

    i think java is a modest language, meanwhile spring is a great framework, one of the most used it out there, java lives thank to spring, that's all

    • @sylvereleipertz955
      @sylvereleipertz955 3 месяца назад +1

      That's the same for every language. You don't do pure javascript or php either

    • @GafarOlanipekun
      @GafarOlanipekun 3 месяца назад

      I understand you, because it is difficult for you to understand Java right? Java is still best programming language out there. Any langugage you know i can start writing it professionally in 5hours can you say that to Java

    • @haroldpepete
      @haroldpepete 3 месяца назад

      @@GafarOlanipekun i have worked like a spring developer, java is easy to understand, for your information, i know a lot un languages including front and back, i love rails, ruby, .net, .net core and nodejs. i think the best is rails, monster language, you can do amazing things

  • @juancarlospizarromendez3954
    @juancarlospizarromendez3954 3 месяца назад

    About setters and getters, Groovy has the magic of that they are implicit, and to specify explicitly then when are needed. And for Java, it seems no good having a boiler plate of same setters and getters for each class in the system.

  • @bbbbshoow6702
    @bbbbshoow6702 3 месяца назад

    hello Mr Dan , great tutorial , i was wondering if you could make a video about java specification and implantation , specially the compatibility part with tomcat , i struggle a lot in every project to figure our how to choose the correcte set of dependencies that will be compatible with my server , and thanks in advance 😍😍

    • @illyam689
      @illyam689 3 месяца назад

      WTF just use Spring Boot with embedded Tomcat, it's not 2007 anymore

    • @bbbbshoow6702
      @bbbbshoow6702 3 месяца назад

      @@illyam689 hello , i am just trying to learn thing far more from they abstraction of frameworks . Thanks for the advice i will go to spring after that

    • @illyam689
      @illyam689 3 месяца назад

      ​@@bbbbshoow6702my suggestion is to keep things simple and focus on the most important ones. If you want to have something up and running quickly, just use Spring Boot

  • @melmartinez7002
    @melmartinez7002 3 месяца назад

    Modern Java, given all the syntactical sugar they've added since around JDK16, can be pretty concise - yet still retains Java's signature clarity and determinism.

  • @punekarinwinnipeg214
    @punekarinwinnipeg214 3 месяца назад

    How are you displaying the shortcut content in intellij? What is the plugin name ?

    • @RomanTchekashov
      @RomanTchekashov 3 месяца назад

      He has GitHub copilot but you have to be accepted by jetbrains;( Alternatives: Codeium + CodiumAI plugins

    • @DanVega
      @DanVega  3 месяца назад +1

      This is built into the iDE now. appearance and behavior > presentation assistant

  • @stephaneislistening6103
    @stephaneislistening6103 14 дней назад

    Dan rules !

  • @ellkana
    @ellkana 3 месяца назад +1

    Imo, java 21 is the best of all and matured enough. but the number surely scared the students to start fresh. what happens in the next 20 years ? java 40 ? perhaps can be rename to something fresh like jakarta instead. idk.

  • @richardbenes9
    @richardbenes9 3 месяца назад

    Nice video. But I miss comparison with Java's competitors.
    Why would Java's conciseness matter if there was yet better option?
    I feel like most of the "oh why do I have to type it all" feelings originate, in my case, from error handling. I like to have only the "happy path" in the "main code", and all the error handling stuff in background. Algebraic data types and the "?" operator, that are available in Rust (not that Rust would be perfect), feel to me like a huge helpers in this regard.
    And records are a nice addition. However, I do still prefer Lombok. It seems more customizable.. But a real, thorough comparison would be useful.

    • @sylvain-k
      @sylvain-k 19 дней назад

      At least Lombok allows to get : mutable class with fluent chained setters (or immutable with @Value and convenient @Builder(toBuilder = true) if needed), extendable class.
      Record blocks all of these (cannot inherit and cannot be inherited, manual construction if need to create a new object from an existing one and with some values changed)

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

    I tried many languages and developed tools in most of them. To be honest, understanding java code is faster for me than other less verbose languages. But it is just my point of view..

  • @juancarlospizarromendez3954
    @juancarlospizarromendez3954 3 месяца назад

    Dan Vega, HashSet internally uses HashMap to store it's elements instead of its own similar implementation. Due to it,Java it is not being optimized.

  • @DamLee88
    @DamLee88 3 месяца назад

    they're probably TypeScript or React developer or other fancy framework

  • @avalagum7957
    @avalagum7957 3 месяца назад +1

    Verbosity is like beauty: it's in the eyes of the beholder. For example, Dan Vega is handsome in his wife's eyes. In Miss Universe's eyes, he's... at the same level with me 😜

  • @ichigo_kurosaaki
    @ichigo_kurosaaki 3 месяца назад +1

    I feel at the end of the day, Java is just a tool, it's the programmers who can't use it properly or are too stuck up with their opinionated mindset that say nonsense like "Java is Bad".

  • @adambickford8720
    @adambickford8720 3 месяца назад

    Records cover such a small surface area in use cases to be a non-factor for me. In real code I want named args, not positional ones. Without lombok you're looking at 90s levels of boilerplate to create a fluent builder. And at the end you still have the 'builder()' and 'build()' cruft.
    Take a record with 10 properties and then 'change' one. We're once again back to 1900s boilerplate with error prone positional arguments as we're still lacking a simple with/copy function.
    We're getting there, but it's way too early to declare victory. And the other languages aren't sitting still.

  • @carlosabreu5012
    @carlosabreu5012 3 месяца назад +2

    lombok

  • @coderlady_
    @coderlady_ 3 месяца назад +1

    whenever I say that I'm using java, most devs laugh at me, one just said: I would rather use kobol but never use java, java is for caveman!

    • @avalagum7957
      @avalagum7957 3 месяца назад +1

      What are those devs using? If they're not using a JVM language, does their languages have something like Java virtual threads?

    • @coderlady_
      @coderlady_ 3 месяца назад

      @@avalagum7957 mostly use javascript

  • @jeevaathecoder
    @jeevaathecoder 3 месяца назад

    Why Everyone uses python for AI/ML?

    • @adambickford8720
      @adambickford8720 3 месяца назад

      Thats generally researchers, not programmers. They are doing a lot more iterative/exploratory 1-off kind of stuff. Languages like java bring too much 'accidental complexity' to that domain.

    • @masterofIich
      @masterofIich 3 месяца назад

      Mostly because is not static typed and easy to wrap c code which all of the ML source code is written in anyway.

  • @birandkoray
    @birandkoray 3 месяца назад +3

    if it were slow and verbose, would 3 billion devices run Java? :D

    • @DanVega
      @DanVega  3 месяца назад

      Exactly!

    • @Skiamakhos
      @Skiamakhos 3 месяца назад

      Actually, yeah, because when Java started in the 1990s it was the only language that would run on anything that had a JVM. That was a huge advantage. C projects had to be compiled specifically for the target machine. Assembly language had a different dialect for different chips, and you'd need device drivers for anything outside the CPU. Where Java was historically slow was at start-up but if your machine is a web server or a vending machine or a helicopter it doesn't matter much if it takes 3 seconds to start the program: as long as it processes data correctly and swiftly once it has started, which it mostly did. Verbosity is very much a secondary problem: when your IDE has shortcuts for everything you learn the shortcuts, like sout for System.out.println() etc, and we've been using Lombok for years now to do what Dan just did with records. Lombok allows you to control whether you're using setters or a builder, and you can override the annotations for debugging purposes if need be, or if you need to incorporate rules in setters etc.
      Sure, Java was slow to start and verbose, but it was available on everything very quickly, and its verbosity often meant it was very readable. Bob Martin's "Clean Code" often sacrifices succinctness for readability. We're encouraged to use long, meaningful class, method & variable names such that comments aren't needed. We use descriptive commit messages that link to well written JIRA tickets too, so the question "What the hell was [long departed developer] thinking?" is usually 2 or 3 clicks away. Compare with Perl, which was easy as pie to write but looked like line noise when you came back to it in 6 months.

    • @GafarOlanipekun
      @GafarOlanipekun 3 месяца назад

      speak of secuirty, multiprocessing, and standard memory and error management talked about Java. As someone who has used Java, kotlin and javasscript and typescript I can tell you Java is far better than them all. You can't use Javascript built backend service in a bank and be confident that big issue will not happen. infact no one will allow you, use another language except java

  • @harisahmad7871
    @harisahmad7871 3 месяца назад +2

    Stop living in denial, Java is verbose and it has its own advantages and disadvantages

    • @GafarOlanipekun
      @GafarOlanipekun 3 месяца назад

      you like it or not you know java you already know all the programming language in proxy . whenever you are interested in other language as java developer. it will only take you few weeks to master. knowing other language first you will still find it difficult to understand java

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

    i have done a step by step replay: at 05:48 I get a "java.lang.ClassNotFoundException: Application" and also there is no "target" dir. A "Build Project" also not generated the output dir. I need to do a "maven: recompile" to get the dir. Code changes are not visible when I rerun. I fixed it with manualy adding to the Run Configuration: "Modify options / Before Launch / Add before launch Task" and then "Before Launch / Run Maven Goal: Compile"

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

      I am somehow confused why I need to add this manually (IntelliJ IDEA 2024.1 Beta (Ultimate Edition) Build #IU-241.14494.17, built on March 6, 2024)

  • @binio28
    @binio28 3 месяца назад +1

    Its too verbose... I hear this through whole my professional life

  • @user-qm2uo6ht5l
    @user-qm2uo6ht5l 3 месяца назад

    spring boot is slow though takes 1 min to start …

  • @quocdattranquoc1832
    @quocdattranquoc1832 3 месяца назад +1

    Haha, @Lombok make Java not verbose

  • @smidimir
    @smidimir 3 месяца назад

    Thanks, kotlin and other modern languages, for giving java homework to copy from. Java might be even half way there

  • @scrumtuous
    @scrumtuous 2 месяца назад +1

    My two cents? Java isn't verbose enough!

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

      You can write verbose code in any language. Thanks for coming to my TedTalk Darcy 👋🏻

  • @pablovaldes6022
    @pablovaldes6022 3 месяца назад

    In 2024 a language that doesn't warn you or stop you from accessing a possible null value, should just not be considered for a serious project.

    • @sylvereleipertz955
      @sylvereleipertz955 3 месяца назад +1

      Java, javascript, php, c, c++ but ok. The entire world is running on language that do permit it

    • @pablovaldes6022
      @pablovaldes6022 3 месяца назад

      Time to change that

  • @MichalGebauer
    @MichalGebauer 3 месяца назад

    I use java (and love it), javascript and groovy and I do agree java is very verbose. The new features you mentioned partially mitigate some verbosity but I still see no significant difference. As an example, I use Lombok and therefore records don't have effect on amount of my code. The most significant difference for me is visible in data driven development. What I miss in Java is something like object literal that is present in javascript and partially in groovy. I love your channel but I do not agree persuading developers (with real experience) that java isn't verbose is the way to go. We should rather accept reality and aim for future improvements.

  • @ITksh-zp1ob
    @ITksh-zp1ob 3 месяца назад

    slow.... compare with what ? JS ? x10 faster, python x10 faster.
    verbose - plain sources or bytecode? if sources, what so?

  • @vijayjangid8967
    @vijayjangid8967 8 дней назад

    I earn 60 thousand monthly but I don't wear Zudio 😂

  • @peshutanpavri1599
    @peshutanpavri1599 3 месяца назад

    Java is not verbose, It's actually even less verbose than Kotlin in many aspects if understood properly there are just lots of really bad code with awful 5 word classes, I am working on a new framework server side, I am trying to address this

  • @deeplife9654
    @deeplife9654 3 месяца назад +1

    If you thinks that Java is hard , then do not be a backend coder. go to code frontend. I am too much pissed off people making fun of my Java.

    • @sylvereleipertz955
      @sylvereleipertz955 3 месяца назад

      Grow up then

    • @deeplife9654
      @deeplife9654 3 месяца назад

      @@sylvereleipertz955 Java is the reason that I code. lolz. so, thanks you. Java is hard at beginning but becomes most beautiful later

    • @deeplife9654
      @deeplife9654 3 месяца назад

      @@sylvereleipertz955 you grow up

  • @Lutz64
    @Lutz64 3 месяца назад +1

    Java becomes awful when annotations are used. anytime java in used for anything, thousands of lines of code and many 10s of objects are created for the sake of OO for something that doesn't do much. the only good thing about java is the ecosystem. C# is mildly better as a language except everything in the MS ecosystem is broken. A 10K lines of java can be rewritten into several hundred lines of go code (which is also very short lines)

    • @avalagum7957
      @avalagum7957 3 месяца назад

      Then Scala is the winner 🙂

    • @JamesStansell
      @JamesStansell 3 месяца назад

      2 orders of magnitude difference in line count - seems nutty

    • @Lutz64
      @Lutz64 3 месяца назад +1

      @@JamesStansell go does not have objects, it only has structs from C. It is basically C with conveniences and garbage collection.

    • @GafarOlanipekun
      @GafarOlanipekun 3 месяца назад +2

      then you don't know Java. use of the langugae only depend on the person not the language

    • @avalagum7957
      @avalagum7957 3 месяца назад

      @@GafarOlanipekundefine "know"

  • @haroldpepete
    @haroldpepete 3 месяца назад

    your billion is 1.000 millions, for rest of the world a billion is 1.000.000 of millions

  • @kelvinnjuguna349
    @kelvinnjuguna349 3 месяца назад

    Tbh, the only reason I don't use Java (& c#) as much is because the length of `System.out.println` traumatized me in college. Every other language just says `print`. Also OOP just isn't beginner friendly. Java makes students dislike it from the start since students just want to build without focusing too much on architecture. Sure, Java 21 addresses some of the non-beginner friendly parts of Java. But people know that the companies that use Java don't have Java 21 unfortunately

    • @DanVega
      @DanVega  3 месяца назад +2

      I can't remember the last time i actually had to type that out. In IntelliJ i type out sout-> which turns into that or there is also a postfix completion for it. Seems like a silly reason not to use a language.

    • @kelvinnjuguna349
      @kelvinnjuguna349 3 месяца назад

      @@DanVega You can choose to call it silly but those points are why many CS students leaving college don't like the language. Luckily, Java is addressing them after realizing that Kotlin is slowly chipping away at Java work in the back end of many companies

    • @sylvereleipertz955
      @sylvereleipertz955 3 месяца назад

      Any IDE will write it for you. Or you could just create another static method to encapsulate the original one. Out.print() for exemple. You're welcome

    • @khmarbaise
      @khmarbaise 3 месяца назад

      Functional programming has been introduced with JDK 8 (2014!! a decade ago en.wikipedia.org/wiki/Java_version_history)... And the real question is: How often have you written "public static void main(..)" in a real project (I simply don't know it anymore).. (also the hint by @DanVega your IDE) ? and in the meantime many companies have changed to JDK11 or even JDK17... a few to JDK21.. yes of course it takes time... (while at 19.03.2024 JDK22 will released; The pressure increased)..
      The cause for disliked might be also based on the teacher or ways of teaching many students have reported that..