Live data from Hacker News

The Crystal Programming Language

crystal-lang.org

151–160 of 180 posts

Re: The Crystal Programming Language

#152
post #151

I don't understand why Ruby's syntax is seen as so elegant. It's ambiguous and a nightmare to parse. http://programmingisterrible.com/post/42432568185/how-to-par...

Try to build a class with it and you will understand.

I've built many a class in Ruby.

Re: The Crystal Programming Language

#153
post #147

Earlier quoted context omitted.

Get used to this, watching people run benchmarks after having forgotten to compile with optimizations is basically a meme in the Rust community. :)

I don't think it's a big deal, benchmarks are just toy programs. Once you learn about the `--release` flag you never forget it for production-ready code. C has -O3, why isn't it the default? Because it takes a lot more time to compile. So I think no optimizations by default is the best choice. And I think Rust should do the same, you will be compiling more things in non-release mode than in release mode.

Compiling without optimizations is indeed the default in Rust, but we have seen such an unbelievably large number of people not realize that a `--release` option exists that there have been several debates regarding whether or not this should be changed. Instead we've stepped up our documentation, we've made the package manager tell you which mode it's compiling in, and we've made Cargo put the finished binaries in either a clearly-named `debug` or `release` directory... and yet still they crash upon our walls, waving benchmarks where Rust is seemingly three times slower than Ruby.

It may seem obvious to you and I that compilers have optimization levels, but consider how many people for whom Java, with no optimization level flags, is their only exposure to a manually-invoked compiler.

Re: The Crystal Programming Language

#154
post #85
post #31

Earlier quoted context omitted.

Indeed it's becoming quite promising (using crystal already for few pet scripts which were too slow even for rubinius). Where it's most lacking at the moment is gc - it uses stop-world off the shelf boehmgc which is ok but not exactly great for memory heavy tasks.

imho, starting a new language with Boehm GC is a very bad design choice. It means, that one just allocates memory, and does not care for managing it. Even worse, it prevent linking any library, e.g. a 2nd thread running Lua+C, that cares for its own memory, because Boehm GC runs over the complete memory, not only the one the language has to manage. You basically need 3 types of memory: First for the objects in your l…

> A fully concurrent GC is impossible

That's a common misconception, of course mutability gc barriers can be made atomic. But it comes at significant synchronization cost, plus using full shared world like in C does not seem like a good design decision anyway in high level language like crystal.

Which is why I'd be more in favour of refcounting, and let the user make the choice - a simple stop-world gc mark&sweep is alright for tasks which can afford the higher memory usage and pauses (one gains good throughput), or rc - good for low latency, low memory usage (and low throughput and high cache pollution).

Regarding multi core threading, crystal has next to none. All modern gc design decisions depend on how exactly multicore threading will be eventually implemented. hence why fixing gc is not a priority, but rc could be readily useful.

Re: The Crystal Programming Language

#155
post #134

Earlier quoted context omitted.

Wait - are we talking C/C++ here? where a function call, a variable declaration, an expression cast all look identical?

You are probably talking about C++, not C, unless those look identical to you: foo(); int foo; (int)foo;

the cast can equally be int(foo); or (int)(foo); The parenthesis are allowed and optional. The method can be declared (int) foo(int(x), int(y)); which can also be an invocation. etc.

Re: The Crystal Programming Language

#156
post #144
post #130

Earlier quoted context omitted.

D has a memory safe subset (@safe). You could argue that Rust 3rd party libs rely on unsafe blocks.

The person you're replying to wasn't even talking about Rust. You'd also be vastly overestimating the amount of Rust libs that need unsafe code. For example, Rust's most mature web framework, the one powering crates.io, doesn't use unsafe code at all: https://github.com/iron/iron

Crates.io uses Conduit, not iron.

Re: The Crystal Programming Language

#157
post #80

Earlier quoted context omitted.

...and is a slow compiler compared to for example Go :-(

OCaml has separate compilation, a REPL, and it's very fast. None of those things is incompatible with global type inference (although particular type systems can be).

Doesn't OCaml require everything to be defined before used though?

Re: The Crystal Programming Language

#158
post #35

Earlier quoted context omitted.

Yes, Maybe (Optional) is the way to go. The difference is, with nil you basically make every type optional allowing it to have nil as a value.

Well, in Crystal Nil is a separate type that can be combined with others. But, say, a String is always a String, it doesn't implicitly have the Nil type. Same goes with every other type. Maybe you are thinking of Java/C#, where reference types can also be null, but this is not true in Crystal. It's also in a way similar (but not quite) to Swift, where optional types are different than types that can't be null.

Sounds exactly like union types in Ceylon (http://ceylon-lang.org/documentation/1.1/spec/html/introduct...), which is an interesting approach.

Re: The Crystal Programming Language

#159
post #151

Earlier quoted context omitted.

Try to build a class with it and you will understand.

I've built many a class in Ruby.

> I've built many a class in Ruby.

I see.....

Anyway, this is elegant to me:

sum ||= (1..100000).to_a.inject(:+)

Maybe you have a different aesthetical sense than the rest of us. That's perfectly fine, we don't have to like the same things.

But since you questioned, now I'm curious and I would like to ask you: what language in your opinion has the most elegant syntax? Also if you have 2 extra minutes free, would you mind to code that same one-liner above in that language so we could compare the two?

Post reply on HN