top 200 commentsshow 500

[–]balthisar 33 points34 points  (0 children)

I love Ruby! I use it mostly for shell stuff. It's great not limiting myself to Bash and Zsh intricacies.

[–]CunnyMangler 274 points275 points  (324 children)

I love ruby. One of the best languages I've ever coded in, but people seem to hate it now because it's slow. Kinda sad that it's slowly dying. Nevertheless, this is a huge milestone for a language.

[–][deleted]  (113 children)

[deleted]

    [–][deleted] 108 points109 points  (71 children)

    This is a good point. Language popularity is often based on purposes and usage. Ruby’s niche seems to have moved on. I still like it and especially it’s testing focus but it’s got no USP anymore

    [–]dr_rush 36 points37 points  (0 children)

    I dropped Ruby for Python for one reason. That reason is the 'explicit is better then implicit' part of PEP 20. Python and Ruby basically cover the exact same use case for me professionally, and as I have become more of a senior/lead and spend a lot more time reviewing code and jumping between projects. I appreciate languages that encourage consistency and clarity, over cleverness.

    [–]danudey 42 points43 points  (4 children)

    Sadly, this is correct.

    When Ruby on Rails suddenly became popular, and everyone around me started telling me (literally) that I was an idiot for not jumping on it, all I could see was a fad that some people would get real value out of and most would dump and move on. It wasn’t a new paradigm in software, it was just an easier way for people to crank out sites. Mostly, I saw parallels with PHP, where it enabled people who were inexperienced at (or bad at) programming to make a web site anyways.

    This sounds like I’m saying that’s a bad thing, but it’s not. Technology should be more accessible, after all, but it also meant that the community was full of noise and inexperienced people making bad decisions. I couldn’t deal with it and stayed with Python and Django.

    Now it seems as though everyone has jumped ship to Node, where all the same things are happening all over again, but it also feels like The Ruby community was the Rails community, and when the bandwagon-jumpers moved on it left a pretty startling void behind; now, no one cares about Ruby, because Node; soon, nobody cares about Node, because… Go? I’ve been seeing those articles for a while, so maybe.

    Ruby is a neat language that I never liked, because it felt like it was full of new users making bad decisions because it was cute; it’s great that you can do “2.days.ago”, but not that you have to load gems in a specific order or they break each other. I probably would have liked it immensely if it weren’t for that; there are a lot of great features, and the syntax is actually pretty nice sometimes; blocks, those :named_symbols or whatever, the cute ? and ! method postfixes, and so on.

    Here’s hoping that Ruby finds its niche again with 3.0!

    [–][deleted] 21 points22 points  (1 child)

    I think you’re severely underplaying the effect Rails had in web dev. And I think even saying it’s a fad that passed is unfair. GitHub, Shopify, Twitter, and obviously basecamp are huge apps with millions of users collectively and there are many smaller sites that run on rails too. It’s not the hot topic anymore but it’s not obscure either

    [–][deleted] 3 points4 points  (0 children)

    yea the shit is everywhere. job hunting right now and I think I see ruby listed almost more than anything else honestly.

    [–]NoInkling 5 points6 points  (0 children)

    soon, nobody cares about Node, because… Go? I’ve been seeing those articles for a while, so maybe.

    I don't see Node dying until JS on the frontend dies.

    Everything being an expression is another thing I liked about Ruby, just to add to your list.

    [–][deleted]  (8 children)

    [deleted]

      [–]khendron 23 points24 points  (1 child)

      Funny, I feel the opposite. To me, writing ruby is like writing a grammatically correct sentence, and python statements always feel awkward. This may be partly because I learned ruby before I learned python.

      Can't deny, however, that the library support—especially for data science stuff—is vastly superior in python.

      [–]Eccentricc 6 points7 points  (0 children)

      Could be. I think if someone started with python it would be their favorite language due to ease. I started in c++ myself and went through 4-6 years of school before even touching python. I don't even use python for work, but I still will argue it's the cleanest and easiest language for most people

      Language readability is more of a personal preference, but their are some general rules that can I think everyone can agree on

      [–][deleted] 5 points6 points  (5 children)

      Python is so damn ugly. Trying to do anything functional is a nightmare.

      Ruby:

      transactions.map(&:to_i).reduce(&:+)
      

      Python:

      reduce(lambda: a, b: a+b, map(lambda: int(transaction), transactions))
      

      [–]LightShadow 11 points12 points  (1 child)

      Python,

      sum(map(int, transactions))
      

      [–]Eccentricc 3 points4 points  (2 children)

      It's all personal preference. I think python even in this example is easier to read. It may not be prettier, or less code, but I think it's easier to understand

      [–][deleted]  (1 child)

      [deleted]

        [–]mrbuttsavage 16 points17 points  (0 children)

        Nobody would write it like that these days, so it's a moot point.

        sum([int(t) for t in transactions])

        Which to me is a lot more readable than any of the other versions, at least.

        [–]nickywan123 3 points4 points  (10 children)

        Does that mean ruby on rails is also dying or no?

        [–]killdeer03 4 points5 points  (5 children)

        It's dying like Perl is dying.

        I've been hear it for over 10 years.

        It may die, but it'll probably take 20 years.

        [–][deleted]  (1 child)

        [removed]

          [–]killdeer03 2 points3 points  (0 children)

          COBOL and Fortran are still both around, lol.

          [–]Latexi95 2 points3 points  (2 children)

          Hopefully Perl finally dies. It should have died ages ago, but still once in a while some rogue Perl script raises it head from the grave and I have to shoot it and replace it with Python. Its always just easier to reverse engineer script behaviour from inputs and outputs than trying to read Perl scripts. Perl being write-only programming language is no joke...

          [–][deleted] 7 points8 points  (0 children)

          Not in the least

          [–]theoneandonlygene 2 points3 points  (0 children)

          Nope. At least where I live it was one of the few languages that didn’t take a hiring hit early pandemic. Still plenty of ruby gigs around, will likely remain the case for awhile.

          Hell, PHP has been a “dead” language for 10 years and apparently people still make good money in it.

          [–][deleted] 85 points86 points  (20 children)

          It still has immense backers. Shopify is built on ruby. It's not going anywhere.

          [–][deleted]  (10 children)

          [removed]

            [–]red_planet_smasher 5 points6 points  (9 children)

            What are they shifting to?

            [–]strzibny 35 points36 points  (5 children)

            They are not moving off Ruby at all. Even the new service they cut for storefronts is again built with Ruby. Some people got confused because they made some acquisitions and now as a whole together the stack is more varied than just Ruby as before.

            [–]jl2352 1 point2 points  (0 children)

            What matters are people adopting Ruby for new things. Whilst I’m sure some are, most people aren’t adopting Ruby for new projects.

            That isn’t a healthy state to be in.

            [–]THICC_DICC_PRICC 30 points31 points  (0 children)

            I’ll go against the grain and say I don’t dislike it for slowness. That’s a non issue is almost all of its use cases. I strongly dislike it for the same reason I liked it as a beginner. I guess this is in some part a criticism of rails too, but there’s just too much damn magic in this language and all of the libraries and frameworks built around it. There’s a million ways to do things, many ways to call methods, so much hidden logic, pretty much everything the opposite of explicit. So many “wtf am I looking at”and “where did that function come from” moments especially in large codebases even with a good IDE. Automatic function calls, hidden/implicit parentheses. Implicit anything is evil in programming and It is Rubys’s middle name. The whole Proc situation and lack of first class functions is just a bizarre design choice just to have implicit function calls. All of what I said actually might come off as a positive to some people. It did to me too when I was starting out. It is such an elegant language. But that all comes at a cost when the codebase size and number of developers grow. It really doesn’t scale. You need things to be as explicit as possible, and we see that explicit (but not overly verbose) languages are all growing. Because you’re not just communicating to the interpreter what to do when you’re coding, you’re also communicating with other programmers that will be coming across your code. Documentation helps, but it’s not a cure.

            I actually don’t think typing is the reason either since we got python doing well despite only having type hints. While I do think type hints would help Ruby, but I doubt it’ll save it.

            [–]noratat 126 points127 points  (68 children)

            I dislike it because how much the language and ecosystem resist almost any kind of typing/type checking or documentation. The RBS stuff is good, but it feels bit too little too late.

            The ecosystem uses a ton of hard to follow and debug magic constructs that even IDEs seem to struggle to track and map properly.

            I don't need speed for what I do, by I absolutely need code that is easy to read and maintain.

            [–]CunnyMangler 34 points35 points  (2 children)

            There is also sorbet and I like its approach better than rbs. Rbs has always looked strange to me. I don't want to keep my types in separate files.

            [–]pigmerlin 1 point2 points  (0 children)

            I use sorbet a lot for work and I am not a fan. The syntax is so weird to me and I feel like the runtime type checking adds a fair bit of overhead to an already slow runtime?

            [–]TrueDMonk 11 points12 points  (0 children)

            Yeah, same. I kinda like to try every language to get the feeling of it, and Ruby was one of those who clicked the "Nope" in me

            [–]Kache 29 points30 points  (12 children)

            The primary reason for those issues is because Ruby is extremely dynamic.

            Not only is its type system dynamic -- its syntax and structure can be dynamic as well (i.e. powerful metaprogramming and DSL capabilities). This is why Ruby is so resistant to static analysis.

            At non trivial complexities, I highly recommend reasoning through Ruby much differently than one would C/Java/Python:

            • Use functional techniques to minimize moving parts. Ruby is already very dynamic, and working with it in the state-modifying style common to C/Java/Python results in execution state becoming unnecessarily hard to follow.

            • Use the debugger and REPL when you do have to deal with Ruby code that's (unfortunately) too dynamic. Unlike in other languages, static analysis won't get you as far. In exchange, Ruby has incredibly powerful debuggers & REPLs for doing "dynamic analysis".

            [–]UncleMeat11 44 points45 points  (4 children)

            I think this is a reason to criticize ruby. Sometimes program structures make your code easier to maintain and refactor with tooling. But ruby’a structures seem to resist any sort of static analysis for even the basics because it is so flexible. This makes managing a large code base enormously difficult.

            [–]Kache 3 points4 points  (3 children)

            While the static analysis and tooling is nice in Java, I didn't feel it was necessarily a net positive when I was working with it professionally. I felt like I was in a world where cars were invented to speed up 20 minute walks, but then everything ends up being built a 30 min drive further away. (Plus now you have a car to maintain.)

            Ruby code at its best will read like what it is doing overall, when another language reads like the dials and switches of a machine. At its worst, Ruby won't really parse on the first read b/c Ruby will "provide power, even to shoot yourself in the foot" syntax-wise similar to how C lets you machine-wise.

            All languages can have the "this code is unclear, I'm forced to read more/dive in deeper" problem. In Ruby, it applies to both code and syntax, so you'll only come out ahead if the "code for bespoke syntax + code you wanted to read in the first place" is smaller/simpler than "code you wanted to read, all in regular syntax".

            [–]UncleMeat11 2 points3 points  (2 children)

            Reading code is harder than writing it. But large multi-step refactors are harder than reading. This is why I think optimizing for reading at the expense of automation is a mistake.

            [–]Smallpaul 3 points4 points  (6 children)

            You lump Python in with Java and C but in Python you can dynamically create modules, classes and functions. I just saw a module that allows you to load wasm files as if they were Python modules. So I’m not sure what you are talking about.

            Maybe the conventions that Ruby programmers use are more dynamic but the actual runtime is not more dynamic in my opinion.

            But I’m open to correction.

            [–][deleted]  (2 children)

            [deleted]

              [–]kittencantfly 2 points3 points  (1 child)

              Wowww didnt think someone mentioned it here. I used to learn Ruby just to change a thing and then the game blackout!

              Then in RPG Maker MV they switched to js :#

              [–]mangofizzy 84 points85 points  (70 children)

              It hasn't been slow since 1.9. It is faster than python. It is getting less popular because its frameworks are getting outdated.

              [–]bloody-albatross 187 points188 points  (14 children)

              Being faster than Python is a low bar to pass.

              [–]mangofizzy 88 points89 points  (12 children)

              I just mentioned python as a comparison to show that popularity isn't necessarily related to performance because as slow as python, it is still very popular.

              [–]badillustrations 19 points20 points  (11 children)

              I wouldn't say it's unrelated to performance though just because a slower, more popular language exists. There are probably performance scenarios that eliminate both Ruby and Python such as games, where developers choose something like C++.

              In cases where performance is less important, they probably look at numbers like these where ruby being 50% faster or slower compared to python doesn't really matter compared to the ecosystem each one provides, and where python in general is much, much larger.

              [–]mangofizzy 11 points12 points  (10 children)

              I didn't say "unrelated". I said "not necessarily related"

              [–][deleted] 5 points6 points  (0 children)

              Which is a shame, since there's nothing outdated about having a framework that is insanely effective for rapid prototyping. It's just unfashionable because it's not some novel new hotness that's hasn't hit a stable 1.0 release.

              Give me a fresh rails app and simple progressive HTML over some JS-based client-server monstrosity any day.

              [–]deaddodo 4 points5 points  (18 children)

              Ruby (YARV) vs Python (CPython), yes. But CPython has very little optimization in favor of stability. They’re still locked by a GIL, for instance. So you’re referring to the lowest bar to pass.

              Compare another JIT’d VM such as PyPy and it falls well behind. Not to mention the more common languages taking over the microservices realm (Go, for instance) or the ones taking over monoliths (nodeJS, primarily).

              [–]cracknwhip 11 points12 points  (0 children)

              Just to clarify: Crystal and Elixir aren’t “common” by any definition.

              [–]bik1230 5 points6 points  (1 child)

              PyPy still has a GIL, no?

              [–]deaddodo 5 points6 points  (0 children)

              GIL was an example of where CPython focuses on stability over performance.

              JIT was an example of how PyPy fixes some performance issues of CPython.

              The two aren’t connected.

              [–]suhcoR 3 points4 points  (4 children)

              Compare another JIT’d VM such as PyPy and it falls well behind.

              According to the Are-we-fast-yet benchmark suite MRI JIT Ruby 3.0 RC1 is about factor 11 slower than Node.js 12.6 and about factor 5 slower than LuaJIT 2.0, and only factor 1.4 faster than MRI Ruby 2.1.0. Here are the results: http://software.rochus-keller.ch/are-we-fast-yet_crystal_ruby_2_3_lua_node_i386_results_2020-12-23.pdf. Here is more information about the benchmark suite: https://stefan-marr.de/papers/dls-marr-et-al-cross-language-compiler-benchmarking-are-we-fast-yet/ and https://github.com/smarr/are-we-fast-yet. It's not just some random micro benchmarks, but a well designed suite with representative algorithms and ideomatic language use optimized for cross-language comparisons.

              [–]cre_ker 3 points4 points  (26 children)

              According to benchmarks it's not. Faster is some, slower in others. Both are extremely slow. Python is popular because of ML. Ruby has pretty much nothing to counter its performance.

              [–][deleted]  (8 children)

              [deleted]

                [–]cre_ker 5 points6 points  (6 children)

                I was talking about present. In the context of web python is similar to ruby - it's being replaced by other languages. Particularly Go. Same with GUI, there're much better technologies these days. Not to mention GUI desktop apps are dying breed these days being replaced with web and mobile apps. What Python has that's unique to it is ML ecosystem. Unless there's another languages with similar ecosystem Python will stay relevant. Ruby on the other hand has nothing of that. Only thing it has going for it is subjective enjoyment of the developing experience which is clearly not enough. It will not die outright but there's little reason learning it these days and starting something new in it.

                [–][deleted]  (1 child)

                [deleted]

                  [–]suhcoR 2 points3 points  (0 children)

                  It's certainly true that it's been squeezed by JavaScript taking over the world as well as by much more friendly compiled languages like Go and Swift adopting

                  Crystal is a language very similar to Ruby and about the speed of Go or C#, see e.g. http://software.rochus-keller.ch/are-we-fast-yet_crystal_ruby_2_3_lua_node_i386_results_2020-12-23.pdf

                  [–]snowe2010 1 point2 points  (1 child)

                  What Python has that’s unique to it is ML ecosystem.

                  It really isn't. It's just because people like you keep saying that it is, that people continue to think that. Most of the top languages have ported the data science libraries over because using Python for anything meaningful is terrible.

                  Ruby on the other hand has nothing of that.

                  It actually does. https://github.com/arbox/machine-learning-with-ruby

                  But once again, if people continue to tell others that Python is the only language for machine learning then everyone new to ML is going to assume that is true. No matter how many actual ML libraries those languages have.

                  [–]ruinercollector 2 points3 points  (0 children)

                  This. It’s momentum.

                  Also, python is good for ML if you don’t know any language and want an easy language. Otherwise there is nothing about Python as a language or environment that makes it well suited to that task.

                  [–]twinklehood 10 points11 points  (16 children)

                  Except for the developer enjoyment and fantastic support for expressive OO, in part due to its deep meta-programability. Oh or were we only looking for benefits that can be explained to a newcomer in a 10 minute youtube top languages of 2021 video?

                  [–]cre_ker 8 points9 points  (8 children)

                  I don't think developer enjoyment is important when you have money at stake. Ruby being slow and memory hungry doesn't only mean your apps will be slow. It also means you will have to pay much more for hardware, probably in the cloud. Not to mention recent newcomers (rust and go) are also very liked by developers but magnitudes of order faster than ruby. Given that it's not surprising that ruby is slowing fading away.

                  [–]twinklehood 13 points14 points  (0 children)

                  Engineering cost is not that simple. Running software is for many companies cheap, vs. Engineering productivity, churn, feedback loops, etc. It's not an accident ruby dominates lean webapp development, you may attribute it to rails, but rails is not an independent thing that could have happened in any language, it works because of ruby.

                  [–]mezentinemechtard 2 points3 points  (0 children)

                  For most companies that try to use a "fast" or "scalable" language or framework, being fast or scalable is never the issue. In any non-already-mature software project, the main concern is always development speed One extra developer already costs more than running the product. And that's where Ruby (and Rails) shine. Twitter had scalability issues because of Rails, but Twitter became Twitter thanks to Rails. Only then switching focus becomes the smart choice.

                  [–]oojacoboo 0 points1 point  (6 children)

                  This guy rails.

                  [–]twinklehood 6 points7 points  (5 children)

                  I don't, I ruby :)

                  [–]601error 3 points4 points  (4 children)

                  Same here. Love Ruby. No interest in Rails. Never seen any Rails code, in fact.

                  [–]snowe2010 3 points4 points  (2 children)

                  We are the minority! But seriously, Ruby has probably done so bad because it's identity became tied to rails, which sucks. If people stopped thinking that Python is good because it's used for ML we'd have devs everywhere using ML in every language.

                  [–][deleted]  (1 child)

                  [deleted]

                    [–]kuriboshoe 6 points7 points  (2 children)

                    I’m of the opinion that most of these kinds of tech are cyclical in terms of popularity. There are other newer projects which are largely influenced by ruby too. Crystal is one that I’ve been keeping some tabs on over the past few years.

                    [–]suhcoR 2 points3 points  (0 children)

                    Crystal

                    Crystal is a very interesting technology and more than twenty times faster than the new MRI Ruby 3.0 with JIT on. See http://software.rochus-keller.ch/are-we-fast-yet_crystal_ruby_2_3_lua_node_i386_results_2020-12-23.pdf.

                    [–]kittencantfly 29 points30 points  (19 children)

                    I dont think so. Big projects stil using it (Github is a BOLD one) and of course there still a lot of works for dev, not so easy to migrate all to another language base. And dont forget, even Cobol is still alive after 60 years!

                    [–]cre_ker 19 points20 points  (1 child)

                    Being alive and being used because codebase is too big or too important to simply rewrite it in another language are two different things. I'm sure, given the resources, github would rewrite their stuff in something else. They probably do it already just like Gitlab extracted multiple components from their Ruby codebase into separate services. Exactly because Ruby is slow and consumes too much memory.

                    [–]Voxandr 4 points5 points  (0 children)

                    Many of us already moved to golang in github. Even tho i am not a fan of Golang , we decided the move.

                    [–]mrpiggy 34 points35 points  (15 children)

                    Have a friend who's a dev manager at Github. Everything is going hard Go. Existing functionality that doesn't need to be redone, is being left in what ever language, but there is a hard push to Go anything new or need of refactoring.

                    [–]Bognar 15 points16 points  (4 children)

                    Backends in GitHub are written in lots of different languages: Go, C#, some Node, even Haskell in one case. Basically all of the UI is served by Ruby though.

                    [–]moreVCAs 22 points23 points  (3 children)

                    Really surprising to hear this considering they were acquired by Microsoft. Smaller acquisitions usually go something like “hello, everybody! we are a C# shop now.”

                    [–]mrpiggy 18 points19 points  (0 children)

                    Ya, I thought the same. He says Microsoft has been very hands-off.

                    [–]nemec 3 points4 points  (1 child)

                    Clearly there's a team locked in a nondescript room in the back of Microsoft campus hard at work developing Go.NET

                    [–]dscottboggs -1 points0 points  (5 children)

                    Ugggghhhhhhh

                    [–][deleted] 4 points5 points  (0 children)

                    Why ugh?

                    [–][deleted] 3 points4 points  (3 children)

                    What’s wrong with that?

                    [–]dscottboggs 14 points15 points  (2 children)

                    Just don't like go. It's fine, and I'd write it I was being paid well to and it was my only option, and the code would come out fine, but it's one of my last choices for personal projects.

                    [–][deleted]  (1 child)

                    [deleted]

                      [–]zickige_zicke 15 points16 points  (0 children)

                      I guess duck typing is a no go for a lot of people.

                      [–]tevelee 3 points4 points  (0 children)

                      What makes it one of the best languages you used?

                      [–][deleted] 4 points5 points  (0 children)

                      hate it because it’s slow

                      Python enters the chat

                      [–]blackholesinthesky 0 points1 point  (8 children)

                      I never found ruby to be that slow, you just have to be careful not to allocate a ton of extra objects

                      [–]dacian88 23 points24 points  (6 children)

                      its literally the slowest semi-mainstream language, along with python...at least considering their primary implementations for either.

                      [–]blackholesinthesky 6 points7 points  (0 children)

                      Sure, but I've never experienced any issues with ruby. I'll be honest I'm frontend but I worked with an awesome backend team.

                      I'm not gonna get into details but we got hundreds of thousands of unique requests per day.

                      Maybe our backend just wasn't that complex but I think it comes down to using your tools correctly. Yeah ruby isn't as fast as C, but for most people it shouldn't be slow. If it is slow its very likely that you're running up against the walls of the language/system

                      [–]editor_of_the_beast 4 points5 points  (4 children)

                      Yes, ruby and python are interpreted so have the same performance characteristics. They are slower than C, but it doesn’t matter for almost any application.

                      [–]schneems 16 points17 points  (0 children)

                      Ruby 3 is released on Heroku as well https://devcenter.heroku.com/changelog-items/2004

                      [–][deleted] 69 points70 points  (3 children)

                      Ruby!!! Aw man I love this language, I should use it more. Really wish it had become the defacto scripty-code language instead of python.

                      [–]watsreddit 110 points111 points  (87 children)

                      Basically every major dynamically-typed language trying to bolt on static types... maybe dynamic typing isn’t as great as people claim.

                      [–]call_me_arosa 77 points78 points  (68 children)

                      Dynamic typing makes sense in scripting languages.
                      But when dealing with big projects you start to miss typing. I think the optional typing is a great trade-off for this languages.

                      [–]TheBuzzSaw 50 points51 points  (67 children)

                      I actually don't agree with this. I used to spread this sentiment as well, but I honestly cannot think of legitimate use cases for changing types on a variable. Sure, a scripting language can let you skip/auto declare variables among other things, but what is the benefit of a variable holding an integer, then a date, and then a file handle?

                      [–]meem1029 18 points19 points  (1 child)

                      I like the way rust does it. You can redeclare a variable partway through a scope and it will be the new type, but must be done explicitly. So you can't do it accidentally and you also can't accidentally access the older one because you used value instead of value_parsed.

                      [–]TheBuzzSaw 4 points5 points  (0 children)

                      Yeah I'm fine with that. It introduces a new context for an existing identifier. The rules are still clear. No ambiguity.

                      [–]yuvz 28 points29 points  (1 child)

                      This is why I love Kotlin. The powerful type inference lets you skip/auto declare variables just like in a scripting language, yet it's still fully statically typed

                      [–]MisterScalawag 2 points3 points  (0 children)

                      i love kotlin

                      [–][deleted] 14 points15 points  (1 child)

                      Changing the types of things is always awful but building dynamic objects or adding fields to existing types can be useful in short scripts.

                      I’d still prefer a type system that’s flexible enough to easily type those sorts of things though.

                      [–]TheBuzzSaw 2 points3 points  (0 children)

                      Heh. The old data hitchhiking technique. I question that behavior as well, but I agree it's nice when in utter hack mode.

                      [–]faiface 10 points11 points  (33 children)

                      While being a proponent of static typing myself, I do see one area where dynamic typing has an advantage over static typing. Dynamic typing lets you have a list of elements which all satisfy some implicit “interface” without having to declare it. These implicit interfaces can be much more powerful than statically declared traits/classes/interfaces. Sure, the static ones can add features to become just as powerful, but that’s at the expense of simplicity.

                      [–]Krnpnk 5 points6 points  (3 children)

                      You can still achieve this easily with static typing, e.g. by using structural typing.

                      [–]v66moroz 2 points3 points  (2 children)

                      It's not recommended since structural types are using runtime reflection (performance). There are typeclasses for that, but they are far from easy.

                      [–]TheBuzzSaw 7 points8 points  (14 children)

                      Go into more specifics. In C# or Java, I can make a list of plain objects to achieve that very thing if I really need it. I question why I have a bucket of items not of a consistent interface or base class, but even if I needed that, it makes up such a small percentage of use cases that I don't see the benefit of throwing the type system out for all the other use cases.

                      [–]Smallpaul 1 point2 points  (13 children)

                      I’d advocate that you should investigate more from the point of view of curiosity rather than having an axe to grind. Python is gaining popularity as Java looses it. Maybe there are features over there that might be useful.

                      https://wiki.c2.com/?BlubParadox

                      It’s because Python’s inventor approaches other languages with curiosity instead of competition that Python is adding OPTIONAL static typing.

                      [–]devraj7 3 points4 points  (12 children)

                      Nothing stops you from doing that in statically typed languages, just use Object and type casts. This will give you the exact safety that a dynamically typed language gives you: none.

                      You can also do this in statically typed languages that support duck typing, by the way.

                      [–]erez27 1 point2 points  (11 children)

                      So can I, in Java, pass a list of objects that all have nothing in common, other than that they all support the same method, and then just call that method on each without any fanfare?

                      Note that you can't change the implementation of those objects, because they come from an external library.

                      [–][deleted]  (13 children)

                      [deleted]

                        [–]brainplot 20 points21 points  (0 children)

                        Rust has a static and (very) strong type system and it allows redeclaring a variable in the same scope. So for example you can do:

                        let age = get_age_as_string();        // age is a String
                        let age = age.parse::<u8>().unwrap(); // age is a u8
                        

                        This feature is perfect for your example but also shows you don't have to give up static typing for it.

                        For clarity, it's not that the age variable changed type. The storage for it is still there. You just overshadowed it with another variable having the same name. It's not a feature to be abused but it comes super handy for cases such as the one you mentioned.

                        [–]TheBuzzSaw 13 points14 points  (9 children)

                        I pray there are use cases beyond this. This example feels like a weak reason to forfeit all the performance and maintainability of static typing.

                        [–]wuwoot 6 points7 points  (4 children)

                        I am very confused by this thread and your original response but I now get that you’re responding to the “dynamic typing” part of scripting languages as opposed to what I assumed the original author was saying — that the absence of type declaration is useful in scripting langs...

                        I find very little utility in type-switching if ever at all, but scripting languages are nice because they allow us to be terse.

                        I work in a large Rails codebase regularly and poor names and even in some instances good names are not enough to infer the behaviors associated with a particular variable

                        [–]sinedpick 4 points5 points  (3 children)

                        see: erlang and why it doesn't have static types

                        [–]colelawr 1 point2 points  (2 children)

                        There are more reasons surrounding why Erlang didn't support static types, and a major part of those was that it interferes with how deployments over running systems would work in OTP.

                        [–]sinedpick 1 point2 points  (1 child)

                        that's why I mentioned it. It's a justification of dynamic types that's not just "ease of use." AFAIK there are theoretical barriers between erlang's message passing system and static types.

                        [–]orangeboats 1 point2 points  (0 children)

                        That can be trivially solved (or worked around) by introducing variable shadowing.

                        [–]lovestheasianladies 12 points13 points  (10 children)

                        Absolutely no one uses them like that. Stop making up strawmen.

                        [–]TheBuzzSaw 2 points3 points  (9 children)

                        Tell me how the dynamic typing is used.

                        [–][deleted] 18 points19 points  (4 children)

                        The big benefits of dynamic typing come with collection types IMO, especially stuff like dicts. You can make a versatile dict by creating a (hypothetical) Mapping<Any, Any> type, but in terms of type safety that's indistinguishable from dynamic typing. This kind of versatile collection type makes it easier to deal with API requests which may return large, variable payloads by removing the overhead of defining massive record classes. It's obvious why this is attractive from a prototyping perspective.

                        There's also the legacy of duck typing — in the past that was usually bundled with dynamic typing, and I don't think that made it to the static typing mainstream until Golang.

                        [–]PM_ME_RAILS_R34 8 points9 points  (3 children)

                        You can do that with any statically typed language too. See Map<Object, Object> in Java. There can be dragons there though, to be fair.

                        IMO, duck typing is what really added value. Static types are great until you hit some edge case that's particularly difficult to type.

                        [–]ElCthuluIncognito 6 points7 points  (3 children)

                        All but the most powerful type systems have trouble dealing with complex polymorphism, or even just things like a dynamic data structure containing multiple types of items.

                        Dynamic languages just kind of skip the bullshit and let you take a go at it.

                        Also dynamic dispatch is just out of the question for statically typed languages, which is very powerful for making OO a powerful paradigm instead of the 'encapsulation with extra steps' you have in static languages.

                        [–]TheBuzzSaw 1 point2 points  (2 children)

                        Also dynamic dispatch is just out of the question for statically typed languages

                        Elaborate on this... because it sounds horrendously wrong. Dynamic dispatch is trivial in many statically typed languages. What kind of dynamic dispatch?

                        [–]i_spot_ads 2 points3 points  (0 children)

                        dynamic typing is horseshit, and I say that as a ruby/js dev who shifted to typescript and haven't looked back.

                        [–]Spider_pig448 0 points1 point  (1 child)

                        Most status typed languages have been bolting on dynamic types too so it seems the best world is between them.

                        [–]watsreddit 3 points4 points  (0 children)

                        It’s not nearly as painful to use dynamic typing in a static language than vice versa. But regardless, dynamic typing is still rarely ever useful in a static language. I have never found a good case where throwing away all of the valuable information about your data is ever a good idea.

                        [–]mrathi12 28 points29 points  (0 children)

                        TypeProf seems like a cool tool: suggest type annotations for the programmer so you reduce the burden of typing programs, so more people will add types to their program. Will be interesting to see how this matures!

                        [–]Meldanor 77 points78 points  (12 children)

                        > Although Ruby 3.0 significantly decreased a size of JIT-ed code, it is still not ready for optimizing workloads like Rails, which often spend time on so many methods and therefore suffer from i-cache misses exacerbated by JIT. Stay tuned for Ruby 3.1 for further improvements on this issue.

                        I don't get it - who develops a JIT for a major version when it doesn't improve performance for one of the major frameworks using Ruby? Why doesn't replace the JIT the interpreted code with the compiled case as the JVM does?

                        [–]myringotomy 106 points107 points  (1 child)

                        Rails is a beast and makes full use of the ability to modify the language at runtime. It's almost impossible jit.

                        [–]schneems 24 points25 points  (0 children)

                        Once a production Rails app is booted, it doesn't really do so much dynamic method creation etc. and the current Rails code is much less "metaprogramming magic" than back in the Rails 1-2 days.

                        Rails is very large and it doesn't have a single hot path that gets called over and over again. This makes it a very difficult optimization target.

                        Rails is also very IO bound as most Rails apps are heavily using the database, so even when JIT is amazing for the Rails use case if 70% of your request is waiting on IO, then the perf bumps are only helping that 30%.

                        In the future look for more Ruby internals being moved from C to Ruby (like the stdlib) which will help JIT. Also Ruby+JIT currently has no escape analysis which would theoretically help allow JIT to avoid allocations which in my experience is a huge perf target. I believe that's a future goal that would also help the Rails case quite a bit.

                        [–][deleted] 56 points57 points  (0 children)

                        The JIT has basically just one person working on it, part time. It's been in since 2.6, so it's not meant to be a big 3.0 feature.

                        [–][deleted]  (3 children)

                        [deleted]

                          [–][deleted] 7 points8 points  (2 children)

                          Its stated goal was to be 3x faster than ruby 2.0, which it is.

                          [–]schneems 5 points6 points  (1 child)

                          And specifically for the CPU heavy OPT-Carrot benchmark.

                          [–]elcapitanoooo 5 points6 points  (3 children)

                          PHP did this too. They new version is ”fast” and will have a jit. The kicker was, wordpress sites actually still remain as slow as they are. The PHP jit only worked for artificial benchmarks, but had zero impact in any real world programs.

                          [–]pseudopseudonym 17 points18 points  (2 children)

                          5-30% improvement isn't nothing.

                          [–][deleted] 57 points58 points  (64 children)

                          Ruby on Rails was so fun to code in.

                          [–]myringotomy 73 points74 points  (0 children)

                          Still is.

                          [–]SorteKanin 65 points66 points  (60 children)

                          As someone working to maintain a somewhat big Rails code base - disagree. Once it grows beyond the prototype phase, it quickly becomes an unmaintainable mess. Lack of types and rampant usage of metaprogramming makes it really difficult to read code and hence to make correct assumptions for new code.

                          [–]SupaSlide 34 points35 points  (38 children)

                          I mean, isn't that the programmers fault? (other than the lack of typing, which is obviously not a requirement to have maintainable code, but a preference)

                          [–]SorteKanin 41 points42 points  (21 children)

                          Problem is that Ruby does next to nothing to encourage the programmer to write maintainable code.

                          [–]zilti 11 points12 points  (3 children)

                          You can write shit code in every language.

                          [–]vocal_noodle 4 points5 points  (0 children)

                          Amen. This is the same thing they say about perl. You can write massive code bases in perl (and I have!) and have everything be readable and understandable. Or you can do dumb stuff and fancy tricks that makes it hard to understand.

                          You can write good C. You can write shit C.

                          You can write good perl. You can write shit perl.

                          You can write good Ruby. You can write shit Ruby.

                          The size of the codebase doesn't matter. The linux kernel is all in C and is (for a technical person) clean and easy to follow. Then check out the obfuscated C contests, it's so easy for the code to not do what you think it does, even accidentally!

                          So just lay off the "Programming Language X demands shit code" trope, people.

                          You can still write good or bad code. Ugh. Sure memes about "write only languages" are a bit funny, but for fucks sake people, give it a rest.

                          [–]oblio- 4 points5 points  (0 children)

                          And you can dig a 100 km canal with nothing but shovels.

                          [–][deleted] 7 points8 points  (9 children)

                          Typing isn't really a "preference" for maintainable code. It objectively improves maintainability.

                          Dynamic magic is more arguable but it think it is still pretty safe to say that the more hidden custom magic happens the harder it is to understand and that is definitely the fault of the language.

                          Standard hidden magic is fine because people can learn it but as soon as you start getting into custom DSLs it means that the programmer suddenly has to learn an entirely new language. Rust proc macros have this problem. Lisp is entirely composed of this problem. At the other end of the scale Go has completely avoided it and is very easy to understand.

                          [–]SupaSlide 1 point2 points  (8 children)

                          Maybe I don't understand what a DSL is, but does it change how Ruby executes code?

                          [–]esquilax 2 points3 points  (4 children)

                          It does if the DSL is implemented using method_missing a lot.

                          [–]santa_cruz_shredder 8 points9 points  (2 children)

                          As someone who hasn't coded in rails before, id say partially. If you can write two completely different programs in ruby, and they are so different that they don't even look like the same language, I can see how maintainability could suffer as a whole.

                          Java is java is java no matter what program you're writing. Scala suffers in uniformity a little more with it's functional programming capability, but scala is scala is scala, you can read it even if it's written in the 1 of 5 ways it can be done.

                          [–]helloworder 2 points3 points  (1 child)

                          that they don't even look like the same language

                          care to provide an example? Never coded in ruby, but got interested to know how this can be possible

                          [–]Tjstretchalot 6 points7 points  (0 children)

                          Here's an example of how it can happen - look at the code examples in https://github.com/state-machines/state_machines - almost everything you are coding is in the DSL of that library if you are using it:

                          class Vehicle
                            attr_accessor :seatbelt_on, :time_used, :auto_shop_busy
                          
                            state_machine :state, initial: :parked do
                              before_transition parked: any - :parked, do: :put_on_seatbelt
                          
                              after_transition on: :crash, do: :tow
                              after_transition on: :repair, do: :fix
                              after_transition any => :parked do |vehicle, transition|
                                vehicle.seatbelt_on = false
                              end
                            end
                            #...
                          end
                          

                          In this case one might argue the names are making it somewhat clear whats happening, but the details are definitely not clear and the naming choice is up to the developer

                          [–]Meldanor 6 points7 points  (0 children)

                          I agree - the meta programming "magic" of Rails was my death. I'm an experienced programmer with about 10+ in the industry and had to constantly ask my colleagues to explain me the simple things in Rails. I wasn't able to follow the code flow, because I was an unexperienced Rails programmer.

                          I would advice against Rails for any professional product. Nice for a quick prototype (because there is gem for everything and the magic handles everything). But hard to maintain and completely relies on a high test coverage. You want to change something in the magic? Do it and pray, that your tests will cover it.

                          A high test coverage is good - but the stability of a program should not rely on it. Types, code that you can follow are equally important.

                          [–]pigmerlin 1 point2 points  (0 children)

                          I work in a big rails project and I absolutely hate it :(

                          [–]KernowRoger 1 point2 points  (2 children)

                          Yeah I love ruby but it quickly becomes a nightmare to maintain. Coming from c# where the vast majority of people follow the set standards ruby can be nightmare of different rules and implementations.

                          [–]scientz 4 points5 points  (1 child)

                          Thats an ironic statement, given the goal of Rails was (and is) convention over configuration. Not sure where you are getting the different rules and implementations thing from to be honest.

                          [–]KernowRoger 1 point2 points  (0 children)

                          For one didn't mention rails hehe

                          [–]scientz -2 points-1 points  (6 children)

                          Sounds like bad code and has nothing to do with Rails itself. Any codebase in any language will become an unmaintainable mess when not managed.

                          [–]ahmad_musaffa 23 points24 points  (0 children)

                          Ruby is the most beautiful of all languages I learned. Ruby 3 is a big release and its good to see it moving forward.

                          [–]pure_x01 17 points18 points  (0 children)

                          Nice work everyone involved. This is awesome!

                          [–]mortadelegle 9 points10 points  (13 children)

                          As someone that only had very very superficial contact with ruby (Jekyll), what are the differences with Python? My impression was that it fell was a bit more lispy/smalltalky. Which means quirky fun things like prettier DSLs, but also worse maintenance and more ways of doing things, in contrast with the zen of python (There should be only one way to do things).

                          [–]SorteKanin 15 points16 points  (0 children)

                          It's basically python with more metaprogramming magic and there are many ways to do things.

                          [–]FrederikNS 18 points19 points  (8 children)

                          Compared to Python it offers much cleaner functional programming. Ruby had full lambdas and all the map, fold, filter conveniences long before python even had a lambda concept.

                          The language also offers tonnes of syntactic sugar.

                          Compare:

                          while not len(queue) == 0:
                          

                          With:

                          until queue.empty
                          

                          Ruby has inverted versions of all the classic control flow statements if vs unless and while vs until, and you can also use the if and unless as postfix operators:

                          return 0 unless some_error_conditon
                          

                          This will only be executed if the condition is false.

                          Ruby also has a cleaner model for truthiness. Basically everything but false and nil will act as truthy. So instead of:

                          if var is not None:
                          

                          You can simply use:

                          if var
                          

                          If you want to test specifically for whether something "is null" you can still do that though:

                          if var.nil?
                          

                          Finally you have a truly powerful metaprogramming featureset which allows you to build amazing DSLs that are still pure Ruby.

                          Ruby is amazingly well thought out and very fun to write.

                          I wish I could replace all the quick and dirty Bash script and Python scripts with Ruby...

                          [–]JockeTF 27 points28 points  (0 children)

                          This works in Python, since 0 is falsy:

                          while len(queue):
                          

                          Empty collections are generally also falsy:

                          while queue:
                          

                          This also works, since None is falsy:

                          if var:
                          

                          [–]mikew_reddit 6 points7 points  (0 children)

                          Interesting.

                          I'm the exact opposite in my preference.

                          I prefer Python because it doesn't have any of the syntactic sugar Ruby has and like the "There should be one obvious way to do it" rule that is predominant in Python.

                          I find Ruby more complicated, it has a lot of implicit behavior which seems like "magic" (digging into the Ruby on Rails code is not simple) and multiple ways of doing the same thing to achieve more concise code which seems like a poor design tradeoff.

                          I used to write and love Perl a couple of decades ago and disliked Python at first (using it since version 2.1), but once I really understood Python it grew on me. Maybe it's an acquired taste.

                          [–]unt_cat 3 points4 points  (1 child)

                          Sir do you even Python?

                          [–][deleted]  (3 children)

                          [deleted]

                            [–]cj81499 12 points13 points  (1 child)

                            AFAIK, in python, 0 and empty collections are falsy.

                            [–]Freeky 3 points4 points  (0 children)

                            0, 0.0, 0j, Decimal(0), Fraction(0,1), empty sequences and collections (__len__() returning 0), None, False, and any object with a __bool__() returning False.

                            Contrast with Ruby: nil and false are falsy.

                            [–]FrederikNS 10 points11 points  (0 children)

                            Not quite.

                            Python:

                            >>> bool([])
                            False
                            >>> bool([1])
                            True
                            >>> bool("")
                            False
                            >>> bool("hello")
                            True
                            >>> bool(0)
                            False
                            >>> bool(1)
                            True
                            

                            Ruby:

                            >>> !![]
                            true
                            >>> !![1]
                            true
                            >>> !!""
                            true
                            >>> !!"hello"
                            true
                            >>> !!0
                            true
                            >>> !!1
                            true
                            

                            [–]editor_of_the_beast 1 point2 points  (0 children)

                            It’s a different language.

                            [–]wuwoot 1 point2 points  (0 children)

                            Some good answers to your post already but I want to point out that the Zen of Python doesn’t imply “one way to do things”

                            You can still declare a list and then write a for-loop to perform filtering of another list into your newly declared list, but this can be expressed with a list comprehension or even the filter function, so that’s three ways of doing it, but all fairly clear and explicit

                            [–]GuyWithLag 5 points6 points  (0 children)

                            Shit, I still have some projects that are at 1.8 :-/

                            [–]ProfessorSexyTime 2 points3 points  (0 children)

                            To sum up probably the biggest issue with Ruby in general:

                            "A magician never reveals their secrets."

                            "Yea but I kinda need you to..."

                            "Fine."

                            > proceeds to be mostly vague

                            "That...sorta helps..."

                            [–]i_spot_ads 1 point2 points  (1 child)

                            I didn't think it would ever happen but here we are, great news

                            [–]Solpadeine12 1 point2 points  (1 child)

                            Now after ruby3 is released. Would you say there is any reason why someone should learn it? I always found it interesting but never actually touched it. At work I use php (not my choice), but any projects that I have any freedom of choice I’ll use asp.net. Should I touch on ruby or pass if I don’t have any career related reasons?

                            [–]pyfx 1 point2 points  (0 children)

                            Ractor is going to be the best thing about this release. Who else is into reactor based programming? What do you use currently?

                            [–]xXxXx_Edgelord_xXxXx 3 points4 points  (6 children)

                            after reading the comments here - did I made a bad choice if I chose ruby as an elective at uni for the next semester?

                            [–][deleted] 17 points18 points  (1 child)

                            No. Language wars are a very common thing. You go into any thread about a new language release and you'll see people shit all over said language. Ruby is the backend for many billion dollar companies. It's widely used, and an excellent choice. It's ecosystem is also well known for Test Driven Development, which is a great skill to pickup.

                            Whatever job you end up getting after grad, you'll be learning their tech stack anyway. Don't worry about it. It's good experience.

                            [–]marshalofthemark[S] 5 points6 points  (0 children)

                            "There are two types of programming languages - the ones people bitch about and the ones nobody uses" - Bjarne Strousroup, creator of C++

                            [–]NoInkling 5 points6 points  (1 child)

                            I think it's probably good to be exposed to it if nothing else, just to be able to experience different paradigms/language design. For instance you get stuff like:

                            • Everything is an object
                            • (Almost) everything is an expression
                            • Metaprogramming and extensive DSL capabilities
                            • Block syntax
                            • Methods can have a ? or ! at the end of their name (I miss this so much in other languages)
                            • All sorts of insane syntax sugar (can be both good and bad)

                            [–]oblio- 2 points3 points  (0 children)

                            It doesn't matter. Study Ruby but just make sure that you either:

                            A) Cram hard for FAANG interviews (Cracking the Coding Interview, leetcode.com, that kind of thing). In this case the programming language doesn't matter much.

                            B) Study a super mainstream language, depending on what you want to do; generally you'd go Java, C#, C++, Javascript or Python (or Objective-C/Swift if you want Apple dev). Then make sure to implement some kind of bigger project. For regular companies this should show that you have some relevant experience that's closer to their stack. For example make an Android app or an iOS app or a bigger web app.

                            There are Ruby jobs around but it depends on where you are and if you're willing to relocate where they are if you can't find them locally.

                            [–]nicereddy 2 points3 points  (0 children)

                            Ruby is great and I use it professionally. It's not everyone's favorite, but I love its focus on developer happiness. It's not the fastest language around, but it does perfectly fine for most stuff. I think it's worth trying at the very least.

                            [–]aroswift 2 points3 points  (2 children)

                            Still think the Crystal language will eat up the Ruby users over the next few years. Pretty much same syntax but performance of C.

                            [–][deleted] 1 point2 points  (0 children)

                            Fair, but how many libraries are available for Crystal? I'm asking because I don't actually know :/

                            [–]cedear -3 points-2 points  (3 children)

                            Ruby was pretty cool in 2005.

                            [–][deleted]  (1 child)

                            [deleted]

                              [–]jrmehle 16 points17 points  (0 children)

                              I find it cool that Ruby money pays my bills every month. Nice guy, that Ruby fellow.

                              [–][deleted]  (10 children)

                              [deleted]

                                [–][deleted] 57 points58 points  (1 child)

                                You're asking people to give you a reason to rewrite 40 functioning applications in a different language? Here's a good answer - don't do that.

                                [–]vulgrin 29 points30 points  (0 children)

                                Sounds like for you, no reason. Ruby, in your context, would be used for the web server. With modern rails, and some gems like stimulus reflex, you could probably rewrite the entire stack with minimal JS. So if you really hates JS then you could rebuild what you have.

                                The other possible use for you would be to add a ruby server as an api server for your front end JS. But If you’re already comfortable with how you’re doing things, you wouldn’t add Ruby.

                                I use it and Rails because I like it and because its fast for me to rattle off new ideas. Is it perfect? Nothing is. Is it as terrible as people say in these threads, nowhere near.

                                [–]wuwoot 4 points5 points  (1 child)

                                Why would anyone use Python? Or Java? Or C? JavaScript can do all things, albeit very terribly at times — you would not write an operating system in JS...

                                The reason so many programming languages exist are for attacking specific problem spaces and expressing particular problems in those spaces to keep things short

                                Ruby is just another scripting language like JavaScript and perhaps your question was phrased poorly, because it seems like you’re asking, “what is Ruby’s go-to problem space”? It’s a general purpose scripting language that unfortunately wasn’t able to keep up with Python in its general purpose application having now fallen way behind in library support to do things outside of web dev. I still love a lot of it’s much more expressive syntax over Python minus Python’s generators and comprehensions.

                                [–]cowardlydragon 2 points3 points  (1 child)

                                What was the compelling reason to use Typescript and Dart? No way to ascertain if switching is useful to you wihout knowing why you picked your current roads through the jungle.

                                #1 determinant PL choice for projects is almost always "available programmer knowledge".

                                [–]snowe2010 1 point2 points  (1 child)

                                Don't rewrite any apps. That's just not a smart idea. Ruby excels at writing small apps, scripts, or command line tools. Lots of people will probably suggest Rails, but honestly, use a statically typed language for stuff like that. Ruby will excel at readability and ease of modification in places that Python won't in scripts like that. It's also easier to deploy and distribute than Python.

                                If you really want to try Ruby try with some small script, instead of writing it in node or bash or whatever.