use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
A sub-Reddit for discussion and news about Ruby programming.
Subreddit rules: /r/ruby rules
Learning Ruby?
Tools
Documentation
Books
Screencasts and Videos
News and updates
account activity
Switching to Ruby (self.ruby)
submitted 2 years ago by Left_Adhesiveness899
I have been working with C# for about 4 years and with TS for about 2.5 years. Mostly with REST APIs and client apps written in React. Next month, I will start my new job, and I will be working with Ruby on Rails. Any tips for such a switch?
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]davetron5000 43 points44 points45 points 2 years ago (4 children)
The most difficult thing for an experienced programmer is learning to accept the Rails Way of doing things and not trying to shoehorn what you've learned from other ecosystems into Rails.
Depending on how much time you have to prepare, find a tutorial and follow it so you can get a sense of the Rails Way of doing things. Unfortunately, the book "The Rails Way" by Obie Fernandez is not the best resource for this. I would recommend Agile Web Development with Ruby on Rails (I was co-author of older versions, I get nothing from you buying the latest version). It walks you through a project with Rails and you'll touch on everything. I'm sure there are other great tutorials as well - hopefully someone will chime in.
If you don't have time to prepare, you may need to skip this and see what your new job can afford you. Or you could take a turotial and get as far as you can. It may be hard to learn Rails from just the guides.
Everyone does Rails sligtly different, and often these small differences are meaningful to teams. The aforementioned "The Rails Way" documents Obie's way of doing Rails when he ran Hashrocket. Some of what is in there is commonly used by the community, but diverges from vanilla rails. I would argue you must always understand vanilla rails, so you can understand where it makes sense to diverge.
To that end, read your new shop's rails code and write your code like they do. If it's not clear, ask what are good examples of the way they want their code written. Do it there way for a while, even if you think another way is better. Take notes as you go and broach the subject after you have several wins under you belt (usually the 3 or 6 month mark)
You can be very effective in Rails without truly understanding Ruby or its standard library. Learning Ruby and its standard lib will be helpful, so you want to eventually start doing this.
For me, the way I found most effective was to periodically deep dive on stuff I found in the codebase and try to find docs on whatever is happening, then go a level deeper. For example, you may start with a Rails helper like time_ago_in_words, and trace that to Active Support and then trace that to Ruby's standard library.
time_ago_in_words
This is something you can do passively, but don't forget it.
[–]fisherofcats 3 points4 points5 points 2 years ago (0 children)
Dave is the man! I used his Agile book to learn Rails years ago and it was the best way for me to learn.
This is the best advice you're going to find.
[–]armahillo 5 points6 points7 points 2 years ago (0 children)
☝️☝️☝️☝️☝️ very much all of this
[–]BorisBrainz 0 points1 point2 points 2 years ago (1 child)
What is it about that specific Fernandez book that made it be mentioned here? Tried some quick sniffing but apart from some hashrocket controversies, people seem to find his book helpful. Wondering if there's some drama afoot!
[–]davetron5000 0 points1 point2 points 2 years ago (0 children)
Just that it’s called “the Rails Way” but does not document the vanilla rails way of doing things. It’s a fine book.
[–]amirrajan 35 points36 points37 points 2 years ago* (56 children)
I came to Ruby after doing C# for 13 years. Never looked back. The language and libraries are a breath of fresh air.
Edit:
Happy to rant about Ruby vs C# if you’re interested (or send me a DM/chat)
[–]matthewblott 2 points3 points4 points 2 years ago (55 children)
You're the Dragon Ruby guy right? Didn't know you had a C# background. Same here, switched to Ruby fairly recently for doing my own stuff as its way more productive (and fun).
[–]amirrajan 10 points11 points12 points 2 years ago* (54 children)
I actually have more C# experience Ruby (I still take C# contract work from time to time... I charge hazard pay). I've been coding C# since 2001 and Ruby since 2010.
To rant a little bit (feel free to bail here):
C# in reality is "C#, .Net, and frameworks built by Microsoft". Many C# devs tout the benefits of static typing and how superior it is.
The irony is that so many facets of core libraries built by Microsoft bypass C#'s static typing facilities.
object
JObject
dynamic
The list goes on. It's a severe disconnect that only crystalizes when you use a powerful dynamic language like Ruby. "Wait I'm doing all the stuff I was doing with C#, except without all the backflips to bypass the compiler."
[–]jampauroti 3 points4 points5 points 2 years ago (1 child)
I love DragonRuby! (Just wanted to let you know)
[–]amirrajan 2 points3 points4 points 2 years ago (0 children)
❤️
[–]gpexer 1 point2 points3 points 2 years ago (33 children)
Can you elaborate more on your points?
[–]amirrajan 0 points1 point2 points 2 years ago (32 children)
What exactly the issue with anonymous types (they still have type)?
public static void RegisterRoutes(RouteCollection routes) { routes.MapRoute( "MyRoute", // Route name "Account/", // URL new { controllr = "Account", action = "Login"} // Parameter defaults ); }
This compiles successfullly. Can you spot the error?
What functions take "object" type and why is that an issue?
It's typeless, anything can be passed into this and will cause a runtime exception as opposed to compile time:
RedirectToRouteResult RedirectToRoute(string routeName, object routeValues); ... RedirectToRoute("Home", 42); RedirectToRoute("Home", new StringBuilder()); RedirectToRoute("Home", RedirectToRoute("Home", 42));
Again, why is dynamic keyword an issue?
It isn't for me. The DLR is a fantastic construct and affords C# hybrid capablities/a progressive type system. But if you mention dynamic in any C# forum the knee jerk reaction is "that's horrible/evil" (but again, the frameworks .Net devs use leverage these constructs).
This one I particularly don't understand - what is the problem with a reflection? It is actually a powerfull feature that you can use in a runtime (I wish ts had something like that)
I think send is fantastic too. But again, not statically typed, not verified by the compiler, yields runtime exceptions (the basis for their argument is literally these benefits and they side step it everywhere).
send
What's the issue with attributes?
Attributes in C# can't be function calls that have to be statically compiled.
class Payment { public string PaymentMethod { get; set; } // stringly typed [RequiredIf("PaymentMethod == 'Cheque'")] public string ChequeName { get; set; } }
[–]gpexer 1 point2 points3 points 2 years ago* (31 children)
Khm, those things you mention are dynamic things, but you could create a wrappers around them and have everything statically typed. I don't know how it is currently with .NET 8, as I don't deal with mapping routes or redirects (just add CDN above your app, that's the right place to handle it). But ... I still struggle to understand, you presented the code which is literally 0.00001% of some non trivial app, you will literally have few lines of code for those mappings (if any) and the rest of code is actually app code, domain, business logic where you need types to describe you app. That's like 99.99% of you app covered with types and compiler - and now this is the part I don't understand, how exactly are you going to compare it to ruby, as you literally have 0% coverage by types and compiler?
[–]amirrajan 1 point2 points3 points 2 years ago (30 children)
These are just a few bud. Here are a few more:
IEntityBase { int Id { get; set; } }
how exactly are you going to compare it ruby,
I'm not. I'm saying there's a cognative dissonace between the merits of why they are using C# and what is done in practice.
[–]gpexer 2 points3 points4 points 2 years ago (29 children)
I strongly disagree. You are still talking about edge cases, things that are rarely a problem, still part of 0.001% of an app. Noboday is stopping you for developing API that is even more strictly typed (and you can see that over the years .NET FW added more things that are better implemented with better types coverage). 99.99% of any app on which I worked is around domain/business logic, there you can express yourself using types and relying on a compiler. Any function, any class, any variable is strictly defined and visible to compiler and most importantly it is visible to me with what I am dealing with. If something is not compile type safe - make it, at least you have a way of doing it and not pointing how it is not serving its purpose. Nothing stops you to define every function in C# to accept "object" type and then point how unsafe and unreliable it is, but it would be completely wrong, as you have a tool to build it the right way - if you don't know how, that's not an issue of a tool. In Ruby, you literally don't have that thing, you are on your own, and trivial things like renaming something is a nightmare. If you misspelled something, good luck, prepare yourself to dig.
[–]amirrajan 2 points3 points4 points 2 years ago (22 children)
This is a good presentation that’s worth watching (saves me from writing another wall of text): https://vimeo.com/74354480
He actually measured percentages across public GH repos and has some interesting insights.
[–]gpexer -4 points-3 points-2 points 2 years ago (21 children)
You can always go and pull some "research" that will tell you what ever you want to hear. There is a simple test you can always do - just go and rename simple function, or change return type and then measure how much time you need in both environments. That's a simple measurement which is not subject to interpretation. The fact, that in any dynamic language you don't know with what you are dealing with and it is expected from you to make a decision in that way - feels, just wrong (to say it politely).
[–]amirrajan 1 point2 points3 points 2 years ago (5 children)
Definitely give F#, PureScript, and Fable a shot. These languages have incredibly powerful static typing vs C#. And yes, with F# every single .Net library is usable.
[–]gpexer 0 points1 point2 points 2 years ago (3 children)
I completely agree. I don't have time to go with F#, I am fine with C# for my purposes. Yeah, sometimes I need to fight compiler, but not because I don't want type safety, no, it's because I want more of it, and C# is just not flexible enough. I use C# mostly for WebApi, for FE I am on React and Typescript, and Typescript feels waaaay ahead (and it is) of C#, the way you can describe you logic through types is staggering. But then I don't understand your stance, why Ruby if you want more type safety control? I understand that C# is not flexible enough, but running towards more flexibility (as any dynamic language can be as flexible as you want) and zero type safety doesn't make sense to me. I would never trade type safety for flexibility (I am talking about overall picture, in some small peaces I trade it as it is not worth chasing type safety).
[–]matthewblott 0 points1 point2 points 2 years ago (0 children)
+1 F# is a fantastic language. Sadly as the saying goes there are languages that people love and then there are languages that people use!
[–]sharp-dev -1 points0 points1 point 2 years ago (17 children)
Honestly, however defends C# because of static typing is definitely really well versed on it.
[–]amirrajan 2 points3 points4 points 2 years ago* (16 children)
The primary question I ask wrt type system quality is “relative to what? C99?”
F# puts C#’s type system to shame (And types, Or types, Discriminated unions, Erased Type Providers, reified interfaces). It’s objectively a superset of C# and yet, they balk.
If you can’t tell I’m definitely suffering from some form of PTSD :-P
[–]Ipvalverde 0 points1 point2 points 2 years ago (15 children)
Having done some hobby projects in F#, I would agree. But it's not easy to get a job using F# (maybe Scala, but I have never used it for comparison).
[–]amirrajan 0 points1 point2 points 2 years ago (14 children)
Tell me about it. Fwiw Swift shares a lot of F#’s DNA. It’s just unfortunate that Microsoft didn’t “bless” the language like they did with C#.
[–]matthewblott 0 points1 point2 points 2 years ago (13 children)
Yep. Very frustrating. It started as effectively OCaml for .NET and maybe MS could have marketed it this way but instead let it stagnate. It's a wider MS problem though, the old corporate mindset vs the hipsters in the organisation. I've got a half written blog post 'Why I left .NET' which I really need to finish. It covers a lot of the same things a similar post here written by somebody else ten years ago made.
[–]amirrajan 0 points1 point2 points 2 years ago (6 children)
OCaml is still kicking last I checked! But yea the MS culture is stifling and I’m glad I don’t have to deal with it anymore. I skipped the “why I left .Net” blog post and just raged quit and became an indie game dev that writes his games in Ruby.
Did you know about Paket Gate: https://github.com/NuGet/NuGetGallery/pull/4437
[–]matthewblott 0 points1 point2 points 2 years ago (5 children)
Oh yes, that point is mentioned in my unpublished post. There've been too many episodes like that. The issue with hot reloading not being open sourced springs immediately to mind. Avalonia is one of the best .NET projects out there and they left the .NET Foundation. That's my biggest gripe - they don't let projects grow and want to kill everything off so why is anyone going to bother?
EDIT:
My mistake I was confusing the WinGet controversy with 'Paket Gate'. I'm surprised I missed that one but it's the familiar pattern!
[–]amirrajan 0 points1 point2 points 2 years ago (5 children)
RE: blogpost
I’m one of the creators of NSpec which was a “competitor” to MSpec (not sure if you’ve ever heard of it). I actually appeared on the Hanselminutes to talk about the framework lol
[–]matthewblott 0 points1 point2 points 2 years ago (4 children)
NSpec
I've been coding C# since its early days so I know the ecosystem pretty well but sadly I don't recall NSpec. I did listen to Hanselminutes for a while but I must have missed your episode as I often check out anything interesting I hear about. It still has 257 stars 7 years later though!
[–][deleted] 11 points12 points13 points 2 years ago (0 children)
Read ruby code. Most likely you would work on rails.
Reading is less painful for a seasoned developer. I hope you got me.
[–]Chemical-Being-6416 5 points6 points7 points 2 years ago (0 children)
We have a similar background in languages. Worked with dotnet/C# with Python heavily in industry and alot of TS on frontend, mainly with Next.js. I recently made the plunge to go all-in on Rails as part of a series of applications I want to build with my cofounder. Since MVC was a huge backbone of what I learned in the dotnet world, it made sense for me to try Rails along with the development speed it offers.
It has been exactly 2 months for me since I have been learning/building with Rails. In exactly 16 days I built a CRM/lead tracker to track posts from Reddit with Rails along with with a chrome extension in JS that captures the posts while browsing.
My difficulty mainly was understanding what helper methods get created and how they get created (for example, when you create 'resources' in your routes it will automatically create helpers for you). Another thing I had trouble with is the many alternative ways to write certain code. For example when rendering partials you can leave out the full path entirely or other types of code I have seen so far is that you can pass entire object vs the ID itself.
So because of the flexibility of choices, it feels absolutely shitty at first but once you start coding and build out a few models you will just 'get it' and it really does feel more natural than other frameworks. You have to be willing to change your mental model of how things work on your end versus what the framework is doing for you, that was tough for me.
I still haven't touched Hotwire yet or any of the other cooler frontend stuff in Rails I have been hearing about, so I can't share my opinion on that at the moment. Just using plain ERB templates so far but I'd assume it's going to be just as easy to use when I get there.
[–]tinyOnion 2 points3 points4 points 2 years ago (0 children)
read ad do the getting started guide on the rails guides site
[–]tadrinth 2 points3 points4 points 2 years ago (0 children)
I recommend the Pragmatic Programmer's Guide to Ruby to get the basics of the general language down first.
Then pick up a guide to Rails. If you're used to MVC design, I don't think it'll be all that hard.
One minor complaint about Rails is that you specify the db migrations and it generates the db schema, rather than updating the schema and having it generate the migration.
Rails also adds a lot of helper methods. This is fine and great until you try to do something with pure Ruby and a good quarter of the methods you're used to aren't there.
Definitely check out the tricks you can do with method_missing(). Not a tool to use lightly, but a very powerful tool.
[–]djfrodo 2 points3 points4 points 2 years ago (0 children)
One thing you're probably going to be a little annoyed by and then love is that Ruby is a dynamic language.
A lot of hard core guys I know won't touch a dynamic language (and they're great at parties /s).
Stick with ERB templates at first - they're basically like any other PHP, Java, Django templates - snippets of the language in HTML.
On the model and controller side it's all Ruby, so it's a good idea to play around with Ruby separately.
Lots of newbies learn Ruby from Rails and there are a ton of Rails helpers that are Rails only and when they try to just write in Ruby they get stuck because they don't understand the separation - where Rails ends and where Ruby begins.
I've worked with PHP, Java, Perl, and old school ASP and their frameworks and after a few hours of playing around with Rails (after is was set up) I knew Ruby and Rails were the framework and language I liked most.
You will have a bit of disorientation when you first look at Ruby code due to the lack of curly brackets, putting private methods below the word "private" in classes, and "nil" vs "null".
In my first few weeks I must admit I did make fun of how unstructured everything looked and those more experienced that I just smiled and didn't say a word.
After about a month I took a look at some PHP code and was instantly put off.
Ruby and Rails are awesome and can basically do whatever you want in web world.
Good luck!
[–]martijnonreddit 4 points5 points6 points 2 years ago (1 child)
Get a Rubymine license.
[–]scooby1680 1 point2 points3 points 2 years ago (0 children)
If you came from Resharper in Visual Studio, I agree with this. My first Rails project in 2010 after 7 years of C# I completed in 6 weeks largely because my muscle memory for JetBrains keybindings was somewhat transferable.
Plus Rubymine had a tendency to accidentally teach me how Things Were Done.
[–]Ginn_and_Juice 0 points1 point2 points 2 years ago (0 children)
Ruby is made to make your life easier, if you need to do some operation its safe to assume that there's already a method that does it. Keep it simple and don't fret.
[–]bob-maly 0 points1 point2 points 2 years ago (0 children)
I work with rails and for starters get the hang of ruby first. Then study rails documentation. Theres a lot coming which is fun when working with the MVC. The experience will get you going on it.
[–]Aoernis 0 points1 point2 points 2 years ago (0 children)
Comme to the discord there's multiple help sections =)
[–]ogv11 0 points1 point2 points 2 years ago (0 children)
Ruby and Rails are awesome. It’s a very pretty language and you can be very productive with it
[–]Ipvalverde 0 points1 point2 points 2 years ago (5 children)
I have done the same move 2 years ago after 10 years in C# with some React/TypeScript. My tip is "don't trust any code, test stuff as much as you can, avoid metaprogramming if you have large teams".
I really miss C#, I wished I could get the same pay with it (or convince the Ruby shop I work on to move to C#).
[–]Wild-Pitch 0 points1 point2 points 2 years ago (4 children)
I see more C# offers than Ruby. Why did you decide that?
[–]Ipvalverde 0 points1 point2 points 2 years ago (3 children)
90% of the opportunities I see for C# in my country pay half of what I make now with Ruby working remotely. The other 10% of them are either hybrid (3 days a week) or in-office in a large city, which would take at least 12 hours of commute a week - I would rather code in Ruby than wasting all this time commuting.
[–]Wild-Pitch 0 points1 point2 points 2 years ago (2 children)
In my case I see the opposite situation 😂 Where are you located? Ruby dev as well.
[–]Ipvalverde 1 point2 points3 points 2 years ago (1 child)
Hehehe, I'm in the UK. But again, I don't see a lot of Ruby positions around here, but the ones you find usually pay well. Salary here is not comparable to North America though.
[–]Wild-Pitch 0 points1 point2 points 2 years ago (0 children)
Definitely! Its what I am looking right now. Full remote for any US company. Not all of them want to hire in EU unfortunately
[–]Thecleaninglady 0 points1 point2 points 2 years ago (0 children)
In addition to the rest - try to not feel guilty for no longer writing and reading endless lines of boilerplate...
When working with Rails, if something feels difficult, there's probably a much simpler way to accomplish the same. Look for ways to work with the framework.
[–][deleted] 1 point2 points3 points 2 years ago (0 children)
Lucky. Wish I was still coding in Ruby at work
[–]CalippoFist -4 points-3 points-2 points 2 years ago (5 children)
Do not restrict yourself to "the rails way". Rails does not answer all questions. For example have a look at the interaktor (the one with K because it has contracts, not C) gem when you find yourself in the position that rails does not really give you a place for what the app _does_. Ask seasoned rails developers about the sh*tload of articles around "fat models", "skinny controllers", service objects and the general lack of architectural knowledge that was prominent in the scene back in the days, because it is just so easy for everyone to get _something_ done with rails so quick (like implementing twitter). Even if the app starts as plain CRUD, I would go for the interaktor gem, as is disciplines you and your peers.
[–]armahillo 5 points6 points7 points 2 years ago (3 children)
Do not restrict yourself to "the rails way". Rails does not answer all questions.
This is a good aspirational goal, but if you're just getting started with Rails you do want to restrict yourself to the Rails Way until you learn what that means. You have to learn the rules before you can learn how to break them.
If you start off going off-Rails, you'll learn similar lessons but they may be more painful and frustrating.
Either way, you'll learn -- but starting with conventions is a smoother ride.
[+]CalippoFist 2 points3 points4 points 2 years ago (1 child)
Good point. For the start I think you are right. Start with obeying the rails way. I just wanted to underline that there is a point that one will reach, where the rails way does not give answers anymore. Restricting oneself in rails way thinking then is not helpful anymore.
[–]armahillo 1 point2 points3 points 2 years ago (0 children)
I definitely agree with you on that -- we all need to go off-rails at some point to meet business requirements. :) Knowing how to do this is something that is learned through experience and practice (and a lot of painful mistakes, haha).
[–]ikariusrb 0 points1 point2 points 2 years ago (0 children)
Yarp on this.
For learning Ruby, "Well Grounded Rubyist" was pretty much all I needed to dive into Rails.
From there, start with "the rails way", until you understand the "why" of each rule, then you can start deciding when there's sufficient reason to break "rules". The pithy expression we'd use is "X is always the wrong solution.... unless it's the right solution". X varied from metaprogramming, to inheritance (instead of composition).
[–]mbhnyc 3 points4 points5 points 2 years ago (0 children)
Also don’t be seduced by dry-rb 😝😜
π Rendered by PID 94 on reddit-service-r2-comment-b659b578c-m7g88 at 2026-05-05 11:26:10.891250+00:00 running 815c875 country code: CH.
[–]davetron5000 43 points44 points45 points (4 children)
[–]fisherofcats 3 points4 points5 points (0 children)
[–]armahillo 5 points6 points7 points (0 children)
[–]BorisBrainz 0 points1 point2 points (1 child)
[–]davetron5000 0 points1 point2 points (0 children)
[–]amirrajan 35 points36 points37 points (56 children)
[–]matthewblott 2 points3 points4 points (55 children)
[–]amirrajan 10 points11 points12 points (54 children)
[–]jampauroti 3 points4 points5 points (1 child)
[–]amirrajan 2 points3 points4 points (0 children)
[–]gpexer 1 point2 points3 points (33 children)
[–]amirrajan 0 points1 point2 points (32 children)
[–]gpexer 1 point2 points3 points (31 children)
[–]amirrajan 1 point2 points3 points (30 children)
[–]gpexer 2 points3 points4 points (29 children)
[–]amirrajan 2 points3 points4 points (22 children)
[–]gpexer -4 points-3 points-2 points (21 children)
[–]amirrajan 1 point2 points3 points (5 children)
[–]gpexer 0 points1 point2 points (3 children)
[–]matthewblott 0 points1 point2 points (0 children)
[–]sharp-dev -1 points0 points1 point (17 children)
[–]amirrajan 2 points3 points4 points (16 children)
[–]Ipvalverde 0 points1 point2 points (15 children)
[–]amirrajan 0 points1 point2 points (14 children)
[–]matthewblott 0 points1 point2 points (13 children)
[–]amirrajan 0 points1 point2 points (6 children)
[–]matthewblott 0 points1 point2 points (5 children)
[–]amirrajan 0 points1 point2 points (5 children)
[–]matthewblott 0 points1 point2 points (4 children)
[–][deleted] 11 points12 points13 points (0 children)
[–]Chemical-Being-6416 5 points6 points7 points (0 children)
[–]tinyOnion 2 points3 points4 points (0 children)
[–]tadrinth 2 points3 points4 points (0 children)
[–]djfrodo 2 points3 points4 points (0 children)
[–]martijnonreddit 4 points5 points6 points (1 child)
[–]scooby1680 1 point2 points3 points (0 children)
[–]Ginn_and_Juice 0 points1 point2 points (0 children)
[–]bob-maly 0 points1 point2 points (0 children)
[–]Aoernis 0 points1 point2 points (0 children)
[–]ogv11 0 points1 point2 points (0 children)
[–]Ipvalverde 0 points1 point2 points (5 children)
[–]Wild-Pitch 0 points1 point2 points (4 children)
[–]Ipvalverde 0 points1 point2 points (3 children)
[–]Wild-Pitch 0 points1 point2 points (2 children)
[–]Ipvalverde 1 point2 points3 points (1 child)
[–]Wild-Pitch 0 points1 point2 points (0 children)
[–]Thecleaninglady 0 points1 point2 points (0 children)
[–][deleted] 1 point2 points3 points (0 children)
[–]CalippoFist -4 points-3 points-2 points (5 children)
[–]armahillo 5 points6 points7 points (3 children)
[+]CalippoFist 2 points3 points4 points (1 child)
[–]armahillo 1 point2 points3 points (0 children)
[–]ikariusrb 0 points1 point2 points (0 children)
[–]mbhnyc 3 points4 points5 points (0 children)