• lurklurk@lemmy.world
    link
    fedilink
    arrow-up
    5
    ·
    60 minutes ago

    Hello World

    30 minutes of boilerplate

    writing imports

    $ cat <<EOF > Hello.java
    public class Hello {
      public static void main(String args[]) {
        System.out.println("Hello world!");
      }
    }
    EOF
    $ java Hello.java
    Hello world!
    

    ok

    • MooseTheDog@lemmy.world
      link
      fedilink
      arrow-up
      2
      ·
      40 minutes ago

      Welcome to java, we have a couple unconventional ways of doing things, but overall I’m like every other mainstream oo language.

      People: AHH! Scary!

      Welcome to python. your knowledge of me wont help you elsewhere as my syntax is purposefully obtuse and unique. Forget about semicolons, one missed space and your code is as worthless as you after learning this language.

      People: Hello based department

      • lurklurk@lemmy.world
        link
        fedilink
        arrow-up
        1
        ·
        35 minutes ago

        Python has its drawbacks but it also has a pretty useful standard library so as a language for small scripts, one can do much worse

  • Zement@feddit.nl
    link
    fedilink
    arrow-up
    5
    arrow-down
    1
    ·
    1 hour ago

    I really enjoyed the text.

    From the perspective of a python programmer it all seems valid.

    A Java-Dev would probably write the same about an embedded engineer.

    • MooseTheDog@lemmy.world
      link
      fedilink
      arrow-up
      1
      ·
      35 minutes ago

      Sorry, you had a small error in the spacings of your post; Therefore I cannot parse a thing you’re saying. Didn’t mean to scare you with a semicolon either. It’s just a tool in language’s to end a clause and begin a related, independent clause. That could be useful somewhere…

  • MooseTheDog@lemmy.world
    link
    fedilink
    arrow-up
    1
    ·
    44 minutes ago

    I’ll never get the hate for java and love for python. It’s like learning mandarin because you think it’s easier than Spanish. When you know java you also kinda know javascript, C, Php, and others. When you know python, it’s probably a government sponsored course, or a programming class talked your school district into buying their “intro to programming python course”. Plus you only get to know python. I’ll die on this hill

  • lennivelkant@discuss.tchncs.de
    link
    fedilink
    arrow-up
    6
    arrow-down
    2
    ·
    4 hours ago

    Aside from the general stupidity, Java is a heavily front-loaded language in my experience. I’m not going to engage in any tribalism about it or claim that it’s better or worse than others. As a matter of personal taste, I have come to like it, but I had to learn a lot until I reached a level of proficiency where I started considering it usable.

    Likewise, there is a level of preparation on the target machines: “Platform-independent” just means you don’t have to compile the program itself for different platforms and architectures like you would with C and its kin, as long as the target machines have an appropriate runtime installed.

    Libraries and library management is a whole thing in every general-purpose language I’ve dealt with so far. DSLs get away with including everything domain-specific, but non-specific languages can’t possibly cover everything. Again, Java has a steep learning curve for things like Maven - I find it to be powerful for the things I’ve used it in, but it’s a lot to wrap your head around.

    It definitely isn’t beginner-friendly and I still think my university was wrong to start right into it with the first programming classes. Part of it was the teacher (Technically excellent, didactically atrocious), but it also wasn’t a great entry point into programming in general.

    • ebc@lemmy.ca
      link
      fedilink
      arrow-up
      1
      ·
      37 minutes ago

      I’m not a Java dev, but I know enough of it to fix simple bugs in the backends I work with. My main issue with it is that 99% of the code doesn’t seem to do anything. The clear, obvious place that looks like it handles the feature you’re looking for? None of it does anything! It just instantiates another class from God knows where to actually do the work. I swear I spend most of my time in Java projects just looking for the damn implementation in a sea of AbstractSingletonFactoryBean shit.

    • frayedpickles@lemmy.cafe
      link
      fedilink
      English
      arrow-up
      4
      arrow-down
      3
      ·
      edit-2
      2 hours ago

      I’m sorry just as a matter of policy I’m going to have to downvote you for saying you like java. Nothing personal.

      I think some things that were novel when java came out are such old hat at this point the 1990s benefits just aren’t benefits anymore. Run anywhere? I’m in a html app right now. As is my IDE and my chat app. Strong interfaces and sane types are only in comparison to the bizarroland of c++ which visibly always seems to basically be word vomit. JIT compilation is in python which is both easier to use and has way better tooling and libraries…making python today run in the “fast enough” category that java was kinda in. I’ve literally never seen a usable java UI tho.

      • MooseTheDog@lemmy.world
        link
        fedilink
        arrow-up
        1
        ·
        33 minutes ago

        Minecraft is a decent example of a good java program. People jump to the first silly reason to disregard it. Cope.

      • CompassRed@discuss.tchncs.de
        link
        fedilink
        arrow-up
        1
        ·
        1 hour ago

        Python and Java are barely comparable. I adore both languages equally and use them about the same amount at work. They are just different tools better suited to different tasks.

  • AusatKeyboardPremi@lemmy.world
    link
    fedilink
    arrow-up
    33
    arrow-down
    1
    ·
    9 hours ago

    I might have agreed a decade or two ago, when I knew no better. But today, I find the tribalism surrounding programming languages comical.

    I don’t particularly like Java, but I use it because it pays the bills. Similarly, I use C++ (which I prefer) when my work requires it.

    • frayedpickles@lemmy.cafe
      link
      fedilink
      English
      arrow-up
      2
      arrow-down
      6
      ·
      2 hours ago

      Tell us more ancient one, your heroic tale of “giving up against the endless weight of capitalism” is fascinating.

      • AusatKeyboardPremi@lemmy.world
        link
        fedilink
        arrow-up
        2
        ·
        18 minutes ago

        Love the dramatics.

        This ancient one has learned the art of pragmatism. A little time in the trenches of enterprise development can do that – turn passionate ideals into practical choices.

        Some days it’s C++, some days it’s Java, Python and so on. In the end, the code compiles, and the ancient one get paid.

      • lurklurk@lemmy.world
        link
        fedilink
        arrow-up
        3
        ·
        51 minutes ago

        “giving up against the endless weight of capitalism”

        We just call it “having a job” nowadays

    • SorteKanin@feddit.dk
      link
      fedilink
      arrow-up
      29
      arrow-down
      1
      ·
      7 hours ago

      I don’t particularly like Java, but I use it because it pays the bills. Similarly, I use C++ (which I prefer) when my work requires it.

      I mean, anon is not arguing against that. They’re saying the language is shit regardless of how much it is used in business. I don’t think they are entirely wrong.

  • babybus@sh.itjust.works
    link
    fedilink
    English
    arrow-up
    37
    arrow-down
    10
    ·
    9 hours ago

    If it took anon 30 minutes to write hello world in java, programming is not for anon.

  • _____@lemm.ee
    link
    fedilink
    English
    arrow-up
    33
    arrow-down
    4
    ·
    11 hours ago

    C# masterrace and I’m tired of pretending it’s not

    • EnderMB@lemmy.world
      link
      fedilink
      arrow-up
      2
      ·
      3 hours ago

      After close to two decades of programming, C# is still the best language I’ve used. While some of the newer features seem a bit weird, I’d say it’s one of the few languages that has never got in the way and has just let me write code that made sense. Even with all the improvements Java has made over the years it’s still nowhere near as good as what C# was like maybe 15 years ago.

      The same goes for everyone’s other “fav” language, Python. Ruby has been a better beginner scripting language than Python for many years, and while Rails is definitely a ghetto, as a language Ruby is great at teaching great programming fundamentals.

    • drake@lemmy.sdf.org
      link
      fedilink
      arrow-up
      5
      ·
      7 hours ago

      C# is pretty good generally - I know it far better than any other and it pays my bills! - but it certainly has its weak points. Particularly around the newer features, a lot of them feel really rushed and just kind of shitty.

      The one I hate the most is the whole “nullable” pattern. It’s a total mess. Having to mark up files as #nullable enable, having to mark methods with a bunch of attributes, and the way that it works differently if it’s a value type or a reference type, it’s just so half-baked.

      If you spend some time with a more modern language like Rust or Swift then you’ll quickly start to notice C#’s weaknesses.

      • KubeRoot@discuss.tchncs.de
        link
        fedilink
        English
        arrow-up
        1
        ·
        2 hours ago

        I feel like you’re doing something wrong with the nullables… I’m pretty sure you don’t need to mark up files, you can just enable it on the whole project? I’m not sure about the attributes, you might have a point there, but it just makes sense for value vs reference types IMO, since value types are already implicitly different in terms of nullability.

        But yeah, I can imagine it’s half-baked, since nullable reference types (that’s the name, previously reference types were just nullable by default with no extra features) are a more recent addition to the language, one that wasn’t built with them in mind.

    • rekabis@lemmy.ca
      link
      fedilink
      arrow-up
      5
      arrow-down
      1
      ·
      9 hours ago

      C# has had string interpolation for, what - nearly a decade, now? It arrived with C# v6, which was released in 2015.

      Meanwhile Java just pulled their implementation out of the latest beta earlier this year because they couldn’t get it to work right.

      Don’t know about you, but I think that Java is largely resting on its laurels as of late. That the only real reason to go for it is it’s third-party library system, and not much more.

    • Mr_Blott@feddit.uk
      link
      fedilink
      arrow-up
      6
      arrow-down
      2
      ·
      10 hours ago

      Really want to go to La Scala one day but I looked it up and the tickets are like 500 euros. An eclipse is much cheaper

  • Orbituary@lemmy.world
    link
    fedilink
    English
    arrow-up
    35
    arrow-down
    3
    ·
    13 hours ago

    My old boss is one of the 3 initial creators of Java. He ran our department the same way this greentext reads.

    He was also a paedo. You can figure out the rest if you dig.

  • Ginny [they/she]@lemmy.blahaj.zone
    link
    fedilink
    arrow-up
    129
    arrow-down
    1
    ·
    16 hours ago

    I also think Java is shit, but if you manage to get a NullPointerException while writing a hello world program, maybe anon is just not cut out for computers?

  • WormFood@lemmy.world
    link
    fedilink
    arrow-up
    20
    arrow-down
    4
    ·
    14 hours ago

    object orientated programming is the wrong idiom for almost all problems, and even in the few cases where it makes sense, you have to be very careful or it’ll hurt you

    • 31337@sh.itjust.works
      link
      fedilink
      arrow-up
      8
      ·
      6 hours ago

      Idk. Maybe it’s because I learned OOP first that it makes more sense to me; but OOP is a good way to break down complex problems and encapsulate them into easily understable modules. Languages like Java almost force everyone on the project to use similar paradigms and styles, so it’s easier for everyone to understand the code base. Whenever I’ve worked on large non-OOP projects, it was a hard-to-maintain mess. I’ve never worked on projects such as the Linux kernel, and I’m hoping it’s not an unmaintainable mess, so I’m pretty sure it’s possible to not use OOP on large projects and still be maintainable. I am curious if they still use OOP concepts, even though they are not using strictly OOP.

      I also like procedural python for quick small scripts. And although Rust isn’t strictly OOP, it obviously borrows heavily from it. Haskell is neat, but I haven’t used it enough to be proficient or develop good sense of application architecture.

      I’ve done production work in C, but still used largely OOP concepts; and the code looks much different than code I’ve seen that was written before C++ was popular.

      • LH0ezVT@sh.itjust.works
        link
        fedilink
        arrow-up
        1
        ·
        edit-2
        4 hours ago

        The Linux kernel actually uses quite a bit of OOP ideas. You have modules that are supposed to have a clear interface with the rest of the world, and they (ab)use structs to basically work like objects. If you try hard enough, you can even do “inheritance” with them, like with their struct kobject. It is actually somewhat well-thought-out, imo. No need to go full OOP, just pick some of the good parts, and avoid the MappingModelFactoryServiceImpl hell or the madness that is C++.

    • sum_yung_gai@lemm.ee
      link
      fedilink
      arrow-up
      7
      ·
      12 hours ago

      I have been trying to be more functional but I still use classes for things like loading/modeling configs. What are some common situations where using an object is a good solution?

      I use python if that helps at all.

      • bstix@feddit.dk
        link
        fedilink
        English
        arrow-up
        6
        ·
        4 hours ago

        Objects are great for game programming.

        Stuff like enemies, bullets, loot, items, etc. are constantly changing and affecting each other. This makes it difficult to program in fixed functions that run through and crosscheck a bunch of constantly changing arrays. It makes logical sense to have objects with their own functions stored in dynamic lists instead of arrays. A lot of the properties are used by several different objecs, like coordinates or health points, so it also makes sense to describe them in classes.

        So, I’d say that it’s a useful way to classify data that is very dynamic, or when different functions need to run depending on that data.

        I don’t like putting all code into classes, because a lot of code doesn’t need that kind of flexibility.

      • pivot_root@lemmy.world
        link
        fedilink
        arrow-up
        10
        ·
        edit-2
        10 hours ago

        What are some common situations where using an object is a good solution?

        It depends on what you mean by “object”

        • Some kind of structured data?
        • Some named type which fulfills an interface?

        When you have some kind of structured data, having a class to represent it is fine. If you’re able to give it type annotations, that’s much better than passing around random dictionaries.

        When you need polymorphism and have an interface where some method on an object needs to exist (e.g. car.honk()), that’s also fine as long as you avoid creating subclasses and using inheritance. If you need some car that can honk like a truck and drive like a racecar, use composition.

        What I would consider a good use of classes (more specifically, nominal types) is dependent types. The idea is that you use the type system to enforce invariants for data.

        For example, suppose you have a string for a user email. It might be a valid email string, or it might be garbage like “z#%@(”=))??". You have a function for updating the user email in a database, and it requires the email string to be valid.

        One approach is to validate the email string after receiving it from the user. That works, but what if your coworker creates a new form and forgets to validate the email string there? Bad data gets passed downstream to functions that expect well-formed data.

        Another approach is to validate the email string at the top of every function that expects well-formed data. That also works, but now you’re validating the same string multiple times and pasting validate_email(email) everywhere.

        With a dependent type, you have a ValidatedEmail type and a constructor for it. The constructor will return an instance of the ValidatedEmail if and only if the email string is valid. Any function that expects a valid email will only accept a ValidatedEmail, and not a string. If your coworker creates a new form and forgets to validate the email, the type system will complain about a string being passed instead of a ValidatedEmail. You also shift the responsibility of validating the email to wherever there is a boundary between validated and unvalidated data, avoiding unnecessary validation since you know a ValidatedEmail is already valid.

        It’s an extremely useful paradigm for avoiding logic errors, but it’s unfortunately not as common as it should be.

    • SorteKanin@feddit.dk
      link
      fedilink
      arrow-up
      6
      arrow-down
      1
      ·
      6 hours ago

      Honestly I would consider that a bit weird. At the very least, old-fashioned. If you like Java, it makes me think you haven’t tried a better more modern language to compare it with.

      • KoalaUnknown@lemmy.world
        link
        fedilink
        arrow-up
        1
        ·
        edit-2
        1 hour ago

        The first language I learned was Python and I hated it. I have not tried Rust yet but I have tried all the Cs.

        Edit: added missing not

        • SorteKanin@feddit.dk
          link
          fedilink
          arrow-up
          1
          ·
          1 hour ago

          (I assume you left out a “not” there)

          You should definitely give Rust a shot. It is only conceptually similar to C++ but otherwise very different.

    • dev_null@lemmy.ml
      link
      fedilink
      arrow-up
      11
      ·
      edit-2
      9 hours ago

      I thought I like Java until I tried Kotlin. It’s everything I liked about Java, but with everything wrong with it fixed.

    • Serinus@lemmy.world
      link
      fedilink
      arrow-up
      46
      arrow-down
      1
      ·
      16 hours ago

      C# is nearly the same, but much, much better.

      • It doesn’t (usually) come with the Java culture 8 layers of abstraction. This isn’t in the Java language. This isn’t in OO. Yet nearly every Java programmer makes things way more complicated than it needs to be.
      • It’s a prettier language. Similar syntax with less bullshit.
      • It’s open source
      • It’s still multiplatform. Modern dotnet / C# works on anything.
      • Both Visual Studio and Visual Studio code are great IDEs that blow Eclipse out of the water
      • It’s one of the most common business languages.
      • It’s going to be supported forever.

      If I could restrict the world of programming to two languages, it’d be C# and Rust. C# for most things and Rust for a lower level language.

      • spongebue@lemmy.world
        link
        fedilink
        arrow-up
        4
        ·
        11 hours ago

        I only had one job that used C#, and it was the worst job I ever had. Even with the worst possible way to be introduced to the language, I still love it.

      • PlusMinus@lemmy.world
        link
        fedilink
        arrow-up
        12
        arrow-down
        3
        ·
        15 hours ago

        Nah, C# suffers from a lot of the same shit Java does. Needing everything to be a class is just no longer a good design choice (if it ever was). AOT support is still lacking. I don’t get, why it does not have typdefs. I think the solution / project structure is unnecessary and I could probably think of more stuff I dislike about C#. But imho, it still beats Java.

        Golang is my choice over C# any time. I strongly prefer how interfaces are handled and I actually like the error handling.

        • Serinus@lemmy.world
          link
          fedilink
          arrow-up
          11
          arrow-down
          1
          ·
          15 hours ago

          Needing everything to be a class

          In 2015 they added scripting. If you’re making a real project, you should absolutely use classes. (It’s not that hard. Don’t do the Java shit.) But you can absolutely write one off scripts just fine.

          AOT support is still lacking.

          Publishing your app as Native AOT produces an app that’s self-contained and that has been ahead-of-time (AOT) compiled to native code. Source.

          • PlusMinus@lemmy.world
            link
            fedilink
            arrow-up
            5
            ·
            15 hours ago

            I think you misunderstood my post. I am quite proficient with C#. I just think other languages do it better.

            AOT is not where it should be yet, because not all libraries have full stripping support.

        • pivot_root@lemmy.world
          link
          fedilink
          arrow-up
          3
          arrow-down
          2
          ·
          edit-2
          6 hours ago

          I strongly prefer how interfaces are handled

          It’s better than Java, but they still chose to walk headfirst into the same trap that bites Java developers in the ass: associating interface implementations with the struct/class rather than the interface itself.

          When you have two interfaces that each require you to implement a function with the same name but a different signature, you’re in for a bad time featuring an abomination of wrapper types.

          Edit: Clarity.

          • Willem@kutsuya.dev
            link
            fedilink
            arrow-up
            7
            arrow-down
            1
            ·
            11 hours ago

            On that last note, can’t you use the explicit interface implementation in C#?

            e.g.

            public class SampleClass : IControl, ISurface
            {
                void IControl.Paint()
                {
                    System.Console.WriteLine("IControl.Paint");
                }
                void ISurface.Paint()
                {
                    System.Console.WriteLine("ISurface.Paint");
                }
            }
            
            • pivot_root@lemmy.world
              link
              fedilink
              arrow-up
              2
              arrow-down
              1
              ·
              edit-2
              6 hours ago

              Edit: I misread your comment as “like in C#” and wrote this as an answer to the non-existent question of “can’t you use explicit interfaces like in C#”

              I haven’t kept up with recent Java developments, but with Go, you’re out of luck. Interface implementations are completely implicit. You don’t even have an implements keyword.

              Edit: For Java, a cursory search suggests that they haven’t yet added explicit interfaces: https://stackoverflow.com/questions/19111090/does-java-support-explicit-interface-implementation-like-c

              • ඞmir@lemmy.ml
                link
                fedilink
                arrow-up
                2
                ·
                6 hours ago

                He mentioned C#, which does let you explicitly choose to implement same-name functions of two interfaces with different code

                • pivot_root@lemmy.world
                  link
                  fedilink
                  arrow-up
                  3
                  ·
                  edit-2
                  6 hours ago

                  For some reason, my brain inserted a “like” before “in C#”, and answered the question of “can’t you use explicit interfaces like in C#.”

          • TunaCowboy@lemmy.world
            link
            fedilink
            arrow-up
            3
            arrow-down
            3
            ·
            12 hours ago

            just one more oop bro I swear

            Pure oopium. All oop ‘design patterns’ exist solely to overcome the inherent flaws of oop.

            • pivot_root@lemmy.world
              link
              fedilink
              arrow-up
              8
              arrow-down
              2
              ·
              edit-2
              11 hours ago

              just one more oop bro I swear

              Didn’t understand my criticisms of Go and Java’s interfaces, or do you just enjoy LARPing as a senior programmer while living in a small world where the term “interface” strictly means object-oriented programming and not the broader idea of being a specification describing how systems can interact with each other?

    • Sentient Loom@sh.itjust.works
      link
      fedilink
      English
      arrow-up
      26
      arrow-down
      1
      ·
      17 hours ago

      I like how straight-forward the syntax is. And it also seems orderly to have everything be a class. There’s a system to it.

      I’m using C++ for a project now and I like it in a similar way, but there’s more freedom (everything doesn’t HAVE to be a class). So with C++ I’ll never go back to Java (unless it’s for a job).

    • chunkystyles@sopuli.xyz
      link
      fedilink
      English
      arrow-up
      24
      arrow-down
      5
      ·
      17 hours ago

      No. Every language has its haters. There’s a reason Java is so widely used. If you like it, keep at it.

      • tempest@lemmy.ca
        link
        fedilink
        arrow-up
        20
        arrow-down
        3
        ·
        16 hours ago

        Yes and the reason is because millions of lines of production code were written and it isn’t worth rewriting them.

        Plenty of languages around now that don’t have 30 years of baggage and the specter of Oracle hanging over it.

        Now a days many businesses choose Go.

        • AusatKeyboardPremi@lemmy.world
          link
          fedilink
          arrow-up
          4
          ·
          9 hours ago

          Now a days many businesses choose Go.

          Many companies may choose something other than Java, but Java is still the behemoth.

          Such a decision is taken when the company is completely new or if it is a green field project.

          Even in the case of the latter, companies just choose to stick with their existing tech (read: expertise and experience of their tech teams)…

        • porous_grey_matter@lemmy.ml
          link
          fedilink
          arrow-up
          5
          ·
          16 hours ago

          I don’t really like Go either, but it’s better than Java, and it’s pretty good for Big Software ™. In the end, every language has some problems. Java just has all of them.

        • dukatos@lemm.ee
          link
          fedilink
          English
          arrow-up
          1
          ·
          13 hours ago

          The only reason not to choose Go is legacy systems with SOAP. That shit will never die.

    • Ginny [they/she]@lemmy.blahaj.zone
      link
      fedilink
      arrow-up
      8
      ·
      16 hours ago

      I am a certified Java hater, but you’re allowed to like it. If simple and objected oriented is what you want, I can see the attraction, and it has a good and mature ecosystem.

      • bitchkat@lemmy.world
        link
        fedilink
        English
        arrow-up
        4
        ·
        15 hours ago

        The ecosystem is java’s biggest asset. C# is actually a pretty decent language to develop in but the ecosystem just pales. Zookeeper for example doesn’t have an official client. But one guy ported the Java client but it hasn’t been updated in years. Maybe it’s recently because I moved on from that job.

    • lurch (he/him)@sh.itjust.works
      link
      fedilink
      arrow-up
      5
      ·
      16 hours ago

      No, Java has lots of merits. For example, once you know layout managers, you can have a resizable GUI app in no time. It’s the exact opposite of arranging things pixel by pixel. You just define “I want a grid of these buttons south and a big text field in the center” and Java will do the rest. I whip up apps like this for the silliest things, like noting which dungeon has what rotating boss this week in a game, so it’s more convinient than noting it in a text file.