00:00:10.240
thank you to to ruko for having me here
00:00:15.640
and for me it's it's an honor to to be
00:00:18.640
in in this huge
00:00:20.439
stage sharing with this amazing
00:00:23.720
community that I love so much
00:00:27.240
um but well I I know that maybe the
00:00:30.679
majority of of the people here are maybe
00:00:34.399
wondering who is this
00:00:36.600
guy uh I I I want to take a a little bit
00:00:41.600
to properly introduce
00:00:44.320
myself um my name is Rafael Peña
00:00:48.879
assar uh I'm from Colombia uh from a
00:00:53.559
city named Santa
00:00:55.559
Marta pretty far
00:00:57.800
away um
00:01:00.320
uh if maybe my name sounds uh a little
00:01:04.000
bit familiar to you uh I known in almost
00:01:08.040
every social networks arepa
00:01:10.600
web uh and I married I have two
00:01:14.759
beautiful kids Benjamin and
00:01:18.159
Nicholas there you
00:01:21.280
go and I've got uh a lot of roles in my
00:01:26.119
in my work
00:01:27.240
experience but uh in general I consider
00:01:30.159
myself as a programmer it's it's the
00:01:33.159
term that I like the most uh I have
00:01:36.320
almost 15 years doing software
00:01:40.040
development and 12 of those 15 years are
00:01:43.920
with Ruby and Ruby and
00:01:46.280
rails uh I sometimes do public speaking
00:01:50.360
uh I've been a teacher from some
00:01:53.159
universities back there in
00:01:55.680
Colombia did some conference in the past
00:01:58.719
too uh some
00:02:00.920
rubicons in Colombia too uh but I'm
00:02:05.799
pretty sure none of them is like this
00:02:08.879
one um I'm also a technical writer um
00:02:14.720
we're going to agree that uh we like a a
00:02:17.680
very well structured
00:02:19.120
documentation but also I I write love to
00:02:22.360
write technical articles um recently I
00:02:25.760
started a kind of series of Articles
00:02:29.040
called Ruby out rails uh in my death
00:02:32.400
profile where I talk about um basically
00:02:37.040
powerful things about U Ruby without
00:02:41.400
without rails um things like um generic
00:02:45.879
algorithms um machine learning
00:02:49.360
blockchain um I'm also an aspiring
00:02:53.800
solopreneur uh I'm I don't know if many
00:02:57.280
of you are familiar with with uh uh a
00:03:00.040
project that I'm building called
00:03:03.000
Skeletor um and the the the thing is not
00:03:06.720
to to spread the word with it but I'm
00:03:10.400
kind of mention it because I use crystal
00:03:12.440
too in that
00:03:13.959
project um I'm
00:03:17.200
also back in Colombia I'm considered
00:03:20.120
like a ruby and rails
00:03:23.400
evangelizer uh that's because uh
00:03:26.200
wherever I go or or every company I
00:03:28.599
works for I always end up talking about
00:03:31.360
ruby and and rails and at some point
00:03:33.760
they end up they end up making something
00:03:36.720
uh on on Rails or or even rewriting
00:03:40.599
projects existing projects with with
00:03:44.159
rails
00:03:45.720
and what else I I found Ruby Santa Mara
00:03:50.080
in in my city it's a a ruby user group
00:03:52.799
based on on that
00:03:54.519
City and and besides I consider myself
00:03:58.360
as as a Crystal
00:04:00.920
Enthusiast uh I'm not a I'm not consider
00:04:04.680
myself as an
00:04:06.159
expert but um I need to address that
00:04:10.400
it's it's a a project that that moves me
00:04:13.920
and makes me wanted to contribute at
00:04:16.440
some
00:04:18.040
point uh I know it takes maybe a lot of
00:04:22.400
courage to being here in a ruby
00:04:25.280
conference and talk about another
00:04:28.160
language but uh uh I I I will try to to
00:04:31.960
make it the best
00:04:33.960
way um
00:04:36.840
I want to to start with a little
00:04:41.520
poll and I please raise your your hand
00:04:45.919
if how many of you have even heard about
00:04:50.000
Crystal
00:04:51.720
language
00:04:53.479
awesome and how many of you have
00:04:57.120
developed something on crystal
00:05:01.320
or
00:05:02.520
less and after that I I would like to
00:05:05.759
ask if you
00:05:07.800
know Frameworks that are based on
00:05:12.000
crystal
00:05:14.039
language
00:05:16.320
okay well um that message is a little
00:05:20.960
powerful for me because I I I didn't
00:05:23.680
cross
00:05:25.160
the the the Atlantic to come to to uh
00:05:28.880
the largest Ruby convention in Europe to
00:05:32.720
tell you to stop being Ruby developers
00:05:35.720
it's kind of foolish uh I'm just another
00:05:40.039
Enthusiast guy about a language that
00:05:44.280
um uh it's highly influenced by by Ruby
00:05:47.720
and and I wanted to share with all of
00:05:49.720
you um that this
00:05:52.479
language exist that that it's it's very
00:05:56.280
very well maintained and and also it's
00:05:59.759
not my my intention today to go very
00:06:03.960
deep about comparisons because the the
00:06:07.599
goal of this talk is not about um saying
00:06:11.160
at the end which language is better it's
00:06:14.319
not the that that's not the point the
00:06:17.440
goal is to explore how Ruby have
00:06:21.000
influenced the creation and the
00:06:22.800
evolution of Crystal and show maybe
00:06:26.120
their similarities some differences and
00:06:29.319
and reflect on what the future may hold
00:06:32.720
between both
00:06:34.120
languages so let's talk about Crystal
00:06:37.080
language a little
00:06:38.680
bit uh the work on the language began in
00:06:44.639
2011 the crystal compiler was first
00:06:47.599
written in Ruby then later written in
00:06:50.560
Crystal becoming self-hosted in
00:06:53.680
2013 its first official version comes in
00:06:57.560
2014 and
00:07:00.039
in 2016 became a more mature and more
00:07:03.639
more stable encourage its
00:07:06.000
adoption and in more serious projects
00:07:09.639
fast forward in
00:07:11.240
2021 Crystal reaches version 1.0 and
00:07:15.199
marking the first official stable
00:07:17.360
release and indicating that the language
00:07:19.440
was production ready and now talking
00:07:23.360
about this year Crystal's popularity
00:07:25.639
continues its
00:07:26.879
rise especially in in in areas where
00:07:29.520
where performance and and efficiency are
00:07:32.879
critical while keeping RIS
00:07:36.160
elagance but let's talk about what is
00:07:41.759
Crystal well uh
00:07:45.840
in in a compress uh definition basically
00:07:50.360
it's a high level General propose object
00:07:53.919
orent
00:07:55.240
compile programming language with static
00:07:57.879
type checking
00:08:01.400
was sted by Ari bores and
00:08:04.960
Johan Warner man with the idea of
00:08:08.400
creating a language that combines the
00:08:11.199
elegance and the Simplicity of
00:08:13.440
Ruby but with the efficiency and the
00:08:16.479
speed of
00:08:17.360
sea although Crystal and and Ruby share
00:08:20.800
a lot of terms in philosophy and and
00:08:23.960
syntax they are maybe key differences
00:08:28.400
crystal is static type
00:08:31.039
and allowing allowing it to deliver
00:08:35.159
maybe SE like performance while Ruby is
00:08:38.599
a dynamically type interpreted language
00:08:41.560
optimized by uh for developers
00:08:45.440
productivity but from the beginning
00:08:47.800
Crystal syntax was designed to feel
00:08:51.360
familiar to to Ruby
00:08:53.640
developers and well let's take a look at
00:08:57.600
some CCO can can you please someone find
00:09:01.240
a difference between these two pieces of
00:09:07.000
code there's the same class and the same
00:09:11.680
method even the same response written in
00:09:15.680
both
00:09:17.560
languages but let's go to use uh an
00:09:21.040
object orent structure to make that
00:09:22.720
hello word in Crystal and see if we got
00:09:25.600
some
00:09:26.480
difference here we got the name very
00:09:29.680
declared now as a string and it's not
00:09:32.160
even necessary to assign anything inside
00:09:34.959
the initialized
00:09:37.920
method
00:09:39.440
but Crystal has grown its popularity and
00:09:44.000
has even grown an an activ an active
00:09:49.560
Community projects like kimal like Ember
00:09:54.279
and loocking are are helping to expand
00:09:57.399
its ecosystem making an attractive
00:10:01.240
option for Ruby developers looking for
00:10:04.079
something new maybe some
00:10:08.120
challenges Crystal was designed to look
00:10:10.440
like Ruby and making the code familiar
00:10:14.079
and readable for Ruby
00:10:16.240
developers but this is not only makes
00:10:19.640
the transition easier but also allows
00:10:22.399
Crystal to benefit from ru's Rich
00:10:25.560
history in language design
00:10:29.480
let's talk a little bit about syntaxis
00:10:32.959
as you can see both codes are almost
00:10:36.560
identical demonstrating the familiarity
00:10:38.959
between Crystal and and Ruby and Ruby's
00:10:43.240
readability and expressiveness were key
00:10:46.440
Inspirations to Crystal
00:10:50.480
design although the syntax is very
00:10:53.920
similar there are important differences
00:10:56.360
in
00:10:57.440
semantics crystal is static type again
00:11:00.160
checking language and specifying data
00:11:03.079
types not only improves performance but
00:11:06.120
also allow you to detect
00:11:08.120
errors uh at compile time Crystal adopts
00:11:12.720
many of the Ruby design principles this
00:11:17.200
make crystal code AS intuitive as Ruby
00:11:21.959
but with a Ned benefit to optimize
00:11:25.600
performance Crystal adopts um
00:11:30.639
many of the again that's the the design
00:11:34.440
principles but now I want to try to
00:11:37.639
explain about that static type checking
00:11:39.800
on crystal because it's a little bit
00:11:42.399
different on than other static type
00:11:47.560
languages Al about Crystal is based on
00:11:49.880
Ruby the diverge on how it solve the
00:11:52.880
problems some problems but what it means
00:11:56.920
that it's a static type checking in
00:11:59.480
different than other static type
00:12:02.360
languages let's let's start by
00:12:06.120
addressing some of the terminology
00:12:09.120
static type language means that the
00:12:11.800
types are checked at compile time rather
00:12:14.160
than at run time which helps catch
00:12:16.680
potential errors early in the
00:12:18.800
development
00:12:20.399
process this leads to improve
00:12:23.519
performance and as the compiler
00:12:25.720
generates more efficient mashing code
00:12:29.600
based on the know types and increase the
00:12:32.680
readability by
00:12:34.800
catching type related errors before the
00:12:37.639
code is
00:12:39.440
executed but what's the difference with
00:12:44.639
other static type languages Crystal
00:12:48.199
takes a different approach compared to
00:12:51.240
some
00:12:52.160
other statically type language by
00:12:55.639
emphasizing in readability and the
00:12:58.480
Developers productivity remember the
00:13:01.920
influence is Ruby and that's the way
00:13:04.320
Ruby
00:13:05.760
Works here's
00:13:07.839
how Crystal can achieve that
00:13:12.399
balance there are five items that we're
00:13:16.240
gonna we're going to discuss and Crystal
00:13:19.800
has these checks that we're going to go
00:13:22.440
through to understand a little bit more
00:13:24.320
about
00:13:25.880
it and about type inference
00:13:30.079
Crystal and this is very interesting
00:13:32.560
Crystal uses type inference extensively
00:13:35.560
meaning the
00:13:37.040
compiler automatically determines the
00:13:39.760
type of the variables and expressions
00:13:42.399
based on their values and context this
00:13:46.120
reduce the need for developers to
00:13:48.720
explicitly declare the types
00:13:52.240
everywhere leading to a cleaner more
00:13:54.440
readable code base I I always try here
00:13:58.199
to remember how typescript works and
00:14:02.240
make a parallel line between both
00:14:05.759
languages so this reduces
00:14:09.720
the the the needs for developers to
00:14:12.279
explicitly declare types everywhere and
00:14:15.399
in this case the compiler infers that
00:14:19.000
the value of a name
00:14:21.920
String and the value of
00:14:24.839
H are inferred that it's one of a string
00:14:29.199
and the the other one is at 32bit
00:14:31.040
interor but without the clearing
00:14:38.600
anywhere but there's the optional type
00:14:43.440
annotations so look at the
00:14:46.120
code while Crystal infers the types as I
00:14:49.360
was saying it also allows developers to
00:14:52.279
add type annotations were needed for
00:14:55.519
clarity or to enforce strict type
00:14:58.160
constraints for instance in this casee
00:15:02.160
both argument and return types are
00:15:04.680
annotated which makes the funion
00:15:06.480
contract
00:15:07.639
explicit and this ensures that any
00:15:10.120
misuse like passing a non-string
00:15:12.920
argument will be CAU at compile
00:15:18.279
time this is another interesting
00:15:22.880
topic Crystal introduces a type system
00:15:26.720
that treats Neil as a special type not a
00:15:29.880
regular and rather than simply allowing
00:15:32.759
any type to be nil this means that you
00:15:36.759
can accidentally assign NE to a variable
00:15:39.880
unless it's explicitly
00:15:42.040
allowed this reduces common errors such
00:15:44.480
as the N pointer exception that we are
00:15:46.680
all familiar with and for example in in
00:15:52.240
this case the question mark allows name
00:15:56.360
to be Neil in the case if Neil is not
00:16:00.120
allowed the compiler will rise an error
00:16:03.360
and if you try to assign Neil to a non
00:16:05.399
knable
00:16:08.079
type that's another interesting topic
00:16:11.839
with Crystal the unit types Crystal
00:16:14.360
allows varibles to hold
00:16:17.720
values of more than one um type using
00:16:22.759
this called Union types this means that
00:16:26.440
you can express situations where
00:16:29.759
the type of of the in this case the
00:16:34.079
compiler infers that the type of the
00:16:36.639
value is a string or a 32bit integer can
00:16:39.920
be both and will keep track of the
00:16:42.399
possible types and enforce correct
00:16:45.360
operations on them this also makes the
00:16:48.600
code easier to understand because it
00:16:51.680
conveys to the exact types expects in
00:16:55.519
various context
00:16:58.959
crystals also uh static type Works hand
00:17:03.000
inand with its friendly compiler error
00:17:06.039
messages if a type mismatch or a
00:17:09.799
potential error is detected Crystal
00:17:12.439
provides feedback that is clear and
00:17:15.360
helps developer paino the issue without
00:17:18.240
requiring them to sift through verbos
00:17:20.160
complex
00:17:22.039
messages crystals static type enhance
00:17:26.000
safety and performance through compile
00:17:28.480
time checks while maintaining the
00:17:30.720
ratability through the type inference
00:17:33.520
optional type annotations and the
00:17:35.720
flexible unit types this allows
00:17:38.360
developers to enjoy the benefits of a
00:17:41.720
tactically typed language without the
00:17:44.880
verbosity typically associated with it
00:17:48.760
again always think about typescript and
00:17:52.160
make the parallel
00:17:55.200
comparison
00:17:56.960
but crystal is not Ruby so there's also
00:18:01.360
points where Crystal takes total
00:18:03.039
distance from
00:18:04.080
Ruby where they have nothing to do with
00:18:07.400
each
00:18:08.760
other let's talk a little bit about
00:18:11.000
those unique features Crystal has for
00:18:14.960
instance Crystal focuses on performance
00:18:18.159
through native comp compilation and
00:18:20.760
efficient concering mechanisms leverage
00:18:25.080
fibers to manage concurrency separating
00:18:28.960
a little bit of the what we know about
00:18:32.039
Ruby's
00:18:33.080
threats so again crystal is a compil
00:18:37.720
language so it compiles to Native
00:18:40.640
matching code using the llbm compiler in
00:18:44.039
Fr to this means that the crystal code
00:18:48.080
is
00:18:49.080
directly translated into a high
00:18:53.000
optimized masching code which can be
00:18:56.240
executed very efficiently
00:18:59.159
and Native compilation allows Crystal to
00:19:03.240
achieve near C
00:19:06.640
performance for many tasks as it
00:19:09.000
eliminates the possible overhead of an
00:19:12.080
interpreter and optimize the generate
00:19:16.200
code but I mentioned this word about two
00:19:20.120
times what's a
00:19:22.159
fiber Crystal uses this for concurrency
00:19:25.880
it's it's a key for concurrency in
00:19:27.400
Crystal
00:19:29.039
fibers are lightweight Cooperative units
00:19:33.880
of execution that are a scheduled
00:19:37.200
manually by the
00:19:39.240
programmer and the difference with Ruby
00:19:42.120
threats is that they're memory efficient
00:19:45.320
because they share the same OS thread
00:19:48.600
and only need a fraction of those
00:19:51.440
overheads of
00:19:52.880
threats fibersa are cooperatively
00:19:56.159
scheduled meaning that yield control
00:20:00.080
explicitly this makes context switching
00:20:02.880
between fibers extremely fast and
00:20:06.679
because fiber doesn't involve context
00:20:08.480
switching at the oest level they have
00:20:11.679
lower
00:20:15.480
overhead this little code demonstrates
00:20:19.200
how fiber can be used to achieve
00:20:21.280
concurrency in a simple and efficient
00:20:23.640
manner the spa keyword is used to create
00:20:27.559
a new fiber on in Crystal every time we
00:20:31.600
call the spound we make a new
00:20:36.400
fiber okay and now this is a term that I
00:20:40.080
didn't mention before in Crystal macros
00:20:44.760
are a feature that allows you to Define
00:20:47.440
code
00:20:48.840
patterns which are
00:20:50.880
expanded let me show you in actual
00:20:54.200
during compilation macros and Crystal
00:20:56.799
can be used for very many proposes such
00:21:00.360
as simplifying repetitive code or
00:21:03.320
creating more readable and maintainable
00:21:05.000
code
00:21:08.240
patterns here is an example of how you
00:21:11.799
might use a macro in
00:21:14.279
Crystal you Define macros using the
00:21:17.240
macro
00:21:18.360
keyword and the macro body contains a
00:21:20.960
template code that maybe you are
00:21:23.400
familiar with that will be substitut
00:21:26.440
wherever the macro is used
00:21:28.960
for this particular example the macro
00:21:31.679
will generate three methods dynamically
00:21:35.000
the food method The Bar Method and the
00:21:37.520
bass
00:21:38.559
method in summary macro series um are uh
00:21:43.440
in Crystal a powerful feature for code
00:21:46.799
generation and meta programming allowing
00:21:49.400
to write
00:21:51.400
flexible and reusable code templates
00:21:54.720
that are expanded during
00:21:56.840
compilation they help reducing
00:21:59.200
redundancy and automating repetitive
00:22:01.960
task while providing a way to embed
00:22:05.840
complex code logic in consist and
00:22:08.240
manageable
00:22:10.960
firat crystal is
00:22:13.400
also specially useful in applications
00:22:17.960
where it's critical such as high
00:22:22.039
performance with servers or embedded
00:22:25.600
systems let's see an example of a basic
00:22:28.840
with server in
00:22:33.320
Crystal okay this simple web server
00:22:37.240
shows how Crystal can handle in some
00:22:40.919
workloads with high
00:22:43.200
efficiency but let me see I if I can
00:22:47.440
just make it run for
00:22:53.679
fun are you seeing
00:23:25.400
okay better
00:23:33.320
contr
00:23:36.320
perfect so let me see where
00:23:41.840
I'm work
00:23:55.600
space there you go
00:24:00.000
there you
00:24:01.799
go okay uh the web
00:24:07.039
server that's the same code I was
00:24:10.080
sharing
00:24:12.720
here so let me close this a little
00:24:17.720
bit
00:24:20.200
and do it again no it's not tab it's
00:24:24.440
Spain there you go
00:24:28.960
and let's make it
00:24:31.480
wrong
00:24:33.039
Crystal basic
00:24:39.120
server okay there you go that server
00:24:42.320
it's it's running and you see the the
00:24:45.520
the code right there and how they um get
00:24:50.720
the HTTP Direction and put it into the
00:24:55.880
server let's see another example
00:25:05.320
clear
00:25:19.679
uh let's start with the hello world to
00:25:24.000
see how we C in r in Crystal excuse me
00:25:28.679
another example that it's the same about
00:25:32.679
between Ruby and Crystal with the
00:25:35.279
syntaxis it's it's exactly the same
00:25:38.000
hello world with gruby and
00:25:41.000
Crystal so let's go in
00:25:44.640
run
00:25:48.399
Crystal hello
00:25:52.960
R there you
00:25:55.320
go can youe
00:25:59.240
uh I think
00:26:02.760
not but let me do one more and we
00:26:08.720
continue let's see about the
00:26:12.919
fibers that's the the same code uh I
00:26:16.320
shared recently with the
00:26:18.840
slides and if I do
00:26:23.559
crystal
00:26:25.399
fibers let's see there
00:26:30.640
go so let me put it
00:26:38.080
back well uh we we covered already
00:26:43.279
the the maybe the the comparison how is
00:26:47.120
the the landscape between the both
00:26:48.720
languages let's talk a little bit about
00:26:50.720
the
00:26:51.399
future crystal is constantly evolving
00:26:55.080
and and its Community it's it's
00:26:58.240
continues to grow so the Ruby's
00:27:01.600
influence here on crystal is pretty
00:27:04.360
clear and the language uh itself is
00:27:08.159
Charing its own path to into the future
00:27:11.240
with new features and
00:27:13.760
improvements the future of Crystal and
00:27:16.320
Ruby may be intertwined with
00:27:19.399
opportunities for collaboration between
00:27:21.720
both communities and I make a stop here
00:27:25.440
I personally would love that to happen
00:27:29.840
uh the learning of one of them can
00:27:33.640
enrich for sure the other one and
00:27:36.760
together can continue to innovate
00:27:39.640
software
00:27:42.799
development
00:27:44.440
so remember that I started the talk with
00:27:48.679
the same slide but with a question mark
00:27:51.360
at the
00:27:52.279
end well now uh if some of you didn't
00:27:56.720
heard anything before before about
00:28:00.360
Crystal uh then now we just know a
00:28:03.919
little
00:28:05.600
bit it may be a little bit but it's it's
00:28:08.960
something so I am replacing the question
00:28:12.080
mark with exclamation point and that has
00:28:14.159
a reason specifically if you're a ruby
00:28:17.679
developer and
00:28:20.200
haven't explored Crystal yet I encourage
00:28:24.120
you to give it a try it's a language
00:28:27.880
that that takes everything we love about
00:28:31.799
Ruby but has its own how how can I call
00:28:35.880
it um keys to to
00:28:39.240
success in terms of performance and
00:28:44.320
capabilities today uh we explored how
00:28:48.080
Ruby has shape or paraphrasing the name
00:28:51.279
of the talk has Forge Crystal and the
00:28:55.159
similarities and the differences between
00:28:57.480
the two languages
00:28:59.200
and obviously there's
00:29:01.399
more
00:29:05.720
but and where they might be HED into the
00:29:10.440
future it's the because Crystal
00:29:12.960
obviously has a a very bright
00:29:15.640
future
00:29:17.240
uh just to to finish let let me say
00:29:22.399
something uh
00:29:25.360
Crystal maybe it's not the the only one
00:29:28.559
but it's it's a testament on how Ruby's
00:29:33.519
inspiration has led into into
00:29:36.799
Innovation um I think that's pretty much
00:29:41.440
it thank you very
00:29:57.039
much and