Crystal

Jacob Carlborg doob at me.com
Sun Feb 17 04:14:39 PST 2013


On 2013-02-17 07:28, Ary Borenszweig wrote:
> Hello everyone :-)
>
> I follow this newsgroup from time to time. I like D templates. I like
> the auto keyword. I like auto in templates. I love efficiency and
> expressiveness.
>
> I believe in smart compilers.
>
> (you might remember me: I'm the author of Descent)
>
> I *really* like D, because it cares about one thing I care about:
> *performance*. Let's save this world's energy. Let's make a better
> world. Let's make users' life more enjoyable. Let's be happy :-)
>
> But... do we really have to specify const pure safe nothrow and whatnot?
> Can't the compiler be smarter? I'm sure there must be a better way. Most
> new programming languages look like older ones. Newness comes slowly...
>
> One time I asked in this newsgroup if it was possible to have an "auto"
> keyword for function/method arguments. And... why not make all
> functions/methods be templates on the type of its arguments?
>
> I think nobody liked this idea. I said "Ruby is like this: you never
> specify types in method definitions".
>
> "But Ruby is not efficient". "Ruby is a dynamic language". "D is
> compiled, so it's faster". "Don't make the mistake of comparing a
> dynamic language with a static/systems programming language". This were
> some of the answers I got.
>
> I started thinking about this idea: a compiled language that looked like
> a dynamic language. Is it possible?
>
> Today, I'd like you to take a look at what me and my friend Juan have
> been working on for the last half month or so. It's a new programming
> language which aims to be efficient, have similar syntax to Ruby, and
> where you never have to specify types of variables and arguments.
>
> https://github.com/manastech/crystal/wiki/Introduction

In general I like it.

> I'd also like to ask you:
>
> 1. Do you know whether a similar language exists?

Except from what others already have mentioned someone created a 
language with a Python like syntax written in D. But I think that had 
explicit types.

> 2. Do you think it's feasible? Right now we are getting rather high
> compilation times (say, a minute) if we use lots of generic classes on
> medium-large programs. We are still trying to think of the best way to
> improve compilation times while at the same time taking off programmer's
> burden.
>
> (The compiler is written in Ruby, which is a bit slow, so that might be
> one reason it is a bit slow on medium-large programs... imagine Ruby
> might be 10 to 100 times slower than C, so that minute might be reduced
> to less than a second... we are currently working on bootstrapping the
> compiler... but if compilation is on an exponential order, well, you
> know... ... and the compiler is written in Ruby because it'll later
> (now?) be easier to port to Crystal, which has a very similar syntax)

You can try and precompiled it with MacRuby and see if you get different 
timings.

> I ask about feasibility, but right now you can use this language for
> small to medium programs (except the standard library is still incomplete).
>
> The goal of this programming language it so be as efficient as possible,
> but probably it won't be as efficient as C in the general case. But...
> who knows?
>
> We are also thinking about incorporating concurrency features, like the
> ones present in Erlang and Go.
>
> In short: utopy =o)
>
> I hope at least someone likes this project...
>
> (I hope at least you, Jacob Carlborg, Ruby lover, find it interesting...
> or maybe you, bearophile?)

I find it very interesting. But actually I'm going to agree with Denis, 
mostly. If I was going to use Crystal I would probably use a lot more 
static typing than it's probably made for.

I quite often miss static typing in Ruby. Often there are functions that 
are supposed to only work with a given type, I don't see why I shouldn't 
explicitly write that type out then.

A couple of questions:

* Executable code at class level, is that supported? If that's the case, 
when is it run? Example:

class Foo
   puts "asd"
end

* With a statically typed languages you quite soon get the need for 
interfaces, abstract classes and similar. How is this handled?

* Is Ruby code supposed to be able to run of out the box in Crystal? 
That is can I take arbitrary Ruby code and compile it with Crystal and 
expect it to work. If that's the case, what's currently supported and 
what's not supported?

-- 
/Jacob Carlborg


More information about the Digitalmars-d-announce mailing list