<gr33n7007h>
jhass: cool, how do you install/require libs?
<gr33n7007h>
so with require
<jhass>
there's not too much out there and dependency management is very basic still, just downloading github repos and symlinking them to the right place basically
<gr33n7007h>
why i didn't take a look at this months ago i don't know :(
<jhass>
don't worry, still the perfect time to shape the language and contribute a bit to stdlib
<jhass>
everything is written in crystal itself and has pretty much rubys open class model, so very easy to just monkey patch in what's missing while working on something and turning it into a proper PR later
<gr33n7007h>
or jhass man this is the shit!!!
<epitron>
i know right!
<gr33n7007h>
epitron: yes man
<epitron>
API is a bit unstable though, watch out gr33n7007h
<gr33n7007h>
gotcha @_
<epitron>
i wrote a great tool, and then the core method i used disappeared :)
<gr33n7007h>
shit, how?
<epitron>
it wasn't cross platform enough or something
<gr33n7007h>
damn
<epitron>
luckily you can just copy/paste it into your script
<jhass>
well, you basically had luck it was working for you :P
asterite has joined #crystal-lang
<gr33n7007h>
seriously why the fuck have i not looked at this before #baffled#
<jhass>
oh, good morning asterite
<epitron>
asterite \o/
<asterite>
good evening :)
<gr33n7007h>
jhass: if it wasn't i'd make it work ! :)
<gr33n7007h>
afk
<jhass>
gr33n7007h: well, there simply is not cross platform way to do what it does that's anywhere near a reasonable performance
<epitron>
that's so surprising1
<epitron>
i thought all platforms would have a fast way of listing a dir, and telling you whether the thing was a file or a dir
<jhass>
well, actually it was worse, it was filesystem specific
<epitron>
(without having to call dir? on everything)
<epitron>
haha
<epitron>
but there must be a cross-platform way to list a directory with reasonable performance
<jhass>
if you find it, I'm happy to learn about it!
<epitron>
(with filenames tagged as file/dir)
<epitron>
that's quite baffling
<jhass>
yeah well,
<jhass>
do man getpass
<epitron>
haha
<jhass>
" This function is obsolete. Do not use it."
<gr33n7007h>
it's even got a better stack trace then ruby
<gr33n7007h>
8)
<asterite>
If we find a way, we can add it. But I don't think that functionality will be a bottleneck in any program
<gr33n7007h>
can you not [*1..10]?
<gr33n7007h>
my mind is stamped in ruby
<jhass>
1.to(10) is better anyway :P
<gr33n7007h>
Syntax error in ./foo.cr:1: unterminated array literal
<epitron>
gr33n7007h: watch out for ? methods too
<epitron>
they're slightly different
<gr33n7007h>
in what way? epitron
<jhass>
>> {1, 2}[2]
<DeBot>
jhass: Error in line 3: index out of bounds for tuple {Int32, Int32}
<jhass>
>> {1, 2}[2]?
<DeBot>
jhass: Error in line 3: undefined method '[]?' for {Int32, Int32}
<jhass>
oh :D
<jhass>
>> [1, 2][2]?
<DeBot>
jhass: nil
<jhass>
>> [1, 2][2]
<DeBot>
jhass: #{e.class}: Index out of bounds
<gr33n7007h>
ok got it
<epitron>
>> "hello"["hell"]?
<DeBot>
epitron: "hell"
<epitron>
:D
<gr33n7007h>
do/end {}/ still exsist?
<gr33n7007h>
do/end {}/ still exist?
<jhass>
yeah
<epitron>
>> begin end
<DeBot>
epitron: nil
<epitron>
:D
<jhass>
more powerful shortform though
<epitron>
the differences are subtle
<gr33n7007h>
>> 1.to(10) {|n| puts n }
<DeBot>
gr33n7007h: 1
<epitron>
it's 95% ruby
<gr33n7007h>
man i'm liking this
<jhass>
>> [1,2,3].map &.+(2)
<DeBot>
jhass: [3, 4, 5]
<epitron>
>> 1.to(10) { |n| print n }
<DeBot>
epitron: 123456789101
<epitron>
haha
<epitron>
it returns the 1
asterite has quit [Ping timeout: 246 seconds]
<gr33n7007h>
>> 0.to(0xff) {|n| Math.sin(n) }
<DeBot>
gr33n7007h: 0
<gr33n7007h>
i will learn
<jhass>
it's the 0 Int#to returns
<gr33n7007h>
>> 0.to(0xff) &.**2
<DeBot>
gr33n7007h: Syntax error in eval:3: unexpected token: .
<jhass>
since you didn't do anything with the sinus ;)
<gr33n7007h>
>> 0.to(0xff) &.(**2)
<DeBot>
gr33n7007h: Syntax error in eval:3: unexpected token: .
<gr33n7007h>
>> 0.to(0xff) &.**(2)
<DeBot>
gr33n7007h: Syntax error in eval:3: unexpected token: .
<jhass>
>> 0.to(0xff, &.**2)
<DeBot>
jhass: Syntax error in eval:3: expecting token ')', not '2'
<jhass>
>> 0.to(0xff, &.**(2))
<DeBot>
jhass: 0
<jhass>
>> 0.to 0xff, &.**(2)
<DeBot>
jhass: 0
<gr33n7007h>
>> 0.to((0xff) &.**(2))
<DeBot>
gr33n7007h: Syntax error in eval:3: unterminated call
<jhass>
but again just Int#to's return value
<gr33n7007h>
yeah i see
<jhass>
&. should be passed like an argument
<jhass>
much like &: in ruby
<gr33n7007h>
>> 0.to(0xff).map {|n| n**2 }
<DeBot>
gr33n7007h: Error in line 3: 'Int32#to' is expected to be invoked with a block, but no block was given
<epitron>
most languages abolished that strange thing
<gr33n7007h>
interpolation?
<epitron>
no, using single quotes to mean a char
<epitron>
>> 'c'
<DeBot>
epitron: 'c'
<jhass>
>> {'a', "a"}.class
<DeBot>
jhass: {Char, String}
<epitron>
>> 'c'.class
<DeBot>
epitron: Char
<epitron>
haha
<epitron>
>> 'char'.class
<DeBot>
epitron: Syntax error in eval:3: unterminated char literal
<gr33n7007h>
ok got it
<gr33n7007h>
:)
asterite has quit [Ping timeout: 246 seconds]
asterite_ has joined #crystal-lang
<jhass>
asterite still needs a bouncer :P
<asterite_>
epitron: but a char makes sense
<asterite_>
:)
<asterite_>
and are much more efficient
<epitron>
i don't mind chars
<epitron>
single quoted strings are nice though
<epitron>
less pressing shift
<asterite_>
well, you can Amway's
<asterite_>
mm...
<asterite_>
you can always use %(...)
<epitron>
omg so much pressing shift
<epitron>
:)
<asterite_>
:P
<asterite_>
?a
<DeBot>
asterite_: Nothing known about a.
<asterite_>
ugh
<epitron>
?a was what i was expecting
<asterite_>
what's "?"?
<asterite_>
but ?a is ugly
<jhass>
yeah, let's not do ?a
<epitron>
hmmm
<epitron>
\a ? :)
<jhass>
\\n?
<asterite_>
¿a
<jhass>
looks silly
<jhass>
heh
<epitron>
CHARACTER(a)
<epitron>
<a>
<epitron>
that's kinda cute ^_^
<epitron>
[a]
<epitron>
ok nevermind
<jhass>
array
<epitron>
yeah, i know
<epitron>
i just like how it looks like a key on the keyboard
<epitron>
:)
<epitron>
[ENTER]
<jhass>
´a´ :D
<jhass>
just to confuse everybody
asterite_ has quit [Ping timeout: 246 seconds]
havenwood has quit [Ping timeout: 256 seconds]
<gr33n7007h>
:)
gr33n7007h has left #crystal-lang ["WeeChat 0.3.8"]
ponga has joined #crystal-lang
<ponga>
has the style for Proc.new changed from ruby?
<ponga>
Proc.new { |n| code } spits error saying wrong number of arguments
ponga has quit [Read error: Connection reset by peer]
ponga has joined #crystal-lang
asterite has joined #crystal-lang
<asterite>
hi ponga
<ponga>
hi
asterite has quit [Ping timeout: 246 seconds]
<jhass>
ponga: yeah, always use the stabby lambda basically
<ponga>
jhass: what is 'stabby' lambda
<jhass>
>> -> { puts "I am" }.call
<DeBot>
jhass: I am
<ponga>
oh
<ponga>
what is ->
<ponga>
didn't see that in doc
<jhass>
the stabby lambda
<ponga>
>> a = -> { puts "hi" }; a.call
<DeBot>
ponga: hi
<ponga>
oh
<jhass>
ruby has it too
<ponga>
ok 'stab'
<jhass>
>> lambda { "h" }
<DeBot>
jhass: Error in line 3: undefined local variable or method 'lambda'
<jhass>
yeah, so we don't have anything else in crystal really, so could just call it anonymous function literal or whatever
<ponga>
>> a = -> do puts "hi" end; a.call
<DeBot>
ponga: hi
<ponga>
anonymous function sounds good
<jhass>
but stabby lambda is the ruby community name :P
<ponga>
dma
asterite has joined #crystal-lang
<asterite>
ponga: what is alis lang? It looks similar to Esperanto in some ways
<ponga>
asterite: it is influenced by Esperanto style
<ponga>
its a mock-up language to support Japanese/Korean chatbot integration
<asterite>
Nice
<ponga>
um yeah its like ByteCode of human language
<ponga>
asterite: korean/japanese sentence is converted into Alislang, then process into the bot
<ponga>
compiler? maybe?
<ponga>
dunno
asterite has quit [Ping timeout: 246 seconds]
ponga has quit [Remote host closed the connection]
ponga has joined #crystal-lang
<ponga>
n
havenwood has joined #crystal-lang
<ponga>
hi havenwood
<havenwood>
hello
waj has joined #crystal-lang
gr33n7007h has joined #crystal-lang
havenwood has quit [Ping timeout: 264 seconds]
havenn has joined #crystal-lang
<gr33n7007h>
>> a = 2 > 1 ? 100 : "100"; if a.responds_to?(:round); puts "yep"; else; puts "nope"; end
<DeBot>
gr33n7007h: yep
<jhass>
runtime check afaik
<jhass>
but the compiler knows that the object has that method if in that branch, so it's safe to call
<gr33n7007h>
to add to an array is it just .push?
<jhass>
.push, or <<, just like in Ruby
<gr33n7007h>
ok, thanks
<gr33n7007h>
Syntax error in ./test.cr:13: for empty arrays use '[] of ElementType' ?
<gr33n7007h>
doing targets = []
<jhass>
yup
<jhass>
needs to be targets = [] of String or whatever you want it
<gr33n7007h>
howcome jhass?
<jhass>
can't infer which type the array should have from pushes anywhere later in the code (yet)
<gr33n7007h>
oh silly me
<gr33n7007h>
so if a was pushing a struct onto the array I would do targets = [] of Struct?
<jhass>
yep
<gr33n7007h>
ok
<jhass>
if you push multiple things, you can specify a union
<gr33n7007h>
jhass how?
<jhass>
targets = [] of String|Symbol
<gr33n7007h>
ok got
<gr33n7007h>
it
<jhass>
a common union is the one with nil, Class|Nil, so it can be abbreviated with Class?
<ytti>
how is crystal planning to handle language and standard libraries, will they be synchronous?
<gr33n7007h>
thanks jhass
<jhass>
ytti: not sure I fully understood the question, but I think so, yes
<ytti>
i'll try to elaborate, take ruby and YAML parser
<ytti>
it was changed, somewhat radically at one point, which caused some breakage
<ytti>
and i thought, if standard libraries and language itself would live asynchronously, then you might gain feature velocity while at the same time reduce breakage
<ytti>
langauge itself would have implicit standard libraries version, which it would expect
<ytti>
but you could specifically in packaging specify which standard library version you are using
<jhass>
mmh, I think we're still far to early to worry about such concepts yet tbh
<ytti>
this way you would arbitrarily do incompatible changes to standard libraries, without fearing about breaking anything
<ytti>
as you could have all the standard versions installed, and package would simply tell you which one to use
<jhass>
For example you won't see Crystal supported multiple LLVM versions for quite some time
<ytti>
but not incur any overhead on typical scenario, due to implicit standards version
<ytti>
i think it's almost perfect situation, because later on, it'll be hard to fix
<ytti>
lot of standard libraries in ruby are kind of terrible, because introducing changes there is not very practical
<gr33n7007h>
how do you get a value from a struct then?
<ytti>
if you could communicate in package descrpition set of standard libraries you use, new version of crystal could innovatem much more freely, without fearing breakage
<ytti>
and you could run new language with older set of standard libraries
<jhass>
gr33n7007h: as I understood it so far, a struct is like a regular Object still, except pass by value instead of pass by reference
<gr33n7007h>
jhass: Yep, as I understand also
<jhass>
ytti: don't you just trade stdlib innovation for compiler innovation? Since the compiler needs to understand old standard libraries?
<jhass>
gr33n7007h: which means regular instance variables and accessors ;)
<ytti>
jhass, but aren't the standard libraries high-level typically
<gr33n7007h>
let me consult the docs somemore
<ytti>
jhass, perhaps there needs to be another layer, low-level, which need to remain relatively static for API compatibility
<jhass>
ytti: not too much, in the case of crystal at least, since it's written in itself
<ytti>
jhass, and higher-level, utility libraries, whose collection version is implied by language version, but may be explicitly defined as something else
<jhass>
the compiler as a program relies heavily on its stdlib
<ytti>
i'm looking for opposite example in crystal/tree/master/src, but yeah they are not too high level
<asterite>
gr33n7007h: what are you trying to do?
<gr33n7007h>
asterite: retrieve a value out of a struct would a just do getter :var1
<ytti>
jhass, on example from ruby that springs to mind is 'ipaddr', it's pretty bad, but there is no reasonable way to change it, without too much breakage
<asterite>
gr33n7007h: yes... doesn't work?
<jhass>
ytti: anyway, my point is that I think that this would introduce way to much overhead for now that'll harm innovation at the moment
<gr33n7007h>
no doesn't seem to work
<asterite>
gr33n7007h: can we see your code?
ponga has quit [Quit: Leaving...]
<gr33n7007h>
sure
<jhass>
ytti: that is we're still below 1.0, we don't really need to worry about backwards compatibility for a while
<ytti>
jhass, but once you do have to worry about, it might be hard to fix :)
<ytti>
i guess it's broader discussion on the responsibilities of langauge and package manager
<ytti>
i love that language has good selection of standard libraries, ruby does this fairly well
<asterite>
gr33n7007h: do [] of Foo
<gr33n7007h>
oh ok one sec
<ytti>
andd probably the people active in development know what common use libraries are good
<asterite>
the compiler won't know which of the many structs are in that array
<gr33n7007h>
asterite: great that worked :)
<ytti>
but if you ship them as standard library, then you're very committed to it, i'd love to have both, low commit + rich set of standard libraries
<ytti>
and i think it is possible, but yeah, certainly not matter that is urgent for crystal
<asterite>
ytti: the problem is that user code must rely on some common base, otherwise it's every library reinventing the wheel
<gr33n7007h>
asterite: so I could do something like `targets.map &.bssid` ?
<asterite>
gr33n7007h: yes, you can try
<gr33n7007h>
let me try
<gr33n7007h>
1 sec
<ytti>
asterite, quite and i want the stadard library to broad, i just also want it to be able to live without breakage, maybe some library which is de-facto for 5 years, suddently becomes inferior to newer alternative, which is completely API incompatible
<ytti>
asterite, i'd love if language could start shipping with that library instead, without breaking
<gr33n7007h>
yep, works neat
<ytti>
asterite, and i think it is possible, by asynchronous standard library version and language version, but language version implies standard library version, if not explicitly statically configured
<ytti>
perhapsin my gemspec i could do Gem::Specification.new do { |s| s.standard_library_version = '>=1.2.3' }
<ytti>
and even though language now ships with say newer 'ipaddr' library
<ytti>
my old code keeps on working, as it keeps using older 'ipaddr' library
<asterite>
If your code depends on one version of the std, but your code also depends on a library that depends on another version of the std, how would that work?
<ytti>
is there reason they couldn't use each their own version?
<ytti>
as long as you're not serializing data between them in API dependent manner?
<ytti>
isn't that problem going to surface regardless in package manager?
<ytti>
if i require libA and libB >= 1.2
<ytti>
but libA requires libB >=2.0
<ytti>
i guess my fault then was, that i didn't specify libA version, which is compatible with my idea of libB?
<ytti>
anyhow very excited about crystal, great work, i hope it keeps on gaining traction
asterite has quit [Ping timeout: 246 seconds]
<ytti>
anyone happen to have idea of high performance network libraries like dpdk, netmap and pf_ring? I'm mostly C illiterate, but in need for network packet loss and jitter tester for up-to 1Gbps rates
<ytti>
it seems perhaps on surface as trivial task, but if you rely on UDPSocket, your performance is going to be terrible
<ytti>
i started writing one in rust, presuming i was held back by ruby, but turns out, i'm held back by linux kernel, and rust doesn't help me one bit
<ytti>
and cursory look at plugging DPDK in to rust showed it to be too complex for my level of C clue
<jhass>
ytti: the easiest is probably to write a binding to one of these
<jhass>
writing bindings to C libraries is fairly easy in crystal
<ytti>
yeah i was looking at YAML and was 'the fsck, i can understand this, surely there is some other file needed that i'm mnissing'
<ytti>
but DPDK is complex in itself, even for C clued, I've understood
<ytti>
maybe netmap is easier, gotta take a look one of these days
weskinner_mac has joined #crystal-lang
<gr33n7007h>
just a quick question h = {} of Int32 => Int32 is that correct syntax?
<jhass>
I think so, yes
<jhass>
>> h = {} of Int32 => Int32
<DeBot>
jhass: {}
<gr33n7007h>
oh i forgot about bot only used it before aswell :)
<gr33n7007h>
jhass: can that be union'd?
<jhass>
it can
<gr33n7007h>
thanks
<jhass>
>> h = {} of Int32|Symbol => Int32|Symbol
<DeBot>
jhass: {}
<jhass>
>> h = {} of (Int32|Symbol => Int32|Symbol)|String => Int32
<DeBot>
jhass: Syntax error in eval:3: expecting token ')', not '=>'
<jhass>
okay, not that way :P
<jhass>
if the Foo => Bar syntax starts to fail, use the generic one: Hash(Foo, Bar)
<gr33n7007h>
ok, will do
<gr33n7007h>
oh i forgot what type is Float ?
ponga has joined #crystal-lang
<jhass>
>> 1.245.class
<DeBot>
jhass: Float64
<ponga>
>> 1.class
<DeBot>
ponga: Int32
<ponga>
>> "hi".class
<DeBot>
ponga: String
<jhass>
>> 0e24.class
<DeBot>
jhass: Syntax error in eval:3: unexpected token: e24
<jhass>
heh
<gr33n7007h>
ah the good old class method
<ponga>
>> a = -> { puts "hi"}; a.class
<DeBot>
ponga: ( -> Nil)
<ponga>
?
<gr33n7007h>
>> 0x00.class
<DeBot>
gr33n7007h: Int32
<ponga>
>> a = -> { puts "hi"}; a.class; a.call
<DeBot>
ponga: hi
<ponga>
>> a = -> { puts "hi"}; a.class
<DeBot>
ponga: ( -> Nil)
<jhass>
ponga: lambda type representation, like Foo => Bar for hash
<jhass>
uh, we're doing that %d too already, so I guess just wait until somebody trips over it :P
<ytti>
heh
<ytti>
but that isn't formatter problem?
<ytti>
that is .to_i problem
<jhass>
well, debatable
<ytti>
or is to_i supposed to always return Int32?
<jhass>
that's the question! ;)
<ytti>
my least surprise would be to return appropriate integer
<ytti>
and to_i(arg) for specific
<jhass>
mmh, you want to return it a specific Int though I think, not the union of all of them
<jhass>
so that's why we have to_i64 and so on already
<ytti>
of course then we can debate what is appropriate, is it host dependant? or is it smallest which will fit it?
<jhass>
>> "123".to_i64
<DeBot>
jhass: 123
<jhass>
I think it's always Int32
<ytti>
that is gonna bite people
<jhass>
yeah, maybe we should drop to_i and keep just to_i32 etc. :/
<jhass>
*just keep
<jhass>
but meh
<jhass>
mmh, weird
<jhass>
>> "8589934592".to_i
<DeBot>
jhass: 2147483647
<jhass>
>> 8589934592
<DeBot>
jhass: 8589934592
<jhass>
>> 8589934592.class
<DeBot>
jhass: Int32
<ytti>
i think it should be changed to something that returns most sensible integer, even if it is costly
<ytti>
if you want performance, be explicit
<jhass>
otoh one could argue that Int32 is the default integer for literals too
<jhass>
>> (8589934592 + 1).class
<DeBot>
jhass: Int64
<jhass>
but it's a bit inconsistent atm, I agree
<jhass>
haha
<jhass>
>> a = 2147483648; a.class
<DeBot>
jhass: Int64
<crystal-gh>
[crystal] ytti opened pull request #458: support binary, octal and hex output (master...master) http://git.io/x8w8
<ytti>
i need to figure out how to get llvm working, sorry guys
<ytti>
but hopefully it'll give explicit idea what i'd like to be able to do
<ytti>
how long does it take to compile crystal on average box?
<jhass>
depends on a few factors, initial compile in release mode does take a minute or two on my i7 @ 2Ghz here
<ytti>
ok good
<ytti>
minutes is fine
<ytti>
tens of minutes would be a problem
<jhass>
yeah, no
<jhass>
my IRC bot has a few kloc by now let's see the stats in release mode
<ponga>
does crystal have socket class
<jhass>
ponga: yup
<jhass>
Parse: 00:00:00.0482750
<jhass>
Type inference: 00:00:00.4211250
<jhass>
Codegen (crystal): 00:00:00.1791310
<jhass>
Codegen (bc+obj): 00:00:06.7517470
<jhass>
Codegen (clang): 00:00:00.1464730
<jhass>
that's release mode
<jhass>
Parse: 00:00:00.0598570
<jhass>
Type inference: 00:00:00.4404460
<jhass>
Codegen (crystal): 00:00:00.2404370
<jhass>
Codegen (bc+obj): 00:00:00.5519700
<jhass>
Codegen (clang): 00:00:00.1611600
<jhass>
that's without optimizations
<ytti>
ok, that's fast
<ytti>
lto of bots out there, but for my specific case (puking messages from various monitoring systems) i have requirement where one channel cannot block other channels
<ytti>
other requirement that i had, which i couldn't satisfy in the few examples i read through, was ability to trigger messages without having incoming message from irc
<ytti>
for say notify script, which will send you message after N passage of time
waj has quit [Quit: Leaving.]
havenwood has joined #crystal-lang
havenn has quit [Ping timeout: 246 seconds]
ponga has quit [Remote host closed the connection]