DEV Community

Seth T.
Seth T.

Posted on

Crystal for the curious Ruby on Rails Developer

Have you been hearing about the language Crystal lately and you're curious what it's all about? Well, I'm right there with you! Specifically I'm curious how Crystal can be used to create web applications that are highly performant but use less resources.

A little about me

My name is Seth and I'm a self-taught full-stack Ruby on Rails developer. My strong suites are mostly back-end and infrastructure.

The goal of this article

Since I'm self-taught, and because of the way I learn, I rely heavily on video tutorials to help me build my understanding of how Ruby, Javascript, HTML/CSS and infrastructure work together to create functional web applications.

Crystal caught my attention because of it's similarity to Ruby, but with benefits of a compiled language that I think Ruby is naturally trying to move towards. The challenge I find myself having is... a lack of videos helping introduce the different frameworks and the language.

So, I decided I'll take multiple Crystal web frameworks for a test drive and we'll build the same app in each one to explore how each one is different. I plan to personally highlight the differences I notice between the Crystal framework and Rails because most of my app development experience is with Rails.

Crystal Web Frameworks I'll Be Exploring

Here's the list of frameworks I will be making videos for. I'll be creating the same simple blog app on each framework so that anyone following along can compare how each one. I'll update each list item with a link to the article specifically about the framework with links to the videos and the source code for anyone to clone/fork and play around with. So if you don't see a link yet, please check back in the future ๐Ÿ˜„

The order here is roughly based on the full featured-ness of the framework. I say that because from my current experience Lucky is more fully featured as an out of the box system, but I'm already working with Amber currently and I'm more familiar with it so I plan to start there. Kemal and Athena are much lighter weight and are better compared to a Sinatra type framework.

Blog Project Outline

I'm rarely this structured, but a simple blog site is a good way to explore a frameworks ORM, controller and view layer, routing, simple user authentication and all of the basic CRUD actions.

Since the purpose of this project is to explore the frameworks themselves I'll be using bootstrap for the front-end and making all of the projects look essentially the same with standard bootstrap styling. If I use any Javascript, it'll be through Webpack and using Stimulus or just plain Javascript (clearly I haven't decided yet).

Pages

  • Home: This will act as the index page for the posts, displaying up to 10 posts and paginating any additional posts.
  • Sign Up
  • Sign In
  • Post: the individual post page displaying the post contents. Post pages will accept comments from non-signed in users.
  • User Account: screen showing all of the posts belonging to the signed in user, with all of the CRUD actions for all the posts belonging to that user.

All pages will have a sticky top nav with links to sign in/out and create/manage posts.

And there you have it!

I'll update this post as I finish the videos and posts with each framework. If this has helped you, or caused you to have more questions that I didn't answer, please let me know. I'd love to get your feedback!

Top comments (3)

Collapse
 
blacksmoke16 profile image
Blacksmoke16

@seesethcode Glad to hear you're going to be trying out Athena!

I plan to personally highlight the differences I notice between the Crystal framework and Rails

I think you're going to find it is quite a bit different than Rails, and even the other Crystal frameworks. The main reason for this is it was inspired by non Ruby frameworks, which ultimately have different design patterns and stuff. The plus side to this is it brings some super cool and unique patterns/features to Crystal.

I will point out Athena, at this point in time, is better setup for RESTful APIs than server rendering HTML like you're wanting to make. It definitely can be used for that, but that's a less developed area so some built-in features may be lacking.

However, your exploration of that may be helpful in identifying some quick wins or areas that can be easily improved. I look forward to seeing what you think.

Kemal and Athena are much lighter weight and are better compared to a Sinatra type framework.

Athena is deff lighter on features compared to Lucky, but this is mainly related to Lucky being much more mature of a project while Athena is relatively young. I wouldn't compare it to Kemal tho, as that's more of a fancy router than a framework IMO.

Of course if you have any questions, run into any issues, or just want to chat about the overall architecture/design of Athena, etc feel free to join the gitter channel, or message me on Discord:

Collapse
 
seesethcode profile image
Seth T.

Yeah man Iโ€™ll reach out with any questions when I get to Athena! The goal here with comparing everything to Rails is specifically to use a very familiar perspective of development and show how the same type of functionality would be accomplished on a Crystal framework.

I get married in two weeks and then we close on our house in 4 weeks and move in 6 weeks, so itโ€™ll probably be January or February before I get to doing the Athena framework

Collapse
 
cloutiy profile image
yc

Looking forward to it๐Ÿ‘