Crystal Cove: Creating a functional Web App in Crystal Language

Rishav Sharan
4 min readJun 28, 2018

--

Howdy mate! Welcome to the Crystal Cove!

This is the ToC of the series:

  1. Crystal Cove 01: From 0 to Webapp
  2. Crystal Cove 02: It’s a Viewtiful world
  3. Crystal Cove 03: (M)VC-ing it up

In this series of articles I will create a tutorial about creating a very basic webapp using Crystal language. The App itself will be a simple blog app with auth, posts, comments and user profiles. A mini “Realworld” app, if you will.

If you are here, you probably know about Crystal, this amazing new language which essentially is Ruby with the performance of C. Before you even begin, you should visit the Crystal homepage to decide if you want to use this language at all.

Assuming that you are now well aware of the language, you are now ready to embark on this journey. And keep these handy lifesavers (XinYMinutes, APIDocs, Gitbook, Gitter) ready in a different tab.

As a novice programmer and Crystal fan, there were several issues that I bumped against when working on my webapp. One of my biggest challenges with Crystal was simply the lack of good guides. Crystal is a young language and the community, though extremely friendly, is small. I think Crystal ecosystem has amazing potential and I have met some amazingly talented people here who have helped me along. And this is how I plan on contributing to its growth.

It is my belief that if you are picking any new tech, your first projects should be as bare to the metal as possible. Frameworks are amazing when you understand the language and its nuances. But there’s too much magic. Too much stuff that I don’t understand. Why is it like that? What happens if you delete this? Is there documentation on using that custom function? and so on. So, in this guide I will try to use as few libraries and 3rd party code as possible.

I actually use Windows as my OS of choice and Crysta runs on the WSL subsystem in it. Expect some eccentricities in how I do things. 😺

Some of the core ideals of this guide are:

  1. It is for the new user.
    Assume no burden of knowledge. However, while I will touch upon something new or interesting about the language itself, whenever I chance upon it during this guide, I will have to assume that you know at least the basics of programming, in general, and Crystal, in particular.
  2. Keeping it simple.
    I barely understand 10% of the language. I do not want to use concepts I myself am not clear on. So I plan to keep the app as simple as I possibly can. There may be boilerplate, there may be crappy code but it should all be readable and digestable to a new user.
  3. (or close to 0) Dependency.
    When I tried Go, i asked “what framework should I use”. The answer often was to use no framework at all. Go provides everything you need to create a webapp. When I tried Crystal, I realized the same was true here. I plan on using as few frameworks and libraries as possible and to stick only to the tools Crystal provides.
  4. Focus on end to end development and deployment.
    Starting from scratch. Ending in a deployed and functional app. I hope to make this a very expansive series touching upon every facet of webdev.
  5. Its my journey.
    I am learning Crystal. This tutorial is as much for me as it is for you. I will make stupid decisions, implement strange patterns, but I will try to shed some light on my thought process. Hopefully you will see the code improve as I write more of it.
  6. Iterate.
    I plan on incorporating suggestions and improvements to the guide that my readers give me. So please be vocal. :D
  7. I am not very reliable.
    😿 Seriously, this is a very very ambitious thing for me. I may not be able to finish it. I may give up on it somewhere. So, please do recognize that my own life may not leave me enough time/energy to finish the entire guide. Crystal occupies a rather small portion of the time I have to myself.

Section WIP. will update here as the content gets developed.`

This is the overall structure that I have planned for my series;
1. Crystal Cove 01: From 0 to Webapp
Crystal Cove 0x: A Viewtiful World

Crystal Cove 0x: Routing up a Storm

Crystal Cove 0x: Actions, Payload and the App framework

Crystal Cove 0x: TDD

Crystal Cove 0x: Database it
Crystal Cove 0x: Auth with JWT
….

……

Crystal Cove 0x: Dockerize and Deploy
Crystal Cove 0x: Monitoring app health

Once I have some more content, I will reorganize this list as a Table of Content and this current introduction piece will also serve as a ToC.

--

--