Live data from Hacker News

Building a Command-Line Application with Crystal

jclem.net

1–10 of 35 posts

Re: Building a Command-Line Application with Crystal

#3

Anyone compare Nim to Crystal? Both are AOT languages with syntax inspired by dynamic languages (Python & Ruby). Nim transpiles to C and Crystal uses LLVM. I've been playing with Nim, but I have a feeling Crystal will catch on quicker.

CoC, bad compiler, bad type system, no formal proofing whatsoever, some of documentation reads like someone who knows English as a second or third or fourth language wrote it, in some cases it's just plain wrong.

Elixir has already taken most of the ruby mindshare, the crystal team really isn't hacking it when it comes to presenting why crystal should be used instead of ruby except for speed. That its faster is the only viable motivation currently.

I don't know anything about nim, so I can't really compare it. I wrote some compiler plugins and utilities for crystal at my company, but I ended just rewriting the component in ruby, and it runs hourly with JRuby.

I hope Ruby3 gets optional types a la Dart, and a code conversion tool. Those two things would revive the entire ruby universe.

Edit: last time I touched crystal was 6-7 months ago, but I doubt anything has changed.

Edit edit: not an elixir fanboy. It sucks too, but at least it compiles down to BEAM so if I'm writing erlang I don't have to actually touch it as long as it works.

The elixir astroturfing is out of control lately. It's cool, it ain't THAT cool.

Re: Building a Command-Line Application with Crystal

#4

Anyone compare Nim to Crystal? Both are AOT languages with syntax inspired by dynamic languages (Python & Ruby). Nim transpiles to C and Crystal uses LLVM. I've been playing with Nim, but I have a feeling Crystal will catch on quicker.

CoC, bad compiler, bad type system, no formal proofing whatsoever, some of documentation reads like someone who knows English as a second or third or fourth language wrote it, in some cases it's just plain wrong. Elixir has already taken most of the ruby mindshare, the crystal team really isn't hacking it when it comes to presenting why crystal should be used instead of ruby except for speed. That its faster is the o…

I've started to transition from Ruby to Crystal for my pet projects and haven't hit any serious issues so far. Since you seem to have much more experience than I do, would you mind elaborating a bit on the issues you found and why you think the compiler and type system are bad?

Re: Building a Command-Line Application with Crystal

#5
Hmm, seems like the author either does not know about JSON.mapping [0] or just chose not to use it. Honestly, the corresponding macro for YAML is the main reason I use Crystal for CLI apps since it comes with the stdlib. YAML is easy enough to write quickly that I don't have to do too much with option parsing. Plus you can just use your editor rather than the shell.

[0] https://crystal-lang.org/api/master/JSON.html#mapping%28prop...

Re: Building a Command-Line Application with Crystal

#6

Anyone compare Nim to Crystal? Both are AOT languages with syntax inspired by dynamic languages (Python & Ruby). Nim transpiles to C and Crystal uses LLVM. I've been playing with Nim, but I have a feeling Crystal will catch on quicker.

CoC, bad compiler, bad type system, no formal proofing whatsoever, some of documentation reads like someone who knows English as a second or third or fourth language wrote it, in some cases it's just plain wrong. Elixir has already taken most of the ruby mindshare, the crystal team really isn't hacking it when it comes to presenting why crystal should be used instead of ruby except for speed. That its faster is the o…

Elixir is by far my favorite language out of the 6 I've seriously tried (Elixir, Ruby, JavaScript, Python, Java, Bash). I'm​ gonna dive into Go in near future.

Re: Building a Command-Line Application with Crystal

#7

Anyone compare Nim to Crystal? Both are AOT languages with syntax inspired by dynamic languages (Python & Ruby). Nim transpiles to C and Crystal uses LLVM. I've been playing with Nim, but I have a feeling Crystal will catch on quicker.

i think nim has better compiler options (in particular, i don't know if it has already achieved go-like cross-compilation of static binaries, but if not it's further along that road than crystal is). https://nim-lang.org/docs/nimc.html

meanwhile, crystal does not even support windows yet. https://github.com/crystal-lang/crystal/issues/26

Re: Building a Command-Line Application with Crystal

#8

Hmm, seems like the author either does not know about JSON.mapping [0] or just chose not to use it. Honestly, the corresponding macro for YAML is the main reason I use Crystal for CLI apps since it comes with the stdlib. YAML is easy enough to write quickly that I don't have to do too much with option parsing. Plus you can just use your editor rather than the shell. [0] https://crystal-lang.org/api/master/JSON.html#m…

I do use it in this project, but most definitely in the wrong way. I had a little trouble seeing how I could use it for getting at nested values of varying types and still have some sane error handling.

This post is very much about my first pass at this and my first experience with Crystal. Cleaning up the JSON parsing is the next item on my list when I have time.

Re: Building a Command-Line Application with Crystal

#9

Anyone compare Nim to Crystal? Both are AOT languages with syntax inspired by dynamic languages (Python & Ruby). Nim transpiles to C and Crystal uses LLVM. I've been playing with Nim, but I have a feeling Crystal will catch on quicker.

CoC, bad compiler, bad type system, no formal proofing whatsoever, some of documentation reads like someone who knows English as a second or third or fourth language wrote it, in some cases it's just plain wrong. Elixir has already taken most of the ruby mindshare, the crystal team really isn't hacking it when it comes to presenting why crystal should be used instead of ruby except for speed. That its faster is the o…

> ... some of documentation reads like someone who knows English as a second or third or fourth language wrote it, ...

Um, what's wrong with that? Not everyone gets to learn English as their first language, do their efforts deserve to be discarded just because of that?

I mean, I could point out that your grammar ('some of documentation') invalidates your entire comment, but that's kinda silly.

Re: Building a Command-Line Application with Crystal

#10
post #8

Hmm, seems like the author either does not know about JSON.mapping [0] or just chose not to use it. Honestly, the corresponding macro for YAML is the main reason I use Crystal for CLI apps since it comes with the stdlib. YAML is easy enough to write quickly that I don't have to do too much with option parsing. Plus you can just use your editor rather than the shell. [0] https://crystal-lang.org/api/master/JSON.html#m…

I do use it in this project, but most definitely in the wrong way. I had a little trouble seeing how I could use it for getting at nested values of varying types and still have some sane error handling. This post is very much about my first pass at this and my first experience with Crystal. Cleaning up the JSON parsing is the next item on my list when I have time.

You can pass union types to the macro, so that should handle your "varying types" problem. In terms of nesting, I just create another struct with its own JSON.mapping and use that as the type for the field.
Post reply on HN