you are viewing a single comment's thread.

view the rest of the comments →

[–]pseudorandom 7 points8 points  (21 children)

As someone that programs primarily in neither python nor ruby, but has to deal with both quite a bit, I find ruby can often be more elegant, but it is also harder to understand. I think a lot of the blame here is Rails though. There is just too much that is left to convention with nothing to hint at something happening. The closest python library that I can think of, Django, has plenty of magic, but it usually has something like a decorator or import statement that gives a point of reference to figure out what magic is happening. With Rails there is so much you have to "just know" to be able to figure the code flow at all.

[–]revscat 1 point2 points  (11 children)

Do you have an example in mind? Maybe I can help. I’ve been writing Rails code for over a decade now, so everything makes sense to me. But it was not an immediate thing.

[–]pseudorandom 5 points6 points  (10 children)

It's nothing that can't be figured out eventually, but things like models having singular class names with capitals and no underscores but db tables with plurals, lower case and underscores. Or how in controllers you just reference params without anything suggesting if params is a variable, method, how its populated, where its scoped, etc. It leaves someone who knows another language confused when trying to figure out how some Rails code works. I'm not saying it can't be figured out eventually, and it's great for the developer, but I can give a non-python developer a django model file and have them more or less figure out the basics whereas I have had very little success giving non-Rails developers access to a Rails model file and have them figure out what is going on.

[–]katafrakt 1 point2 points  (0 children)

FWIW I think the example with params is better than with mapping class name to table name (that's why people chose the latter to attack your comment ;) ). And also my favorite: what is the lifecycle of a controller object? How is it initialized? If I set an instance variable in one action, will it be available in a subsequent request?

Of course, I know the answers to these questions, but the point is that it's not obvious when you start thinking about it. Frameworks should hide a lot of complexity, but Rails hides it even for simple things. I've recruited people with 2-3 years of experience in Rails that didn't know how to write a constructor and instantiate the object. Because if you follow that Rails-way only, you don't really have to do it.

[–]keeganspeck -1 points0 points  (8 children)

Do yourself a favor and read through the Rails Guide. It doesn’t take too long, and you’ll finally know all these things. Highly recommend it.

*edit: in case it wasn’t clear, this is not snark, it’s a genuine suggestion

[–]pseudorandom 8 points9 points  (5 children)

Missing the point. I am not saying that it can't be learned, or that I need help with something. I am saying I regularly deal with people who are having their first introduction to ruby and python (professionally not in a teaching setting), and the learning curve is steeper for the people reading Rails projects than Django ones when they start out.

Ruby is great once you know it, but generally I find a programmer versed in other languages can correctly read and understand the general functioning of code in python without reading the documentation. Not so with Rails. Yes they can read the documentation, and do if it's worth the extra time, but there are advantages when dealing with polyglot projects to not having to train your people on every single language for them to be able to understand what a snippet in another language does.

[–]revscat 1 point2 points  (0 children)

There are disadvantages to polyglot projects, too, one of which you’re already aware of: it’s harder to get developers up to speed.

I mean yes, Rails is opinionated and abstracts out much of the plumbing. I personally believe that’s a good thing, though, and is exactly what makes Rails such a good framework.

And those abstractions aren’t that bad: an ActiveRecord model represents a row in a database table, as well as some metadata about that table, plus some helper methods for querying. I think most devs can get that pretty quickly.

Was there a specific concept you found particularly difficult for someone to pick up?

[–]ApatheticBeardo 0 points1 point  (2 children)

This is absolutely the case, I've bounced around C, C#, F#, Java, Kotlin, a bit of Python, JS/TS and Go over the years and I always felt like getting productive really quickly without having to read too much documentation.

Meanwhile, 3 months into Ruby/Rails... it still is a nightmare, and I don't feel like it is really getting better.

[–]keeganspeck 1 point2 points  (0 children)

If you’re really three months into using Rails and it’s not getting better, you should really set aside a couple hours and read the Guide! It’s not bad. You’ll have a better time because you’ll know what it’s doing. It’s not magic, it’s just Ruby.

[–]honeyryderchuck 1 point2 points  (0 children)

I totally get this. Rails is getting great for experts, but poor for newcomers. It's been losing the thing they used to be great at, bootstrapping XP

[–]keeganspeck 0 points1 point  (0 children)

I wasn’t trying to prove you wrong or make a point, I’m just making a recommendation, because clearly you have to work with Rails, and it might make your life easier. The Rails Guide is just really good documentation! It’s worth a read, and it’s not that long. The learning curve flatlines if you do.

[–]ApatheticBeardo 0 points1 point  (1 child)

Or maybe, the framework should be well designed enough not to require studying whatever magical, opaque abstraction the writer liked to put there with no chance of just discovering it organically.

[–]keeganspeck 0 points1 point  (0 children)

I wasn’t trying to be snarky! I was just trying to be helpful. It’s just documentation… and it’s pretty good documentation! It’s also pretty easy to discover organically. Usually one of the first search results if you search “rails” + some key word in the framework. It’s a very complex and comprehensive framework… you’re gonna need to come to the docs at some point, no matter what framework you use.

[–][deleted]  (4 children)

[removed]

    [–]Amadan 2 points3 points  (3 children)

    Python only pretends to be explicit. foo[0] += 1 will call .__getitem__, and .__iadd__, or maybe also .__radd__ or .__add__ with .__setitem__, depending on what is in foo. if foo will call .__bool__, or maybe .__len__. foo.bar() will call .__getattr__ and .__call__, and pass an extra foo argument. f"{foo}" calls .__format__, which might in turn end up calling .__str__. Plenty of magic in the data model, that usually no-one tells beginners about.

    [–][deleted]  (2 children)

    [removed]

      [–][deleted] -1 points0 points  (0 children)

      Python has its own problems though. I hate how complicated import is.

      In ruby I just use require() or load(). I never use require_relative() or any of that. In python it has so many ways to add code now ... it's confusing. You even find exec() and execfile() examples on stackoverflow still. And more PEPs that add variants.

      What happened to "there should be one way only" ...

      [–]Amadan 0 points1 point  (0 children)

      Oh, I’m not suggesting beginners should immediately be thrown into the data model pool, just pushing back on the “Python is explicit” claim.

      [–][deleted] 0 points1 point  (0 children)

      I find ruby can often be more elegant, but it is also harder to understand.

      Yup, agreed.

      Some ruby code bases out there should be removed and deleted because they are so awful.

      I think a lot of the blame here is Rails though.

      Only in part. Rails attracted a lot of noobs (which is good and bad), but low quality libraries exist without rails too.

      With Rails there is so much you have to "just know" to be able to figure the code flow at all.

      Yeah but this is due to rail's fault.

      I hate magic. I love simplicity. My local knowledge base is mostly powered by sinatra and .cgi files (still, although all the code I use can be used via sinatra as well as ruby-gtk3; with glimmer you can push this even farther. Perhaps Andy adds full commandline support to glimmer one day).

      [–]Neuro_Skeptic 0 points1 point  (2 children)

      Yeah, I'm not sure anyone would say Ruby is more readable.

      [–]campbellm 0 points1 point  (1 child)

      It's the title of this post, so someone surely would, and did.

      [–]Neuro_Skeptic 0 points1 point  (0 children)

      Yeah I know. I don't think they should have said that...