13 ms·
Ruby is the very least favorite of all the programming languages I've had to use regularly over my career. Its syntax strongly favors cuteness over familiarity
by pavlov 8y ago
Ruby is the very least favorite of all the programming languages I've had to use regularly over my career.
Its syntax strongly favors cuteness over familiarity. Wherever Ruby can diverge from expectations to give you a pointless little tickle of whimsical inventiveness instead, it seems to do so.
Visually it looks like an unwanted love child of Pascal and Python. There's no clear rhyme or reason to the use of sigils and keywords.
The standard library and built-in types are acceptable for a mediocre '90s scripting language, I guess. The difference between symbols and strings as hashmap keys is a footgun that opens up endless bugs for the type of glue code that you'd often be writing in Ruby.
Probably the only thing that keeps Ruby afloat is Rails, an extremely resource-intensive web server framework built around assumptions of what web apps were like in 2003. Everything in Rails seems to happen by pooping magic keywords in your code or in file names according to mysterious conventions, so when something goes wrong, you'll have a hell of a time figuring out why Rails isn't calling your code or is generating broken SQL. OTOH it honors the Ruby tradition of doing lots of unexpected and useless cute things like pluralizing words in your database migrations [1].
[1] https://stackoverflow.com/questions/1185035/how-do-i-override-rails-naming-conventions https://stackoverflow.com/questions/1185035/how-do-i-overrid...
- Rooster61 8y ago> Its syntax strongly favors cuteness over familiarity. Funny, I recently made a stack switch from Ruby to Python, and I had the exact opposite impression. Ruby coding style/syntax tends to favor convention over configuration (at least in terms of Rails setup), while Python to me seems less so. Ruby also seems to me a bit more consistent across it's versions. One of the biggest gripes I've had about Python so far is how many things are broken across various versions of the language, and the odd way some issues have been handled (having two distinctly different types of strings with distinctly different syntax according to encoding for instance). Perhaps Ruby simply doesn't offer familiarity to you individually. I'm more comfortable with Ruby as I used it much longer, so I may be biased, and I am not shitting on Python either. It has things I don't particularly dig, but that may be my own bias. Both languages have their pros and cons, and both are certainly viable as scripting languages in this particular epoch of programming.
- sametmax 8y ago> having two distinctly different types of strings You must be talking about Python 2, the deprecated version for 12 years now, with support ending next year. Because last time I checked, current, modern Python only has one type of string.
- deleted 8y ago[deleted]
- Rooster61 8y agoTry passing a std::string in from C/C++ code. It treats it as a byte string, which you have to prepend with 'b', and Python 3 will not do any nice casting under the hood back and forth between the two types. Sure, I am picking out one particular use case, but it isn't uncommon to wrap C code in python scripts to mung data going in and out of it. You are right though. String manipulation does appear to be easier than Python 2's implementation.
- jessedhillon 8y agoYou need to use `Py_BuildValue` with the `s` argument to get that into a python string.
- sametmax 8y agob"" is not "a byte string". It's a raw byte sequence: >>> type(b"foo") <class 'bytes'> >>> b'foo'[0] 102 It can hold any bytes, it just happens that one way to contruct/represent it can be done with a string-like syntax as a convenience for developers. But you can actually built it in another way, or make it hold data in any other format: >>> bytes([102, 111, 111]) b'foo' >>> struct.unpack('I', b'\x01\x01\x00\x02') (33554689, ) Also, std::string is exactly that, a raw byte sequence, with some string operations attached to it. But you don't have any encoding attached to it: https://stackoverflow.com/questions/1010783/what-encoding-does-stdstring-c-str-use https://stackoverflow.com/questions/1010783/what-encoding-do... So it makes sense that Python is treating it has a raw bytes array (what you call "a byte string"): it has no way to know that it is UTF8 or CP850 if you don't tell it. But because of c/c++ experience or habits from python 2, one tends to confuse the concept of text (represented with the type "str" in python) with some specific low level implementation (the raw bytes array). Python explicitly avoid this problem, by defining that either you know what it is (utf8 text, big endian number, etc) or you don't (raw bytes array). Manipulating text as a raw byte sequence manually would be the equivalent of manipulating directly the IEEE 754 representation of a number: it's not what you want for a high level scripting language, and hence it's why Python 3 doesn't do that anymore.
- DFHippie 8y ago>There's no clear rhyme or reason to the use of sigils and keywords. You have trouble with the use of sigils in Ruby? That seems like an odd complaint. I would have expected you to complain more about MINWAN.
- izietto 8y ago"pluralizing words in your database migrations" is ispired by convention over configuration pattern, and comes from an age where there weren't almost any standard rules, even table names were some singular, some plurals, some ALL_UPCASED, some all_downcased, some MiXeD, some dash-erized, some camel_ized, ... I come from that age and it helped a lot.
- lowercased 8y agopluralization seems to be somewhat orthogonal to the "no standards" issue you raise; one could have introduced standard rules to help with that 'wild west' and still left out pluralization. pluralization brings with it runtime overhead and edge cases (which can be dealt with with more runtime overhead, of course).
- calaveraDeluxe 8y agoI'm curious, where does pluralization of table names bring runtime overhead? AFAIK, they are stored in the model and not generated every time they are needed.
- dnautics 8y agoIt does bring cognitive overhead, when it's not explicit
- Karunamon 8y agoBut you’re writing an ActiveRecord migration. It’s explicit in the same way that echoing a string out is ‘puts’ instead of ‘print’ because this is Ruby and not Python.
- dnautics 8y agowhat if you're on a team where your responsibilities are divided and you only touch ActiveRecord sporadically? What does ActiveRecord consider the plural of "fish"?
- evancaine 8y ago> Ruby is the very least favorite of all the programming languages I've had to use regularly over my career. > Its syntax strongly favors cuteness over familiarity How do you define regular? I use both Ruby and JS almost daily, and have previously used Java and python for several years. I find ruby a joy to use and have no issues with 'familiarity'
- pavlov 8y agoIf I used Ruby daily, I'd probably be used to it. Right now it's something I have to touch 2-3 times a week to implement specific features in a fairly large Rails codebase, and it always feels jarring to make the switch from the familiar JS/C++/Obj-C spheres of syntactic overlap.
- Lambdanaut 8y agoWeird. It doesn't feel jarring for me to make that switch.
- throwaway427 8y agoSounds like PHP is perfect for you.
- welliman 8y agoWhimsical inventiveness is the one thing that keeps me enjoying the art of programming. There's a tension in programming between being verbosity and ingenuity. More flexible languages and programmers general favor ingenuity, while rigid ones favor verbosity. When people complain about the "magic" in Rails, it's usually because it's a pattern that is new to them, and they would have preferred an older pattern even if it was a more verbose one. Which is fine, but it is a preference amidst a large spectrum of tradeoffs. Unfortunately, many people tend to not see most tradeoffs in software engineering and try to come up with as many reasons as possible for why their way is right and the other way is trivial, stupid, cute, or useless.
- pavlov 8y ago> "Whimsical inventiveness is the one thing that keeps me enjoying the art of programming." A personality difference then. Reading clever code does nothing for me. I'm much happier digging around hulking layered codebases that may look ugly but do something valuable for the user. I agree that the cuteness of a programming language is just a matter of taste and habit. I'm not going to pretend my criticism was anything deeper than an expression of why I personally dislike having to work in Ruby.
- thekingofh 8y agoI think there's more to it. Ruby, to me at least, seems objectively more difficult to understand intuitively when scanning the code. Maybe it's just a superficial lack of knowledge on my part, but my brain makes base assumptions on how code should work, and whenever something magical happens, it's cool, but slows down the cognitive understanding enough that it seems to me to be a net negative. There's a crossover point where verbosness becomes too much to grok as well. Maybe spending more time in the language raises the bar enough to then become massively more productive. I'm assuming this is the case with Ruby, but I've not given it enough time to make that determination. Python, on the other hand, is immediately understandable to me, and I can jump in and be productive with no previous experience in the language and just an open webpage to the documentation. To each their own, but this is a continuing question for me. The perfect example I think is Perl 6. To me, when I look at everything they're doing in Perl 6, it really does look like the next generation in languages. It's got so many good ideas and insanely helpful constructs. However I'm not so sure if the ability to do things cleverly is a benefit. I look back at Python and see how simple it is and how productive I can be in it immediately and ask myself.. what's the catch. I'd like to use these complex languages for fun's sake, but the alternative is very, very, intuitive.
- DJHenk 8y agoI wholeheartedly agree. My main gripe is that people insist Ruby is 'easy', because it 'looks just like English'. Yeah, well, it doesn't. Programming languages are different from normal languages because they have different goals, different users and different requirements. The result in of this forced unification in Rails is something that resembles English, if you squint really hard, but in order to do so, it uses a massive amount of non-intuitive assumptions (sorry: conventions) that I as a programmer somehow should know. This makes debugging unnecessary hard. Also, when developing new features I'm constant guessing whether I should this or that form. The only way to find out is trying things out. This is fun as a hobby, but irritating when you're on the clock. The idea that a programing language can be unified with a normal language is offensive to me both as a programmer and as a writer. They only benefit is that people who are not programmers can dabble around and still make something useful. Which isn't nothing, but not for someone who programs professionally.
- skywhopper 8y agoI've never heard anyone say Ruby "looks just like English". Do you have a source?
- taf2 8y agoDefinitely look up any of the great talks by "Jamis Buck"
- drstewart 8y agoIt sounds like you're confusing Ruby with Cucumber
- beforedawn 8y agoFully agree.
- skywhopper 8y agoI don't understand your bit about "cuteness over familiarity". Can you give an example outside that's not Rails-related (given that Rails seems to be the main source of your concrete complaints)? Sigils in Ruby actually do have strong and clear meanings. And the difference between symbols and strings is a useful distinction. And contrary to your statement, Ruby's stdlib is far more complete and more internally consistent than what you get from Perl or Python, so I'm not sure what your beef is with that. It's fair not to like particular decisions a language has made, but from what you say, I'm not getting the sense that you understand the decisions Ruby has made well enough to criticize them effectively. Again, it seems like your experience was colored heavily by Rails, and fair enough if that's the case. But stick to criticizing the actual source of your problems.
- pavlov 8y agoYes, maybe my problem is more with Rails. (Because of monkeypatched APIs, it’s not always obvious to me whether a particular weirdness originates from Ruby’s standard library or is a Rails addition. Arguably this is something the language has also encouraged though.) Is there any reason to use Ruby outside Rails? Its niche seems to completely overlap with Python and modern JavaScript, and those have enormously more ecosystem support and everything that comes along with it: faster VMs, better tooling, large corporations on committees developing language features, etc. I view Ruby as a sort of “COBOL of Web 2.0”. A generation of programmers learned the trade with it, and it powers important legacy apps, but I can’t imagine building anything new on it.
- jhbadger 8y agoPython already existed when Ruby came out and before rails was a thing. I understand you don't care for the language but the main reason for its creation was to have a completely object-oriented (in the Smalltalk sense) scripting language which python just isn't. Personally, I like a language where everything is classes and methods and I don't have to remember to use a function rather than a method to get (for example) the length of arrays as I have to do in python
- 8y ago
- vinceguidry 8y agoRails has an answer for the hashmap keys problem, HashWithIndifferentAccess.
- TheRealDunkirk 8y agoSo, I'm old, and have done lots of stuff in lots of languages in frameworks. For about a dozen years, Rails was my go-to toolkit. I've written a couple dozen production applications with it. Unfortunately, Rails has really fallen out of favor lately. Even a Rails-specialty shop I worked for briefly has pivoted to using ASP.NET. I've played around in that stack, and found it lacking. (EF just doesn't compete as an ORM.) However, they've moved on to bigger corporate customers, and those places just don't use Rails. Recently, and because of this same we-don't-"do"-Rails sentiment, I was forced into using Java for a web application. So I prototyped a site with Spring and Angular 6, thinking this -- arguably -- represents the "state of the art" when doing a Java web app. Out of frustration, I also cranked up a prototype with Rails. What was taking me literally 160 lines of Java and JS, to build two related models and a form to edit the relationship, took me 3 lines with Rails. Nothing else I've found allows me to be as productive as Rails for writing web applications. I can understand criticizing Ruby for being clever. There are still magic tricks you can do with it I've never even tried to understand. I can understand criticizing Rails for being obscure. I realize that it took me MANY years to be REALLY effective with it. But if you're telling me the alternative for web applications is ANYTHING related to Java, I'll call you crazy. I've just inherited a Laravel-based PHP site, which is so old I can't download the version of the framework it uses. Yikes. I did PHP for about 10 years, 20 years ago. It doesn't feel like a lot has changed. So, I'm honestly asking, as someone who hates Rails: What framework, out there, somewhere, allows me to be as productive as Rails, but which is are "better," somehow?
- ATsch 8y agoDo you have any experience with Django? I haven't used rails myself, but I'm told they are very similar in the "look at what I'm not doing" regard.
- tomc1985 8y agoDjango has a lot going for it in terms of simplicity but it lacks most of Rails' advanced features and timesavers. In my experience it sits somewhere between Sinatra and Rails
- fouc 8y agoI think you need to share your favorite programming languages so that we know the type of language you are biased towards, and why you might dislike ruby.
- Buttons840 8y agoEarly in my career, I only "knew" a little C++ from a high school programming class I had taken, and I knew a tiny bit about Java. Then I found Ruby, and people talked very highly of it. But it had all these "Gems", I couldn't figure out what a Gem was. I didn't know enough. I thought it was like a compiler plugin or something. I thought that just like there were different versions of Java, there were different versions of Ruby called Gems. Then I found Python, it had "libraries", I knew what a library was, it was something you could download and use in your code. I learned Python and liked it a lot. If Ruby had "libraries" instead of "Gems" I would have learned Ruby instead since I was exposed to it first.
- ken 8y agoPython has a Cheese Shop full of Eggs. I love straightforward names as much as anyone, but I don't think Python is exactly the leader in this department, either.
- Buttons840 8y agoI did a Google search for "hacker news ruby" and "hacker news python" and then searched the top results for "gem" or "egg" or "wheel" usage. It's not a big study, but it is empirical. Comments about Ruby say: - "the webpacker gem" - "Simple to integrate gems" - "supported via gems" - "few dozen obscure gems" - "the I18n gem" - "the ruby-each-line gem" - "vast amount of Ruby gems available" - "working with so many gems" Comments about Python say: - "packaged either as a Wheel or an Egg" - "The numpy module is a wheel" - "a wheel is specifically not a source distribution" - "NumPy publishes a lot of wheels for a given release" All those Python related comments are from one single comment who's author was discussing the technical differences between Eggs and Wheels as packaging formats. Arguably only the last Python comment uses "wheel" as a synonym for "package" or "library".
- marcosdumay 8y agoPython's libraries come as eggs, wheels or source packages. Ruby has gems. Rust inherited that characteristic, what is not great. It's not a big problem either, but it's there.
- swat535 8y agoYour complaints regarding ruby has been noted. It's not you favorite language and that's cool. Every language out there has pros and cons with different set of tradeoffs , you can't point at a language and objectively say X is better than Y. Ruby has its place and whilst you think Rails is "magic" the internet begs to differ. Of course any framework looks like "magic" if you don't bother digging into implementation details of it. That is the whole point! The fact that so many successful companies are using rails in production and scaling it, just shows the complete opposite of what you claim: "an extremely resource-intensive web server framework built around assumptions of what web apps were like in 2003." There has been plenty of times where i wondered how a piece of AR worked and popped over to the Rails github repo and quickly glanced over the details and had no problem understanding it. You are entitled to your own opinion, but from the outside, it looks like you are just not familiar with ruby.
- moojd 8y ago"Ruby has its place and whilst you think Rails is "magic" the internet begs to differ. Of course any framework looks like "magic" if you don't bother digging into implementation details of it. That is the whole point!" I think most people including many Rails proponents would agree that Rails has a huge emphasis on "magic" compared to other frameworks. It's a feature. Convention over Configuration implies magic and that is one of Rails' most famous tenets. Love it or hate it, magic is Rails' modus operandi
- beforedawn 8y agoMagic or abstraction layers should be intuitive, so you understand them and are able to solve edge cases. If the abstraction layers are too foggy or magical and you are unable to fix edge cases yourself, something is wrong.
- nwmcsween 8y agoHow long did you program in ruby? Since its an OO programming language the keywords are per object which makes things simple to understand. Ruby was the first language I really enjoyed and allowed for some really nice DSLs. Even Rust borrowed syntax from ruby (although more ugly IMO).
- beforedawn 8y agoSo true. Best was ActiveRecord, the most cumbersome ORM I have ever met, it could create 20 SQL requests out of a simple query. There must be a reason that Ruby dropped few places on Github's Octoverse 2018. While I was never against Ruby, every time has its tools, it was the culture of the Ruby community which I didn't like. Being a Rubyist was always a good excuse to not help on the frontend or help with some devops. Now they escape into Elixir which is the next good academic excuse to not help with the frontend because React is so working class...
- eropple 8y agoMeanwhile, every devops environment I've ever worked in has been Ruby-first, to the point where I learned Ruby specifically for devops work. I get that you are new here, but this place isn't big on shitposting.
- zackmorris 8y agoOk I'll bite. Ruby's biggest flaw is implicit context, due to its emphasis on convention over derivation. Which means that (for example) a developer new to Ruby/Rails won't know that paths are automatically generated from routes.rb, or how those routes and paths automagically connect to controller classes. It's not clear in the beginning how symbols relate to strings or why you would even want them (they are like enums so have better performance, but other languages get around this with better string comparison techniques), or how hashes relate to the associative arrays in other languages, or why hash method work differently from array methods. For example: https://apidock.com/ruby/Hash/flatten https://apidock.com/ruby/Hash/flatten Which doesn't recursively flatten like Array#flatten, even when depth is specified. To me, most of these choices are arbitrary or done for performance reasons which get less compelling with each passing year. I never know from one day to the next which new concept is going to be thrown at me, or how much I'm going to have to memorize. Whether it's Rails, or Rspec, or any other gem - each has its own ecosystem of technobabble that can't be derived from first principles. In the end, I don't know what problems Ruby is trying to solve. I find it no faster to write than PHP or Javascript. I find that having multiple ways to specify blocks with begin/end and {} merely increases the permutations I must hold in my head as I'm trying to grok code. This is all very perl-like, which makes sense for a 90's language. But I wouldn't advise learning Ruby or using it in production today. Better to go with a more formal language such as Go/Rust/Swift/Kotlin, even though each of those has its own unique set of flaws and pain points. P.S. If you are struggling with learning Ruby, I highly recommend learning PHP/Laravel first. It has most of the same concepts as Rails/.NET but builds on the existing context that C-style language programmers tend to be familiar with. Then from there you can create a virtual errata document in your mind to store any arbitrary conventions that Rails introduces.
- joelbluminator 8y agoYou just never bothered digging into Rails and going through at least the majority of the documntation. I tried playing around with Spring, guess what? It sucks, the amount of reading you have to do just to try and get a hello world is immense. Agree about symbols though, that's not a good thing. Every language has mistakes though.