• Ephera
    link
    fedilink
    arrow-up
    4
    arrow-down
    1
    ·
    3 年前

    I thought this was a stack trace at first, with the fully-qualified package names just being this long.

    To be fair, though, if we’re including badly formatted “one-liners”, then a lot of the more functional-style programming languages would need that monitor.

    I frequently produce such “lines” in Scala and Rust with the list/iterator operations.
    The entire family of the LISPs would also need it.

    • ☆ Yσɠƚԋσʂ ☆OP
      link
      fedilink
      arrow-up
      5
      ·
      3 年前

      Definitely would not be of any use in Lisps from my experience. I rarely have lines that have over 100 characters in Clojure. Here’s what typical Lisp code looks like in my experience. :)

      • Ephera
        link
        fedilink
        arrow-up
        3
        ·
        3 年前

        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σɠƚԋσʂ ☆OP
          link
          fedilink
          arrow-up
          2
          ·
          3 年前

          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
            link
            fedilink
            arrow-up
            2
            ·
            3 年前

            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σɠƚԋσʂ ☆OP
              link
              fedilink
              arrow-up
              3
              ·
              edit-2
              3 年前

              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
                link
                fedilink
                arrow-up
                3
                ·
                3 年前

                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σɠƚԋσʂ ☆OP
                  link
                  fedilink
                  arrow-up
                  2
                  ·
                  3 年前

                  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.

    • remram
      link
      fedilink
      arrow-up
      4
      ·
      edit-2
      3 年前

      I think they just repeat the same sequence multiple times instead of using variables:

      oreAncillaryProductInfo.setSeatRequestTransactionId( sabreEnhancedBookResponse.getEnhancedHotelBookRS().getTravelItineraryRead().getTravelItinerary().getOpenReservationElements().getOpenReservationElement().get(i).getAncillaryProduct().getXmlData() .getAncillaryServiceData().getSeatRequestTransactionID()); oreAncillaryProductInfo.setPaperDocRequired( sabreEnhancedBookResponse.getEnhancedHotelBookRS().getTravelItineraryRead().getTravelItinerary().getOpenReservationElements().getOpenReservationElement().get(i).getAncillaryProduct().getXmlData() .getAncillaryServiceData().getPaperDocRequired()); …

      No idiomatic use of Rust (or Java) would yield this code. In any case, in both Java and Rust whitespace doesn’t matter so you can make those lines shorter even when writing functional-style code.

    • Ravn
      link
      fedilink
      arrow-up
      3
      ·
      3 年前

      I frequently produce such “lines” in […] Rust with the list/iterator operations.

      Use method chaining and rustfmt.

      • Ephera
        link
        fedilink
        arrow-up
        4
        ·
        3 年前

        I put those quotes there, because I don’t actually write them into one line. That Java code sample seems to just have done so unnecessarily.

        So, while I don’t use rustfmt, I do probably format it the way it would format that.