I’m not going to lie — the transition from Ruby and Rails to JavaScript wasn’t the easiest. Ruby’s structure and language just made sense to me, and JS felt like a similar but very different animal for quite a while.
But once I started diving into the world of JSON — or JavaScript Object Notation — JS immediately started to feel more familiar. Here was a handy way to serialize data that looked and behaved like a way more powerful Ruby hash, thanks to AJAX.
Ruby was my introduction to object-oriented programming, and the ability to build class instances that responded to their own methods and related to each other via belongs_to
and has_many
made it easy to start imagining building out bigger and bigger apps with complex interrelationships.
JSON continued that education — now I could get and post complicated data structures that, with the help of JS class constructors, could then behave similarly to a Ruby class.
When I first approached my Rails with JavaScript project, I was intimidated. I had a fully functional Rails app. Now I was going to tear it apart and build it back up? The appeal of asynchronous data posting and display was a big motivator, though. As soon as I saw my data, which I had so carefully constructed to work with Rails, quickly come back when requested as JSON, I realized how versatile an app could be with a deeper and more diverse code stack to pull from.
Moving forward, I’m excited to get as comfortable with JS as I’ve gotten with Ruby. I know it has the power to make an app feel more fluid and user-friendly, thanks to the speed of asynchronous data operations and JavaScript’s event handlers, for example.
While Ruby and Rails had become my comfort zone, building my Rails with JavaScript project helped me see that with a methodical and open-minded approach, every new language, functionality and approach can become a valuable and easy tool among many.