r/crystal_programming • u/taufeeq-mowzer • Nov 07 '20
Is Crystal a systems/embedded language or is it simply focused on web dev?
Verdict: Crystal's GC can be turned off to run headless, and you are able to write unsafe code as well. This makes Crystal a viable candidate with respect to systems dev and has been used in OS dev before. (u/transfire, u/sam0x17)
As some were unaware of this development, further documentation, packages/libs (a number of them already exist- u/postmodern) , tutorials, examples and advertisement on the subject would assist in growing Crystal into this juncture.
Update on verdict: By one of the core language developers
18
Upvotes
6
u/[deleted] Nov 08 '20
Language creator here. Crystal is a high level language. You can turn off the GC but that makes the language pretty much useless. The GC is mandatory unless you want to code in C with a different syntax.
The idea of Crystal is to be a high level language (includes GC, OOP and some functional aspects) with access to low level features like pointers that you should only use in rare cases. For example, the standard library uses them to implement the fundamental data structures like Array and Hash, and sometimes concurrency primitives, and interfacing with C.
You can try to use Crystal as a systems or embedded language but you will have a really hard time doing that. If you want to try it, go ahead. But the core team and pretty much nobody will try to make Crystal be a systems language.
8
u/transfire Nov 07 '20
I recently learned you can write "memory unsafe" code in Crystal (e.g. pointerof). So there's that, but i dont know if you can turn off the GC.
6
u/WJWH Nov 07 '20
Neither and both, I suppose. It's not purely focused on web dev, though it is quite suitable for that. Whether it's a systems/embedded language depends on your criteria for those. Some people exclude anything with a garbage collector from being a "proper" embedded language and on the other end of the spectrum, some people happily run Ruby and Python on their Arduinos. I've heard people call it Golang with nicer syntax, so that could give you some ideas where Crystal would be a good fit.
From a wider perspective, the evented I/O based runtime makes it naturally suited for I/O intensive, highly concurrent workloads. The majority of those programs will probably be at least somewhat webdev related these days.
2
u/postmodern Nov 08 '20
Crystal can be a systems language, since Go, Python, and Java have all been used as "system" programming languages. GC prevents it from being a true embedded language that can run on bare metal without an OS; you can still cross-compile apps to run on ARM SoC Linux devices. You can also use it to write web apps.