• LiveLM@lemmy.zip
    link
    fedilink
    English
    arrow-up
    12
    arrow-down
    1
    ·
    23 hours ago

    Go look at that Lisp kojumbo then tell me Rust is ugly.

    (defmethod wake ((object magic-packet) address port)
      (let* ((payload (encode-payload object))
             (size (length payload))
             (socket (usocket:socket-connect nil nil :protocol :datagram :element-type '(unsigned-byte 8))))
        (setf (usocket:socket-option socket :broadcast) t)
        (usocket:socket-send socket payload size :host address :port port)
        (usocket:socket-close socket)))
    

    Actually unreadable.

    • Zak@lemmy.world
      link
      fedilink
      arrow-up
      4
      ·
      19 hours ago

      Entirely readable to someone who knows Common Lisp, and unreadable to someone who doesn’t know any kind of Lisp. Mostly readable to someone who knows Emacs Lisp, Clojure, or Scheme.

      Being able to correctly guess what the syntax does without knowing the language is a function of similarity to familiar languages more often than it is a characteristic of the syntax itself.

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

        Emacs Lisp

        If someone knows elisp, they would have no trouble with that. Emacs has EIEIO, which is basically like CLOS lite

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

          I imagine the tricky part for someone unfamiliar with Lisp would be that there’s no syntactic clue that a particular thing is a macro or special form that’s going to treat its arguments differently from a function call. Someone who knows Scheme may have never seen anything like CLOS, but would see from context that defmethod must not be a function.

            • Zak@lemmy.world
              link
              fedilink
              arrow-up
              1
              ·
              7 hours ago

              You don’t even need to define a class to define methods. I’m sure that’s surprising to people coming from today’s popular language, but the original comment was about syntax.

              Whether Lisp syntax is ugly is a matter of taste, but it’s objectively not unreadable.

                • Zak@lemmy.world
                  link
                  fedilink
                  arrow-up
                  1
                  ·
                  5 hours ago

                  In most languages, I would agree with that. In Lisp, I think I might not. If Common Lisp didn’t come with CLOS, you could implement it as a library, and that is not true of the object systems of the vast majority of languages.

    • bigfondue@lemmy.world
      link
      fedilink
      arrow-up
      7
      ·
      edit-2
      22 hours ago

      Maybe Emacs has fried my brain, but that is perfectly readable. Common Lisp has one of the most advanced object systems around, so yea you can write hard to read stuff if you want

    • Victor@lemmy.world
      link
      fedilink
      arrow-up
      3
      ·
      20 hours ago

      It’s like comparing Hitler to Stalin. Both are pretty shit… Two things can be ugly at the same time. 😅