• MrJameGumb@lemmy.world
    link
    fedilink
    arrow-up
    1
    ·
    23 hours ago

    Threads will literally punch you in the face

    Like…through the monitor? How does that work? Is it an actual fist or some kind of mobile computer component?

  • lurklurk@lemmy.world
    link
    fedilink
    arrow-up
    20
    arrow-down
    1
    ·
    8 hours 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

      • dch82@lemmy.zip
        link
        fedilink
        arrow-up
        7
        ·
        edit-2
        5 hours ago

        C:

        #include <stdio.h>
        
        int main() {
            printf("Hello World!");
            return(0);
        }
        

        EDIT: POSIX-compatible shell:

        echo "Hello World!"
        
    • MooseTheDog@lemmy.world
      link
      fedilink
      arrow-up
      18
      arrow-down
      3
      ·
      8 hours 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

      • Classy@sh.itjust.works
        link
        fedilink
        arrow-up
        5
        ·
        6 hours ago

        Oh my god I got fucked by a python script once because of a single space. It took forever to figure out what went wrong

      • JackbyDev@programming.dev
        link
        fedilink
        English
        arrow-up
        1
        ·
        edit-2
        4 hours ago

        **kwargs

        “No, I don’t use type annotations because they don’t actually do anything. In fact I purposefully give this parameter different types for different behaviors. How is that confusing?”

      • lurklurk@lemmy.world
        link
        fedilink
        arrow-up
        2
        ·
        8 hours 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

    • JackbyDev@programming.dev
      link
      fedilink
      English
      arrow-up
      3
      ·
      4 hours ago

      This is getting a little better nowadays.

      > cat Hello.java
      void main() {
          System.out.println("Hello, World!");
      }
      > java --enable-preview Hello.java
      Hello, World!
      

      Things to notice:

      1. No compilation step.
      2. No class declaration.
      3. Main method is not public static
      4. No String[] args.

      This still uses preview features though. However, like you demonstrated already, compilation is no longer a required step for simplistic programs like this.

      • cashew@lemmy.world
        link
        fedilink
        arrow-up
        1
        ·
        edit-2
        52 minutes ago

        Microsoft Java is a one-liner these days.

        > cat program.cs
        Console.WriteLine("Hello, World!");
        > dotnet run
        Hello, World!
        
    • meowMix2525@lemm.ee
      link
      fedilink
      arrow-up
      2
      ·
      edit-2
      6 hours ago

      I got the impression they skipped the hello world cause it was too easy and they wanted to get right to writing their app, so they moved on to more advanced stuff without having a real grasp of the basics

    • unalivejoy@lemm.ee
      link
      fedilink
      English
      arrow-up
      34
      ·
      edit-2
      1 day ago

      They only had to deal with LWJGL. The corporate java world has to use Spring.

      Edit: They also had to deal with all the fans saying they should’ve written it in C#.

      • dev_null@lemmy.ml
        link
        fedilink
        arrow-up
        6
        ·
        17 hours ago

        And much of the confusion and frustration at “Java” is actually because of Spring, or the “enterprise” nonsense making everything unnecessarily complex. You can just… write Java without any of that.

        You shouldn’t though, because Kotlin exists, which fixes everything that’s wrong with Java while still being 100% compatible, so even in legacy projects you can mix and match and write new code in Kotlin without needing to rewrite any of the existing Java.

  • babybus@sh.itjust.works
    link
    fedilink
    English
    arrow-up
    40
    arrow-down
    13
    ·
    16 hours ago

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

      • babybus@sh.itjust.works
        link
        fedilink
        English
        arrow-up
        4
        arrow-down
        1
        ·
        8 hours ago

        Thank you. If you bothered to read a 5 minutes tutorial instead of posting to 4chan, you could also reach this level of knowledge.

        • pinkystew@reddthat.com
          link
          fedilink
          English
          arrow-up
          2
          arrow-down
          1
          ·
          edit-2
          7 hours ago

          Don’t be mad, you’re the one that commented lol. It’s like you’re choosing to be upset

          • babybus@sh.itjust.works
            link
            fedilink
            English
            arrow-up
            2
            arrow-down
            1
            ·
            6 hours ago

            I thanked you for your reply and suggested reading a tutorial. How does that make me mad and upset? You’re acting weird.

        • Malfeasant@lemm.ee
          link
          fedilink
          arrow-up
          5
          ·
          7 hours ago

          Some of us try to understand what we’re doing, rather than just copy/paste. It’s easy to discount how difficult learning the basics of something is when you’re already past it.

        • sugar_in_your_tea@sh.itjust.works
          link
          fedilink
          arrow-up
          1
          arrow-down
          1
          ·
          edit-2
          5 hours ago

          And most IDEs will autogenerate it for you.

          That said, I think it highlights everything I hate about Java:

          public class MyClass {

          Why does it need to be a class? I’m not constructing anything?

          public static void main(String[] args) {

          Why is this a method? It should be a top-level function. Also, in most cases, I don’t care about the arguments, so those should be left out.

          System.out.println(“Hello world!”);

          Excuse me, what? Where did System come from, and why does it have an “out” static member? Also, how would I format it if I felt so inclined? So many questions.

          And here are examples from languages I prefer:

          C:

          #include “stdio.h”

          Ok, makes sense, I start with nothing.

          int main() {

          Makes sense that we’d have an entrypoint.

          printf(“Hello world”);

          Again, pretty simple.

          Python:

          print(“Hello world”)

          Ok, Python cheats.

          Rust:

          fn main() {

          Ooh, entrypoint.

          println!(“Hello world”);

          I have to understand macros enough to realize this is special, but that’s it.

          In C, Python, and Rust, complexity starts later, whereas Java shoves it down your throat.

  • Batman@lemmy.world
    link
    fedilink
    arrow-up
    15
    ·
    6 hours ago

    My inner mathematician respects Java. The first step in any problem is defining your universe

  • AusatKeyboardPremi@lemmy.world
    link
    fedilink
    arrow-up
    37
    arrow-down
    2
    ·
    16 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
      7
      ·
      9 hours ago

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

      • lurklurk@lemmy.world
        link
        fedilink
        arrow-up
        7
        ·
        8 hours ago

        “giving up against the endless weight of capitalism”

        We just call it “having a job” nowadays

      • AusatKeyboardPremi@lemmy.world
        link
        fedilink
        arrow-up
        4
        ·
        7 hours 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.

    • SorteKanin@feddit.dk
      link
      fedilink
      arrow-up
      33
      arrow-down
      1
      ·
      14 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.

    • Mr_Blott@feddit.uk
      link
      fedilink
      arrow-up
      6
      arrow-down
      2
      ·
      17 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

  • yokonzo@lemmy.world
    link
    fedilink
    arrow-up
    12
    ·
    1 day ago

    I started with java for school. The day I tried C for the first time I was flabbergasted, “what do you mean it doesn’t matter which order I put things in?”

    • Sentient Loom@sh.itjust.works
      link
      fedilink
      English
      arrow-up
      27
      arrow-down
      1
      ·
      24 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).

    • Serinus@lemmy.world
      link
      fedilink
      arrow-up
      51
      arrow-down
      2
      ·
      23 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
        6
        ·
        18 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
        13
        arrow-down
        5
        ·
        22 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
          15
          arrow-down
          1
          ·
          22 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
            ·
            22 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
          13 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.

          • TunaCowboy@lemmy.world
            link
            fedilink
            arrow-up
            3
            arrow-down
            3
            ·
            19 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
              9
              arrow-down
              2
              ·
              edit-2
              18 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?

          • Willem@kutsuya.dev
            link
            fedilink
            arrow-up
            8
            arrow-down
            1
            ·
            18 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
              13 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
                ·
                14 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
                  13 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#.”

    • lurch (he/him)@sh.itjust.works
      link
      fedilink
      arrow-up
      5
      ·
      23 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.

    • chunkystyles@sopuli.xyz
      link
      fedilink
      English
      arrow-up
      25
      arrow-down
      6
      ·
      24 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
        22
        arrow-down
        3
        ·
        23 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
          ·
          16 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
          6
          ·
          23 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
          arrow-down
          1
          ·
          20 hours ago

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

    • dev_null@lemmy.ml
      link
      fedilink
      arrow-up
      12
      ·
      edit-2
      17 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.

    • SorteKanin@feddit.dk
      link
      fedilink
      arrow-up
      8
      arrow-down
      1
      ·
      13 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.

      • Malfeasant@lemm.ee
        link
        fedilink
        arrow-up
        1
        ·
        7 hours ago

        Which would you suggest? (And if you say python, I will attack you with a pointed stick)

      • KoalaUnknown@lemmy.world
        link
        fedilink
        arrow-up
        1
        ·
        edit-2
        8 hours 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
          ·
          9 hours 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.

    • Ginny [they/she]@lemmy.blahaj.zone
      link
      fedilink
      arrow-up
      9
      ·
      23 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
        ·
        22 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.

  • Zement@feddit.nl
    link
    fedilink
    arrow-up
    11
    arrow-down
    1
    ·
    8 hours 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.

    • MajorasMaskForever@lemmy.world
      link
      fedilink
      English
      arrow-up
      4
      ·
      6 hours ago

      As embedded dev, the stack trace alone scares me. It would be funny to watch the Java runtime blow the 8 frame deep stack on a PIC18 tho

    • sugar_in_your_tea@sh.itjust.works
      link
      fedilink
      arrow-up
      3
      ·
      edit-2
      5 hours ago

      Honestly, I prefer C to Java, it’s incredibly simple without all the BS that Java throws at you:

      • interfaces - compiler will fail if you provide the wrong types; w/ Java, figuring out what types to pass is an effort unto itself
      • functions - everything needs to be in a class; even callback functions are wrapped in a class (behind the scenes if you use modern Java); in C, you just pass a function
      • performance - Java uses a stop the world GC, which can cause issues if you have enough data churn; in C, you decide when/if you want to allocate or free memory, no surprises

      There are certainly some bad parts, but all in all, when I run into an issue in C, I know it’s my fault, whereas in Java, there are a million reasons why my assumptions could be considered valid, and I have to dig around the docs to find that one sentence that tells me where I went wrong w/ the stuff I chose.

      That said, I prefer Rust to both because:

      • get fancy stack traces like I do in Java (I really miss stack traces in C)
      • compiler catches most of my stupid mistakes, Java will just throw exceptions
      • still no stupid interface hell, I just satisfy a specific trait and we’re good
      • generally pretty concise for what it is; I can rarely point to a piece of syntax and say it’s unnecessary

      I use:

      • Python - scripting and small projects
      • Rust - serious projects or things that need to be fast
      • Go - relatively simple IO-heavy projects that need to be pretty fast
      • C - embedded stuff where I don’t want to mess w/ the Rust toolchain

      Java has been absent from my toolbox for well over a decade, and I actively avoid it to this day because it causes me to break out in hives.

    • MooseTheDog@lemmy.world
      link
      fedilink
      arrow-up
      5
      arrow-down
      1
      ·
      8 hours 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…