Setting up the environment
Let's prepare ourselves to create and run Crystal applications, which we will begin in the Creating our first program section. For this, the two most important things you will need are a text editor and the Crystal compiler:
- Text editor: Any code editor will get the job done, but using one with good plugins for Crystal will make life much easier. Visual Studio Code or Sublime Text are recommended. You can find more details about the editor setup in Appendix A.
- Crystal compiler: Please follow the installation instructions on Crystal's website at https://crystal-lang.org/install/.
After installing a text editor and the compiler, you should have a working Crystal installation! Let's check it: open up your terminal and type the following: crystal eval "puts 1 + 1"
:
This command will compile and execute the puts 1 + 1
Crystal code, which writes the result of this computation back to the console. If you see 2
then all is set and we can move forward to writing actual Crystal code.