5 ms·
I love the idea of Crystal but I remember reading that compilation times can balloon very quickly for moderately sized apps. Can anyone who writes Crystal toda
by terracatta 6y ago
I love the idea of Crystal but I remember reading that compilation times can balloon very quickly for moderately sized apps.
Can anyone who writes Crystal today dispel or confirm that information? I imagine the inferred typing makes building a fast compiler really tough.
- chrisseaton 6y agoWas that possibly before they backed off from global type inference? I think that was the cause of long compilation times. They require you to annotate a few types manually now which is an effective cut.
- astrowilson 6y agoThey haven’t backed off from global inference. They did move to require you to type collections, but methods are not inferred at definition but rather at invocation and it happens globally. There is no solution really. If you want a language to feel like it is dynamically typed but actually has types, something gotta give, and in this case it is compilation times. And it gets quite high fast.
- chrisseaton 6y ago> They haven’t backed off from global inference. You might know a lot more than me about the subject, so feel free to correct me, but I think it used to be truly global inference - as in you were expected to write the whole program with no annotations. But now you're required to annotate instance and class variable types, because compile times were becoming intractable.
- astrowilson 6y agoIt is still global. Typing collections and instance/class variables help, you can optionally type methods, but anything that is not explicitly typed is going to be inferred during invocation and that needs to happen based on all callers in the whole program. Reducing the amount of type variables do not eliminate the global behavior. In contrast, local inference considers a predefined context, such as the current module or class, and is much faster, easier to cache, etc.
- edflsafoiewq 6y agoI just downloaded 1.0 and tried hello world. It took over 2 seconds. I hope that's just some kind of bug.
- blacksmoke16 6y agoThere is a cache that was previously cold. Subsequent runs should be faster. However compile times are longer than other languages like Go.
- edflsafoiewq 6y agoIn .cache/crystal/? 2 seconds is with that. If I delete it, the next build takes 3.
- straight-shoota 6y agoNo, that's expected. The program you wrote might be minimalistic, but there is still a lot of code under the hood for the runtime. If you compile a program that's twice as complex, you should still get roughly the same build time. FWIW The compiler builds in about 30 seconds. And it's a really complex piece of software.
- rienko 6y agoThis comes from my experience building a prototype cli application, the language itself fells very productive, and the stdlib is robust fast and useful. Compiling isn't fast. By the language design it won't ever be possible to be in the same ballpark as golang. It's common for us that our 5k lines app, take >1m to build in release mode as we added more and more dependencies for integrations with different nosql databases (elastic, rocksdb etc). Using LLVM as backend is great for getting top notch performance, but to generate multiple IR methods for each type signature consumes a lot of time, especially when doing optimisation in release mode builds. I guess it's a similar problem that cranelift is trying to fix in Rust. Open classes makes it hard to cache compilation results from dependencies / libraries.
- devmunchies 6y ago> It's common for us that our 5k lines app, take >1m to build in release mode Yes, for this reason I think crystal could be one of the best languages for microservices or faas.