News for hackers. Stuff that matters.
Re:Lilith: x86-64 OS written in Crystal by lmm on Sunday December 22, 2019 @09:04PM (#21861001)
What's Crystal's unique selling point? It's older than Rust, Kotlin, Swift, Nim, or even OCaml, and doesn't really offer anything they don't. More Ruby-like syntax? Fine, but most people don't particularly like Ruby syntax.
Re:Lilith: x86-64 OS written in Crystal by shakna on Sunday December 22, 2019 @09:14PM (#21861032)
> It's older than Rust, Kotlin, Swift, Nim, or even OCaml, and doesn't really offer anything they don't.

Crystal is only five years old.

Nim is 11, Rust is 9, Kotlin is 8, OCaml is 23 and Swift is 5.

Basically, Crystal is tied with Swift as the youngest.

What it offers right now is a simple porting process for those with Ruby codebases.

Re:Lilith: x86-64 OS written in Crystal by k__ on Sunday December 22, 2019 @09:32PM (#21861084)
I think they meant younger.

But, yeah, besides the syntax familiarity for Ruby programmers it doesn't seem offer much that the others do.

Re:Lilith: x86-64 OS written in Crystal by shakna on Monday December 23, 2019 @11:03AM (#21864494)
> I think they meant younger.

The "even OCaml" is what threw me. Still not quite sure if they meant older or younger from it.

> But, yeah, besides the syntax familiarity for Ruby programmers it doesn't seem offer much that the others do.

A familiar syntax is a huge benefit in a lot of contexts. There's plenty of Ruby-only shops around the world. Making a faster and statically-typed language accessible to them is a decent niche.

Crystal isn't quite Ruby. It has type guarantees that Ruby doesn't, which makes it easier to maintain. The async and parallel stories are also immensely better in Crystal than Ruby.

The "Nil is a compile-time error" is also a feature I highly appreciate.

Re:Lilith: x86-64 OS written in Crystal by nine_k on Sunday December 22, 2019 @11:36PM (#21861500)
Okay, port your existing Ruby code to a compiled language, giving it multiple times the speed? Maybe three is a slight business opportunity here.

Also, give your developers a more productive language that can go where Ruby can't (like OS development), which is 90% instantly recognizable — may also be worth something?

Re:Lilith: x86-64 OS written in Crystal by lmm on Sunday December 22, 2019 @11:43PM (#21861523)
Is it really so hard to port Ruby code to any of the languages I mentioned? Even with Crystal you will still have to make changes to your code, is having to use a slightly different syntax such a big difference? If you've got Ruby code and you haven't already ported it, how badly do you need the speed?
Re:Lilith: x86-64 OS written in Crystal by EamonnMR on Monday December 23, 2019 @07:51AM (#21863291)
Mentally context switching between Ruby and any other language to do the translation actually is kind of a hassle.
Re:Lilith: x86-64 OS written in Crystal by k__ on Monday December 23, 2019 @08:16AM (#21863389)
I could imagine, that the subtle differences could get you ugly problems while porting.
Re:Lilith: x86-64 OS written in Crystal by lmm on Tuesday December 24, 2019 @01:08AM (#21870222)
Won't the differences be more subtle and difficult if you use a language that's syntactically Ruby-like but not actually Ruby?
Re:Lilith: x86-64 OS written in Crystal by rvz on Monday December 23, 2019 @03:49AM (#21862304)
Well it seems most developers here would rather use Ruby + several memory-optimised VM clusters to make their services go faster and destroy their balance sheet than to use a faster language that is efficient in memory and is also blazing fast.

A rewrite in (other fast language) from Ruby sounds ridiculous as soon as you include writing a extra FFI wrapper around this you have to maintain so that would be out of the picture and that sounds a lot harder than a semi 1:1 port of the source code.

The trouble is Ruby itself is starting to become a sunken cost as a language but is survived because of Rails, thus also explains the countless memory issues that happen when developers use it. So for a stopgap to something sort of better, I would rather port to Crystal or Elixir so I can run on those low-cost VMs and save cash.

Re:Lilith: x86-64 OS written in Crystal by PixyMisa on Monday December 23, 2019 @07:25AM (#21863193)
Slightly different?
Re:Lilith: x86-64 OS written in Crystal by k__ on Monday December 23, 2019 @08:20AM (#21863409)
I understood that Crystal is a huge thing for Ruby devs.

I just want to know if it is more than that or not.

I'm not a fan of Ruby and would prefer Nim or Rust if it were about syntax.

I ask myself if I miss any huge speciality of Crystal if I dismiss it just because of its syntax.

Re:Lilith: x86-64 OS written in Crystal by rishav_sharan on Monday December 23, 2019 @03:36AM (#21862266)
I am subscribed to the windows support github issue since 2013, so Crystal is definitely older than 5 years. I think its around 7 years old
Re:Lilith: x86-64 OS written in Crystal by shakna on Monday December 23, 2019 @05:32AM (#21862737)
The first release, 0.1.0, was in 2014. [0]

[0] https://crystal-lang.org/2014/06/19/crystal-0.1.0-released.h...

Re:Lilith: x86-64 OS written in Crystal by rishav_sharan on Tuesday December 24, 2019 @05:01AM (#21870982)
First official release maybe. But folks have been using Crystal since before that. This is the Github issue in question; https://github.com/crystal-lang/crystal/issues/26
Re:Lilith: x86-64 OS written in Crystal by shakna on Tuesday December 24, 2019 @05:23AM (#21871047)
Not arguing with it. However, choosing a point in time to check a language's age from is somewhat arbitrary, and first release seemed good enough.

The main point was comparative age of languages. Like OCaml which is more than two decades old compared to Crystal which is young.

Re:Lilith: x86-64 OS written in Crystal by steveklabnik on Monday December 23, 2019 @10:24AM (#21864135)
Rust is more like 4 than 9; 2015 was the initial stable release, most people couldn’t really use it for things before that.
Re:Lilith: x86-64 OS written in Crystal by icelend on Monday December 23, 2019 @11:48AM (#21864884)
Well, ok, so Crystal is 0 years old.
Re:Lilith: x86-64 OS written in Crystal by steveklabnik on Monday December 23, 2019 @01:28PM (#21865797)
Yep, I’d agree with that!
Re:Lilith: x86-64 OS written in Crystal by nlh on Sunday December 22, 2019 @09:16PM (#21861042)
C bindings, strongly-typed, a great concurrency model, very fast, and Ruby-like syntax. That makes it a very unique and appealing language to me (and others).

If you / most people don’t particularly like the Ruby-like syntax, then Crystal might not appeal to you. But I can assure you to those of us who like the syntax, the language is wonderful and super fun to work with.

Re:Lilith: x86-64 OS written in Crystal by dragonwriter on Monday December 23, 2019 @12:12AM (#21861622)
> C bindings, strongly-typed, a great concurrency model, very fast, and Ruby-like syntax.

Ruby’s syntax is a great fit for Ruby’s semantics but—and Ruby is my personal favorite language—I don't see much point for it divorced from that. It's the one thing I like least about Elixir.

OTOH, Crystal looks like it may be close enough to Ruby semantics that Rubyish syntax is a plus rather than a misdirection and distraction.

Re:Lilith: x86-64 OS written in Crystal by cosarara on Monday December 23, 2019 @07:45AM (#21863269)
In what way is Elixir's syntax like Ruby's? It has "end" on blocks and string interpolation with "#{whatever}", but everything else is different. It's about as close to Ruby as Ruby is to Python (which is to say, not much).
Re:Lilith: x86-64 OS written in Crystal by onlyrealcuzzo on Monday December 23, 2019 @02:13PM (#21866310)
I think it really helps that you can write mostly functional code in Ruby by just chaining higher-order array functions, and you can use Pipes in Elixir to do this almost identically -- when you consider the fact that all the higher-order array functions have identical or very similar names and parameters in the two languages.

My Ruby code is like 95% chained higher-order array functions. My classes almost never have state. I'm basically writing functional code, and it seems like this is a pretty common paradigm in Ruby. I will say this was HEAVILY influenced by learning Elixir.

When not taking external libraries into account, my Elixir code (at least to me) seems almost identical to my Ruby code.

I think Python and Ruby are very close. But I personally think list comprehensions are un-intuitive and you can't easily chain higher-order array functions in Python.

So although I feel the spirit of my Ruby and Python code is identical, in no way do they look and feel identical. In the same way, I think my Elixir and Python are quite different.

Sample size of 1. I know. Just thought I'd share.

Re:Lilith: x86-64 OS written in Crystal by cosarara on Monday December 23, 2019 @02:39PM (#21866580)
Thanks for sharing! I think though that what you are referring to is not syntax but semantics. On both places you are chaining HO array functions, so the algorithm is pretty much the same, but the syntax you use is different in both places (pipes, dot).
Re:Lilith: x86-64 OS written in Crystal by pseudalopex on Tuesday December 24, 2019 @06:14AM (#21871245)
Python's ist comprehensions are just set builder notation with English keywords.
Re:Lilith: x86-64 OS written in Crystal by yellowapple on Monday December 23, 2019 @05:48PM (#21868183)
Having done lots of development in both Ruby and Elixir (both professionally and on my free time), I'd say the only substantial differences boil down to the following:

- Elixir has |> instead of method chaining

- Elixir uses "do [...] end" consistently for blocks (as opposed to Ruby omitting the "do" in front of function/module/class/etc. bodies)

- Elixir supports Erlang-style tuples on a syntax level while Ruby (AFAICT) does not

- Elixir supports Erlang-style pattern matching / destructuring while Ruby (last I checked) does not

- Elixir's a fair bit stricter about differentiating zero-argument function calls from variables (i.e. if it's ambiguous it'll complain)

That is to say, Elixir's syntax descends directly from Erlang and Ruby, just as Ruby's syntax descends directly from Eiffel and Perl, and it shows rather strongly. That should be unsurprising, given that Elixir is the creation of a (former?) Rails maintainer.

Re:Lilith: x86-64 OS written in Crystal by lmm on Sunday December 22, 2019 @11:37PM (#21861504)
> C bindings, strongly-typed, a great concurrency model, very fast

My point is that all this is normal, and all the languages I list have offered it for longer than Crystal.

Re:Lilith: x86-64 OS written in Crystal by jbverschoor on Monday December 23, 2019 @04:32AM (#21862474)
LLVM based, and in terms of performance, it's one of the fastests
Re:Lilith: x86-64 OS written in Crystal by viraptor on Monday December 23, 2019 @02:21AM (#21862014)
Kotlin - it's on JVM which is a good thing for some and a bad thing for others. It's easier to distribute standalone crystal binary for example.

Swift - crystal throws exceptions, swift explodes...

Ocaml - the functional approach is not for everyone.

Rust - I like rust a lot. But sometimes I want to write something quick and I'm happy to sacrifice some memory and speed to not have to deal with the ownership issues.

Nim - the most comparable, I guess it's syntax preference at that point

Re:Lilith: x86-64 OS written in Crystal by ernst_klim on Monday December 23, 2019 @03:57AM (#21862324)
> Ocaml - the functional approach is not for everyone.

OCaml is pretty general purpose though, it has loops, objects, mutable state. libguestfs [1] and some other codebases (the compiler itself, btw) are written in a pretty imperative OCaml.

[1] https://github.com/libguestfs/libguestfs

Re:Lilith: x86-64 OS written in Crystal by Jenz on Monday December 23, 2019 @07:33AM (#21863222)
OCaml somewhat tries to be familiar for OOPs, but it _is_ first and foremost a functional language.

Personally, I am learning it now, and I think rather than it being a stepping stone between OOP and FP, it might as well be its own separate and hybrid paragdim; I find purer FP languages like Haskell much more intuitive than the mix of modules, objects, types and classes of OCaml.

Though do not get me wrong, OCaml is an amazing language. It just stands rather by itself.

Pardon my terrible english.

Re:Lilith: x86-64 OS written in Crystal by imhoguy on Monday December 23, 2019 @03:08AM (#21862174)
You can use Kotlin/Native [0] or just plain Kotlin over Java with GraalVM which produces compact binaries.

[0] https://kotlinlang.org/docs/reference/native-overview.html

Re:Lilith: x86-64 OS written in Crystal by vips7L on Monday December 23, 2019 @08:20AM (#21863408)
Kotlin/native's stdlib isn't feature complete. You have to use raw syscalls to do anything.
Re:Lilith: x86-64 OS written in Crystal by PixyMisa on Monday December 23, 2019 @07:24AM (#21863188)
Unique? There are a hell of a lot of computer languages out there. The only unique ones are those that are so bad that no-one ever did that again.

The selling point for Crystal is that it has a clean syntax that's easy for Ruby or Python developers to pick up (almost the same as Ruby), but compiles to standalone binaries that run really, really fast.

I mostly work in Python because the libraries are a lot more mature, but I use Crystal when I need to produce a standalone binary.

Re:Lilith: x86-64 OS written in Crystal by Shorel on Monday December 23, 2019 @05:31PM (#21868080)
> but compiles to standalone binaries that run really, really fast.

In a world with Go, Rust, D, C++ and C, this part requires comparison with these other languages.

Faster than Ruby and faster than Python doesn't cut it.

Re:Lilith: x86-64 OS written in Crystal by dom96 on Monday December 23, 2019 @09:42AM (#21863850)
Have you given Nim a try, as a Python developer it seems like it would be right up your alley.
Re:Lilith: x86-64 OS written in Crystal by disc on Sunday December 22, 2019 @11:32PM (#21861483)
It's possible that some (many?) programmers enjoy a Ruby-like syntax?
Re:Lilith: x86-64 OS written in Crystal by RX14 on Monday December 23, 2019 @08:50AM (#21863555)
It's unique selling point is union types as a part of the type system, with whole-program type inference and flow typing. This has never been done before (as far as I am aware), and it is incredibly powerful and interesting. It's compile-time duck typing.
Re:Lilith: x86-64 OS written in Crystal by mapcars on Monday December 23, 2019 @09:13AM (#21863676)
>whole-program type inference and flow typing

What do these mean?

Re:Lilith: x86-64 OS written in Crystal by loktarogar on Sunday December 22, 2019 @09:37PM (#21861112)
Ruby's syntax is a huge draw for many people.
Re:Lilith: x86-64 OS written in Crystal by Symmetry on Monday December 23, 2019 @08:20AM (#21863402)
I'm not familiar with all those langauges but I found the inference of union types pretty impressive.

foo = ENV["FOO"]? || 10

Re:Lilith: x86-64 OS written in Crystal by c-cube on Tuesday December 24, 2019 @07:38AM (#21871609)
It's very expressive and pleasant (and I never used ruby), while being fast and statically typed. That's a great combination of features. If it were stable, it'd be a serious contender to Go imho.
Re:Lilith: x86-64 OS written in Crystal by unixhero on Monday December 23, 2019 @02:51AM (#21862118)
It's for Ruby's developer friendly syntax. That's a huge selling point!
[dead]
Re:Lilith: x86-64 OS written in Crystal by klyrs on Sunday December 22, 2019 @09:28PM (#21861069)
I'm not smitten with the rust fandom either, but at least do your homework

https://www.redox-os.org/