Live data from Hacker News

Crystal: Fast as C, Slick as Ruby

blog.codeship.com

391–400 of 439 posts

Re: Crystal: Fast as C, Slick as Ruby

#391

Earlier quoted context omitted.

I think a stack trace and an exception would help most people with a modicum of debugging skills.

> I think a stack trace and an exception would help most people with a modicum of debugging skills. What if the error is difficult to reproduce in the first place? This isn't too uncommon in concurrent programming.

You can look at the code, see why you can't prove it correct, or work backward to see how the code could have gotten to such a state. Like I said, debugging skills.

Re: Crystal: Fast as C, Slick as Ruby

#392
post #171

Earlier quoted context omitted.

Maybe the makers of Crystal need to take a leaf out of Go's book. Despite the Go creators not being windows users (AFAIK), they support Windows as a primary target, to help adoption, I assume. Of course the Crystal people probably don't have the same number of developers working on it as Go did even early on. Edit: Go took a little while to support windows, not until around July 2010. See this question from November…

The plan is to support windows before 1.0, although the core devs are reluctant to "open up" to the large amount of developers windows support would bring before they are finished making breaking changes.

I don't think they're afraid of it, more like haven't gotten around to it would be my guess...

Re: Crystal: Fast as C, Slick as Ruby

#393

Earlier quoted context omitted.

> I think a stack trace and an exception would help most people with a modicum of debugging skills. What if the error is difficult to reproduce in the first place? This isn't too uncommon in concurrent programming.

You can look at the code, see why you can't prove it correct, or work backward to see how the code could have gotten to such a state. Like I said, debugging skills.

> You can look at the code,

Of course I can look at the code. Trust me the reason why I introduced the bug wasn't because I was looking at something else at the moment.

> see why you can't prove it correct,

Realistically, this is because the language and the program's design conspire to make proving anything about the program an uphill battle. If the language could perform basic sanity checks (e.g., no attempting to use objects after ownership has been transferred to someone else), then at least I could have a fighting change to manually prove more interesting properties.

> or work backward to see how the code could have gotten to such a state.

Doing this on a per case basis is an incredibly mind-numbing task.

Re: Crystal: Fast as C, Slick as Ruby

#394
post #289

Earlier quoted context omitted.

Have you ever used a language with a decent type system though? I couldn't stand to use Javascript or Go at this point.

Of course. I've used C pretty extensively, Java enough to hate it, and C#. I consider myself a javascript developer because that's what I've done my best work in and that's what I enjoy the most.

I wouldn't really consider any of those decent (certainly not C or Java), unless C# got sum types when I wasn't looking.

Re: Crystal: Fast as C, Slick as Ruby

#395
post #262

Earlier quoted context omitted.

Having worked in environments where GC was an absolute "no go", I'm always amazed that so many people have problems with a GC. Yes there are types of software where using a GC'd language would probably be a bad thing. If you're talking about huge projects with heavy performance constraints (os kernels, AAA games and browsers come to mind), I would probably try to avoid it. But most likely - you simply do not need a l…

> But most likely - you simply do not need a language without a GC. Absolutely. That doesn't mean I can't want predictable performance or deterministic destruction. I also think it's a shame that we waste so much electricity and rare earth minerals on keeping ourselves from screwing up (i.e. on the overhead of managed runtimes and GCs). Before, I'd have argued that it was just necessary. Having spent a bunch of time…

That doesn't mean I can't want predictable performance or deterministic destruction.

You're assuming your compiler or operating system won't cause memory to be freed at different times.

I also think it's a shame that we waste so much electricity and rare earth minerals on keeping ourselves from screwing up.

Wasting man hours on manufactured problems is far worse than wasting coal.

Re: Crystal: Fast as C, Slick as Ruby

#396
post #52

Earlier quoted context omitted.

Memory management is difficult, extremely difficult, to get correct in the way rust does. I don't think I've seen a leak or bad dereference in years. The only way it really manages this is by tying references into what amounts to a proof assistant. Every simpler method of which I can think either sacrifices capability (e.g. no references at all; only raii + copy on write) or it becomes a GC with all its wonderful tra…

> Memory management is difficult, extremely difficult, to get correct in the way rust does Memory management isn't hard --- you just need to pay attention to detail and not say "YOLO, let's abort on OOM" like the Rust stdlib does. Rust is an unacceptable language for anyone who cares about robustly responding to heap exhaustion.

"Memory management isn't hard --- you just need to pay attention to detail"

You're quite right. The problem is that every bit of attention you spend on that detail is attention that you're not spending on details that are actually solving your problem.

I programmed in C for decades. I do not miss malloc() and free() in the least.

(I still do use C when the situation warrants, but the situations where it is warranted are becoming rarer and rarer with each passing year).

Re: Crystal: Fast as C, Slick as Ruby

#398
post #47

Earlier quoted context omitted.

??? Ask any C programmer if they could wave their magic wand and turn every single undefined behavior in their programs into a segfault how much better their life would be. It's not a small improvement it's a huge improvement.

Thats simply not true. UB is simply the latest stick to hit C with. In day-to-day working nobody worries about UB at all as you generally don't notice it. Same with lack of a GC; this is a plus point for C for most applications, not a negative. (and yes, I do have plenty of experience in it, I've been using it for the past 20 years, have you?).

> UB is simply the latest stick to hit C with. In day-to-day working nobody worries about UB at all as you generally don't notice it.

I agree that in day-to-day working nobody worries about it, and I see odd behaviors all the time because of it. In particular as fewer applications are using C, a much higher fraction of C becomes systems and embedded where you are more likely to accidentally run afoul of choices that were made to compete with FORTRAN on numerical performance.

A read from NULL will crash on most unixen, but will not crash on some targets without an MPU and when running in kernel mode, so may be left lurking (see the linux kernel).

The C89 aliasing rules in particular are completely at odds with a lot of kernel and device driver code, and in addition where the int size was 2 bytes previously but is now 4 bytes you can have signed overflow where before the behavior was well defined:

    UINT2 x; // 16 bit integer
    ...
    x+=2;    // addition mod 2**16 on 16 bit targets, undefined behavior on 32 bit targets.
These are some real-world bugs I've dealt with.

> (and yes, I do have plenty of experience in it, I've been using it for the past 20 years, have you?).

I've been using it professionally for only about 15 years, but I started using C at home in '92.

[edit]

> Same with lack of a GC; this is a plus point for C for most applications, not a negative.

This is a bit of a non-sequitur, as I didn't mention memory management at all. C doesn't need a GC. It could use more memory safety though. There's been plenty of academic research on improving C's memory safety without significant runtime overhead; a lot of those techniques were used in rust. There are plenty of tools that can catch a large fraction of memory errors at compile time, which is a good thing.

Re: Crystal: Fast as C, Slick as Ruby

#400

Can someone comments the differences between Nim (old mimrod) and Crystal? Which one do you prefer and why. Thanks.

Apart for different syntax:

Plus of NIM:

* powerful compiler can produce C, C++, JS, ObjectiveC code

* GC can be completely removed to adapt to the program

* support parallelism via threading

Plus of Crystal:

* use of types union permit to mix types in almost every data structure, let you pondering if the langugae is really strong typed

* so similar to Ruby that porting a 100-lines library (with no fancy-metaprogramming) to Crystal is often a matter of few hours

* use of green threads suits very nicely with HTTP request/response cycle (like GO and Erlang), where using threads/processes is more memory/CPU consuming

What Crystal still lacks is parallelism, but core team are working on that.

Said that both are modern, fast, elegant languages, with a good standard library and a vibrant community.

Post reply on HN