39 ms·
Ruby Is Still a Diamond
- dzonga 5y agoruby is a still a pleasurable language to use. it's simpler than python. rails for crud stuff is gold standard alongside django. at least in the ruby world, there isn't much momentum compared to most languages of adding static typing though things like sorbet exist. in the js world the typescript folks came in, the dynamism of js is disappearing
- pjam 5y ago> the dynamism of js is disappearing As an outsider, really curious to hear more about this. Is it from an ecosystem point of view, where the "dynamism is disappearing" or more from a day to day, the fact that writing TS is significantly different than writing JS? Or even something else?
- zdragnar 5y agoThere are a few patterns that TS simply cannot or is too painful to handle. I still have no idea how to define a class the old way with prototypes in Typescript, which I really only discovered when I ran into some edge cases around how static members and methods in the new class syntax were typed. You also lose the "type out code really quickly without thinking too hard about it" and the thrill of wondering if it'll work when you load the page.
- dzonga 5y agowith dynamic language and yeah a multi-paradigm language like js, means you can come up with patterns a compiler can never expect. because javascript is so flexible, your code ends up like a mini dsl yet still remains readable javascript. with typescript, you won't have much flexibility. you lose a lot of productivity fighting the tool i.e typescript compiler
- platz 5y agoThe dynamism of creating functions that happily take an object, or an array or a string (never detailed thouroughly in the documentation, of course) and then does different things based on which one you got, was always teleogically a dead end.
- __s 5y agoNot sure how you conclude it's simpler than python. Different precedence of !/not has burned me in the past. Symbol/String keys have burned me. Module/Class (Python has this to some extent, but you don't declare modules so it doesn't come up), block/proc, fail/raise, extend/include, case/when can be used for bool expressions or instanceof checks I enjoy ruby, & it's nice once you get that every property access is a method call ("it's all message passing") which has nice dynamism (see Sequel) Maybe you can argue Ruby does a better job not leaking its abstractions (no __slots__ etc)
- sigzero 5y agoRuby is not "simpler than Python".
- cupofjoakim 5y agoA counterpoint is nothing without argument. Care to elaborate?
- WJW 5y agoRuby occupies a similar space to Golang in my mind, where it is "just" a solid business oriented language that gets out of your way. It will never wow you like Rust or Haskell and that is fine, because that is not what it is aiming for. Rails is one of best DSLs for writing simple SAAS apps, too. That said, different usecases require different languages. I would never use Ruby for a compiler project.
- JohnWhigham 5y agoGo has Google support behind it though. Its journey is far from over (that is, until Google abandons it for another language), whereas Ruby's/Rail's growth phase is more than a decade behind us, and it's hard to know what its future holds. I hope it's a good one since I've been doing Rails my whole career.
- MattGaiser 5y agoFWIW, I had a call with a recruiter a couple days ago who claimed that the most expensive candidates to find at the moment are Rails people. And I'm not a Rails person, so it wasn't flattery.
- JohnWhigham 5y agoI've noticed that as well, that senior Ruby/Rails people will become very valuable in the coming years, which is good to hear. However, 10+ years into the future is the real scary part. Will jobs dry up so much so (especially due to the accelerating pace of tech turnover) that Ruby/Rails will essentially become the FORTRAN of the times? Who knows.
- MattGaiser 5y agoDo companies care about about tech turnover? I have friends everywhere from FAANGMULA to Deloitte to 100 person tech startups (and I am at one myself)to banks. We have a group chat of classmates. No attempts to stem the wave of resignations anywhere as far as we can tell.
- mattgreenrocks 5y agoI love Ruby's syntax (even if the parser is a nightmare of special cases) and overall feel. But, I have no reason to use it because I really don't like using Rails. Rails remains one of the few libraries/frameworks that I just don't get along with.
- BilalBudhani 5y agoThere is Hanami (https://hanamirb.org/ https://hanamirb.org/) web framework which could try if Rails bothers you.
- mattgreenrocks 5y agoHanami has progressed quite nicely. I may give it a try! Thank you.
- goatlover 5y agoIs Sinatra too bare bones?
- lovegoblin 5y agoAn old joke: any sufficiently advanced Sinatra app is indistinguishable from Rails.
- tinnet 5y agoMany systems using other “preferred languages” also implement some form of GIL (e.g., Javascript’s V8 machine, CPython); we don’t hear complaints about it, because these languages have a rapport for heavy lifting and parallel tasks. As a python developer i almost fell off my chair when i read this section. We don't hear complaints about the GIL in python? I love the article's tone in general but that's some heavy Gell-Mann Amnesia or filtered news sources :)
- deleted 5y ago[deleted]
- goatlover 5y agoThere's scarcely a Python thread on here that doesn't mention the GIL. Or version 2. Or whitespace. It's like generics for Go and framework churn for JS.
- shuckforjustice 5y agoHey guys, I'm the author of this article and I have been rueing the day I ever said this. I have since received complaints and/or restraining orders from a number of Python developers. I truly apologize, that one is on me, I made a classic mistake of writing about what I hear about instead of what's actually out there, for which I repent. We live and we learn! This is my first article so I gotta start somewhere. I've edited the article to avoid further contact with rage-filled Python devs: "Note: Many systems using other “preferred languages” also implement some form of GIL (e.g., Javascript’s V8 machine, CPython). Python has a reputation for heavy machine learning lifting and parallel tasks. However, when it comes down to actually looking at the benchmarks, the constraints, and the underlying implementations, its quite hard to pull out any statistically significant metric or distinction between how Python and Ruby handle these tasks — what Python has in advantage over Ruby is its popularity, vast library, and very active data-science community, moreso than any benchmark. Ruby is a little faster in some things, Python is a little faster in others. Edited: I previously had a line in here saying that we “don’t hear about” Python’s GIL, to which I received a number of messages from Python developers who assure me that it is all they talk about. Sorry Python!"
- nixpulvis 5y agoI'd be curious to have a good example of when to use a Fiber vs a Ractor in Ruby. I'm assuming it's much much faster to spawn a Fiber? Or am I missing something?
- chrisseaton 5y agoFibres are best for concurrency. Ractors are best for parallelism.
- jrochkind1 5y agoIn actual practice... ractors are kind of still new experimental technology, that are hard to use if you are using any existing gem code. And fibers are not new, but also can be hard to use and aren't super popular in general use. So the practical answer is you probably won't use either. :) But one way to explain the difference is that fibers are basically for cooperative/evented concurrency, while ractors are a new invention that are more like (OS native) threads but without shared memory.
- ComputerGuru 5y agoThis is a really fluffy article devoid of real technical content. It does not sound like the author fully grasps all the concepts discussed, especially in the section on parallelism and concurrency. > Many systems using other “preferred languages” also implement some form of GIL (e.g., Javascript’s V8 machine, CPython); we don’t hear complaints about it, because these languages have a rapport for heavy lifting and parallel tasks. GIL is the biggest performance obstacle for python and is constantly discussed. JavaScript is notorious for being exclusively single threaded (unless you consider the very late arrival of workers to be true multithreading).
- pavlov 5y agoJavaScript is single-threaded, but in the most popular runtimes, almost all I/O is event-based. This is a great difference from Ruby where library functions are blocking (or at least were when I last used the language many years ago). A single thread of execution for scripts isn't so bad when those scripts are all relatively small callbacks.
- ComputerGuru 5y agoYeah, it's fine for "reactive" processing but not for anything where you'd actually spin up a separate thread (or use a threadpool thread) in a lower-level language - i.e. to perform cpu-intensive calculations/computations in parallel. In practice, JS being single-threaded isn't an obstacle for the uses the developers using JS are after. It doesn't sound like Ruby 3 affords the same with its GIL (but all I'm going off of is TFA).
- shuckforjustice 5y agoHey! I'm the writer of the article. I'm not a fantastic writer but am trying to improve and felt I needed to start somewhere, so I started with something I'm passionate about. Truth be told I do not know as much about Python as I do about Ruby, I think I was probably responding to its comparative popularity and not in fact if it is discussed about or not, so that's on me. I'd like to know more about what you would have liked to see in an article like this, it is a bit of a fluff piece; the goal wasn't to provide a super technical explanation. The goal was to get people talking about Ruby 3 and I am happy to see so much discourse here! But yeah, I was asked by the maintainer of the blog to try to provide "layman's explanations" when I could, which I think may have kneecapped me a bit in retrospect - but obviously layman's explanations usually are best when they are succinct and accurate. Is there anything else, particularly in the layman's examples for parallelism and concurrency, that felt inaccurate or misleading? I want to make sure I am communicating the concepts and implications correctly. From my perspective, the goal of the article is provide an explanation of concurrency/parallelism, so that when I begin to describe the features in Ruby 3.0 we have appropriate context to understand why fibers/ractors matter, so if I didn't do that I really bungled it!
- tristor 5y agoI still enjoy writing Ruby, and while I consider myself a rather rudimentary programmer, I do regular exercises to maintain my skill in Ruby so that I can use it to get things done. For many years, Perl was my go-to language for getting things done, and Ruby has fully supplanted that. For some of the things I used to reach for Ruby to do, I now use Go, but for the most part it's now all Ruby. One of the things I love about Ruby is that you can do very powerful things with minimal code, while still having it be understandable. The way metaprogramming works in particular is fantastic. I also like that Ruby provides an escape hatch to do horrible but necessary things (backticks), which lets me utilize existing hacky scripts and build upon them, without needing to rewrite everything to include it.
- bdcravens 5y ago> while I consider myself a rather rudimentary programmer You missed an opportunity for a amazing pun :-)
- FigurativeVoid 5y agoThe company I work for re-implemented out entire platform with Ruby on Rails. Even though it's not super new, everyone has really fallen in love with ruby. The gem ecosystem and the community are great. Ruby is an absolute joy to program in.
- codeduck 5y agoRubygems is one of the best packaging systems I've used.
- FigurativeVoid 5y agoWe use Devise. The fact that it's free and open source blows my mind. It's some incredible software.
- switch007 5y agoWhat was it written in prior?
- FigurativeVoid 5y ago.NET / VB6
- zionic 5y ago> Ruby is an absolute joy to program in. Really? At my company it seems like 90% of the tests are catching things that would be caught automatically if we had used a proper language with strong types/compiler. IMO Ruby is slow, not particularly beautiful (yes, this is subjective), and seems optimized for shoving crappy REST endpoints out the door as quickly as possible.
- pmontra 5y agoDo you really need those tests? We are testing validations, CRUD operations, states, border conditions. Sometimes an integration test is enough to validate at least the happy path and catch any mismatch between passed and expected arguments: if we are passing a string instead of an array of strings somewhere, the test will fail.
- 41209 5y agoIs it just me or are Ruby and Python cousins. I really really didn't like Ruby when I tried to learn it at work , but Python just clicked. I imagine many Ruby programers migrated to Python. Then again, Nodejs started to take off when Ruby declined. I strongly suspect this is due to all the "full stack" positions. Hey Billy, you write all that nice js on the front end, now you can write it on the back end too.
- throw_m239339 5y ago> Is it just me or are Ruby and Python cousins. Not at all, they used to be competitors in the web space but Python won the academia space. Python is taught at university in Europe, Ruby far less. Node.js is a mess, not because of javascript but all these layers of complexity imposed by professional front-end development, and on the server because Node.js standard library is pretty poor. I shouldn't have to use a third party library just to parse a multipart http request or work with cookies... Go in that domain is just examplary. The std lib even comes with a Go parser, which is just invaluable for implementing code analysis tools, and it's very easy to do so.
- wil421 5y agoPersonally I like Python much more than JavaScript but at work I almost exclusively use JS. Recently I’ve been doing stuff in node.js and it does make it much easier to flip back and forth. Still like Python more and I can’t help but put ;, (), and {} all over the place.
- petercooper 5y agoI imagine many Ruby programers migrated to Python. Not my experience being involved with the community. Indeed, there seems to be rather less migration between the two communities than than other languages (e.g. Python + Go, or Ruby + Elixir) probably by virtue of their similar problem spaces and approaches. I'm a Rubyist who also knows some Python and while I admire Python, I certainly prefer Ruby. Python is flexible and fantastic in many ways, but is a far less consistent language in terms of organization (e.g. you use methods for some things, functions for others) which didn't click with me. If you want to do something with an array/list in Ruby, say, 95% of the time it's "arr.method" whereas in Python it might be len(arr) or arr.method, a comprehension, etc.
- 3pt14159 5y agoI wish I could merge the parts of Ruby and Python I like while discarding the parts I don't. Mutable strings by default was a huge mistake in Ruby and so was allowing non-self calls to methods from another method of the same class. Within the class scope, it's great, but it just leads to bugs in the method scope. The things I love most about Ruby over Python is I don't have to memorize as many things. With Python I'm never sure if it is isinstance or is_instance or DefautlDict or default_dict. It's annoying having to constantly lookup things. Oh and how I miss one line if statements and conditional assignment when I'm in Python. One thing I like about both languages is how nice it is to write tests. The patching and the assertions are great.
- throw_m239339 5y ago> I wish I could merge the parts of Ruby and Python I Crystal lang does a bunch of great thing but the poor support on Windows (having to install some Linux subsystem to compile stuff) is a non starter for many companies. I personnally never liked Python's syntax, or OOP, it feels tacked on. However Python's ecosystem is just too huge to be ignored.
- strzibny 5y agoI have the same feeling. Chaining is so much more intuitive in Ruby.
- derac 5y agoYou can write one line if statements in Python. You can also do conditional assignment with the ternary operator. i.e. if True: a = 1 if True else 0
- sealthedeal 5y agoI do love Ruby, my first love, and honestly could be my last. I turned my back on her when I found Node and Go, but as of late I have come to appreciate her simplicity and ease of use. Performance aside, I would re-write our stack in Ruby specifically rails just for the organizational aspect and the fact that Ruby is just so damn pretty.
- robotmay 5y agoI still love writing Ruby. I suspect I probably always will, in fact, and I use it as my system scripting language over Python and the like. It has always made sense to me and I enjoy it being a part of my day-job too. If I need to write something, like a small tool, or an API, or a Prometheus exporter (https://github.com/robotmay/prometheus-aanet-exporter/blob/master/prometheus-aanet-exporter https://github.com/robotmay/prometheus-aanet-exporter/blob/m...), I write it in Ruby. The Prometheus exporter is a good example actually: nobody else seems to write them in Ruby, but I found it easier to make one from scratch than to figure out the pretty obtuse and non-standardised examples written in Go by everybody else. Obviously this won't be true for everyone else, we all have our own favourite languages, but for me it's very rare that I find something that can't be written effectively in Ruby, so I'm happy to keep writing code that way. There's always a lot of arguments about Ruby/Rails performance, but it's actually not too tricky to make it run fast enough for most tasks. It is fairly easy to shoot yourself in the foot I guess, compared to other languages which are natively fast, but there's a downside to all languages.
- codr7 5y agoI totally get what Matz said about threads, and it's also no mystery to me that there are so many GIL's around. Adding threads complicates the interpreter, to the point where I'm beginning to doubt it's worth the effort. For my own interpreters I've had success running separate interpreter instances in their own threads and communicating via channels. This allows multi-threading without making a mess. https://github.com/codr7 https://github.com/codr7
- jerf 5y agoTo amplify your statement, it seems to be borderline impossible to 1. develop a world-class interpreter for over a decade and then 2. retrofit multithreading onto it. I don't have an example of that I'd call successful, where here I'm defining "success" as "the entire community casually uses it whenever it is useful and there are no special warnings to be given about the threading support". There are some implementations, but last I knew they all tend to be sort of dangerous and things the community will warn you away from, and some languages just don't have them. I would be intrigued to see someone try to create a modern dynamically-typed language or interpreter written from the beginning to be threadable, but it seems to me the energy in the dynamic typing community may not be there any more to sustain it. While it's not "dying", I suspect that as static typing is getting better the dynamic typing community is, shall we say, losing the updraft it has ridden these last 30 years. It's not like it's going to crash straight to the ground or anything, but I don't know that there's a whole lot of people chomping at the bit to write such a thing rather than write something static and useful. Especially when you deal with the fact that even the fastest dynamic languages are still ~10x slower than compiled languages on general tasks now, and it's hard to justify going crazy with threading when a single thread in a modern statically-typed language, which may only be modestly harder to write now than with a dynamic language (if that), starts out with such a performance advantage, one that only continues to multiple if the static language also starts spawning threads.
- Scarbutt 5y agoI would be intrigued to see someone try to create a modern dynamically-typed language or interpreter written from the beginning to be threadable There is Clojure, is dynamic and allows for multithreaded programming, courtesy of the JVM. The JVM being a very dynamic system is a good target for new dynamically typed languages. But as you said, they are a hard sell today not only because of performance but more because of static typing.
- febrianrendak 5y agoRuby & Ruby on Rails was my first love, my side projects were always use Ruby, until the performance really hit the point where I can't tolerate it anymore. I moved to Elixir then Golang. But one day I would love to start new project using Ruby 3.0.
- dopamean 5y agoI'd love to hear more about the performance needs of your side projects that made you have to stop using Ruby. I also use ruby for my side projects and have been considering a switch but for other reasons.
- aantix 5y agoWhen it comes time for the Ruby project, try out JumpStartRails. It's just a great skeleton Rails app to begin with. You'll be able to start on the hard problems much sooner. https://jumpstartrails.com/ https://jumpstartrails.com/
- ravenstine 5y agoRuby is a great language if you don't go hog wild with extreme OO ideas and metaprogramming. Unfortunately, in my experience, it's way more common to go hog wild than to just do things in a straight forward way. Before y'all throw tomatoes at me, allow me to make things more confusing... The problem with elegance is that it is mostly about being clever, but cleverness is often a tradeoff for being cryptic and hard to follow for those who don't have context or understanding. Because it is an abstraction, elegance in the form of things like metaprogramming and inheritance hierarchies make the underlying ideas more difficult to understand, not less. Many programmers, including myself at one time, confused the idea of making something abstract as making said thing simpler, but more often than not it is the underlying details that are most important to be able to read and understand as a sequence of instructions and you are abstracting at the wrong level. Languages like Ruby are already so abstract that even just a level of abstraction above what it already provides can make code murky, resulting in lots of "thinginess" but not "this does this, and then this, in order to result in this". I'm not singling out Ruby, BTW, but the topic of the article just happens to be especially vulnerable to the issues that caused me to lose interest in it and OOP in general. I won't go into inheritance other than that I've realized that it's a terrible idea most of the time and that a growing number of programmers agree. Over the years things like Rails have added concepts that lean more into composition, but every single Rails project I've ever worked on was a mess of countless levels of inheritance that makes it difficult to know where behavior is coming from (which is ironic in a way). This isn't necessarily a failure of Ruby but rather its community since countless other languages implement inheritance. There's something about Ruby that encourages overuse of inheritance and so many projects suffer from the pitfalls of it whether the developers are willing to admit it or not. Speaking of the community, I really don't understand the amount of effort they go through to avoid documenting anything. I'm not talking about the language, frameworks, or libraries, since they generally provide great API documentation, but if you are reading Ruby code you are far less likely to find inline documentation or meaningful readme files than in other languages. Strangely, after having used the Ruby language for 8+ years, colleagues still discourage me from adding comments here or there to provide context around why something works the way it does. In contrast, it's rare that I'm ever told not to add inline documentation to JavaScript code by other JavaScript devs. It does happen, but I've really only had that experience one time in my career. Ruby developers buy this line that "Ruby is so expressive that you don't need to write documentation, and the tests will describe anything else." That sounds wonderful but, frankly, I'm not a computer. I don't live and breathe code, and I'm not interested in modeling MRI in my head so I can interpret Ruby code. Even if I did, I doubt it could actually communicate contextual ideas in a meaningful way because that's not what computer languages are designed for, because computers don't understand anything. When you throw in metaprogramming and other dangerous ideas, the "documentation" you are writing effectively turns into a Choose Your Own Adventure book where every page has a 6 line paragraph that rarely finishes a full thought and makes you jump to random pages in the book. I used to not trust the notion that Ruby is slow, and I still think that perspective is overstated, but not in the way a lot of people think. The vast majority of Ruby projects I've worked were much slower than they needed to be and, again, it usually came down to the community not being interested in how to write code in a performant way and understand which parts of the interpreter and standard library are faster or slower. The barrier of entry to Ruby is so low that a big chunk of brand new code is written by junior developers, which is insane but also extremely economical. My first Ruby job paid me $40k (in SoCal of all places!) and although I did achieve some pretty interesting things, I also wrote a lot of crappy code that the businesses didn't care was bad. And they won't ever care until they can't hire anyone to fix the mistakes that were also piled on top of my own, in which case it will all be rewritten with PHP and React. It's astounding just how slow a Rails project can get, not just when it serves HTTP requests but in just starting up the server. JavaScript and Node has its definite faults when it comes to over-reliance on 3rd party packages, but the Ruby world too has a problem with over-reliance on packages; it's just fewer people care because Ruby's package management has advantages over the wild west of NPM. It seems that with every `rails-` gem that gets installed, the speed of everything decreases exponentially and no one bothers keeping track of it. Rather than waste time working towards 100% code-coverage, track performance* and you will save countless dollars in human hours. Ruby seems like a great way for small companies to whip out something great, but has anyone actually figured out whether less time, money, and energy is expended on Ruby projects than on alternatives? Ruby sells itself as being good for productivity, but if it's more often slower than projects that use other languages and frameworks (which is true in my experience), then it's not living up to the promise that people are still buying into. Ruby has an awesome syntax, thus I wish there was a radical shift in Ruby, perhaps a fork, where the great parts of the language that make it especially readable and expressive could be kept while metaprogramming be made highly limited and inheritance impossible. Basically, it should get rid of the things that drag it down in terms of performance and readability and focus on what other languages managed to do right. EDIT: Other thoughts... Oh, and it should be made possible to declare and import modules without automagically bringing them into the global scope unless you `require` them under your own module scope. That way programmers can just write functions and not feel the need to add them under a named module or class scope. Speaking of, the distinction of a method, proc, and lambda should go away and just be replaced with functions that have a binding. They add nothing but confusion, and I doubt most Ruby programmers even know the difference or why it is that they call everything "methods" while other languages have "functions" that can both be methods and assigned to local variables. And yeah, you can kind of do that with procs, but procs really suck. Implicit returns are also... yeah, kinda not worth it and makes things less clear IMO. Again, I actually like a lot about Ruby, but I've never gotten used to implicit returns. I really don't think it adds anything useful to the language and just makes things more confusing for people coming from other languages.
- Zababa 5y agoI wonder, is Ruby with Rails still the best choice if you're starting out and want to build web applications? A few years ago the "new" stack was something like MEAN or MERN but Express doesn't seem to have the productivity of Ruby. If you had to start today, what would you pick and why?