00:00
<
kori >
the language I know the most is Go
00:00
<
kori >
go is nice but it's missing a couple stuff
00:00
<
jhass >
mmh, I guess you don't have some fairly small Go program you could port for fun?
00:00
<
kori >
I actually do
00:00
<
kori >
a concurrent uploader
00:01
<
kori >
for this website
00:01
<
jhass >
doesn't sound too small :P
00:01
<
kori >
I wanted to implement support for more websites
00:01
<
kori >
but then I got lazy
00:01
<
kori >
jhass: it actually is
00:01
<
kori >
it only requires http, ssl, json...
00:01
<
kori >
unless it isn't for crystal :P
00:01
<
jhass >
yeah, could actually be feasible already
00:02
<
kori >
to be worth porting over
00:02
<
kori >
actually it might not be
00:02
<
kori >
it involves command line parsing
00:02
strcmp1 has quit [Quit: Leaving]
00:03
<
jhass >
heh yeah, chance to look at OptionParser ;)
00:04
<
Kilo`byte >
yay parsing ipv6 addresses is fun (tm)
00:04
<
jhass >
if the -w wouldn't be it just be puts ARGV[0]? || "good" though :P
00:05
<
kori >
good might become my new hello world
00:06
* Kilo`byte
is feeling like he is asking too many noob questions
00:06
<
Kilo`byte >
does String have a method to count the times a certain char is present
00:06
<
jhass >
>> "foo".count('o')
00:09
<
kori >
jhass: I'm getting index out of bounds
00:10
<
kori >
wouldn't it be something along the lines
00:10
<
jhass >
kori: missed the ? ?
00:10
<
jhass >
[x] raises, [x]? returns nil
00:10
<
kori >
aaaand it's done
00:11
<
Kilo`byte >
now i just need to parse 1-4 hex digits into 2 UInt8s
00:11
<
Kilo`byte >
what'd be the best approach?
00:12
<
kori >
alright... uhhh
00:12
<
jhass >
>> "ab".to_u8(16)
00:12
<
Kilo`byte >
>> "abcd".to_u8(16)
00:12
<
Kilo`byte >
thats the problem :P
00:12
<
jhass >
hardest part is to find some efficient slicing for the string I guess
00:13
<
jhass >
>> "abdef".split(/(?<=..)/).map &.to_u8(16)
00:13
<
Kilo`byte >
i could use an u16 and then do some modulo on it
00:13
<
jhass >
that's probably the fastest way actually
00:13
<
jhass >
just shift & mask
00:15
<
jhass >
>> u = "abdef".to_u16(16); l &= 0xFF; u >>= 8; {u, l}
00:15
<
jhass >
>> u = "abdef".to_u16(16); l = u & 0xFF; u >>= 8; {u, l}
00:15
<
jhass >
>> u = "abcd".to_u16(16); l = u & 0xFF; u >>= 8; {u, l}
00:16
<
jhass >
is that right? I suck at those :D
00:16
<
jhass >
>> "cd".to_u8(16)
00:16
<
Kilo`byte >
jhass: that looks like a good approach though
00:17
<
jhass >
keeps them as UInt16's though
00:18
<
Kilo`byte >
nothing a .to_u8 won't fix
00:18
<
jhass >
>> u = "abcd".to_u16(16); l = u & 0xFF; u >>= 8; {u.to_u8, l.to_u8} # and hope LLVM is smart about it
00:18
<
kori >
FIRST PROJECT IN CRYSTAL, DONE
00:18
<
jhass >
congratz :D
00:19
<
jhass >
btw we kinda inherited two spaces for indentation from ruby, just in case you seek contributors at something more elaborate ;P
00:21
<
jhass >
that module is maybe a bit pointless, but who cares^^
00:21
<
kori >
I don't understand the language yet
00:21
<
kori >
it's not required for this kind of program, right?
00:21
<
kori >
just so I know
00:21
<
kori >
gotta make it ultra-minimalist
00:23
<
kori >
jhass: wanna know the funniest part? something similar happened with good
00:23
<
kori >
just keeping in line :P
00:23
<
kori >
then again, the market for GNU yes replacements isn't that large...
00:24
<
jhass >
module serves two and a half purposes: 1) as a namespace for other constants (which modules and classes two kind of are) module Foo; class Bar; end; end; Foo::Bar 2) as mixins; module Foo; def foo; end; end; class Bar; include Foo; end; Bar.new.foo 2.5) as holders for utility "class methods", module Foo; def self.foo; end; end; Foo.foo,
00:24
<
kori >
I haven't dabbled with OOP
00:24
<
kori >
but I guess I'll have to now
00:25
<
kori >
I thought it was somewhat similar to Go's package declaration
00:25
wmoxam has quit [Ping timeout: 260 seconds]
00:25
<
kori >
...but then I realized: I haven't defined any functions anyway
00:25
<
jhass >
and of course you can combine all of these in one module if you really want
00:26
<
jhass >
namespace is probably the most common usecase actually
00:26
<
jhass >
since there's only one global one shared across all files
00:26
wmoxam has joined #crystal-lang
00:26
<
kori >
just curious, have you used go?
00:26
<
jhass >
you usually keep all your my_library's stuff inside a module MyLibrary
00:26
<
jhass >
my strongest language is Ruby
00:26
<
kori >
the package declaration is kind of a namespace
00:27
<
kori >
for example, package "fmt" has a function named Println
00:27
<
kori >
when you import it
00:27
<
kori >
you call it as fmt.Println
00:27
<
jhass >
yeah, though I guess it has closer to python style imports? you can eg. rename?
00:28
<
kori >
import foo as bar?
00:28
<
kori >
for example?
00:28
<
kori >
you can kinda
00:28
<
kori >
it's import ( bar "foo" )
00:28
<
jhass >
so Crystal's loading system is file based
00:29
<
jhass >
require takes filenames and those just happen to define some module by convention. Or they don't, end-user issue
00:29
<
kori >
so it's kinda similar to go?
00:29
<
jhass >
I really haven't touched go yet :/
00:30
<
kori >
jhass: uhh 1sec
00:30
<
kori >
has an Upload method
00:31
<
kori >
go source code is organized like that, files beling to a certain package in a dir
00:31
<
kori >
named after the package
00:31
<
kori >
I could have another foo.go file there
00:31
<
kori >
that would be in package teknik
00:31
<
kori >
and it'd get imported
00:31
<
jhass >
yup, and the filename has to match the package declaration, right?
00:32
<
kori >
it doesn't have to, I think
00:32
<
kori >
but it usually does :P
00:32
<
jhass >
mmh, so I can say for sure that in Crytal it doesn't, of course it's sane convention that it does
00:32
<
kori >
I don't know for certain how it works in go
00:32
<
kori >
but there's a go path
00:32
<
Kilo`byte >
in a spec, how do i ensure the class of a value is correct?
00:33
<
kori >
and then packages are searched for there
00:33
<
kori >
so you import "fmt"
00:33
<
kori >
not import "/some/path/fmt"
00:33
<
Kilo`byte >
stuff.class.should be(WhateverClass) prodices a compile error
00:33
<
jhass >
sure, the question is if import "fmt" could make the package blawub available
00:34
<
kori >
I think crystal should import modules, not directories
00:34
<
kori >
s/import/load/
00:34
<
jhass >
it loads files really
00:34
<
Kilo`byte >
like ruby
00:34
<
kori >
I'm really not sure how things are working here
00:34
<
kori >
hmm how about this
00:35
<
jhass >
>> require "spec"; "foo".class.should be(String)
00:35
<
kori >
do I need to specify a relative/absolute path when loading modules, or is there some environment variable which will let me load a module just by its name?
00:35
<
jhass >
>> require "spec"; "foo".class.should eq(String)
00:35
<
kori >
something like
00:36
<
jhass >
kori: require "foo"; will search CRYSTAL_PATH (or the baked in value from CRYSTAL_CONFIG_PATH if unset) for "foo.cr" and "foo/foo.cr"
00:36
<
kori >
that might be what I want then, yeah
00:36
<
jhass >
require "foo/bar" will search it for "foo/bar.cr" and "foo/bar/bar.cr"
00:37
<
kori >
and then when foo.cr file is loaded
00:37
<
kori >
the contents, being in module "foo"
00:37
<
Kilo`byte >
require "spec"; class MyClass; end; (MyClass.new as MyClass|String).should be(MyClass)
00:37
<
Kilo`byte >
>> require "spec"; class MyClass; end; (MyClass.new as MyClass|String).should be(MyClass)
00:37
<
DeBot >
Kilo`byte: in /usr/lib/crystal/spec/expectations.cr:28: no overload matches 'String#same?' with types MyClass:Class -
http://carc.in/#/r/cck
00:37
<
kori >
I can call foo.Bar
00:37
<
kori >
(bar being a function in module foo)
00:37
<
jhass >
right, module names have to start with an uppercase letter though and by convention should use CamelCase
00:37
<
Kilo`byte >
jhass: thats where my issue happens :P
00:37
<
jhass >
just like class names
00:38
<
Kilo`byte >
so it'd be Foo.bar
00:38
<
kori >
this is going to be pretty weird to get used to
00:38
<
jhass >
>> require "spec"; class MyClass; end; (MyClass.new as MyClass|String).class.should eq(MyClass)
00:38
<
kori >
since I'm used to foo.Bar, not Foo.bar
00:38
<
Kilo`byte >
function names are by convention snake_case
00:38
<
Kilo`byte >
same for variables
00:39
<
Kilo`byte >
in fact, local variables MUST be lowercase or they are treated as class constants
00:39
<
Kilo`byte >
(at least first char)
00:39
<
kori >
crystal is still in alpha, I'll pretend that convention doesn't exist and some day it'll go away
00:39
<
kori >
just kidding :P
00:39
<
Kilo`byte >
jhass: right i have a .class there in my code though
00:39
<
jhass >
>> require "spec"; class MyClass; end; (MyClass.new as MyClass|String).is_a?(MyClass).should be_true
00:39
<
jhass >
perhaps better
00:40
<
jhass >
Kilo`byte: note how I swapped your be with eq
00:41
<
jhass >
oh, actually
00:41
<
jhass >
>> require "spec"; class MyClass; end; (MyClass.new as MyClass|String).should be_a(MyClass) # Kilo`byte use this
00:42
<
kori >
alright cool
00:42
<
Kilo`byte >
hmm nice
00:42
<
kori >
jhass: thanks for all the help so far, by the way
00:43
<
kori >
also, if I want to refer to some pack-, er, module's documentation, what should I do?
00:43
<
kori >
go has godoc <module> <function>
00:43
<
kori >
... <package>
00:44
<
kori >
as in, godoc fmt Println would give me information on how to use fmt.Println, alongside the type signature
00:44
<
Kilo`byte >
kori: thing is: most functions do not even include typeinfo in their definition
00:45
<
Kilo`byte >
also, test state on ip parsing: .FFF..F..
00:45
<
kori >
Kilo`byte: oh
00:45
<
jhass >
kori: for stdlib, just hit crystal-lang.org/api
00:46
<
jhass >
there's a site that parses github repos, let me find it
00:47
<
kori >
alright this is pretty great
00:47
<
jhass >
and if you have something locally you can run crystal doc
00:47
<
jhass >
that'll parse src/ iirc
00:49
<
kori >
well hrmm I don't know what else to do
00:49
<
kori >
...actually I just forgot I have an IDEAS folder
00:49
<
kori >
s/forgot/remembered/
00:50
<
jhass >
in doubt you can always read through stdlib until you find an undocumented method (well, that shouldn't take long :P), try to understand it and write docs for it :P
00:52
<
Kilo`byte >
jhass: wait, count does not support counting occurances of strings in another string?
00:52
<
Kilo`byte >
that one got me
00:53
<
Kilo`byte >
luckily there are unit tests
00:53
<
jhass >
>> "foo".count("fo")
00:53
<
jhass >
ah right, it's String#count syntax :D
00:53
<
Kilo`byte >
it takes the string as a set
00:53
<
jhass >
yeah, like Ruby
00:53
<
Kilo`byte >
this broke my error check logic D:
00:54
<
jhass >
I actually wrote Crystals String#count -.-
00:54
<
jhass >
I don't think my set parsing is fully complete yet though
00:55
<
Kilo`byte >
jhass: i think .count_string might be useful
00:55
<
kori >
jhass: on a scale of 1 to 20, how much would you recommend me using your IRC library?
00:55
<
Kilo`byte >
for now i'll go with a regex
00:56
<
jhass >
it's written against 0.6 still, soo, more like 2-3 :/
00:56
<
kori >
I don't know if I have the skill to write my own
00:56
<
Kilo`byte >
expected: "10:0:0:0:0:0:0:0"
00:56
<
Kilo`byte >
got: "0:10:0:0:0:0:0:0:0:0:0:0:0:0:0:0"
00:56
<
Kilo`byte >
that looks like i derped something
00:56
<
Kilo`byte >
oright...
00:57
<
kori >
I have never used ruby, but from what I've heard, cinch is pretty neat
00:58
kyrylo has quit [Ping timeout: 260 seconds]
00:59
<
Kilo`byte >
have used it myself multiple times
01:03
<
Kilo`byte >
((@data[i * 2].to_u16 << 8) & @data[i * 2 + 1].to_u16).to_s(16)
01:03
<
Kilo`byte >
that line isn't working as expected, where is my mistake?
01:03
<
Kilo`byte >
any ideas?
01:04
<
Kilo`byte >
@data is a Slice(UInt8)
01:05
<
willl >
i think you want | not &
01:05
<
Kilo`byte >
err yes
01:05
<
Kilo`byte >
of course
01:13
<
Kilo`byte >
9 examples, 0 failures, 0 errors, 0 pending
01:17
<
Kilo`byte >
willl: regarding your performance concerns: its not as big of a concern here, as its not going to be called that often
01:17
<
Kilo`byte >
also the performance difference is practically nothing
01:17
<
willl >
i had those from when i was benchmarking something
01:18
<
willl >
but it shows a few different ways to do it. i settled on the handshift ones because both the 32 and 64 ended up looking similar
01:18
<
willl >
and llvm optimized them to be byteswap instructions anyway
01:20
<
Kilo`byte >
what i did however learn was the existance of Benchmark.ips
01:20
<
Kilo`byte >
thanks :P
01:21
<
Kilo`byte >
kori: also your skill concerns: i cobbled together a really simple irc lib thingy last night in rust
01:21
<
Kilo`byte >
the hardest part was the parsing code, i can give you that
01:22
NeverDie has joined #crystal-lang
01:22
<
Kilo`byte >
did i say rust
01:22
<
Kilo`byte >
i am getting
_really_ tired
01:22
<
Kilo`byte >
crystal ofc
01:22
<
jhass >
oh, a third parser? :P
01:23
<
Kilo`byte >
it doesn't handle tags yet though :P
01:23
<
kori >
Kilo`byte: when I say "new" programmer
01:23
<
kori >
I really mean it :P
01:23
<
Kilo`byte >
jhass: ircv3 feature
01:23
<
kori >
especially to OOP
01:23
<
jhass >
ah right, mine neither I guess :P
01:24
<
Kilo`byte >
example: @account=Kilobyte22 :Kilobyte!~kilobyte@cucumber.kilobyte22.de PRIVMSG #crystal-lang :test
01:28
<
kori >
does crystal have map, filter and reduce
01:29
<
Kilo`byte >
well, i think filter has a different name
01:29
<
Kilo`byte >
select works for sure
01:29
<
jhass >
map is .map {|i| ... }
01:29
<
jhass >
filter is .select {|i| ... } I guess
01:30
<
Kilo`byte >
sadly afaik they are not lazy
01:30
<
jhass >
and .reduce(optional_initial) {|accum, i| ... }
01:30
<
kori >
navigating the docs is kinda confusing
01:30
<
Kilo`byte >
kori: /api is there as well
01:31
<
jhass >
Kilo`byte: map and select have Iterator versions by now
01:31
<
kori >
Kilo`byte: aye
01:31
<
kori >
jhass: just wondering
01:31
<
jhass >
>> "foo".each_char
01:31
<
Kilo`byte >
jhass: yeah, but they are not default :P
01:31
<
DeBot >
jhass: # => #<String::CharIterator:0x910efc0 @reader=CharReader(@string="foo", @pos=0, @current_char='f', @current_char_width=1, @end=false), @end=false> -
http://carc.in/#/r/ccv
01:31
<
kori >
is Iterator similar to Enumerable?
01:31
<
Kilo`byte >
oh they are?
01:31
<
jhass >
>> "foo".each_char.map {|c| c.ord }
01:31
<
DeBot >
jhass: # => Iterator(T)::Map(String::CharIterator, Char, Int32)(@iterator=#<String::CharIterator:0x8eedfc0 @reader=CharReader(@string="foo", @pos=0, @current_char='f', @current_char_width=1, @end=false), @end=false>, @func=#<(Char -> Int32):0x8050380>) -
http://carc.in/#/r/ccw
01:31
<
jhass >
>> "foo".each_char.map {|c| c.ord }.to_a
01:32
<
Kilo`byte >
"foo bar".each_char.map {|c| c.ord }.take(2).to_a
01:32
<
Kilo`byte >
>> "foo bar".each_char.map {|c| c.ord }.take(2).to_a
01:32
<
jhass >
kori: not quite, they expose similar API but Enumerable is a module that gives you a bunch of functionality based on your .each method
01:32
<
jhass >
while Iterator is for lazy iteration
01:32
<
Kilo`byte >
now... can you create infinite iterators?
01:32
<
kori >
I know how rust iterators work
01:33
<
Kilo`byte >
or is there no api for that yet
01:33
<
kori >
oh whatever I won't compare languages
01:33
<
Kilo`byte >
like, it'd work in theory
01:33
<
kori >
but yeah some better documentation is needed
01:33
<
jhass >
Kilo`byte: most of them are structs, so pretty much
01:33
<
Kilo`byte >
kori: i keep comparing it to scala :P
01:33
<
Kilo`byte >
in my head at least
01:33
<
jhass >
oh you mean upto infinity
01:33
<
jhass >
>> 1.upto(Float::INFINITY)
01:33
<
jhass >
eh, we don't?
01:34
<
kori >
if I keep comparing crystal to anything I'll go mad
01:34
<
jhass >
>> 1.upto(1/0.0)
01:34
<
Kilo`byte >
jhass: nono xD
01:34
<
Kilo`byte >
that returns an iterator? :O
01:34
<
jhass >
>> 1.upto(1/0.0).take(20)
01:34
<
DeBot >
jhass: # => #<Iterator(T)::Take(Int::UptoIterator(Int32, Float64), Int32):0x9483f78 @iterator=#<Int::UptoIterator(Int32, Float64):0x9483f90 @from=1, @to=inf, @current=1>, @n=20, @original=20> -
http://carc.in/#/r/cd2
01:34
<
Kilo`byte >
thats some interesting news
01:34
<
jhass >
>> 1.upto(1/0.0).take(20).to_a
01:34
<
DeBot >
jhass: # => [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20] -
http://carc.in/#/r/cd3
01:34
<
jhass >
Kilo`byte: if you don't pass a block
01:34
<
Kilo`byte >
yeah noticed that
01:35
<
Kilo`byte >
reminds me of a guy who used the rust macro facilities to implement a syntax element for recurrent sequences
01:35
<
Kilo`byte >
(i've yet to see a language with as powerful macro capabs *wink*)
01:36
<
Kilo`byte >
to be fair, crystal isn't THAT far off
01:38
<
kori >
Kilo`byte: any lisp?
01:38
<
Kilo`byte >
i've yet to look into lisp really
01:40
<
Kilo`byte >
heh, thats pretty nice
01:41
<
Kilo`byte >
rust cannot do that without a compiler plugin :P
01:44
<
Kilo`byte >
jhass: the main thing rust macros can do that crystal ones can't is specifying the call syntax
01:45
<
Kilo`byte >
inside of the call brackets you can do basicly anything as long as there are no unmatched brackets
01:46
<
jhass >
you can do anything in crystal macros as long as the result parses to valid crystal expression
01:46
<
jhass >
I can get you your argument list from a shell script or whatever
01:46
<
Kilo`byte >
no, the call syntax
01:47
<
Kilo`byte >
stuff!(somevar -> sometype);
01:47
<
jhass >
oh, you mean the macro call, gotcha
01:47
<
jhass >
well, you could pass a string pass that to the run macro and do whatever :P
01:48
<
Kilo`byte >
well, thats boring ;)
01:48
<
Kilo`byte >
like, D has a recurrance function which does that
01:48
elbow_jason has quit [Ping timeout: 246 seconds]
01:48
<
Kilo`byte >
auto fib = recurrence!("a[n-1] + a[n-2]")(0, 1);
01:49
<
jhass >
but given you can pass any valid crystal expression to a macro it's good enough I guess
01:49
<
Kilo`byte >
in rust you can model that without string
01:49
<
Kilo`byte >
let fib = recurrence!(a[n]: u64 = 0, 1 ... a[n-1] + a[n-2]);
01:49
<
jhass >
thinking about it I'm not even sure if allowing to introduce arbitrary syntax is a good idea
01:50
<
Kilo`byte >
its just something to think about ;)
01:50
<
jhass >
if you limit to valid crystal syntax it looks more coherent and there's probably less to learn
01:50
<
Kilo`byte >
certainly would make things more flexible
01:50
<
Kilo`byte >
i do like how you can pass blocks to macros though :P
01:51
<
Kilo`byte >
thats a nice touch
01:53
NeverDie_ has joined #crystal-lang
01:56
NeverDie has quit [Ping timeout: 256 seconds]
01:57
elbow_jason has joined #crystal-lang
02:11
<
Kilo`byte >
jhass: btw, i did some irc lib benchmarking, however the one by Thor77 is really not looking like it fully implements the irc protocol
02:11
<
jhass >
interesting
02:12
<
Kilo`byte >
just out of curiousity, lets throw in a regex based one
02:12
<
jhass >
didn't think pcre performs that well
02:12
<
jhass >
oh, wait, I misremember
02:12
<
jhass >
well, it's 4am here, I should sleep a bit :D
02:15
<
Kilo`byte >
jhass: same here
02:15
<
Kilo`byte >
who needs sleep :P
02:19
<
Kilo`byte >
well, to be fair, i should get some sleep as well
02:25
elbow_jason has quit [Ping timeout: 260 seconds]
02:35
NeverDie has joined #crystal-lang
02:37
NeverDie_ has quit [Ping timeout: 240 seconds]
02:48
elbow_jason has joined #crystal-lang
03:10
NeverDie has quit [Quit: I'm off to sleep. ZZZzzz…]
03:13
elbow_jason has quit [Remote host closed the connection]
03:27
Sadin has joined #crystal-lang
04:21
Sadin has quit [Ping timeout: 244 seconds]
04:42
havenwood has joined #crystal-lang
04:56
kulelu88 has joined #crystal-lang
05:24
blue_deref has quit [Quit: bbn]
05:28
ryanf_ is now known as ryanf
05:29
sailorswift has joined #crystal-lang
05:32
sailorswift has quit [Max SendQ exceeded]
05:33
kulelu88 has left #crystal-lang ["Leaving"]
05:33
sailorswift has joined #crystal-lang
05:34
sailorswift has quit [Max SendQ exceeded]
05:38
sailorswift has joined #crystal-lang
05:42
sailorswift has quit [Ping timeout: 265 seconds]
05:46
sailorswift has joined #crystal-lang
05:48
sailorsw_ has joined #crystal-lang
05:50
sailors__ has joined #crystal-lang
05:50
sailorswift has quit [Ping timeout: 244 seconds]
05:51
sailorswift has joined #crystal-lang
05:53
sailorsw_ has quit [Read error: Connection reset by peer]
05:54
sailors__ has quit [Read error: Connection reset by peer]
05:54
sailorsw_ has joined #crystal-lang
05:58
sailorswift has quit [Ping timeout: 244 seconds]
06:06
sailorswift has joined #crystal-lang
06:10
sailorsw_ has quit [Ping timeout: 256 seconds]
06:11
havenwood has quit [Ping timeout: 246 seconds]
06:45
sailorswift has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
06:47
<
crystal-gh >
[crystal] bjmllr opened pull request #1262: several small improvements to Regex (master...regex)
http://git.io/vswhD
06:48
sailorswift has joined #crystal-lang
07:08
BlaXpirit has joined #crystal-lang
07:36
sleeper_ is now known as sleeper
08:25
<
thor77 >
Kilo`byte: no, my lib is far away from complete
08:28
sailorswift has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
08:43
ssvb has quit [Ping timeout: 256 seconds]
08:55
ssvb has joined #crystal-lang
09:18
kyrylo has joined #crystal-lang
09:23
NeverDie has joined #crystal-lang
09:27
zamith has joined #crystal-lang
09:28
zamith has quit [Client Quit]
09:59
NeverDie has quit [Quit: I'm off to sleep. ZZZzzz…]
10:23
<
Kilo`byte >
thor77: the code is pretty hard to understand though :P
10:24
<
thor77 >
Kilo`byte: uh, sry :/
10:24
<
thor77 >
i'm not that experienced in writing crystal-code
10:24
<
Kilo`byte >
also, does it support both messages with and without prefix? :P
10:25
<
thor77 >
message-prefix?
10:26
<
Kilo`byte >
the irc format is :prefix command params :more params
10:26
<
Kilo`byte >
prefix, params and more params being optional
10:27
<
Kilo`byte >
yeah, i know
10:27
<
Kilo`byte >
i benchmarked it yesterday
10:27
<
Kilo`byte >
didn't apply unit testing to it though
10:29
<
Kilo`byte >
thor77: so whats the output? i'd expect for example a tuple {prefix: String|Nil, command: String, params: Array(String)}
10:29
<
Kilo`byte >
doesn't look like that to me :P
10:30
<
Kilo`byte >
so i'd personally rate it as hacky parser that "works"
10:30
kyrylo has quit [Quit: Konversation terminated!]
10:30
<
thor77 >
Message-obj.init calls the Message.parse-method
10:30
<
thor77 >
and this parse-method fills the class with some information-attr
10:30
kyrylo has joined #crystal-lang
10:30
<
thor77 >
type, data, host and target
10:31
<
Kilo`byte >
well yes, but it looks like it nowhere has an array or something of params
10:31
<
Kilo`byte >
which has me concerned, as messages can contain practically an unlimited amount of parameters
10:31
<
thor77 >
maybe you can call the Message-obj an array of params
10:31
<
thor77 >
s/params/data
10:31
<
thor77 >
and msg.data includes everything
10:32
<
Kilo`byte >
lets say you have this message: SOMETHING param1 param2 param3 :param 4
10:32
<
Kilo`byte >
how'd that get parsed
10:32
<
thor77 >
let's test it
10:32
<
Kilo`byte >
i'd expect {nil, "SOMETHING", ["param1", "param2", "param3", "param 4"]}
10:33
<
Kilo`byte >
or w/e representation
10:33
<
Kilo`byte >
my implementation stores it in a class as well
10:35
<
thor77 >
type = "SOMETHING", host = "", target = "", data = "param1 param2 param3 :param 4"
10:35
<
jhass >
so no parameter parsing
10:36
<
jhass >
what about :jhass@2001::dead:beef 331 * :foo
10:36
<
Kilo`byte >
jhass: you missed a jhass! there :P
10:37
<
Kilo`byte >
but w/e it proves the point
10:37
<
Kilo`byte >
also yeah, my first irc parser (which i wrote before reading the RFC) had issues with ipv6
10:38
<
thor77 >
type = '331', host = 'jhass@2001::dead:beef', target = '*', data = 'foo'
10:38
<
Kilo`byte >
whats target about
10:38
<
jhass >
and why wasn't it in the previous one
10:39
<
thor77 >
target is the recevier of the msg
10:40
<
Kilo`byte >
why'd you make that a seperate field
10:40
<
Kilo`byte >
because its technically a regular parameter
10:41
<
jhass >
235 :foo: bar
10:42
<
Kilo`byte >
my parser would make that IRCLine{prefix: "jhass@2001::dead:beef", command: "331", params: ["*", "foo"]}
10:42
<
thor77 >
type = '235', host = '', target = '', data = ':foo: bar'
10:42
<
sardaukar >
is it possible to do before_each on spec?
10:42
<
sardaukar >
I see theres a before_each, but it's not being used anywhere in the source
10:43
<
jhass >
thor77: :me!you@::1 235 :foo: bar then?
10:43
<
jhass >
sardaukar: no, spec doesn't support that. The before_each is global and meant for things like mocking libs
10:43
<
Kilo`byte >
thor77: does it also properly handle it if the last param doesn't start with a :
10:44
<
thor77 >
type = '235', host = 'me!you@::1', target = ':foo:', data = ''
10:44
<
thor77 >
Kilo`byte: it doesn't care about different params
10:44
<
jhass >
thor77: where's the bar? I broke it :P
10:44
<
Kilo`byte >
like ":someone PRIVMSG #channel :foo" and ":someone PRIVMSG #channel foo" should yield exact same result
10:44
<
thor77 >
Kilo`byte: it's just stupid string-splitting
10:45
<
thor77 >
jhass: uh, yeah o.O
10:46
<
thor77 >
i didn't copy your complete message
10:46
<
thor77 >
type = '235', host = 'me!you@::1', target = ':foo:', data = 'ar'
10:46
<
thor77 >
but still weird output
10:47
<
thor77 >
actually it DOES care about the :
10:48
<
jhass >
it should, while FOO :bar and FOO bar are the same, FOO :bar :baz and FOO bar baz are not
10:49
<
thor77 >
i never really thought about this parsing-algorythm, it worked perfectly for me until now
10:49
<
jhass >
nobody in your channel does : highlights I guess :P
10:50
<
jhass >
someone FOO foo : bar, someone FOO foo :bar, someone FOO : foo : bar
10:50
<
thor77 >
i just remove the first character from @data, because i assume its the :
10:51
<
Kilo`byte >
it doesn't have to be a :
10:51
<
Kilo`byte >
well, the thing is: a parser that "works" will eventually break
10:51
<
thor77 >
but on most irc-servers its a :
10:51
<
Kilo`byte >
and you'll have fun figuring it out, because its hard to notice
10:51
<
jhass >
in FOO :foo: bar there's only one param and its "foo: bar"
10:51
<
Kilo`byte >
always unit test a parser
10:51
<
thor77 >
is your parser somewhere available on github?
10:52
<
Kilo`byte >
might actually contain bugs
10:52
<
Kilo`byte >
if you find something that breaks it i'll be happy to fix it
10:54
<
thor77 >
let's see if i can include your parser into my code
10:54
<
thor77 >
or do you want to create a pull request? :P
10:56
<
Kilo`byte >
well, i wanna test it fully first
10:56
<
Kilo`byte >
and i will add tag support
10:56
<
Kilo`byte >
its about 50% slower than yours though
10:57
<
Kilo`byte >
but they are all so fast, it doesn't really make difference
10:59
<
Kilo`byte >
thing about that code
10:59
<
Kilo`byte >
i have actually not unit tested it
10:59
<
thor77 >
okey. if you're finished testing, please create a pr :)
10:59
<
Kilo`byte >
only real-world testing
11:05
<
Kilo`byte >
jhass: in a hash, is nil a valid value or does that unset it
11:05
<
jhass >
it's a valid value
11:14
zamith has joined #crystal-lang
11:19
zamith has quit [Quit: Be back later ...]
11:19
<
Kilo`byte >
>> {"a": "b"} == {"a": "b"}
11:26
<
Kilo`byte >
>> {} of String => String == {} of String => String|Nil
11:27
<
Kilo`byte >
very nice
11:28
<
jhass >
Kilo`byte: String|Nil has a shortcut: String?
11:29
<
Kilo`byte >
i am aware :P
11:29
<
Kilo`byte >
but i personally tend to prefer |Nil
11:35
<
RX14 >
i might make a crask at a IRC lib
11:35
<
RX14 >
i've done one in java before
11:36
<
Kilo`byte >
jhass: is the output order for Hash#each always same if i put same stuff into hash in same order?
11:37
<
Kilo`byte >
otherwise i need a way to change that so i can properly unittest serialization of tags
11:37
<
jhass >
mmh, I hope it has insertion order yeah, but I never checked
11:41
<
BlaXpirit >
how can it be insertion ordered
11:41
<
jhass >
one singly linked list through all items
11:42
<
jhass >
oh, that's actually even doubly linked
11:42
<
BlaXpirit >
sounds like a horrible implementation
11:42
<
Kilo`byte >
....E.FFFFFF
11:42
<
Kilo`byte >
looks like my unit tests are broken
11:43
<
RX14 >
so which crystal IRC lib has the most complete specs for me to nick?
11:43
* thor77
has no specs
11:44
<
thor77 >
but maybe you can get some inspiration
11:45
<
BlaXpirit >
no, i don't understand this Hash at all
11:47
<
jhass >
happens, if you have any questions just ask them
11:47
<
Kilo`byte >
RX14: i am writing specs for my parser atm
11:47
<
Kilo`byte >
can give you once done
11:47
<
Kilo`byte >
it also tests ircv3 capabs. if your parser doesn't support that just remove the respective specs
11:48
<
RX14 >
well i'll make it parse ircv2 before v3
11:49
<
Kilo`byte >
jhass: uh, aren't you maintaining the aur package?
11:49
<
Kilo`byte >
could you maybe get it to use llvm35
11:49
<
Kilo`byte >
for debug symbols
11:50
<
jhass >
I'd rather like it to keep it on 35 tbh
11:50
<
jhass >
37 is around the corner
11:50
<
Kilo`byte >
well without debug symbols its a pain to debug
11:50
<
jhass >
yeah, but we should rather patch crystal to generate the correct ones
11:51
<
Kilo`byte >
like, i have this stack thingy: *parse<String>:IRCParser::IRCLine +6 [139652844377784]
11:51
<
Kilo`byte >
i think its probably at the beginning somewhere (see the +6) but idk
11:51
<
Kilo`byte >
actually nvm
11:52
<
jhass >
I'd say get a copy of the repo that you build against 35 and then just alias crystal35="~/foo/bin/crystal"
11:52
<
jhass >
it's retaining that semantic, yes
11:53
<
BlaXpirit >
so is there really no additional cost in having this implementation with insertion order?
11:53
<
jhass >
semantic != implementation
11:53
<
jhass >
Crystal's hash implementation isn't as advanced
11:53
<
Kilo`byte >
12 examples, 0 failures, 0 errors, 0 pending
11:55
<
jhass >
mmh, actually the implementation is similar
11:55
<
jhass >
BlaXpirit: the additional cost is two pointers per entry
11:56
<
jhass >
and a tail pointer
11:56
<
BlaXpirit >
how to benchmark memory?
11:56
<
BlaXpirit >
how much memory a data structure uses
11:56
<
jhass >
that's a good and tricky question
11:56
<
Kilo`byte >
including all pointers? tricky one
11:57
<
BlaXpirit >
surely the GC knows everything
11:57
<
jhass >
the easiest is probably to observe external RSS and have different implementations in distinct processes
11:57
<
jhass >
maybe disabling GC
11:57
<
Kilo`byte >
my favourite c++ define: #define delete
11:58
<
Kilo`byte >
awesome to troll ppl
11:58
<
Kilo`byte >
just slip it in their header file
11:58
<
BlaXpirit >
people don't use delete these days
11:58
<
BlaXpirit >
at least good c++ programmers
11:58
<
jhass >
Bjarne says every new and delete is probably a bug anyway ;)
11:58
<
Kilo`byte >
yeah, true
11:58
<
Kilo`byte >
but still, the odd place where they do
11:59
<
BlaXpirit >
anyway... for now i'll just benchmark python vs crystal Hash
11:59
<
jhass >
but you can troll much better in Ruby. class Object; def !; [true, false].sample; end; end;
11:59
<
BlaXpirit >
wondering what would be a good benchmark
11:59
<
thor77 >
BlaXpirit: thats not fair^^
11:59
<
BlaXpirit >
why not?
11:59
<
thor77 >
because crystal compiles to c
12:00
<
BlaXpirit >
uhh no..?
12:00
<
thor77 >
python is just a scripting-lang
12:00
<
Kilo`byte >
it compiles to llvm bytecode
12:00
<
BlaXpirit >
i'll move on to ruby then
12:00
<
thor77 >
s/compiles to c/compiles to a optimized executable
12:00
<
Kilo`byte >
ruby > python imo
12:01
<
Kilo`byte >
we no need no stinkin' python
12:01
<
Kilo`byte >
my personal opinion is that python is a steaming piece of turd
12:01
<
jhass >
thor77: python's hash implementation is written in python itself?
12:02
<
Kilo`byte >
jhass: its called a dict because they want to feel special
12:02
<
Kilo`byte >
but i highly doubt it
12:02
<
thor77 >
jhass: don't think so
12:02
<
BlaXpirit >
Kilo`byte, yeah, please tell me how great of a name Hash is
12:02
<
jhass >
whatever, map then
12:02
<
BlaXpirit >
please just stop this BS
12:02
<
Kilo`byte >
BlaXpirit: you can smoke hash
12:02
<
BlaXpirit >
you can suck dict
12:02
<
jhass >
thor77: so, it's both native code then, no? ;)
12:02
<
Kilo`byte >
well, you can also smoke a dict, but the effect is probably not that great
12:02
<
thor77 >
uhm, you're right
12:02
* thor77
still loves python
12:03
<
thor77 >
especially the syntax
12:03
<
Kilo`byte >
thats the worst part imo
12:03
<
Kilo`byte >
directly followed by the standard api
12:03
<
thor77 >
ruby-syntax is very confusing to me
12:03
<
Kilo`byte >
its an oop language
12:03
<
Kilo`byte >
yet to_string or w/e isn't a method for all classes
12:03
<
Kilo`byte >
but instead you use string(stuff)
12:03
<
Kilo`byte >
actually str()
12:04
<
Kilo`byte >
thats just completely unexpected
12:04
<
BlaXpirit >
Kilo`byte, get out. nobody was arguing the merits of any language
12:04
<
BlaXpirit >
then you just come in saying python sucks
12:04
<
Kilo`byte >
BlaXpirit: sorry, just telling my opinion :P will stop now
12:05
<
thor77 >
at least we all agree php sucks? :P
12:05
<
Kilo`byte >
was just that a python fanboy was realling pissing me off the other day
12:05
<
Kilo`byte >
thor77: i hope we do
12:11
<
RX14 >
how do you pass by reference?
12:12
<
BlaXpirit >
RX14, everything is passed by reference
12:12
<
BlaXpirit >
(except for values and structs)
12:12
<
RX14 >
yeah i knew objects are references
12:14
<
RX14 >
but passing an int by reference?
12:14
<
RX14 >
how do you reference a value type
12:14
<
BlaXpirit >
RX14, that's against the language's idioms
12:14
<
BlaXpirit >
you can make pointerof(that_int)
12:14
<
RX14 >
ugh so you can't pass an int out
12:15
<
BlaXpirit >
i don't know otherwise
12:15
<
RX14 >
yeah i guessed pointers could
12:15
<
BlaXpirit >
RX14, what do you actually want to do?
12:20
<
RX14 >
the way you return 2 values from a method constructs an array right?
12:20
<
RX14 >
that's overhead
12:23
<
BlaXpirit >
RX14, no
12:23
havenwood has joined #crystal-lang
12:24
<
BlaXpirit >
you return a tuple
12:24
<
BlaXpirit >
barely any overhead, especially after llvm has had its way with it
12:29
<
jhass >
>> def foo; {1, 2}; end; a, b = foo; b
12:32
leafybasil has quit [Remote host closed the connection]
12:35
<
jhass >
%"{Int32, Int32}" = type { i32, i32 }
12:36
<
jhass >
%1 = call %"{Int32, Int32}" @"*foo:{Int32, Int32}"()
12:36
<
jhass >
%3 = getelementptr inbounds %"{Int32, Int32}"* %__temp_1, i32 0, i32 0
12:37
<
jhass >
I guess that's like returning a C struct?
12:39
<
BlaXpirit >
that seems to be the idea
12:44
<
BlaXpirit >
ok the implementation of Hash is just fine :)
13:01
kyrylo has quit [Ping timeout: 260 seconds]
13:05
<
RX14 >
what's the best way to convert a Slice(Char) to a string?
13:06
<
BlaXpirit >
RX14, i think String.new(that) ?
13:06
<
BlaXpirit >
not sure, but there was something similar for sure
13:06
<
RX14 >
i don't think it has one for Slice)Char)
13:06
<
RX14 >
there's one that takes a slice of bytes
13:06
<
RX14 >
Slice(UInt8)
13:06
<
BlaXpirit >
oh right!
13:07
<
BlaXpirit >
RX14, that.join
13:11
<
RX14 >
and how do I turn a string into a slice of chars
13:12
<
jhass >
why do you have that anyway?
13:12
<
jhass >
are you really sure you don't want a Slice(UInt8)?
13:13
<
BlaXpirit >
RX14, s.chars gives an array
13:13
<
RX14 >
but then I have to deal with unicode myself
13:13
<
jhass >
why do you have a Slice?
13:13
<
BlaXpirit >
i strongly suspect C lib is involved
13:13
<
BlaXpirit >
if not, then this is disturbind
13:14
<
RX14 >
no c is involved
13:14
<
BlaXpirit >
then this is disturbing
13:16
<
Kilo`byte >
are crystal strings null terminated or length based.
13:16
<
Kilo`byte >
i assume latter
13:16
<
BlaXpirit >
hm i never thought about this
13:18
<
Kilo`byte >
like, from my unit test code for ircv3 tags I'd say null terminated
13:19
<
BlaXpirit >
Kilo`byte, length is definitely involved
13:19
<
BlaXpirit >
and doesn't appear to be null terminated, but i'm not sure
13:23
<
BlaXpirit >
i wonder how to get a pointer to the data
13:26
<
jhass >
>> "foo".@buffer
13:26
<
BlaXpirit >
to_slice even
13:26
<
BlaXpirit >
jhass, it actually is @c :o
13:26
<
BlaXpirit >
and it seems like string has parts of it inside the compiler, not just stdlib
13:27
<
RX14 >
>> "foo".to_slice
13:27
<
RX14 >
>> 102 == 'f'
13:27
<
jhass >
>> 'f' == 102
13:27
<
BlaXpirit >
use chr, ord
13:27
<
jhass >
ah, but I think at least the latter might change
13:27
<
Kilo`byte >
jhass: you can access instance vars? wut
13:28
<
BlaXpirit >
>> "adsf".cstr.to_slice(10)
13:28
<
jhass >
Kilo`byte: eh yeah, but don't :D
13:28
<
Kilo`byte >
i was about to say
13:28
<
jhass >
Kilo`byte: hack for instance_variable_get replacement
13:28
<
Kilo`byte >
that sounds like a bad idea
13:28
<
BlaXpirit >
so who can answer: are strings 0 terminated or not?
13:28
<
RX14 >
>> "adfd".@c
13:28
<
Kilo`byte >
meanwhile my sis just raged really hard for w/e reason
13:29
<
jhass >
>> "foo" as UInt8*
13:29
<
RX14 >
oh @c is the pointer to the beginning?
13:29
<
BlaXpirit >
>> "foo".to_unsafe.to_slice(10)
13:29
<
BlaXpirit >
RX14, don't use @c
13:29
<
BlaXpirit >
.cstr is the right way to access the same thing
13:29
<
BlaXpirit >
and to_unsafe seems to be exactly the same as well
13:29
<
jhass >
>> b = ("foo" as UInt8*); Array.new(4) { |i| b[i] }
13:30
<
RX14 >
crystal strings must be null-terminated right?
13:30
<
BlaXpirit >
jhass, i don't think this casting is valid.
13:30
<
BlaXpirit >
RX14, length is used everywhere
13:30
<
jhass >
BlaXpirit: eh, right, it's a tuple actually
13:30
<
RX14 >
but look at the def new with the yield
13:31
<
RX14 >
doesn't it set the last char to be null?
13:31
bawNg_ has joined #crystal-lang
13:31
<
BlaXpirit >
great catch, RX14
13:31
<
BlaXpirit >
perhaps it does the same as Nim
13:31
<
BlaXpirit >
it probably does
13:31
<
BlaXpirit >
length is used everywhere
13:31
<
BlaXpirit >
but 0-termination is just a bonus for interoperability with C
13:32
<
RX14 >
anyway if .cstr is just a pointer to the start, then it must be null-terminated or cstr wouldn't be nul-terminated
13:32
<
BlaXpirit >
"sdf\0asd" this wouldnt work
13:32
<
BlaXpirit >
>> "sdf\0asd" # this wouldnt work if 0termination meant anything
13:33
<
jhass >
>> String.new("sdf\0asd".cstr)
13:33
<
jhass >
it means something when creating a new string from a C string, but that's expected
13:34
<
jhass >
since it just strlen's it
13:34
<
RX14 >
so you can do it but if you use C code it will break
13:34
<
jhass >
well, there are C APIs that don't use 0 terminated strings either
13:35
<
jhass >
where you would pass s.cstr, s.bytesize
13:37
<
RX14 >
hmmn I wonder if I have to worry about unicode if i'm dealing with a byte[]
13:38
<
RX14 >
because I don't need to detect unicode just keep it intact
13:38
<
jhass >
crystal strings are UTF-8 encoded
13:38
<
BlaXpirit >
+ pretty sure utf-8 uses 0 byte only for 0 codepoint itself
13:39
<
jhass >
sure, it's ASCII compatible
13:39
<
RX14 >
Slice of bytes out of string is how easy?
13:39
<
BlaXpirit >
RX14, huh?
13:39
vikaton has joined #crystal-lang
13:40
<
BlaXpirit >
"я".to_slice
13:40
<
BlaXpirit >
>> "я".to_slice
13:40
<
RX14 >
>> ":".to_slice[0] == ':'
13:40
<
BlaXpirit >
RX14, you yourself used it 13 minutes ago :p
13:40
<
RX14 >
yeah i have a short memory :P
13:40
<
jhass >
>> ":".to_slice[0] == ':'.ord
13:40
<
RX14 >
yeah that'll do
13:41
* RX14
rubs his hands in anticipation
13:41
<
BlaXpirit >
>> {"я".to_slice[0], 'я'.ord}
13:41
<
RX14 >
>> ":".to_slice.type
13:41
<
BlaXpirit >
and it's Slice, what do u expect
13:42
<
RX14 >
i thought .class and typed .type
13:42
<
RX14 >
my hands have a mind of my own
13:42
leafybasil has joined #crystal-lang
13:43
<
RX14 >
i'm trying to get an irc parser with the least memory copies as possible
13:45
<
vikaton >
glad to see Crystal growing
13:45
<
jhass >
most operations don't copy, they add new pointers and a small buffer for the new header
13:46
<
jhass >
since String is immutable
13:47
leafybasil has quit [Ping timeout: 240 seconds]
13:48
Ven has joined #crystal-lang
13:48
<
Kilo`byte >
RX14: hows your irc parser coming along
13:52
<
RX14 >
well i've started
14:05
<
RX14 >
is there a nice way to microbenchmark or do you ahve to roll your own?
14:05
<
jhass >
Benchmark.ips
14:06
<
RX14 >
yup, found it
14:08
<
RX14 >
if I wasn't on a shit laptop and could have the docs on another monitor...
14:24
<
RX14 >
is there a UInt8 to char method for debugging?
14:25
<
RX14 >
no, char doesn't have a constructor
14:27
<
BlaXpirit >
RX14, what do you want?
14:27
<
RX14 >
i'm so think
14:27
<
BlaXpirit >
UInt8 is not a character
14:27
<
BlaXpirit >
your best hope is .chr
14:27
<
BlaXpirit >
but it is valid only for ascii!!!!
14:27
<
RX14 >
well that should be fine for debugging
14:27
<
RX14 >
that's all I want really
14:27
<
Kilo`byte >
>> 255.chr
14:28
<
Kilo`byte >
i wonder...
14:28
<
Kilo`byte >
>> "\n"
14:28
<
Kilo`byte >
good thats been taken care of
14:30
<
BlaXpirit >
>> Pointer(Int).null
14:30
<
DeBot >
BlaXpirit: Error in line 4: can't use Int as generic type argument yet, use a more specific type -
http://carc.in/#/r/chm
14:30
<
BlaXpirit >
>> if Pointer(Int32).null; p ":("; end
14:31
<
Kilo`byte >
>> !!Pointer(Int32)
14:31
<
Kilo`byte >
>> !!Pointer(Int32).null
14:32
<
BlaXpirit >
>> Pointer(Int32).null ? true : false
14:32
<
BlaXpirit >
>> !!(Pointer(Int32).null)
14:32
<
BlaXpirit >
ok then
14:32
<
BlaXpirit >
>> n = 5; {pointerof(n) or nil, Pointer(Int32).null or nil}
14:33
<
BlaXpirit >
>> n = 5; {(pointerof(n) or nil), (Pointer(Int32).null or nil)}
14:33
<
BlaXpirit >
>> n = 5; "#{pointerof(n) or nil} #{Pointer(Int32).null or nil}"
14:33
<
BlaXpirit >
come on, this is too much
14:34
<
BlaXpirit >
>> n = 5; p1 = pointerof(n) or nil; p2 = Pointer(Int32).null or nil; {p1, p2}
14:34
<
BlaXpirit >
now i get it :D
14:34
<
BlaXpirit >
>> n = 5; {pointerof(n) or nil, Pointer(Int32).null or nil}
14:35
<
BlaXpirit >
>> n = 5; {pointerof(n) || nil, Pointer(Int32).null || nil} # so sorry for spam :(
14:38
leafybasil has joined #crystal-lang
14:42
ssvb has quit [Ping timeout: 244 seconds]
14:45
Ven has quit [Ping timeout: 265 seconds]
14:53
<
RX14 >
>> p "a" while true
14:53
<
RX14 >
yeah i thought that got removed
15:05
blue_deref has joined #crystal-lang
15:06
ssvb has joined #crystal-lang
15:18
<
RX14 >
apparently I can't call a private macro from another private macro
15:42
<
Kilo`byte >
also, i might look into a dbus lib
15:43
daphee has joined #crystal-lang
15:43
<
BlaXpirit >
Kilo`byte, what do you mean
15:43
<
Kilo`byte >
being able to use dbus from crystal
15:44
<
BlaXpirit >
Kilo`byte, well i started that already
15:44
<
Kilo`byte >
oh nice
15:44
<
Kilo`byte >
i hope nice and OOP? :P
15:44
<
BlaXpirit >
nobody cared about it so i kinda stopped
15:44
<
Kilo`byte >
well, i do care
15:46
<
BlaXpirit >
it's really difficult to figure out how to make receiving messages good
15:46
<
BlaXpirit >
it basically expects you to have an event loop
15:46
<
Kilo`byte >
well you can do that in background
15:50
<
BlaXpirit >
Kilo`byte, so what are your plans now?
15:52
<
Kilo`byte >
uh i'd really like to implement an interface to avahi
15:52
<
Kilo`byte >
and iirc that uses dbus
15:52
<
Kilo`byte >
although it also has c bindings i think
15:54
vikaton has quit [Quit: Connection closed for inactivity]
15:58
<
daphee >
I have a question on how to get all matches with the Regex class. There is nothing like a "findall" function. So I tried using loops and the pos argument of match but nothing really works:
http://carc.in/#/r/cic
15:59
<
BlaXpirit >
daphee, string.scan
16:00
<
daphee >
Cool, thanks. Don't know how I have missed that.
16:00
<
BlaXpirit >
daphee, well it's extremely difficult to find
16:00
<
BlaXpirit >
i would have no idea if not for that ruby search
16:01
<
sardaukar >
even on Ruby ppl seem to complain that it is on String and not on Regexp
16:02
kulelu88 has joined #crystal-lang
16:03
<
jhass >
they do? makes sense to me
16:03
<
jhass >
you scan the string, not the regex
16:06
<
bjmllr >
we have =~ and match on both string and regex, should we add scan to regex as well?
16:07
<
bjmllr >
then should we remove the duplication of the other methods?
16:08
<
BlaXpirit >
=~ makes sense
16:08
<
BlaXpirit >
duplicate, that is
16:08
<
BlaXpirit >
because it's kinda symmetric, 1:1
16:08
<
BlaXpirit >
scan is like an n:1 operation
16:08
<
BlaXpirit >
i'm not making myself clear, am i
16:08
<
bjmllr >
they're all binary functions, but i kinda see what you mean. operators = ok to alias, named methods = ng
16:10
<
BlaXpirit >
no, it's not that
16:11
<
bjmllr >
is it because scan returns a collection?
16:12
<
BlaXpirit >
because scan uses 1 thing to find N things in a string
16:14
sleeper has left #crystal-lang ["tfw no sleeper"]
16:18
<
bjmllr >
it combines 1 regex and 1 string to find N matches. i'm not sure there's a particular order of regex and string that makes more sense than the other, but if there is i'd think it would apply equally to #match
16:18
<
BlaXpirit >
=~, match are a 1:1 operations, so everything makes sense to me
16:24
<
bjmllr >
(String, Regex) -> makes more sense than (Regex, String) -> in the case of -> Enumerable(MatchData) but not in the case of -> MatchData ?
16:26
<
bjmllr >
trying to understand your perspective on this
16:58
<
BlaXpirit >
i think it was something suggested by jhass, and i don't understand it, and removing the code had no consequences that i noticed
17:00
<
jhass >
guess something about not making it a generic and preventing a union somewhere, idk
17:01
<
BlaXpirit >
oooh, so i added the generic and happened to remove that piece of code after doing that
17:01
<
BlaXpirit >
probably would've broken otherwise
17:15
<
RX14 >
i forgot @ types were always nillable
17:22
<
RX14 >
oh my god this is such a pain in the ass
17:25
<
BlaXpirit >
no, RX14, that's not true
17:28
<
RX14 >
no, this macro is a pain in the ass
17:31
<
jhass >
just properly initialize your stuff
17:32
<
RX14 >
okay it now parses the irc prefix
17:34
<
RX14 >
so you can't use a private macro inside a macro
17:34
<
RX14 >
it says it doesn't exist
17:49
bawNg_ has quit [Read error: Connection reset by peer]
17:58
kulelu88 has left #crystal-lang ["Leaving"]
18:28
Ven has joined #crystal-lang
18:30
<
RX14 >
if I define a macro in a module, how do I use it
18:31
<
RX14 >
wait private macros are per file...
18:38
<
jhass >
>> module Foo; macro self.bar; puts "hi"; end; end; Foo.bar
18:38
<
jhass >
don't think you can use it outside
18:41
Ven has quit [Ping timeout: 252 seconds]
18:49
<
crystal-gh >
[crystal] bebac opened pull request #1264: Handle web socket close packet + add send method to web socket sessio… (master...websocket-close)
http://git.io/vsKm1
18:50
Ven has joined #crystal-lang
18:50
<
BlaXpirit >
behavior seems wrong, makes sense
18:51
<
RX14 >
well if I expanded that macro into real code it would work
18:51
<
RX14 >
if you expand y manually then it works, so it's clearly a work
18:52
<
RX14 >
damn i'm tired
18:52
<
RX14 >
can't even english
18:55
<
RX14 >
if you have a non-private macro in a class how do you access it?
18:55
<
RX14 >
outside the class
19:02
Ven has quit [Ping timeout: 255 seconds]
19:02
<
jhass >
I don't think you can atm
19:03
<
jhass >
maybe you want a macro def?
19:04
<
RX14 >
i was just thinking what's the point of private macros in classes if they can't be accessed outside the class anyway!
19:05
Ven has joined #crystal-lang
19:06
<
jhass >
>> class Foo; macro bar; end; end; class Bar < Foo; bar; end;
19:06
<
jhass >
>> class Foo; private macro bar; end; end; class Bar < Foo; bar; end;
19:09
kyrylo has joined #crystal-lang
19:11
Ven_ has joined #crystal-lang
19:11
Ven has quit [Ping timeout: 272 seconds]
19:13
<
Kilo`byte >
DeBot: well, the macro gets expanded there
19:13
<
Kilo`byte >
wait, derp
19:31
<
RX14 >
Kilo`byte, is your irc parser on github?
19:38
<
Kilo`byte >
RX14: gist, but yes
19:38
<
Kilo`byte >
actually there is an old version
19:39
<
RX14 >
i want to see the interface your IRCLine class provides
19:40
<
Kilo`byte >
yeah, check that link
19:41
<
Kilo`byte >
only a couple getters really
19:55
Ven_ has quit [Ping timeout: 260 seconds]
20:03
Ven has joined #crystal-lang
20:08
Ven has quit [Read error: Connection reset by peer]
20:09
Ven has joined #crystal-lang
20:11
<
RX14 >
hmmn string.to_slice isn't null terminated
20:14
<
RX14 >
>> "a".to_slice
20:14
<
RX14 >
>> "a".bytelength
20:14
<
RX14 >
>> "a".bytelen
20:14
<
RX14 >
>> "a".bytesize
20:14
<
RX14 >
>> a = "a"; Slice.new a.cstr, a.bytesize + 1
20:15
<
RX14 >
>> a = "a"; Slice.new a.cstr, a.bytesize + 4
20:15
<
RX14 >
yeah then you get unsafe
20:15
<
RX14 >
>> a = "a"; Slice.new a.cstr, a.bytesize + 10
20:15
<
DeBot >
RX14: # => [97, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0] -
http://carc.in/#/r/cjn
20:15
<
RX14 >
>> a = "a"; Slice.new a.cstr, a.bytesize + 1
20:15
<
RX14 >
so that's what I want for a null terminated byte
20:15
<
RX14 >
the null termination really does make processing it a lot easier
20:16
<
jhass >
I wonder what happens if you send a nullbyte inside a message though
20:16
<
jhass >
>> puts "\o"
20:16
<
jhass >
>> puts "\0"
20:16
<
jhass >
>> puts "\0hi"
20:17
<
jhass >
I guess it doesn't survive the service :p
20:17
<
RX14 >
>> "a\0b".bytesize
20:18
<
RX14 >
>> "a\0b".to_slice
20:18
<
RX14 >
well basically don't
20:18
<
RX14 >
my vim is running slow...
20:18
<
RX14 >
how can this be
20:19
<
jhass >
anyway, it's there, just cut off since the size of course doesn't include it
20:19
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
20:19
<
RX14 >
any chance of crystal breaking that contract?
20:19
<
jhass >
I doubt that
20:19
<
jhass >
and the cstr has it
20:21
<
RX14 >
well cstr doesn't have size
20:21
<
BlaXpirit >
RX14, bytesize is the size
20:21
<
BlaXpirit >
what do u mean
20:21
<
RX14 >
... never mind
20:22
<
RX14 >
i wish I had a bigger screen :(
20:31
ssvb has quit [Ping timeout: 252 seconds]
20:44
ssvb has joined #crystal-lang
20:56
<
RX14 >
man am I going to need to unit test this parser
21:02
<
RX14 >
damn I really want to step through this in a debugger
21:06
<
RX14 >
>> while true; break; end
21:07
<
BlaXpirit >
RX14, what do u want?
21:07
<
BlaXpirit >
wondering why this is printed out?
21:07
<
RX14 >
no break doesn't seem to work in my while loop
21:07
<
RX14 >
probably just me
21:08
<
jhass >
RX14: keep in mind it breaks from blocks too
21:08
<
jhass >
while true; something { break }; end # endless loop
21:12
<
RX14 >
but it's not
21:12
<
RX14 >
i'm really confused
21:12
<
jhass >
well, can't hint anything without the code
21:13
<
RX14 >
i'm really really confused
21:15
<
crystal-gh >
crystal/master 3af1bb9 Oleh Prypin: Add `pred` to Int and Char
21:15
<
crystal-gh >
crystal/master 44ef2bb Oleh Prypin: Add specs for `succ` and `pred`
21:15
<
crystal-gh >
crystal/master 492e152 Oleh Prypin: Add Range#reverse_each
21:16
<
crystal-gh >
crystal/master 8776e64 Konstantin Makarchev: add array#rotate
21:16
<
crystal-gh >
crystal/master 6802d1e Konstantin Makarchev: little fix
21:16
<
crystal-gh >
crystal/master 67e3298 Konstantin Makarchev: copy seems faster
21:18
zamith has joined #crystal-lang
21:18
<
crystal-gh >
crystal/master 08c8e97 Tobias Pfeiffer: Spec/sort/doc remaining Enumerable methods...
21:18
<
crystal-gh >
crystal/master 5bbde2e Ary Borenszweig: Merge pull request #1238 from PragTob/spec-more-enumerable...
21:19
<
RX14 >
it was my fault
21:20
<
RX14 >
i swear I had exactly the same code before and it didn't work but that's how it always goes
21:21
<
crystal-gh >
[crystal] asterite closed pull request #1244: Added HTML parsing to XML module, references #1240 (master...html_parser_with_libxml2)
http://git.io/vsnSi
21:26
<
RX14 >
ok my irc library looks to kinda work
21:26
<
RX14 >
now to bend the unit tests into compiling
21:26
<
14WAAW4DD >
crystal/master cafec4a Will Leinweber: ENV: add documentation
21:26
<
14WAAW4DD >
crystal/master cafea9a Will Leinweber: ENV: #[]= returns the value that was set
21:26
<
14WAAW4DD >
crystal/master cafe2be Will Leinweber: ENV: add .keys and .values
21:27
<
crystal-gh >
crystal/master ac04727 Tobias Pfeiffer: Sorted Iterator methods
21:27
<
crystal-gh >
crystal/master 3d5ed1e Tobias Pfeiffer: Put Iterator implementations beneath method definitions...
21:27
<
crystal-gh >
crystal/master a58192d Tobias Pfeiffer: Sort the iterator spec files
21:32
lukas has left #crystal-lang ["WeeChat 0.4.2"]
21:33
<
crystal-gh >
crystal/master 251216e Jonne Haß: Fix a File.expand_path spec to not expect to be run in a two level deep...
21:33
<
crystal-gh >
crystal/master 0e7fc22 Jonne Haß: run 32bit on travis via docker
21:33
<
crystal-gh >
crystal/master 95806c3 Ary Borenszweig: Merge pull request #1249 from jhass/docker_travis...
21:35
<
RX14 >
what bot is this for the github?
21:35
<
RX14 >
it's so colourless
21:35
<
BlaXpirit >
RX14, so change settings in your client
21:36
<
BlaXpirit >
it's the only good way to do this
21:36
<
BlaXpirit >
what no
21:36
<
RX14 >
you expect me to parse it and colourise it?
21:36
<
RX14 >
the bot should emit colour codes
21:36
<
crystal-gh >
[crystal] asterite closed pull request #1250: Add StaticArray#== for equality comparisons (master...static-array-equality)
http://git.io/vsRHb
21:36
<
RX14 >
oh the channel is +c?
21:37
<
RX14 >
that explains the lack of colours
21:38
<
BlaXpirit >
RX14, the bot should not emit color codes, it's doing the right thing
21:38
<
BlaXpirit >
it gives channel notices
21:38
<
BlaXpirit >
my irc client displays them in brownish yellow
21:38
<
RX14 >
yeah but it would look so much nicer if it was coloured properly
21:39
<
crystal-gh >
[crystal] decioferreira opened pull request #1266: Add documentation for Array#delete_at and Array#delete_if (master...array-delete_at-delete_if)
http://git.io/vsK7y
21:39
<
RX14 >
i'm talking about colourising parts of the message, not the whole message
21:40
<
BlaXpirit >
oh ok, sorry. i still like this best
21:40
<
BlaXpirit >
there is a bonus that it trigger the irc client saying there was a new message in this room
21:40
<
RX14 >
i'm used to it looking nice, the colours amke it easier to distinguish the syntax of the message
21:40
<
BlaXpirit >
that it DOES NOT* trigger
21:40
<
RX14 >
yeah it should be NOTICE
21:41
<
RX14 >
but AFAIK it's actually the github bot
21:41
<
RX14 >
the one set in the services section
21:41
<
RX14 >
and that does emit colours
21:41
<
RX14 >
it's just that this room is +c
21:53
<
crystal-gh >
crystal/master cafe898 Will Leinweber: StringScanner: docs and specs
21:53
<
crystal-gh >
crystal/master cafec0a Will Leinweber: StringScanner: add #[] and #[]?
21:53
<
crystal-gh >
crystal/master cafe861 Will Leinweber: StringScanner: add several helper methods...
22:01
<
RX14 >
oh shit the specs compile!
22:03
<
crystal-gh >
[crystal] asterite closed pull request #1258: add String#sub (master...string_sub)
http://git.io/vsgc3
22:17
BlaXpirit has quit [Quit: Konversation]
22:18
Mo0O has quit [Ping timeout: 244 seconds]
22:19
<
crystal-gh >
crystal/master ee0ea54 Ben Miller: regex.cr: sort methods by name
22:19
<
crystal-gh >
crystal/master 4afda56 Ben Miller: regex: convert #options to a getter
22:19
<
crystal-gh >
crystal/master abd81c0 Ben Miller: regex: document existing methods
22:24
<
crystal-gh >
[crystal] asterite closed pull request #1266: Add documentation for Array#delete_at and Array#delete_if (master...array-delete_at-delete_if)
http://git.io/vsK7y
22:35
<
crystal-gh >
crystal/master 6b9eb0a Ary Borenszweig: Tiny Enumerable doc fixes. Related to #1238
22:35
<
crystal-gh >
crystal/master cea3d6a Ary Borenszweig: Parser: missing function literal argument location
22:35
<
crystal-gh >
crystal/master e0074b1 Ary Borenszweig: XML: parse_html from IO. Related to #1244
22:39
<
RX14 >
most non-ircv3 spec pass now!
22:39
<
RX14 >
time to go to bed
22:40
<
crystal-gh >
crystal/master ba05360 Ary Borenszweig: Allow comparing StaticArrays of different types. Related to #1250
22:40
<
crystal-gh >
crystal/master 08d5218 Ary Borenszweig: Tiny fix in Regex docs for `options`. Related to #1262
22:45
<
crystal-gh >
crystal/master be7c803 Ary Borenszweig: Better document `eval` command. Related to #1263
22:46
Mo0O has joined #crystal-lang
22:59
<
Kilo`byte >
RX14: didn't you want to go to bed? :P
23:00
<
RX14 >
well i'm trying
23:00
<
RX14 >
but i'm bad at such things as turning my computer off
23:00
<
Kilo`byte >
RX14: also scanned through your code and i may have found a flaw
23:00
<
jhass >
ew, too many spaces :P
23:01
<
RX14 >
Kilo`byte, yup?
23:01
<
Kilo`byte >
looks like you assume that a prefix always contains nick, user and host
23:01
<
Kilo`byte >
however it may not
23:01
<
RX14 >
i assume it contains a nick
23:01
<
RX14 >
and the user and host are optional
23:01
<
Kilo`byte >
there are also times where there only is a host
23:02
<
Kilo`byte >
ie: when you get a server message
23:02
<
Kilo`byte >
not uncommon when for example 2 servers link
23:02
<
RX14 >
it will skip those and the two other paramethers will be nil
23:03
<
Kilo`byte >
just curious
23:03
<
RX14 >
it should work
23:03
<
Kilo`byte >
can you push lines from outside into your library?
23:03
<
RX14 >
I havent tested it
23:03
<
RX14 >
Kilo`byte, what do you mean?
23:03
<
Kilo`byte >
that'd be useful as fuck for stuff like epoll (servers!)
23:03
<
Kilo`byte >
like, you don't force using one thread per user
23:04
<
Kilo`byte >
or even 2 (one for reading, one for writing)
23:04
daphee has left #crystal-lang [#crystal-lang]
23:04
<
RX14 >
i don't have anything but [parsing
23:04
<
RX14 >
so whatever network shizz doesn't matter
23:04
<
Kilo`byte >
an irc server usually will run on like one or two treads in total and can easily handle 1k connections :P
23:04
<
Kilo`byte >
thanks to epoll
23:04
<
RX14 >
well i havent benchmarked this
23:04
<
RX14 >
it would be nice if you could for me
23:05
<
RX14 >
but it's midnight
23:05
<
Kilo`byte >
things like nginx up that. i've read its been reported to have 6 million simultanious connections on probably way below 20 threads
23:05
<
Kilo`byte >
night :P
23:05
<
Kilo`byte >
jhass: how efficient is the web server implementation actually
23:07
<
jhass >
42 efficient
23:07
<
Kilo`byte >
actually, does crystal have an async io thingy yet?
23:07
<
Kilo`byte >
if not i may look into that
23:07
<
jhass >
sort of, all IO is evented
23:07
<
jhass >
if you spawn a coroutine and IO would block a different coroutine is scheduled
23:08
<
Kilo`byte >
well, i mean like, a concrete one, kinda like eventmachine
23:08
<
jhass >
only if all are blocked it stalls
23:08
<
Kilo`byte >
jhass: what does it use in background? poll? select? epoll?
23:10
<
jhass >
(guess that's epoll?)
23:10
<
Kilo`byte >
wouldn't surprise me if that used epoll
23:10
<
Kilo`byte >
now the question is just: how much does a coroutine switch cost (performance wise)
23:11
<
Kilo`byte >
libevent2 does support epoll, idk is it uses that by default
23:11
<
Kilo`byte >
(ofc on linux that is, as epoll is linux specific)
23:12
<
jhass >
if you take a look at that branch you can see it that's really just swapping out the stackframe
23:13
<
Kilo`byte >
how'd i spawn a coroutine?
23:13
<
jhass >
>> spawn do puts "yay" end
23:13
<
DeBot >
jhass: # => [#<Fiber:0x91a7f30 @cr=Pointer(Void)@0xb63f6000, @proc=#<( -> Void):0x804fdd0>, @stack=Pointer(Void)@0xb63f6000, @stack_top=Pointer(Void)@0xb6bf6000, @stack_bottom=Pointer(Void)@0xb6bf6000, @next_fiber=#<Fiber:0x91a7f00 @cr=Pointer(Void)@0xb5bf6000, @proc=#<( -> Void):0x80502b0>, @stack=Pointer(Void)@0xb5bf6000, @stack_top=Pointer(Void)@0xb63f ... -
http://carc.in/#/r/cll
23:13
<
jhass >
heh, should block the main one I guess
23:14
<
Kilo`byte >
so how'd i create a thread? or does crystal not support those
23:14
<
jhass >
>> spawn do puts "yay" end; sleep 1;
23:14
<
jhass >
>> spawn do puts "yay" end; sleep 1; 1
23:14
<
Kilo`byte >
because i assume mutexes and stuf do not work in coroutines
23:14
<
jhass >
well, for now it's single threaded so you wouldn't need to care about locking
23:15
<
Kilo`byte >
also i assume coroutines use cooperative multitasking
23:15
<
jhass >
but Thread.new is still there (mapping out pthread)
23:15
<
jhass >
just IO inside it is pretty much broken in all aspects due to the event loop being in the main thread and stuff
23:15
<
Kilo`byte >
which is nice in most cases but can cause issues in others
23:17
<
Kilo`byte >
(sure, this isn't OS level, where programs are expected to be isolated. On the other hand: preemptive multitasking requires help from the OS which itself needs help from the CPU)
23:18
<
Kilo`byte >
i am actually not sure if i like the implicit event based io
23:18
<
Kilo`byte >
its a nice thing to have certainly
23:18
<
Kilo`byte >
it might break on some low-level stuff though
23:18
<
jhass >
anyway, this is just what stdlib is going to do, I expect libraries to happen that sidestep all of this and provide class pthread concurrency and stuff
23:19
<
Kilo`byte >
but, this actually means using this for high-performance applications is pretty nice
23:19
<
jhass >
er, classic.
23:20
<
Kilo`byte >
also, i should actually rewrite the library i wrote in ruby a long time ago for linking to an inspircd in crystal (i lost the ruby version to a file system failure)
23:21
<
Kilo`byte >
the thing that eventually made me give up was that debugging with dynamic typing was a pain
23:21
<
Kilo`byte >
even though i had a debugger, you always had to remember what type a variable was supposed to be
23:21
<
Kilo`byte >
like, for irc server applications imo its better to just link to an existing irc server
23:22
<
jhass >
well current state is that debugging ruby is a lot easier actually. It's just that crystal catches more stuff at compile time already
23:22
<
jhass >
but hard to beat pry + pry-byebug + pry-stack_explorer
23:22
<
Kilo`byte >
you get more performance usually and certainly more features
23:23
<
Kilo`byte >
jhass: i am using rubymines builtin debugger (uses ruby-debug-ide iirc)
23:23
<
Kilo`byte >
for crystal its gdb ofc
23:23
<
Kilo`byte >
(kinda a pita due to lack of line numbers though)
23:23
<
jhass >
yeah, bummer they changed the debug info format
23:23
<
jhass >
and gonna change it again with 3.7
23:24
<
Kilo`byte >
does crystal ship with a proper TLS implementation?
23:24
<
jhass >
openssl binding in stdlib
23:24
<
Kilo`byte >
no gnutls?
23:24
<
jhass >
haven't seen any
23:24
<
Kilo`byte >
because gnutls has better performance from what i know
23:24
<
jhass >
but I long lost track of every new repo created
23:25
<
Kilo`byte >
but at least something
23:25
<
Kilo`byte >
since server links should run over TLS
23:26
<
jhass >
oh and improved openssl binding at datanoise/openssl.cr iirc
23:26
<
Kilo`byte >
heh neat
23:26
<
Kilo`byte >
tbh, i'd much prefer abstract apis for things like that
23:27
<
jhass >
think they want to merge it back to stdlib at some point
23:27
<
Kilo`byte >
so i as a developer don't have to care about what backend is used for TLS
23:27
<
Kilo`byte >
ofc that does not work too well if you need low-level stuff
23:28
<
Kilo`byte >
like persisting TLS state
23:29
<
Kilo`byte >
also i am considering to expand my irc parser to a full blown server and client library
23:29
<
Kilo`byte >
not sure if that'd be worth it though
23:31
<
jhass >
already did :D why?
23:31
<
Kilo`byte >
asterite: sounds interesting
23:31
<
asterite >
Well, it explains why having threads as a concurrency primitive is bad
23:31
<
Kilo`byte >
thanks for that Pointer(Video)
23:32
<
asterite >
And many new languages are moving away from threads, for example Julia and Go
23:32
<
asterite >
(and Crystal :-P)
23:32
<
asterite >
I was actually against that, when waj suggested it, because threads are simple and known, but now I agree with him
23:32
<
jhass >
asterite: I said it a couple of times in the past, I think what you do is perfectly fine for stdlib and as default
23:32
<
Kilo`byte >
also dang, i just had a really good idea and its gone now
23:33
<
asterite >
Ah, OK. I'm just not sure it would even be possible to have user threads mixed with coroutines, that's all (but waj mentioned it at one point to me, so I guess he knows what he's talking about :-))
23:34
<
jhass >
more classic concurrency approaches are just extremely well understood, so having them available (as third party libraries, not in stdlib) for the cases where you just know it's a more perfect fit would be awesome IMO ;)
23:34
<
Kilo`byte >
right, is there any interest in having bindings for a scripting language? (would probably pick lua as it has a very simple c api)
23:34
<
Kilo`byte >
could be very useful for plugin systems
23:34
<
jhass >
and no, I'm not thinking about mixed at all
23:35
<
Kilo`byte >
since crystal doesn't really support runtime loading plugins written in crystal
23:35
<
jhass >
if you go pthreads you'll need to abandon stdlib concurrency & IO at the same time
23:36
<
jhass >
you should do mruby :P
23:36
<
Kilo`byte >
actually sounds like a decent idea
23:36
<
Kilo`byte >
and like a bigger project
23:37
<
Kilo`byte >
that'd also allow to use things like haml from crystal :D
23:38
<
jhass >
oh, there's haml for mruby already?
23:39
<
Kilo`byte >
well, afaik haml itself is written in pure ruby
23:39
<
Kilo`byte >
might be wrong there
23:39
<
jhass >
mruby is a subset of ruby though
23:45
<
Kilo`byte >
asterite: also thanks for that video link. i finally start to understand what monads are :D
23:47
<
Kilo`byte >
well, i start to get the general idea
23:47
<
Kilo`byte >
i have a friend who understands them but he never was able to explain it in any understandable way
23:48
<
Kilo`byte >
will read that after the video
23:49
<
jhass >
tom stuarts talk is great too, though I'm afraid it falls into the fallacy ;D
23:54
zamith has quit [Quit: Be back later ...]
23:55
<
Kilo`byte >
"it looks like node.js"
23:55
<
Kilo`byte >
i like that guy