Appendix 1: Setting Up a Crystal Environment

Your Turn 1

a. hello_world.cr:

$ crystal build hello_world.cr # size: 1.1MB

$ crystal build hello_world.cr --release # size: 802KB (Use –release –no-debug if –release doesn’t work for you.)

$ crystal build hello_world.cr --debug # size: 1.4MB

b. $ crystal build test.cr --error-trace

c. Put the code within single quotes: $ crystal eval ’puts "Greetings world!"’ # => Greetings world!

d. $ crystal build hello_world.cr --emit llvm-ir/ (see file hello_world.ll)

$ crystal build hello_world.cr --emit asm (see file hello_world)

e. $ crystal env gives as output:

 CRYSTAL_CACHE_DIR="/home/username/.cache/crystal"
 CRYSTAL_PATH="lib:/opt/crystal/src"
 CRYSTAL_VERSION="0.23.1"

f. A Crystal REPL: Clone the repository with $ git https://github.com/greyblake/crystal-icr.git.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.191.134