Crystal 0.25.1 released
crystal-lang.org
crystal-lang.org
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
Still no windows support: https://github.com/crystal-lang/crystal/issues/5430
And as for windows support, I'm working on it right now. Cross-compiling "hello world" has been working for a while.
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?
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.
I'm somewhat new to this so bear with me. With regards to the I/O, is it like node.js? i.e. all requests are handled inside a single thread (until Crystal gets parallelism) and when the thread waits for an I/O response (i.e. a database call), it will process some of the other requests?
I know absolutely nothing about Nim so I can't comment either way.
Go - I want to program explicitly and don't mind a little extra code or syntax to do it. I want close to the best performance possible and a single distributable binary. I don't mind being encouraged to "roll my own" api / web app rather than using a framework.
Crystal - I want to feel like I'm writing in Ruby, but with type checking at compile time and much better performance. I don't mind being a little less performant than other compiled languages. I want access to Rails/Sinatra-like frameworks for web/API apps rather than having to "roll my own".
Basically, if you want something quick and fun that can run in production, I love Crystal. If you want something that needs to be custom and highly performant, I love Go.
But there are Rails-like frameworks you can use in Crystal that are just as much fun (though understandably less mature).
Check out Amber, Lucky, and Kemal to give you an idea of what’s out there.
Disclaimer: I haven't used it, just read a bit about it.
The same, if not more so, goes for Go. It might be statically compiled, but it's far from the most optimised performer.
What other languages? Because the language uses "Fast as C" as part of it's tagline. Is this a false claim?
I've personally found that a lot of Go's marketing is, if not misleading, outright false. As an example: https://blog.plan99.net/modern-garbage-collection-911ef4f8bd...
Beware trading a visible cost for an unbounded number of smaller costs. In Go's case, in return for minimal pausing you get memory fragmentation, terrible performance if the GC is ever seriously taxed, and a 100% (!) heap memory use overhead. If you're just writing commandline daemons or servers you restart every ten minutes though, who cares?
Go doesn't come off too badly in this because it's not Java, which allocates like crazy. That's a laudable tradeoff, but that does not mean they solved garbage collection very well.
All they want is ruby with static types, that runs fast. Those things will satisfy them alone.
Intelligently written C/C++/D/Zig/Rust will always knock Crystal out of the park. :(
Unfortunately, transpiling has a huge bunch of problems, which you can see in for example how quickly nim vs crystal compiler matured - even though the crystal compiler is more complex. I'd be interested in seeing go's stdlib, ssa backend, and toolchain turned into a robust library. Like LLVM but including a GC, a stdlib with a CSP implementation, and a complete toolchain for static compilation.
Go does have a buildmode for c-archive and c-shared, but it's built around the hobbled Cgo, so you have to explicitly export funcs, and things like structs cannot be exported. Still, a swig-like shim/bridge could be developed, but I am unsure at what cost (I think the go mobile stuff does a form of this).
So what has been your experience with Golang so far?
* Speed
* Pleasant to use type system
* Doesn't get in my way
* Catches lots of bugs
* Fun!
I wrote 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
>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?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
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.
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.
https://rocket.rs looks nice ;)
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.
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?
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.
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 :)https://crystal-lang.org/docs/using_the_compiler/ "Creating a standalone executable":
crystal build some_program.cr --release --static
Builds a static binary (just tried it on Ubuntu 18.04 with a simple hello-world).
I'll be updating it later today with 0.25.1 support.
You can statically compile a local crystal file using a docker one-liner that is included in the description.
If someone wants to generate some good tooling around this workflow, it'd be greatly appreciated.
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"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
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.
Also Crystal has a dedicated a wiki page for production users
Used in production: https://github.com/crystal-lang/crystal/wiki/Used-in-product...
$ 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."1 2 3".split(' ').map { it.toInt() }
The same as grandparent, in crystal:
"1 2 3".split.map &.to_i.*(2) "1 2 3".split(' ').map { it.toInt() * 2 }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.
So I think the differences are there but they’re being overstated from a transfer of skills standpoint.
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?
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.
The 'Boo' language does the same for Python.
Humans aren't robots, but one's choice of development tools is steered by real forces, both technical and business. I don't see that whim, unconstrained by such forces, has any place in the decision. Same goes for curiosity.
If it were my decision to choose a language to use in production, I'd want to go with a safe boring choice like Python/Java. Mature and stable on lots of platforms, easy to hire for, plenty of libraries and tooling.
Taking a risk is sometimes the right thing to do, but I don't see choice of programming language as being one of those times.
It's not that I don't like neat languages like Crystal - I really do - and I'm certainly not trying to put them down. I just wouldn't want to try to argue to management that using it is in the company's best interest.
I'm not here to recommend people use it in production, but I can understand the mindset of people who do.
Well, to use an analogy from civil engineering, I don't think choosing a programming language is always as critical as which type of concrete you choose and how it's reinforced. While it's true you wouldn't choose just any language, there is more room for preference here. Especially because you can switch languages for a project, but practically can't switch the material used in the foundation of a building.
> I just wouldn't want to try to argue to management that using it is in the company's best interest.
In some companies you don't need to argue with management about that decision. Also, a language being less popular or obscure doesn't mean you can't evaluate it's stability and feel comfortable enough with where it's at to use it. I'm glad people do because otherwise we wouldn't even see any language as popular as it is.
What do you mean? If you're 100kloc in, you pay a considerable price in jumping ship. Rewriting means throwing out your investment. Interfacing two different languages for one project is rarely a good move.
> I'm glad people do because otherwise we wouldn't even see any language as popular as it is.
Sure, me too. Like I said, I do like new programming languages, I just don't see myself using one for serious work.
That will never happen. Or when it did it will be all mechanized, with machines doing the programming.
It's not a myth, and I don't see that it should be dismissed as a pipe-dream to think that this sort of serious engineering approach could be adopted outside the critical-systems industry.
https://medium.com/@yoelblum_45935/demand-for-ruby-on-rails-...
That said, I was an avid PHP developer in the U.S. about 10-15 years ago and I always liked the language. There's just no one learning PHP anymore since all the kids just learn js, and no one trying out "hipster" languages like ruby/crystal/go/python/elixr/d/nim/rust/etc is going to try crusty old PHP.
I will say though that PHP, without any frameworks, is probably my favorite thing to develop a simple standalone site specifically because it lets you break all conventions and just output some damn content possibly with some simple logic involved and without using classes/mvc/etc.
Tons of startups, and tons of billion dollar companies, run on Ruby / Rails. How is it "obscure"?
Crystal sure.
Then again, PG who created Hacker News used Common Lisp, which at the time had about the same developer pool as Crystal give or take (well, not really, but close enough, compared with industry favorite languages).
Anyone using Crystal? What do you use it for?
I wrote a version in Crystal (v0.10, I think) and Tcl to compare the two:
Crystal: https://chiselapp.com/user/rkeene/repository/hashcache/artif...
Tcl: https://chiselapp.com/user/rkeene/repository/hashcache/artif...
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 :-)
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.
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.
Good luck trying to compile native libraries.
Edit: Sails is not what it claims to be, and doesn't live up to the dream at all
Whoa, that's where you lost me. Sails has a reputation for being horrible, and after working on a production app using Sails, I agree. Perhaps you were wanting something like Rails but in JS, which is what Sails claims to be, but it barely lives up to that. I don't know if there are other frameworks that try to be the Rails of JS but it wouldn't be hard to better than Sails. I'm interested in hearing why you think it's so sane (no snark, I'm sincerely curious)
Really impressed with the language so far and hope to expand its use within our organization.
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.
Perl, python, ruby ?
Not that type-safety is a killer feature, but that's just one difference.
Stripe are trying to solve that issue.
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..)
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
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.
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.
:)
Actually, let me ask you something... Are you just targeting windows or are you a windows user also? I can't imagine writing non-dotnet code with windows, but maybe I'm doing it all wrong.
Still not quite the Year of the Linux Desktop... Any year now....
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.
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.