• swordsmanluke@programming.dev
    link
    fedilink
    arrow-up
    12
    arrow-down
    1
    ·
    1 year ago

    For the beauty of the language: Ruby

    For Doing Businessy Things For Business: Kotlin

    For low-level, gotta-go-fast: Rust

    • potterman28wxcv@beehaw.org
      link
      fedilink
      arrow-up
      7
      ·
      1 year ago

      I love Ruby since I got introduced to it. The syntax is great and you can do many things in a simple manner.

      Before that, Python was my go-to language for scripting but now I cannot stand the syntax anymore. I dislike the lack of braces and forced indent.

      • Senicar@social.cyb3r.dog
        link
        fedilink
        arrow-up
        4
        ·
        1 year ago

        That’s funny, I dislike Ruby for probably the same reasons you like it. I don’t want a language that’s clever or elegant, I want it to do exactly what I say and nothing else. Lower level just makes more sense to me, I’d be a shit & unproductive software engineer.

        • potterman28wxcv@beehaw.org
          link
          fedilink
          arrow-up
          3
          ·
          1 year ago

          Well Ruby does exactly that though. The methods have good documentation so it’s easy to find what something does. There is no magic in the language that makes it do something else than what you wrote.

        • swordsmanluke@programming.dev
          link
          fedilink
          arrow-up
          2
          ·
          1 year ago

          I get that. Ruby does do a lot under the hood for me. But I like that! Different Strokes and all that.

          I guess, for general programming tasks, I enjoy when the language is “clever” enough to do The Right Thing for all the bits I don’t really care about in the moment (like memory management) so I can focus on the logic that solves my problem.

          Otoh, my last “big” personal project was a terminal multiplexer (and some supporting TUI widgets) that needed to run on a raspi zero W. I started in Python, then moved to Kotlin and finally Rust in the pursuit of performance. Once one of the parts I needed to care about became efficient performance, moving to a lower-level compiled language was the move.

          Indeed, one app in particular took 1.5 min to run in Python…which ultimately dropped to 3 sec in Rust - and that was mostly network latency!

          I love languages of all sorts. I’m currently writing an interpreter for a language I’m designing for fun. I’m starting off in Ruby while I figure this all out. I fully expect performance to be appalling. But Ruby lets me build faster while I’m testing things out and learning how interpreters work.

          Once I’ve got my interpreter working though, I’m planning to port it to Rust for better performance.

          • V H@lemmy.stad.social
            link
            fedilink
            arrow-up
            2
            ·
            1 year ago

            My terminal is written in Ruby, and it uses a font-renderer that’s 100% Ruby ( https://github.com/vidarh/skrift - I didn’t write it from scratch, it’s a port from C ), and it’s definitely possible to get things “fast enough” for a surprising portion of code in Ruby these days, but you may end up writing Ruby code that is “surprising”. For faster Ruby, see e.g. Aaron Patterson’s walkthrough of speeding up a lexer which ends up doing things most Ruby devs would not usually do because at least some of the things he ends up doing goes against the readability (e.g. the TrueType renderer I linked above definitely sacrifices speed and assumes you’ll memoize heavily to maintain readability). For an interpreter, you’re probably right to drop to something lower level.

        • V H@lemmy.stad.social
          link
          fedilink
          arrow-up
          1
          ·
          1 year ago

          Not trying to convince you - people have different preferences, but Ruby does exactly what you say and nothing else unless you start pulling in gems that do lots of monkey patching or metaprogramming cleverness.

          This is one of the reasons I dislike Rails in particular - it twists people’s idea of what clean Ruby can be like and introduces a lot of “magic” conventions that makes the code hard to read for someone who doesn’t know Rails.

          A lot of Ruby programmers do overdose on the “clever”, often inspired by Rails. You can do some truly insane things with metaprogramming in Ruby, but a lot of the time the cleverness is unnecessary and a bit of a footgun that people grab too early instead of thinking the problem through and realising there are simpler solutions.

      • swordsmanluke@programming.dev
        link
        fedilink
        arrow-up
        3
        ·
        1 year ago

        I can live with the forced indent in Python, but I really prefer Ruby’s “fluent” OO style vs Python’s more functional style.

        e.g. I prefer seeing operations in processing order like

        get_all_foos()
          .map{|foo| foo.id}
          .each {|id| report("found foo #{id}"}
        

        vs Python’s functional order

        [report(f"found foo {fid}") for fid in map(lambda x: x.foo_id, get_all_foos())]
        

        (Also, Python claiming useful variable names like type and id deeply annoys me)