
Crystal 0.25.1 released - mikece
https://crystal-lang.org/2018/06/28/crystal-0.25.1-released.html
======
Blackstone4
Crystal looks interesting although I decided to learn Golang instead. It's
more mature and the WIP features described below made me cautious (i.e. what
other features are immature).

Anyone know when Crystal will get concurrency-a-la-golang? i.e. running
concurrent processes in parallel? At the moment I think it's still single-
threaded. [https://crystal-
lang.org/docs/guides/concurrency.html](https://crystal-
lang.org/docs/guides/concurrency.html)

Still no windows support: [https://github.com/crystal-
lang/crystal/issues/5430](https://github.com/crystal-lang/crystal/issues/5430)

~~~
everdev
I've programmed in both and as far as I can tell here's the best use case for
each:

Go - I want to program explicitly and don't mind a little extra code or syntax
to do it. I want close to the best performance possible and a single
distributable binary. I don't mind being encouraged to "roll my own" api / web
app rather than using a framework.

Crystal - I want to feel like I'm writing in Ruby, but with type checking at
compile time and much better performance. I don't mind being a little less
performant than other compiled languages. I want access to Rails/Sinatra-like
frameworks for web/API apps rather than having to "roll my own".

Basically, if you want something quick and fun that can run in production, I
love Crystal. If you want something that needs to be custom and highly
performant, I love Go.

~~~
Blackstone4
Great response. [EDIT - as highlighted by the replies below you can't use
Rails with Crystal...my fault for misreading the parent] I didn't quite
realize that I could use Rails with Crystal. That would be make it more
interesting if I knew how to use Rails ^^

~~~
snadon
Lucky uses type safety extensively preventing a lot of bugs. My team really
enjoys working with it. You should definitely check it out.

~~~
paulcsmith
[https://luckyframework.org](https://luckyframework.org)

------
paulcsmith
I've played around with a number of languages and settled on Crystal because:

* Speed

* Pleasant to use type system

* Doesn't get in my way

* Catches lots of bugs

* Fun!

I wrote [http://luckyframework.org/](http://luckyframework.org/) to write web
applications with minimal boilerplate and as few runtime errors as possible.
Take a look and let me know what you think

~~~
vram22
From
[https://luckyframework.org/guides/installing/](https://luckyframework.org/guides/installing/)

    
    
      >To get Lucky, you need to install these first.
      >Install one of these process managers: Overmind (recommended), Heroku CLI (great if you plan to use Heroku to deploy), forego, or foreman.
      >Node. Requires at least v6
      >Yarn
      >Crystal. Requires at least v0.25
      >Postgres (macOS/Others)
    

Why are those dependencies needed, except Crystal, particularly Node? And does
Lucky only work with Postgres?

~~~
paulcsmith
You can use Lucky without a database, but if you use one, Postgres is the only
support database.

You don't need node or yarn if you are using API mode. You can generate an API
only app with `lucky init <app-name> \--api`

The process manager is used to start the watcher process. You can use Lucky
without it by running `lucky watch` instead of `lucky dev`, but using the
process manager is nice because you can also run asset compilation, job queues
and whatever other processes you app needs to run.

Lucky can be stripped down further still, but the documentation focuses on the
more opinionated route

~~~
vram22
Thanks for the info.

------
wokawoka
Godspeed to the Crystal team. Third party library means everything.

Otherwise you end up with the same problem: "cool language...now I need to
bind it to a C library to do this..."

Still betting on Rust and it's ecosystem.

~~~
sam0x17
IMO Crystal as a lot more mass-appeal than Rust, and once people realize that
the interest might swing in that direction as pretty much anyone could pick up
Crystal. Rust is an awesome, very cool language, but Rust code is super weird
looking, and the backflips you have to do to deal with safety make even basic
tasks sometimes extraordinarily difficult, or so I've heard.

~~~
wokawoka
"make even basic tasks sometimes extraordinarily difficult, or so I've heard"

That would be an understatement :-)

But it's a trade-off. You fight the borrow-checker to ensure safe code.

It's really subjective. Are you using a language for front-end/middle-tier
service/back-end process, etc. etc.

Back in the day - you had a handful of people writing C code via CGI for web
development.

Every good language addresses a problem.

Rust = safe code. Crystal = IMO...productivity.

~~~
RX14
Exactly. I wouldn't write a kernel or shared library in Crystal and I wouldn't
write a webapp in Rust.

~~~
floatboth
> wouldn't write a webapp in Rust

[https://rocket.rs](https://rocket.rs) looks nice ;)

~~~
RX14
What other people subject themselves to is none of my business :)

And there is need for HTTP frameworks in Rust, for example embedded stuff
often hosts HTTP servers. However, just like C we frameworks, it's my opinion
they're not for the average use case.

~~~
wtetzner
Yes, and I can see HTTP frameworks in Rust useful for turning high-performance
libraries into web services that can be used by other applications.

~~~
RX14
Yeah, that makes a lot of sense too. For example a database might want to
provide a REST api for management, which would make sense to write in rust if
the DB was written in rust.

------
snake_case
I tried out Crystal and Kemal a few months ago and really enjoyed it. However,
one issue that's preventing me from wanting to take it to production is that
apparently you cannot generate fat binaries and run them without Crystal also
being installed in your deployed environment.

Is that true still? If it is, does anyone know when support for "real" fat
binaries (no need for Crystal on the server) will be available?

~~~
e12e
Not sure when/if this changed recently, but from:

[https://crystal-lang.org/docs/using_the_compiler/](https://crystal-
lang.org/docs/using_the_compiler/) "Creating a standalone executable":

crystal build some_program.cr --release --static

Builds a static binary (just tried it on Ubuntu 18.04 with a simple hello-
world).

~~~
sam0x17
You're going to have much better luck with an alpine-based docker image.
Unfortunately non-musl based systems have a lot of issues with static
compilation, so while this will work with hello world, if you try something
more complicated you will likely get linker errors.

~~~
e12e
Particular to the c library? Because an "ldd" on the hello world listed quite
a few libs which all worked fine with a static build.

~~~
sam0x17
openssl and libz are particularly fussy

~~~
e12e
I could definitely see openssl being tricky (libz not so much, but I might
very well be naive here) - but how does changing the libc help with either?

~~~
RX14
glibc has some plugins which make it not easy to statically link. Musl doesn't
have that. And alpine compiles openssl etc. with a config amenable to static
linking. It's all about distro choices.

------
thomasfedb
Only noticed this in the release post, but the `record` feature is neat:
[https://crystal-
lang.org/api/0.25.1/toplevel.html#record(nam...](https://crystal-
lang.org/api/0.25.1/toplevel.html#record\(name,*properties\)-macro)

~~~
yxhuvud
It's been around for a long time, but perhaps not documented.

~~~
thomasfedb
The clever bit seems to be that, being a macro, it can accept an undefined
constant as if it was an argument, and then define that constant. Neat.

------
shawabawa3
Are compilation times still incredibly slow?

That was the deal breaker for me with crystal, toy project of maybe a few
hundred lines of code taking 30+s to compile

edit: specifically a static release compile, with

    
    
        shards build --no-debug --release --link-flags "-static"

~~~
asterite
The compiler takes about 30 seconds or a bit more to compile, and it has
around 50000 lines of code. Do you have the few hundred lines that took you
30+s to compile?

~~~
shawabawa3
Just dug out the code and tried again

It's 80 lines and depends on kemal, radix and kilt

`shards build --no-debug --release --link-flags "-static"` takes ~60s

I can't send the full code atm, but it basically just fetches json from an
endpoint, stores it in memory, and returns it in a different format on an http
endpoint

~~~
asterite
Oh, release builds do take longer.

My point of view is that while developing you don't need the `--release` flag,
so you can get a more or less fluent experience. The few times where you need
to release an app it takes longer, but for me that's acceptable.

~~~
ModernMech
I always like flipping on the release flag at then end of my work day. I treat
it like a stopping point in my code, where I get to see how fast it is
compared to the slow running debug executables I’d been working with all day.
Great way to end a coding session.

~~~
RX14
I rarely notice the difference between release and debug executables unless
i'm benchmarking or doing something super CPU heavy. I've so far deployed most
of my crystal apps in debug mode because it makes the stack traces nicer
because of the lack of aggressive inlining.

------
sergiotapia
Anyone using Crystal in production? What do you use it for?

~~~
Thaxll
I'm not sure why anyone would actually use it in the current state, unstable,
lack of libraries, lack of community and the biggest problem no multi-
threading / windows support

~~~
nlh
I know you’re (effectively) trolling here, but there are many reasons to
“actually” use it. The community is great and helpful (check out the Gitter
activity if you have any question about that). Lack of Windows support (for
now) doesn’t matter if....you don’t use Windows. Multi-threading is being
worked on.

You’re rehashing the same 2 things many folks point out that Crystal is
missing in its pre-1.0 state and while they’re obviously important for
widespread adoption, they’re not reason in and of themselves to dismiss a
language that’s otherwise super interesting to many.

~~~
Thaxll
I'm actually not trolling, I'm 100% serious, there is no reason to use that
language right now when you have others languages that are better on every
aspect. Maybe Crystal will be ready at some point but right now it's not.

~~~
RX14
I don't think any language feels as close as crystal does to dynamic languages
while being completely type safe with strong types. I think thats why so many
people choose to use it so early. It truly doesn't feel like any other
language out there.

------
kureikain
Crystal is a nice language that just keep getting better.

Think about 10 years ago, we never think of a small company,community be able
to writing a programming language. Nowsaday Crystal/Elixir/Nim prove what we
can without huge financel support from huge company.

Crystal pick Ruby syntax, which is very elegant to me and I'm happy to have
that option available and appreciate that.

~~~
e12e
> Think about 10 years ago, we never think of a small company,community be
> able to writing a programming language.

Perl, python, ruby ?

------
szopanator
Any recommendations on an editor for crystal? I was unable to get the VSCode
extension to work properly.

~~~
sam0x17
Atom behaves pretty well with it. What problems are you having with VSCode?
That's what I use.

------
cutler
Won't the impending releases of TruffleRuby, Graal and Substrate VM make
Crystal irrelevant?

~~~
asterite
That's about speed (though I think Truffle/Graal make an app consume more
memory). Crystal is type-safe, and no optimizing VM can do that for Ruby.

Not that type-safety is a killer feature, but that's just one difference.

~~~
benbristow
[https://medium.com/byteconf/stripe-is-building-a-ruby-
typech...](https://medium.com/byteconf/stripe-is-building-a-ruby-
typechecker-d6cd7cee6abf)

Stripe are trying to solve that issue.

~~~
AsyncAwait
That's still not the same as a compile time type-checker, it still relies on
the interpreter.

------
qop
I gave up on crystal and realized I should've started with rust in the first
place.

Crystal wants very badly to displace ruby, in order to leverage the network of
developers and generate more and more attention. It's a smart decision on
their part.

As such, crystal doesn't seem to have munch interest in low-level nitty
gritty. "we aren't trying to be C" is a common comment amongst contributors.

For game dev, (why I'm bothering with rust) it's too big a turn off to ignore.

For web dev, I suspect crystal will ultimately find some success. Lucky
framework has some REALLY cool features that rails hackers are going to
discover eventually.

Unless ruby 3 drops a type system bomb and finds a 10x perf speedup, the
continuing progress crystal is making will consume the ruby ecosystem.

Congrats on another successful release! Still no exhausting matched, no
parallelism, and the spectre of type system changes in the future still looms,
but aside from those things, looking good!

And windows support. But I personally don't mind windows support being
missing. Fuck 'em. Continuing to settle for windows with alternative
implementations and things like Wine only gives windows more power as an
antihero. Let them be forced to adopt a Linux kernel, no compromise.

Edits: typos

~~~
RX14
Exhaustive matching is on the cards, parallelism is coming, and any type
system changes in the future will be minimal.

And yes, crystal isn't trying to be C, but you can still do many of the low-
level things that you can do in C. It'd be nice to know what exactly you were
missing from Crystal.

~~~
qop
It's not the lack of features it's just the difference in what it's meant for.
Crystal has a GC, it doesn't have a lot of memory control, etc. She just ain't
that type of lady.

Crystal isn't what I thought it was. That's not a bad thing necessarily, it's
certainly nobody's fault....

For what I have in mind, rust fits my needs much more closely. I want to write
a game and learn all about graphics wizardry and rendering pipelines and all
the cool Carmackian arts I've been missing out on. My career is winding down,
but I think I will retain my gray matter longer if I keep myself busy.

If I were thirty years younger and starting out a career in web development,
crystal would excite me. The prospect of all that ruby out there that will
eventually need to be crystallized... Man, what an opportunity.

I don't really have a specific idea in my head of what a crystal for systems
development would look like so I'm not sure that I could really provide what's
missing from crystal.

Rust is made for systems from the start and there appears to be a large number
of really smart low-level hackers on the scene already. I'm glad, because I
don't know, so at least I can fail amongst a crowd.

:)

------
jernfrost
Any Julia programmers who have tried Crystal? I've never quite seen the point
with Crystal when you got something like Julia. Although I guess there is a
value in familiarity.

I was a big fan of Ruby back in the day, but I just feel that our
understanding of what makes good language design has evolved since then. The
heavy OOP focus in Ruby seems very 90s in retrospect.

I don't think it makes sense to restrict dispatch on single objects. Real
world problems often don't fit that paradigm.

~~~
RX14
On the language level, Julia isn't statically typed, and it doesn't have ruby
syntax.

On a tooling level, binaries are easier to deploy than the whole julia JIT and
your whole source code.

And crystal has dynamic multiple dispatch. It's used a lot, it's great.

