• Ephera@lemmy.ml
    link
    fedilink
    arrow-up
    3
    ·
    3 years ago

    I was trying to say that it would be of use, if you remove all the newlines from what can be a one-liner (as that Java code example seems to have done).

    So, e.g. in that file you linked, line 49. That semantically ends in line 64. So, if you removed all the newlines in between, you could make that a one-liner with 346 characters in one line.

    • ☆ Yσɠƚԋσʂ ☆@lemmy.mlOP
      link
      fedilink
      arrow-up
      2
      ·
      3 years ago

      I find vertical alignment actually helps semantically break up code and makes it more readable. If lines 49 through 64 were a single line it would be much harder to read.

      Nesting, and indentation makes it possible to scan the code quickly. One really nice thing about s-expressions is that your code is basically a diagram showing relationships within it visually. By looking at the nesting you can quickly tell which pieces of code are related.

      • Ephera@lemmy.ml
        link
        fedilink
        arrow-up
        2
        ·
        3 years ago

        You seem to misunderstand me completely. 🙃

        I’m saying the Java code in the screenshot is horribly formatted.

        Rather than being written like this:

        something.doX().doY().doZ();
        

        …it should be written like this:

        something
            .doX()
            .doY()
            .doZ();
        

        And I’m saying that if we’re taking horribly formatted code into account, then LISP languages would also be able to produce incredibly long lines of code, but obviously no one does that.

        • ☆ Yσɠƚԋσʂ ☆@lemmy.mlOP
          link
          fedilink
          arrow-up
          3
          ·
          edit-2
          3 years ago

          Java code in the example might be particularly horrible, but I’ve certainly dealt with a lot of code that looks very much like that in Java during my career. Also, the problem isn’t just with formatting, it’s the fact that Java code has very low information to noise ratio. It takes an inordinate amount of code to solve simple problems in Java, and that adds a lot of mental overhead for the developer. A lot of the code is completely incidental to the problem being solved, and it’s just boilerplate resulting from mapping your problem domain to the available constructs. Java is not a terribly expressive language. It’s certainly come a long way recently with stuff like streams and lambda sugar for anonymous classes, but it’s still results in an inordinate amount of incidental code.

          This study shows just how bad the situation is.

          • Ephera@lemmy.ml
            link
            fedilink
            arrow-up
            3
            ·
            3 years ago

            Yeah, I can get agree with that.

            It’s not like I like Java. It tries to keep the number of language concepts extremely low, with the goal of enabling quick on-boarding for new team members.
            And, in my opinion, that is extremely pointless. Learning new libraries and frameworks is daily business as a software engineer. So, learning the syntax and std library of your programming language is a very small overhead.

            I just feel like Java gets more shit than it deserves.
            For example, I think that it’s a much better beginner’s language than Python, because it has less concepts, better error messages and better tooling. Having to memorize public static void main(String[] args) isn’t optimal, but certainly doable by even the biggest dumbass.
            Yet, for whatever reason, Python is all the hype.

            • ☆ Yσɠƚԋσʂ ☆@lemmy.mlOP
              link
              fedilink
              arrow-up
              2
              ·
              3 years ago

              I definitely don’t think Java is the worst language out there, and agree that it’s preferable to Python. I also think that JVM as a platform is absolutely incredible piece of engineering.