Y
HN Search
Hacker News Search
new
|
comments
|
top
|
jobs
asterite
searching PlanetScale…
1.
▲
2.
▲
3.
▲
4.
▲
5.
▲
6.
▲
13 ms
·
31.
▲
by
asterite
11y ago
I think Crystal could fit this bill, yes: it has Ruby syntax and the concurrency model will be something like Go (spawn and channels, but we are still working on this). And the code ends up without much repetition, as you have generics, mac
32.
▲
by
asterite
11y ago
You are right, it's far from obvious after reading that list. I updated it. Thanks!
33.
▲
by
asterite
11y ago
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 re
34.
▲
by
asterite
11y ago
You are right, it wouldn't be wise to create a new language without having concurrency in mind. Starting from the last version there's spawn (lightweight processes) and channels for communications, similar to Go (although it'
35.
▲
by
asterite
11y ago
How do you model a "zero or one" relationship without null? Maybe your answer is "with Optional" (or Option, or Maybe). We just choose to use union types and have "Nil | T" (Nil or T) be the same as "Optio
36.
▲
by
asterite
11y ago
The algorithm isn't very easy to explain in a few words. We don't use any well-known algorithm. It has some bits of the cartesian-product algorithm, but just tiny bits. There's some info here: http://crystal-lang.o
37.
▲
by
asterite
11y ago
It's because we spent some time thinking the algorithms and optimizing them, and whenever we make changes to the compiler we make sure the times remain pretty much the same (it's hard because the compiler's size grows so the
38.
▲
by
asterite
11y ago
We like the way Ruby lets you quickly prototype things, but its performance isn't very good (it's just good) and it also lacks static type checks (for example "undefined method '...' for Nil" is a very common r
39.
▲
by
asterite
11y ago
Yes, you can browse the source code if you want, check it out and compile the compiler. It has between 30k and 60k lines of code (because you have to consider it also includes the standard library) and on a Macbook Pro 2015 it takes less th
40.
▲
by
asterite
11y ago
It took about one year. We originally implemented the compiler in Ruby and because of its similarity with Crystal (or the other way around ;-)) porting it to Crystal was pretty easy in the end. There's this tag: https://gith
41.
▲
by
asterite
11y ago
It has global type inference, there's nothing dynamic in the language. You can specify type restrictions to allow overloading methods, for example, or doing multiple dispatch. But in the general case you don't specify types (excep
42.
▲
by
asterite
12y ago
Hehe, I also don't understand why people always talk about summer and winter like it is a universal thing. Heck, there isn't such thing as summer or winter in some countries!
43.
▲
by
asterite
12y ago
Looks nice. Some ideas are very similar to those of Crystal ( http://crystal-lang.org ) like the automatic type flow. But it seems not to support union types and types are required everywhere (which some might like).
44.
▲
by
asterite
12y ago
Yes. There are some here: https://github.com/kostya/benchmarks Here's another one: https://github.com/nsf/pnoise And then in the samples directory ( https://github.com/manaste
45.
▲
by
asterite
12y ago
Your comment was actually pretty good because it spawned other very positive comments. We really like them all :-)
46.
▲
by
asterite
12y ago
We actually started by copying ruby's syntax and semantic, including the `do end while`. But a long time ago we started to diverge from it. We are also not sure about this "feature" and we still have time to remove it from t
47.
▲
by
asterite
12y ago
It's hard to say, the paper is really long and it's full of mathematical notation that is hard to digest and there are no examples to make it easier. Or, if they are, they are for a symbolic lambda calculus program. The problem wi
48.
▲
by
asterite
12y ago
Yes, exactly. At first we wanted Ruby, but compiled. We started with something that was very, very similar to Ruby (except some dynamic aspects) but the type inference algorithm was very slow. So we made some sacrifices (like telling the co
49.
▲
by
asterite
12y ago
You are not missing anything: named parameters would have been a much nicer choice, but I think they don't want to make the language more complex.
50.
▲
by
asterite
13y ago
It has union types. Right now if you do 1 || 1.5 it gives you Int32 | Float64. If you do Foo.new || Bar.new, and Foo and Bar are not related (except they both inherit from Reference), then you get Foo | Bar. If Foo and Bar are related by so
51.
▲
by
asterite
13y ago
The current String implementation is just a temporary one. UTF-8 will be there.
52.
▲
by
asterite
13y ago
Yes, it's one of our dreams too. Right now you can do: # In a foo.cr file fun init_foo = Init_foo : Void puts "Init foo! :-)" end Compiling it: bin/crystal foo.cr -o foo.bundle Then in Ruby: $ i
53.
▲
by
asterite
13y ago
But actually in Crystal you will have the same behaviour: class Person end class Employer < Person end class Employee < Person end x = some_condition ? Employer.new : Employee.new # x is a Person+ This is not s
54.
▲
by
asterite
13y ago
If your variable gets promoted to a union type, and all of the types respond to the methods you give them, then it will compile and run successfully (duck typing). Yes, it will have a small performance cost. If you then profile your app and
55.
▲
by
asterite
13y ago
Thanks, I just fixed the example.
56.
▲
Can you have null pointer exceptions if you program in Crystal? No.
(crystal-lang.org)
2 points
by
asterite
13y ago
|
0 comments