11 ms·
Crystal 0.25.1 released
- sergiotapia 8y agoAnyone using Crystal in production? What do you use it for?
- sdogruyol 8y agoWe use Crystal at RainforestQA to replace our heavy-load / slowish Ruby microservices. It's been great so far and we love it. We're also increasing the adoption to Crystal inside the organization. Also Crystal has a dedicated a wiki page for production users Used in production: https://github.com/crystal-lang/crystal/wiki/Used-in-production https://github.com/crystal-lang/crystal/wiki/Used-in-product...
- abritinthebay 8y agoInteresting! I’m surprised you didn’t move to Elixir given the syntax similarities to Ruby
- RussianCow 8y agoElixir would probably not have been a huge improvement over Ruby if they switched languages for performance reasons. Elixir is great for many things, but raw number-crunching performance is not one of them.
- RX14 8y agoWhile elixir's syntax is inspired by ruby, the semantics are vastly different. That change in semantics is really good for elixir, because it means it can take advantage of the unique properties of the erlang vm, but it's worth noting that crystal is far far closer to ruby than elixir. For better and for worse.
- pmontra 8y agoThe syntax similarities between Elixir and Ruby stop as soon as one moves on from reading short blog post to writing real code. They are extremely different languages. Knowing Ruby helps only to remember the names of some standard library modules and functions, which were designed on purpose to match the name of the corresponding Ruby modules and methods, but not all of them. A vanilla example: $ iex > "1 2 3" |> String.split |> Enum.map(fn x -> String.to_integer(x) * 2 end) [2, 4, 6] $ irb > "1 2 3".split.map {|x| x.to_i * 2} [2, 4, 6] which by the way highlights the extra verbosity of Elixir compared to Ruby. It's less verbose on more complex examples, mainly because of pattern matching, but the proof would be too long for this reply.
- andyfleming 8y agoKotlin syntax: "1 2 3".split(' ').map { it.toInt() }
- yxhuvud 8y agoYour example doesn't do the same thing. The same as grandparent, in crystal: "1 2 3".split.map &.to_i.*(2)
- andyfleming 8y agoWhoops, you're right. "1 2 3".split(' ').map { it.toInt() * 2 }
- pmontra 8y agoI believe that Ruby also has that & shortcut (or similar) but it's totally unreadable. I never used it and I don't even want to check the exact syntax. Is it the only way it works in Crystal?
- yxhuvud 8y agoIt being readable is a matter of getting used to it. I find it more readable than the block version as there is less syntactic boilerplate. YMMV. Ruby has a similar version using colon instead of dot but that version isn't chainable and doesn't take arguments so it can't do the *2. And no, you can write out the full block just as you did in the Ruby version.
- MaxBarraclough 8y agoWhat drew you to Crystal? If you'll forgive the snark, you've moved from one obscure language, to an even more obscure language that even fewer developers know. What is it about Crystal that outweighs the very boring practical downsides of production use of obscure and immature languages?
- nlh 8y agoI think many tens-of-thousands of developers would not agree that Ruby is obscure.
- rhencke 8y agoHow is Ruby an obscure language...? Their developers are already proficient in Ruby. Crystal is a very, very close cousin of Ruby, syntactically and structurally. This isn't like jumping from Java to Haskell.
- MaxBarraclough 8y agoI didn't know it was that similar. Neat idea for a language. The 'Boo' language does the same for Python.
- AsyncAwait 8y agoI'd say Nim is for Python what Crystal is for Ruby.
- MaxBarraclough 8y agoOn closer inspection I agree - hadn't realised Boo uses the Common Language Infrastructure.
- RX14 8y agoProbably because they loved the language. Humans are humans, and not everything is made with a rational financial decision. If you use the language, and like ruby and static typing, you'll find that there's a lot to love.
- k3liutZu 8y agoLet's make this more generic: Anyone using Crystal? What do you use it for?
- sergiotapia 8y agoI'm specifically interested in production settings, not toy projects. Using something in production is much more interesting.
- rkeene2 8y agoI do. I run a service called "HashCache" which caches resources by hash ( http://hashcache.rkeene.org/ http://hashcache.rkeene.org/ ). I use this as a central cache for build scripts which download resources from the Internet, and the upstream/origin server may go away. I wrote a version in Crystal (v0.10, I think) and Tcl to compare the two: Crystal: https://chiselapp.com/user/rkeene/repository/hashcache/artifact?ln=on&name=4af78cf4e694fa94 https://chiselapp.com/user/rkeene/repository/hashcache/artif... Tcl: https://chiselapp.com/user/rkeene/repository/hashcache/artifact?ln=on&name=5f7d01b159b7b5c9 https://chiselapp.com/user/rkeene/repository/hashcache/artif...
- rishav_sharan 8y agoI am making a simple bloggy webapp with Crystal.
- Thaxll 8y agoI'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
- asterite 8y agoYou could basically say the same about any language. Just switch the descriptions. For example: C#: verbose, magical dependency injection, Microsoft, etc. Ruby: slow Go: ugly syntax, verbose, if err != nil, etc. If a language works for you I see no reason not to use it :-)
- benbristow 8y agoRuby's getting much faster now with recent speed improvements, JIT and recent developments by the TruffleRuby team
- crystalnewb 8y agoFor the thrill man! If it doesn't have a library you need you create it yourself. Eventually enough people who have the skill to contribute will become interested in Crystal and contribute a library, then one day crystal will replace java. In all seriousness, other than the multithreaded windows support, which libraries are missing?
- sam0x17 8y agoFor sure. I've had a lot of fun getting to be the person to create some basic libraries for things like image manipulation and an ORM for mongodb when I find no one else has done that yet. One big thing that is missing still is full google cloud platform and AWS libraries. There is an s3 connector but I think it's out of date.
- nlh 8y agoI 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.
- 33degrees 8y agoI'm planning on trying it to replace some Ruby code that updates our elasticsearch index in a background job. It's currently slow and memory hungry and crystal's similarity to Ruby should make it easy to port.
- sam0x17 8y agoAt BlockVue we use crystal for v2 of most of our core infrastructure (the old version of our app is Rails-based), and we also use crystal heavily in Google Cloud Functions via our gcf.cr (open source) tool. So mainly we use amber and gcf.cr in conjunction with one another. We host everything on Google App Engine and GCP.
- xiljin 8y agoWe're currently using Crystal 0.25.1 with the Kemal web framework to provide an online paycheck calculator for US based employees (it's basically a demo/tool for our SaaS based accounting, payroll and fund raising app). Really impressed with the language so far and hope to expand its use within our organization.
- sdogruyol 8y agoI'm the creator of Kemal, glad to see that you're liking it :)
- Blackstone4 8y agoCrystal 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
- RX14 8y agoCrystal has had concurrency, almost identical to goroutines, for a long time. It's just as if you're always running with GOMAXPROCS=1. And you can still get some excellent performance on IO bound workloads with a single core. The challenge is expanding what crystal is already good at to CPU bound parallelizable workloads by implementing parallelism. This work should be done before 1.0, we have a lot more resources to work on crystal from now on, because brian is working on it full time. And as for windows support, I'm working on it right now. Cross-compiling "hello world" has been working for a while.
- Blackstone4 8y agoThanks for the response. I'm no expert but when you have a server, would each request be handled concurrently by a separate thread (/fibre?)? So in that sense would the server's I/O be non-blocking? (I know each thread would be blocked as it waits for the response). Do you have a rough time frame for parallel concurrency? What's your view on the maturity of the language?
- RX14 8y agoNo, each request is handled concurrently in the same thread using evented IO. You spawn fibers, which are the analogue to go's goroutines, and many of those run in one thread. Just like nodejs (without callbacks/promises/async/await) and similar to go with GOMAXPROCS=1. Unfortunately, I don't have a timeframe for parallelism, it's not my area of crystal and it's a fairly tricky issue. My (biased, i'm a core developer) view on Crystal's maturity, after using it in a few of my own side-projects, is that once crystal code compiles, it runs pretty much rock solid in production. Compiler bugs are fairly rare too, although the compiler clearly isn't as mature as gcc. The main issue you face is lack of available libraries, and being forced to make a few changes every couple months when a new release comes out with breaking changes. Depending on the size of your codebase, that could be a big issue or it could be a 5 minute easy commit.
- thomasfedb 8y agoOnly noticed this in the release post, but the `record` feature is neat: https://crystal-lang.org/api/0.25.1/toplevel.html#record(name,*properties)-macro https://crystal-lang.org/api/0.25.1/toplevel.html#record(nam...
- yxhuvud 8y agoIt's been around for a long time, but perhaps not documented.
- thomasfedb 8y agoThe 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.
- szopanator 8y agoAny recommendations on an editor for crystal? I was unable to get the VSCode extension to work properly.
- sam0x17 8y agoAtom behaves pretty well with it. What problems are you having with VSCode? That's what I use.
- shawabawa3 8y agoAre 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"
- artifinch 8y agoI’ve been using crystal for moderately sized personal projects for a few months now - I’ve never experienced any unreasonable compilation times. If you tried crystal a long time ago, I’d recommend giving it another shot!
- asterite 8y agoThe 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 8y agoJust 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 8y agoOh, 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 8y agoI 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.
- wokawoka 8y agoGodspeed 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 8y agoIMO 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 8y ago"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 8y agoExactly. I wouldn't write a kernel or shared library in Crystal and I wouldn't write a webapp in Rust.
- floatboth 8y ago> wouldn't write a webapp in Rust https://rocket.rs https://rocket.rs looks nice ;)
- RX14 8y agoWhat 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.
- cutler 8y agoWon't the impending releases of TruffleRuby, Graal and Substrate VM make Crystal irrelevant?
- asterite 8y agoThat'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 8y agohttps://medium.com/byteconf/stripe-is-building-a-ruby-typechecker-d6cd7cee6abf https://medium.com/byteconf/stripe-is-building-a-ruby-typech... Stripe are trying to solve that issue.
- AsyncAwait 8y agoThat's still not the same as a compile time type-checker, it still relies on the interpreter.
- floatboth 8y agoOther than being a statically typed language: Crystal AOT compiles down to native code (so, good FFI) and has a much better portability story (you can port it to ~any LLVM target). All that Graal stuff, while a true open source project, has some "Oracle weirdness" around it (IIRC, only Linux (and probably only amd64) is supported in the "community edition") and requires JDK 9/10 (not available on FreeBSD yet..)
- sam0x17 8y agoSome people (myself included) actually want the type safety and method overloading etc. Also you can only make a dynamic language so fast before there are inherent trade-offs.
- snake_case 8y agoI 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?
- sjtgraham 8y agoDo you mean statically linked binaries? Fat binaries generally refer to multiple ABIs in the same image, a mostly Apple thing these days.
- snake_case 8y agoI'm referring to fat binaries like the one Golang would compile too. Apologies if I have some terms mixed up here! Golang produces one single binary you can deploy to your target environment and doesn't really require anything else installed. From what I've read, Crystal generates a binary but you also need to ensure Crystal is installed on your target environment.
- floatboth 8y agoGolang makes statically linked binaries. (Well, until you use cgo.) By default, Crystal generates dynamically linked binaries. You absolutely do not need Crystal to run them. But you do need: - Boehm GC (libgc-threaded) - libevent - PCRE if the program uses regexps - libyaml if the program uses yaml - OpenSSL if the program uses crypto/TLS (?) Here's an example ldd output: /usr/local/bin/shards: libyaml-0.so.2 => /usr/local/lib/libyaml-0.so.2 (0x8c0bb1e000) libpcre.so.1 => /usr/local/lib/libpcre.so.1 (0x8c0bd3c000) libm.so.5 => /lib/libm.so.5 (0x8c0bfb8000) libgc-threaded.so.1 => /usr/local/lib/libgc-threaded.so.1 (0x8c0c1e6000) libthr.so.3 => /lib/libthr.so.3 (0x8c0c444000) libevent-2.1.so.6 => /usr/local/lib/libevent-2.1.so.6 (0x8c0c66c000) libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x8c0c8c3000) libc.so.7 => /lib/libc.so.7 (0x8c0cad2000) libdl.so.1 => /usr/lib/libdl.so.1 (0x8c0ce8f000) libcrypto.so.42 => /usr/local/lib/libcrypto.so (0x8c0d091000) You can try `crystal build --static` though :)
- kureikain 8y agoCrystal 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 8y ago> Think about 10 years ago, we never think of a small company,community be able to writing a programming language. Perl, python, ruby ?
- qop 8y agoI 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 8y agoExhaustive 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 8y agoIt'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 8y agoAny 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.
- sam0x17 8y agoCrystal has OOP features, but you don't have to use them if you don't want to. I do some scientific research in crystal and it is all modules with functions calling other functions and dealing with structs. I love the fact that I can create C-style structs with member methods in Crystal.
- RX14 8y agoOn 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.
- paulcsmith 8y agoI'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
- tvmalsv 8y agoThat looks really nice. When I clicked the link, I wasn't expecting a good looking page and all of those docs, it was a nice surprise. I look forward to checking it out :)
- paulcsmith 8y agoI'm glad you were pleasantly surprised. Feel free to hop on https://gitter.im/luckyframework/Lobby https://gitter.im/luckyframework/Lobby if you have any questions or comments!
- vram22 8y agoFrom 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 8y agoYou 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