Rails Still.Key

Rails Still.Key

PJ Hagerty Rails…Still?!?! [email protected] | @aspleenic DevRelate.io PJ Hagerty | @aspleenic http://devrelate.io | @devrelate Prompt - Mental Health in Tech http://mhprompt.org [email protected] PJ Hagerty | @aspleenic http://devrelate.io | @devrelate I also do some side work coordinating Prompt - a mental health in tech organization. If ever you want to help start the conversation on Mental Health in Tech, let us know. We are also always accepting donations. FULL DISCLOSURE ❖ I don’t hate Rails - let’s just be clear. This talk isn’t meant to disparage Rails or folks who love Rails - there will be no Rails bashing (probably). PJ Hagerty | @aspleenic http://devrelate.io | @devrelate Before we get started, let’s address the elephant in the room. Rails is great. It really is what you need for large scale production applications most of the time. It has history. And if you got started in Ruby working on the web, chances are Rails is what you are most familiar with. Why is Rails so great? PJ Hagerty | @aspleenic image credit: Jason Hoffman / thrillist http://devrelate.io | @devrelate Many developer came to Rails by default. Maybe we were Ruby hobbyists looking to move to the web, maybe we were web developers looking for the next great language. Maybe we learned to code in a bootcamp, where Ruby on Rails is preferred teaching method because of its ease of use and ability to be installed nearly universally (yes, even on windows!). Rails, when it arrived on the scene, shook up the open source world of web development. There was finally an alternative to Java, PHP, and Perl - and it was actually fun to use. There was magic in the air! The Magic image credit: http://www.dailymail.co.uk PJ Hagerty | @aspleenic http://devrelate.io | @devrelate Part of the allure of Rails was the magic. I remember it being said you could build a web application in Ruby on Rails, get 90% of the work done in 10% of the time. While the last 10% was a real pain in the crack, this was very attractive - especially to Dev shops looking to do fast turn over or convert from legacy systems to a more modern language. Rails did things “automagically” - you had ways to handle database connections, you didn’t need to worry about straight SQL queries..I mean, heck, Rails came with a built in index page just to let you know you we’re “Riding the Rails!” But, doing things automagically can come with problems… The Rails Monolith image credit: Rene Aigner - Monolith (from the https://m.signalvnoise.com blog) PJ Hagerty | @aspleenic http://devrelate.io | @devrelate Rails is huge. Huge comes with a cost. One of those costs is not being able to easily find things under the hood. I know there was a reference to this in DHH’s keynote a couple years ago. He was of course defiant and defensive. He wanted to talk about new features, but focused on why monoliths can be better than microservices or other methods of division of application labor. And of course that’s not a surprise - David is part of the problem. Granted, he created the solution initially - but having a Benevolent Dictator for Life can be a hinderance and part of a monolithic structure. But beyond the politics of Rails there is an underlying issue. What else is there? image credit: http://iruntheinternet.com/01548 PJ Hagerty | @aspleenic http://devrelate.io | @devrelate This is where we get into the nitty gritty - looking at alternatives. Once upon a time, there were only a few alternatives to Rails if you wanted to put Ruby on the web. Today, that landscape has changed. While we’ve never achieved the full framework wars of other languages (and that’s really a blessing not a burden), we have seen growth in frameworks that can do specific jobs better and in a more streamlined way in comparison to Rails. Let’s take a look at a few. Sinatra http://sinatrarb.com PJ Hagerty | @aspleenic http://devrelate.io | @devrelate We’ll start with Sinatra. How many folks here have used Sinatra or at least checked it out? Created by a gent named Blake Mizerany back in 2007, Sinatra was really one of the first steps towards using ruby on the web without Rails. Since it’s inception, Konstantin Hasse has been the main maintainer and deserves much credit when it comes to making Sinatra a more recognizable name as time went on. Based on using routes for code to be activated, Sinatra is a lightweight solution for applications that don’t need the overhead Rails provides. Sinatra’s Strengths image credit: Getty Images PJ Hagerty | @aspleenic http://devrelate.io | @devrelate Even with the use of some of the API tools in Rails, Sinatra still has the upper hand when it comes to building an application that is ingesting something from an external API. Because of it’s inherent simplicity Sinatra focuses on the task at hand with none of the over-arching strain the various parts of Rails can put on an application. Say there is no need to retain DB records, just read and organize API pulled information - why would you build a Rails application with all the extra classes just hanging out doing nothing? Sinatra would be the best thing for what you need to do. And if there’s something you need from Rails that Sinatra doesn’t do, YOU CAN ADD IT IN! Sinatra is written in Ruby just as Rails - so you can add components like ActiveRecord as you need them! Sinatra’s Weaknesses PJ Hagerty | @aspleenic http://devrelate.io | @devrelate To be fair, everything has its drawback and nothing is perfect. Sinatra, and the other alternatives on this list will need to show they’re ugly bits as well. With Sinatra, it’s already been said - lightweight. For a larger scale web application, Sinatra will not be what you want. It’s really for applications dealing with fewer endpoints and few or not frequent or concurrent users. Sinatra will crash if put under too heavy a load. That, and as it is compatible with Rails components like ActiveRecord, as your application grows, you may end up with half of Rails revisited - send spawning the need for converting it to a Rails application. While not difficult, a little foresight may have been helpful in avoiding just that. So, Sinatra is small, but good for some things, just not everything. Almost Sinatra https://github.com/rubylibs/almost-sinatra PJ Hagerty | @aspleenic http://devrelate.io | @devrelate When looking for Sinatra and it’s documentation, do not get fooled by something called “Almost Sinatra”. Be it known, maintainer Konstantin Hasse is a bit of a joker and his sense of humor lead him to attempt a rewrite of Sinatra in just six lines. To say it is unsafe but functional would probably be the best quote. For a laugh though….feel free to checkout the repo Padrino http://padrinorb.com/ PJ Hagerty | @aspleenic http://devrelate.io | @devrelate Based in Sinatra at it’s core, Padrino is a lightweight full-stack ruby framework. Unlike Sinatra, it has some features that are very Rails like, such as a method for generating applications with padrino g project myapp. Think of Padrino as Sinatra part two, or maybe Sinatra’s younger but more robust sibling. that happens sometimes, right? Padrino’s Strengths image credit: Paramount Pictures PJ Hagerty | @aspleenic http://devrelate.io | @devrelate Part of the beauty of Padrino is the tooling. With support for many database libraries along with testing and mocking tools, it goes a step further with a drop-in admin interface that is ORM agnostic and comes with scaffolding and authentication features. Essentially, Padrino is a step between Sinatra and Rails that goes beyond the simplicity of Sinatra and allows more complex applications to grow. Padrino’s Weaknesses image credit: Funko Pop Inc. PJ Hagerty | @aspleenic http://devrelate.io | @devrelate Here we run into some of the same issues we ran into with Sinatra. Sure, more of what we need for a more robust application are available, but, if we need to implement more and more things, aren’t we really just implementing Rails? I like Padrino a lot for projects that are bigger then Sinatra, but not quite Rails ready. Think a proof of concept application that may see production someday. Of course, when someday comes, that may be the day you rewrite in Rails. Cuba http://cuba.is PJ Hagerty | @aspleenic http://devrelate.io | @devrelate Since we are on the topic of Micro frameworks - let’s take a look at Cuba! Cuba is one of the most easy to start with micro-frameworks currently available to Rubyists. Written by Michel Martens, the key to Cuba, like Sinatra, is simplicity. With the avoidance of large scale overhead, this micro-framework is designed to build and deploy simple apps while avoiding bloat and unnecessary functionality. Like many micro-frameworks, Cuba is Rack based. Rack minimizes the interaction between the webserver supporting Ruby and the framework itself. This helps improve app response times and makes using the framework, in this case Cuba, fairly simple. Cuba’s Strengths image credit: Shutterstock PJ Hagerty | @aspleenic http://devrelate.io | @devrelate One of the best parts of Cuba is the documentation. A walkthrough guide is available online and allows anyone to look into and take advantage of Cuba’s functionality. After working for a short time with the walkthrough guide you will have a simple Twitter clone called Frogger. At this point, you should be familiar enough with Cuba to start using it in your own projects, if it’s the right fit.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    33 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us