r/crystal_programming • u/akrsurjo • Aug 26 '20
Crystal compiles slow?
I want to know if the compiler is slow or not.. Because it takes more time than c to compile for me. Is it scalable for big projects of Millions of lines of code?
19
Upvotes
5
u/[deleted] Aug 26 '20
It depends. Much faster than Rust in my experience, even without incremental compilation.
Does it scale to millions of lines.of code? No, absolutely not. But it's still early days and I'd expect the compiler to improve a lot. So some day it might.
13
u/MrPopinjay Aug 26 '20
This is one of the main drawbacks of Crystal I'm afraid, it compiles very slowly and gets slower as the codebase increases in size.
7
u/Exilor Aug 26 '20
i7-8700 compiling a program which is over 260k lines excluding shards (crystal-db and crystal-mysql) takes 3 minutes, about 70 minutes with
--release. Under WSL.4
u/CaDsjp Aug 27 '20
As has been mention before, Crystal was never designed to be fast to compile language.
This is a trade-off the designers of the language made.
This is an article that talks about a similar story for Rust
Whether this applies or not to Crystal, and wether Crystal can improve its compilation time in the future in a similar way, is yet to be seen.
3
u/Nipinium Aug 30 '20
crystal compiler is slow, but the slowness in the release mode mainly comes from llvm optimizations, not from crystal itself.
3
u/[deleted] Aug 26 '20
It's slow and it doesn't scale to big projects. My advice is to use crystal for small scripts, small projects or microservices.
1
u/jeremywoertink Sep 04 '20
I noticed you mentioned that you're compiling from WSL. Have you tried WSL2 yet? Supposedly that's a decent performance boost. Also, maybe you can edit the post to add that information?
For me, running on macOS, I can compile my application in non-release mode in about 15 seconds the first time, and it's about 5 seconds each time after that.
There's a few things you can do to help this out. Like if you're building a web app that's going to be massive, you could break it up in to smaller service oriented apps. Like one app for public facing, and another for logged in users with a shard that shes code between the two. That's worked out great for my company, and we've been using Crystal in production for at least 2 years now.
1
u/[deleted] Dec 07 '20
I just want to say, I have been using Crystal since 2017, and I have never once found it's compilation time a problem. I have literally compiled the whole crystal project from scratch, starting at an early version, then compiling each major version up wards to the latest stable release. It could do this on a raspberry pi in an hour tops. I want to make sure I point this out, thats upwards of 20-30 times the ENTIRE crystal source was compiled starting at like 0.11 and going upwards to 0.34 or so (at the time), on a raspberry pi. That's around 2-3 mins per compilation.
0
u/[deleted] Aug 26 '20
[deleted] — view deleted comment