Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<djellemah>
Hey all. Just had a glance through some of your docs. Is there a page somewhere describing which dynamic aspects from ruby that are disallowed? TIA. Some context: ruby for many years, c etc before that.
<djellemah>
s/that are/are/
JuryBatenko has joined #crystal-lang
Ven has joined #crystal-lang
DeBot has joined #crystal-lang
<jhass>
djellemah: Crystal is a new language, it's not Ruby - something
<ponga>
ya
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<djellemah>
I know what you mean. What I'm hoping for is a difference-list from ruby, so I can understand what tradeoffs the language designers have made. If that's not available I'll just read the docs until I find out what I need. No harm in asking though ;-)
<jhass>
well, that list wouldn't be final anyway
<jhass>
I guess the main points are: There are types, so you may need to specify them if interference is not possible. Some methods you know have new names. Some methods you know don't (yet) exist. There are some new methods. There's no runtime modification of the class hierarchy/type system, instead a powerful macro language to generate code at compile time
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Ven has joined #crystal-lang
<djellemah>
I wasn't expecting much in the way of finality from a language in alpha. That would be unreasonable. Looks like I have some doc-reading to do. Thanks anyway.
jua_ has quit [Ping timeout: 264 seconds]
jua_ has joined #crystal-lang
<jhass>
djellemah: btw I learned the language by coding the 2048 sample, learning the differences as the compiler complained about them ;)
havenwood has quit [Remote host closed the connection]
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Ven has joined #crystal-lang
asterite has joined #crystal-lang
<asterite>
djellemah: off the top of my head, there's no define_method, nor instance_eval nor send. However, you can reopen classes and add/redefine methods at compile-time, before the code is executed. There's a thing similar to instance_eval but not quite the same for writing DSLs. And as jhass said there are macros for generating code
<asterite>
djellemah: Also, Crystal is compiled and there's no VM, so that makes it much faster than Ruby
<asterite>
But you have to fiddle a bit more with types, and add more checks and consider types more
asterite has quit [Ping timeout: 246 seconds]
bcardiff has joined #crystal-lang
asterite has joined #crystal-lang
ytti has quit [*.net *.split]
Ven has quit [*.net *.split]
Cassyblanca has quit [*.net *.split]
rdar has joined #crystal-lang
ytti has joined #crystal-lang
Ven has joined #crystal-lang
Cassyblanca has joined #crystal-lang
<rdar>
just wanna say, I think crystal-lang is an awesome idea
<jhass>
hey, how did you find us? :)
<rdar>
Green Ruby News mailing list :)
<jhass>
ah, nice
<asterite>
There's also this: http://www.rwpod.com/ if you want to see how Crystal is pronounced in Russian :-P
<asterite>
rdar: welcome :-)
<jhass>
lol
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
sadin has joined #crystal-lang
Ven has joined #crystal-lang
leafybasil has joined #crystal-lang
weskinner_work has joined #crystal-lang
<a5i>
>> "test"
<DeBot>
a5i: "test"
<asterite>
Now I can try
<asterite>
>> time = Time.now; sleep 0.2; Time.now - time
<DeBot>
asterite: Sorry, I can't let you do that.
<asterite>
>> time = Time.now; sleep 0.1; Time.now - time
<DeBot>
asterite: Sorry, I can't let you do that.
<asterite>
time = Time.now; sleep 0.01; Time.now - time
<asterite>
>> time = Time.now; sleep 0.01; Time.now - time
<DeBot>
asterite: Sorry, I can't let you do that.
<asterite>
Oh, well...
<a5i>
What's Crystal's official logo btw asterite xP
sadin_ has joined #crystal-lang
sadin has quit [Ping timeout: 252 seconds]
<asterite>
I think I don't know :-S
<asterite>
The designer that made that spinning logo really likes it, but the idea was to have that crystal change according to the version of the language
<asterite>
I guess we should get a new logo :-P
<asterite>
You can't put a spinning logo on a paper
<asterite>
At least not just yet ;-)
<a5i>
yeah lol
<a5i>
I can try to find/make one :P
sadin has joined #crystal-lang
sadin_ has quit [Ping timeout: 245 seconds]
<a5i>
asterite: What color does it have to be?
havenwood has joined #crystal-lang
<asterite>
I don't know... I'm not good as a designer :(
<asterite>
But I think we can ask a logo to our designer, he designed the website so I guess he has a good idea of something that would go along with that
<a5i>
Why don't we have a contest? :P
<asterite>
We can do it :)
<a5i>
Ok, I'll make a reddit post, and a Google groups post
<asterite>
Cool
<a5i>
btw, I'm conversing with someone at tutorialspoint.com to put Crystal in there online compilers
<asterite>
But I guess we would need to provide some code for them to do it, right?
<a5i>
Err, I don't know, I'll let you know when he replies
<a5i>
He's just asking about it's user base
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<jhass>
>> time = Time.now; sleep 0.2; Time.now - time
<DeBot>
jhass: 00:00:00.2000940
<asterite>
:)
<asterite>
jhass: what was it?
<jhass>
syscall whitelist
<asterite>
Interesting
<jhass>
I'm adding to the allowed examples as we go
<a5i>
>> 34.is_a?(Number)
<DeBot>
a5i: true
<a5i>
>> 34.is_a?(Int32)
<DeBot>
a5i: true
<a5i>
23745326456.is_a(Int32)
<a5i>
>> 23745326456.is_a?(Int32)
<DeBot>
a5i: false
<a5i>
>> 23745326456.is_a?(Int64)
<DeBot>
a5i: true
<a5i>
does Crystal automatically swtich types if the number is too large for an In32 ?
<jhass>
for a literal yes, not for an already typed variable though
<asterite>
In Crystal it's similar, the syntax is slightly different
<asterite>
also the class hierarchy is different
<a5i>
Okay
c355E3B has joined #crystal-lang
<a5i>
>> 0/5
<DeBot>
a5i: Sorry, that took too long.
<a5i>
>>5/0
<DeBot>
a5i: Sorry, that took too long.
<a5i>
>> 5/0
<DeBot>
a5i: Sorry, that took too long.
<a5i>
asterite: Is that a bug?
<a5i>
shouldn't 0/5 return inf
<a5i>
and 5/0 return 0 ?
<a5i>
err, 0/5 == 0
<jhass>
looks like another syscall I didn't whitelist ;)
rdar has quit [Quit: Leaving]
<a5i>
well that's the bot, I;m talking about Crystal
<jhass>
5/0 raises DivisionByZero locally
<jhass>
0/x is 0
bcardiff has quit [Quit: Leaving.]
<a5i>
but
<a5i>
>> 0/5
<DeBot>
a5i: 0
<a5i>
o
<a5i>
Why does it Raise instead of putput infinity?
<a5i>
output*
<asterite>
>> 1.0 / 0.0
<DeBot>
asterite: inf
<asterite>
With floats it's different, but with integers there's no such thing as infinity
<a5i>
O
<asterite>
Not conceptually, but in computers
Exilor has joined #crystal-lang
<a5i>
How can I open a file and read the first line of it?
<Exilor>
File.read_lines("your_file").first
<Exilor>
comes to mind
<a5i>
o
<asterite>
Some days ago I made an IOLineIterator so that the whole file is not loaded to memory, so you could do File.each_line("your_file").first
<asterite>
I want to add more iterators to the language, but they'll have to be written manually, like in Rust, Java and D
<asterite>
In Ruby you can get one from `each` but that uses fibers and it's very slow… or at least slower than a manual implementation, which takes a bit more time to do but works much faster
<asterite>
waj, on the other hand, want to generate an iterator from the `each` method, like what C# does with yield return
<asterite>
but for me that's a huge task to do, not even sure it's possible to do…
bcardiff has joined #crystal-lang
<jhass>
lazy iterators are hard
<asterite>
The IOLineIterator was like 5 lines long, really simple
<jhass>
but if we do Fiber(T) and fixing passing values, it's actually pretty easy
<asterite>
jhass: do you think it would be acceptable if we had to write hand-written iterators? In any case the std will provide them for the most common cases, like in Ruby
<jhass>
I don't know, I like that I can use Enumerator for my own stuff
<asterite>
I actually have it working with the new IO model, lightweight processes and channels. It works, but it's like 100~1000 times slower than a hand-written iterator
<jhass>
I think ideally we would have Enumerator and optimized versions of it for the core classes
<jhass>
so you could get an easy one for your own stuff and hand write one once it proves to be a bottleneck
<jhass>
I thin I have a branch for Enumerator somewhere, not being able to pass values via Fiber.yield/resume is the only thing blocking it iirc
<asterite>
jhass: that's a nice idea, actually, having a generic (but slower) solution, where you can jump in and write a hand-written version (which shouldn't be hard) in case it's a bottleneck
c355E3B has quit [Quit: Leaving]
<jhass>
I have to look at Channel, maybe that makes it possible
<asterite>
jhass: I think that could work, not sure how to transform those "yield" into yielding to the yileder
<asterite>
It's funny how when people discover these benchmarks they jump to the github repo and start sending improvements to make their language win
<asterite>
I don't understand why they want to "win", or what's "winning" in this case… it's just some code :-P
<a5i>
lol
<Exilor>
lol i had half a mind to do that same thing
<a5i>
Though Crystal does have impressive results
<Exilor>
now i feel bad
<jhass>
asterite: you just call the method with a block
<jhass>
Enumerator.new |y| each do |v| y << v end end (+ types)
<asterite>
Exilor: why feel bad?
<asterite>
jhass: you'll have to show me a full gist with your idea :)
<jhass>
I guess :P
<Exilor>
just kidding. my first reaction was to see the crystal code to see if it could be made faster somehow :)
<asterite>
Ah! :)
<jhass>
I checked whether it was compiled with --release :P
<Exilor>
was it?
<jhass>
yeah
<asterite>
Maybe it can, I don't know. If you look closely you see the winners are the ones using llvm, so the resulting code must be more or less the same
<asterite>
Heck, I'm not proud of Crystal, I'm proud of LLVM :-P
<jhass>
heh
<jhass>
you can be proud of Crystal ;)
<jhass>
else I'll do that for you ;P
<Exilor>
it would be interesting to see the differences in code generated by these llvm languages
<Exilor>
doing the same task
<asterite>
Well, it's nice that we can get awesome performance without too much noise ;)
<jhass>
asterite: to make my idea work I'd need the following from a method AST passed to a macro: the name of the method it defines and the return type of the block it yields to
<jhass>
possible?
<asterite>
I think you can get the name with .name
<DeBot>
asterite: Error in macro 'foo' eval:3, line 1: undefined local variable or method 'hey'
<asterite>
Mmm
<jhass>
yeah, I see property :yields and property :return_type and property :block_arg
<a5i>
Is it DeBot or CeBot...
<jhass>
both
<asterite>
jhass: I guess we can add those
<asterite>
Or, add what's needed
<jhass>
I'll try, name is easy
<a5i>
I like the chart though: http://chartspree.io/bar.svg?sec=0.143604111,0.076729664,1.052041381,0.339820165,0.096995053,0.066999680,0.360201714,0.309625279,0.078053001,0.159299532,0.077463342,0.077063864,0.597987438&_labels=clang,gcc,mono,dmd,ldc2,gdc,go,gccgo,rust,nim-gcc,nim-clang,crystal,java
<jhass>
not sure how I can the block return type though
<asterite>
we need to add more macro methods to ast nodes
<a5i>
Once Crystal gets non-blocking I/O, I think I'm going to swtich my site backend to Crystal
<jhass>
ah, block_arg.fun.def.return_type I guess
<asterite>
the path is Def -> block_arg (BlockArg) -> fun (Fun) -> output (ASTNode)
<asterite>
a5i: I think that's just a proof of concept. However, doing require "twitter" and then Twitter::Rest::Client.new … should work
<asterite>
I think you'll also need to read twitter's docs to get the oauth keys
<a5i>
I have the API access keys
sadin has joined #crystal-lang
<a5i>
just dunno how to get thi particular lib to work, since usually there are examples :P
<asterite>
You can checkout the project and do `crystal doc` on it, it will generate docs… at least you will be able to see classes and methods more easily
<a5i>
o
<a5i>
git clone and cd to it then generate?
<asterite>
Yes
<jhass>
asterite: mmh, I pass it a method that has a yield but block_arg is nil
<asterite>
but does it have def foo(&block_arg) ?
<jhass>
no
<jhass>
I can't get the inferred type because that takes place after macro expansion or...?
<asterite>
Kind of, macros can't rely on types… they change
<asterite>
You can always try to use typeof…
<asterite>
Not sure how, though
<jhass>
let me try
<jhass>
{{method.name.id}} do |value| I want the type of value before I even called this :/
<asterite>
You can always require the type to be passed explicitly :)
<jhass>
I know but that's ugly :P
<asterite>
I think that given that you are now required to do include Enumerable(Int32), that's not that ugly
<asterite>
I mean, it keeps being as ugly as it is now :)
<a5i>
>> 33.years().ago()
<DeBot>
a5i: 1982-04-06 20:23:41
<a5i>
asterite: link to that part of Crystal?
<asterite>
There's also the problem of arguments, hmmm…
<asterite>
a5i: check time.cr and time_span.cr
<jhass>
yeah, those would need to be passed on
<asterite>
I think we can make it work without types if you pass the args to the other method and use yield, hhmmm...
<jhass>
http://paste.mrzyx.de/pkvwsnhhc would be ideal interface IMO ( it also breaks if you leave of the parens when calling the macro, which is another bug), but that gives undefined constant T def initialize(&block : Yielder(T) ->)