News for hackers. Stuff that matters.
Re:Crystal: Fast as C, Slick as Ruby by Svenskunganka on Thursday August 04, 2016 @01:27AM (#12223568)
I'd like to put out there that Crystal is absolutely awesome. The language itself is Crystal clear, but the language documentation and API documentation - oh my!

I had never worked with compiled languages before I tried Crystal, but had always had a huge interest in getting into that. When I wanted to learn the compiled ecosystem I looked at languages like Go and Rust, but the learning curve for those was a bit overwhelming for a newbie. A while later I found Crystal, and much thanks to the simple syntax of the language I learned a ton of new things about compiled languages very quickly. The absolutely best part of the language is that it is written in plain Crystal, and I've been looking at their own implementations for various things a lot - something I've never done before, having worked mostly with Node, Lua and PHP before.

Nowadays I can delve into Go documentation, packages are clear to me and I just understand how things should and should not be implemented to achieve a good efficiency and performance level. The Little Go Book makes sense, the I/O package is simple and this is probably all thanks to the syntax of Crystal, the amazing language & standard library documentation but most importantly the source of Crystal being written in Crystal.

I'm currently working on building a business using Go, because I absolutely need Windows target support - something which Crystal does not yet have. But the second it gets that, I'm moving back. Don't get me wrong, Go is really great and nice to work with - but Crystal is my mentor. Please note that I have not worked with Ruby before, so the whole language was new to me.

To summarize; even if you only wish to learn, Crystal is in my personal opinion the best choice to go with.

Re:Crystal: Fast as C, Slick as Ruby by kristianp on Thursday August 04, 2016 @02:18AM (#12223745)
Maybe the makers of Crystal need to take a leaf out of Go's book. Despite the Go creators not being windows users (AFAIK), they support Windows as a primary target, to help adoption, I assume.

Of course the Crystal people probably don't have the same number of developers working on it as Go did even early on.

Edit: Go took a little while to support windows, not until around July 2010. See this question from November 2009: http://stackoverflow.com/questions/1717652/can-go-compiler-b...

Re:Crystal: Fast as C, Slick as Ruby by RX14 on Thursday August 04, 2016 @06:41AM (#12224652)
The plan is to support windows before 1.0, although the core devs are reluctant to "open up" to the large amount of developers windows support would bring before they are finished making breaking changes.
Re:Crystal: Fast as C, Slick as Ruby by rogerdpack on Thursday August 04, 2016 @06:17PM (#12228856)
I don't think they're afraid of it, more like haven't gotten around to it would be my guess...
Re:Crystal: Fast as C, Slick as Ruby by spoiler on Thursday August 04, 2016 @04:49AM (#12224284)
Crystal supported Windows (albeit unofficially, and it was an epic adventure to compile it, and I've never tried running any serious code on it), however all support practically ceased when it switched from libpcl to inline ASM for coroutines.
Re:Crystal: Fast as C, Slick as Ruby by pyed on Thursday August 04, 2016 @02:58AM (#12223891)
Windows support was implemented by the community, Not the creators.
Re:Crystal: Fast as C, Slick as Ruby by naviix on Thursday August 04, 2016 @11:44AM (#12226293)
not to take away from the point you're trying to make, but i just installed it on windows 10 with the latest update that included bash. felt nice.
Re:Crystal: Fast as C, Slick as Ruby by patates on Thursday August 04, 2016 @03:04AM (#12223910)
For the ones who started to wonder about the Windows support, it is tracked here:

https://github.com/crystal-lang/crystal/issues/26

Re:Crystal: Fast as C, Slick as Ruby by makufiru on Thursday August 04, 2016 @03:42AM (#12224043)
In my experience, Golang's Windows support is actually fairly poor. I think it is largely to do with the clunky interface that is CGo. I found Rust to be less "warty" by a large margin with good library support in a lot of areas. Your mileage may vary, of course.
Re:Crystal: Fast as C, Slick as Ruby by dx034 on Thursday August 04, 2016 @03:45AM (#12224053)
This is not what I experienced so far. I use Golang on both Linux and Windows (50/50) and I didn't have any problems. What are you referring to exactly?
Re:Crystal: Fast as C, Slick as Ruby by makufiru on Thursday August 04, 2016 @03:49AM (#12224072)
As I said, YMMV but the biggest standout that I remember was trying to play sounds using the windows API. There weren't any packages our team could find that really did it correctly, the one that everyone pointed to leaked memory like crazy and it was hard for us to track down since it relied on bouncing back and forth between C and Go so frequently (making malloc/free lifetimes difficult to follow because C can't know what things have been GC'd by the Go runtime)
Re:Crystal: Fast as C, Slick as Ruby by rogerdpack on Thursday August 04, 2016 @10:25AM (#12225716)
sounds more like the ecosystem for windows support is slow. Or were there some stdlib's useful for it in go on linux?
Re:Crystal: Fast as C, Slick as Ruby by spriggan3 on Thursday August 04, 2016 @04:22AM (#12224206)
> Golang's Windows support is actually fairly poor.

It does exist unlike Crystal, so you should explain what you mean by poor. I never had a problem compiling a project with CGo on Windows.

Re:Crystal: Fast as C, Slick as Ruby by dmux on Thursday August 04, 2016 @09:11AM (#12225226)
You mention learning a lot about compiled languages, and mention afterwards being able to understand packages. How are those two related?
Re:Crystal: Fast as C, Slick as Ruby by Svenskunganka on Thursday August 04, 2016 @09:23AM (#12225287)
I meant the packages of the stdlib, not community-made packages. A great example is the things I learned about the IO module and how it plays with the other modules in the stdlib for Crystal that I could easily see a similarity in behavior and methods in the Go implementation, but not being able to fully understand before I had a go with Crystal.

The way they interact with different types, fibers and allocation on the stack vs heap, etc. Makes sense?

Edit: To give you an example of how friendly the Crystal lang & API documentation is to developers unfamilliar with the language, let's look at the Iterator: https://crystal-lang.org/api/0.18.7/Iterator.html

It comes with a great "introduction" to what it is, what it does and gives an example of the advantages it has over the Enumerable. It also explains how you can implement your own Iterator.

We can also look at the IO module for Crystal and the io package for Go: https://crystal-lang.org/api/0.18.7/IO.html https://golang.org/pkg/io/

From a beginners standpoint, you have to see that the Crystal documentation is way more friendlier.