<chino_>
I mean again in ruby fibers were still explicit like I had to start/resume the fiber
waj has quit [Remote host closed the connection]
<dzv>
none of that with spawn
<chino_>
so does that mean there is some type of runtime going on that is managing the fibers?
<jhass>
chino_: the event loop does that for you
<jhass>
yes the libevent event loop
<chino_>
is it still all single threaded or do i have to worry about concurrency?
<dzv>
jhass: the "."'s before method names in toplevel may be confusing.
<jhass>
currently it's single threaded but it will become multithreaded eventually
<chino_>
yea idk how i feel about that part though
<chino_>
I mean sure Go is great and all but now there is no explicit choice / control in all o fi t
<chino_>
of it*
<dzv>
well, if my plans are approved there will be thread groups and fibers run within a group
<chino_>
all communicating via channels like in go right
<chino_>
but why not leave that up to a library?
<dzv>
so you have some control. by default if you do nothing there are N=numcpu threads in a single group
<jhass>
chino_: at the end of the day you can rebuild those parts of stdlib from the ground up, since crystal is entirely self hosted
<chino_>
who's going to do that?
<jhass>
so you can very well go back to blocking IO and pthreads
<jhass>
it's just some effort
<jhass>
somebody, Ruby got event libraries and actor libraries
<jhass>
this is the same, just that it goes from evented to something more traditional
<chino_>
well I'm not saying we want blocking io but with python's twisted, ruby eventmachine / celluloid, etc. people are explicitly running the event loop and controlling things
<dzv>
chino: what type of control do you want? what is the use case?
<dzv>
ok... but they did that because their existing io model couldn't support anything else but blocking or return an error if nonblocking is set. they didn't do that because it was a good model
<chino_>
but i mean so now every time i use io it's hard coded to this particular way?
<dzv>
look at what celluloid-io does. it provides a seemingly blocking io model but uses events behind the scenes. just like crystal
<chino_>
like for instance in game development people still use c++ because it gives them low level control they aren't being forced into some particular io library/model or anything else
<dzv>
what benefit do you gain from using an event loop manually?
<chino_>
yea i mean i loved fiber based io
<chino_>
determinism ?
<jhass>
chino_: to repeat, crystal is self hosted, this is merely what stdlib provides, third party libraries can reimplement it from the ground up if they wish
<dzv>
you consider a callback registered with an external event library deterministic?
<chino_>
are you asking me if I do or don't?
<dzv>
do you?
<jhass>
heck you can embed some assembler and do syscalls without a libc dependency
<chino_>
I say ask a low level game developer if they think it is
<chino_>
I mean i understand you could use your own library
<dzv>
ok if you REALLY wanted control you could set io.blocking = true and the event loop won't be used but it's unsupported. no fibers will be switched to so if you create any they will starve unless you manually switch to them or let the scheduler run somehow
<chino_>
so I guess it's fine if it's by default Go like
<dzv>
in theory this would work without an event loop. Thread.new { sock = TCPSocket.new(...); sock.blocking = true; sock.read # blocks just this thread - no event loop, no fiber switching }
<dzv>
but i wouldn't suggest it
<chino_>
well now your also message passing over channels for concurrency right?
<dzv>
yes
<chino_>
I mean I think it's good that those constructs are in there because that's where everyone is headed and it definitely makes things like server side programming easier if your going after the rails/Go type space I guess
<chino_>
I guess nothing really stops you from using shared memory and locks if you wanted too right?
waj has joined #crystal-lang
<dzv>
go does fine without explicit thread control. ruby does ok without the use multiple threads
<dzv>
nope, call in to libc. do what you like
<chino_>
sure I mean they do fine in their space but what about against something like c/c++ in very controlled domains
<chino_>
where you might want like thread/cpu affinity and not want anything context switching at all ...
<dzv>
my thread groups work will handle that later (affinity also)
<dzv>
assuming it's approved
<chino_>
the reactor pattern can run very quickly without any threads or blocking and fully singled threaded pinned to a core running very quickly without nothing coming in context switching it or thrashing it cache etc.. threads can be optionally spun up but generally for extremely low latency apps the loops is kept very tight and the cpu is busy polling the socket...
<jhass>
dzv: idk this is weird as hell, I never see any output from the debug prints in the after_fork's (or the others) and I noticed that the child process (uname) doesn't even seem to exit, although I see it at least closing its stdio's and exiting in the strace
<chino_>
i mean there is many applications like that in game industry, finance, network daemons, etc.
waj has quit [Remote host closed the connection]
<dzv>
crystal uses that pattern implicitly. so what's the problem?
<dzv>
go spins up multiple threads by default
<dzv>
jhass: i wonder what would happen if clone was changed to fork
willl has joined #crystal-lang
willl has left #crystal-lang [#crystal-lang]
willl has joined #crystal-lang
<jhass>
dzv: well, looks like that API is used to create the pid, network etc namespace?
<willl>
jhass: I suppose there are 2 paths. 1) solve it just for travis. in this case we can just pull from github and build. 2) solve it for all ubuntu. in that case probably package shards, and have the crystal package depend on shards. I can do the first one, but I'd be bad/slow at the second
<jhass>
me too, so I'd say let's go for the first and we can always replace it if somebody does the second
kulelu88 has quit [Read error: Connection reset by peer]
<jhass>
dzv: well, I reverted to 0.7.7's process stuff for the carc.in 0.8 crystal for now, I have no idea where the issue is and would highly appreciate if you'd look into it. If you want or need any aid in getting an environment for that just ask (though I'll probably sleep soon)
<dzv>
yes
<dzv>
my debian install doesn't have sd-bus.h
<dzv>
and i'm on a mac
<crystal-gh>
[crystal] asterite pushed 2 new commits to master: http://git.io/vnZ7c
<crystal-gh>
crystal/master bc16eba Ary Borenszweig: Removed remaining occurrences of `length`
<crystal-gh>
crystal/master a2cb6db Ary Borenszweig: Fixed #1526: improve error message for undefined type vars in generics
<chino_>
anyone ever try to use emscripten to build crystal for the web?
emancu has quit []
BlaXpirit|m has joined #crystal-lang
<BlaXpirit|m>
wmoxam, wow, what a thorough example
<BlaXpirit|m>
consider gist.github.com though
<BlaXpirit|m>
what you should try in that case is use C's malloc with that string's length in Crystal, and memcpy into it
<crystal-gh>
[crystal] asterite pushed 1 new commit to master: http://git.io/vnnLY
<crystal-gh>
crystal/master 4133d34 Ary Borenszweig: Try to invoke `to_unsafe` and perform numeric conversions in C struct/union fields (similar logic to C function arguments). Fixes #452
<BlaXpirit|m>
if the lib uses C free explicitly, C malloc must have been used to allocate
<asterite>
Worse, "Hello there" is a string located in read only memory, so you are freeing... I don't know :-)
<BlaXpirit|m>
asterite, that shouldn't matter with what i suggested
<asterite>
True
<BlaXpirit|m>
no way around making a copy
<BlaXpirit|m>
what i don't know is whether crystal has wrappers for these C functions or u need to write them
<BlaXpirit|m>
I'll make an example later
<travis-ci>
manastech/crystal#4133d34 (master - Try to invoke `to_unsafe` and perform numeric conversions in C struct/union fields (similar logic to C function arguments). Fixes #452): The build passed. https://travis-ci.org/manastech/crystal/builds/81230900
<BlaXpirit|m>
ooh, asterite, are you embracing direct usage of C structs??
<BlaXpirit|m>
well i just need overriding of 'new'
BlaXpirit has quit [Remote host closed the connection]
BlaXpirit has joined #crystal-lang
BlaXpirit|m has quit [Quit: AndChat]
<crystal-gh>
[crystal] tristil opened pull request #1532: Add Dockerfile.development for quick development (master...development_dockerfile) http://git.io/vnnW1
<crystal-gh>
[crystal] tristil opened pull request #1533: Add .fetch to ENV (master...env_fetch) http://git.io/vnnW7
BlaXpirit has quit [Quit: Konversation]
BlaXpirit has joined #crystal-lang
BlaXpirit has quit [Remote host closed the connection]
BlaXpirit has joined #crystal-lang
<jhass>
chino_: yup, macro instead, same for all hooks, included/inherited
<jhass>
so, what did you win and how much do I get from it from making you win?
<RX14>
you win a special gold star
<jhass>
sounds useless tbh
<RX14>
that's the point
<jhass>
you need to buy more cookies
<crystal-gh>
[crystal] asterite pushed 1 new commit to master: http://git.io/vncXN
<crystal-gh>
crystal/master 124e1b1 Ary Borenszweig: Fixed #1490: Added `{% begin %} ... {% end %}` as a nicer alternative to `{% if true %} ... {% end %}`
<chino_>
hm so the c binding api in crystal basically is a wrapper for the llvm api
<jhass>
there's some details in passing the arguments correctly, but that's the gist
<jhass>
well, very basically ;)
<BlaXpirit>
jeromegn, do you have any reasons to believe that this class is reasonably implemented?
<chino_>
yea I've worked with lua bindings and ffi libs quiet a bit but just trying to wrap my head around how cyrstal+llvm would work
<BlaXpirit>
why do you keep referring to it?
greengriminal has joined #crystal-lang
<jeromegn>
BlaXpirit: well, that lib uses it and the spec seem to pass. but that's the only reason. I just needed a starting point. I've often refered to it, but I always gave up using it... now I'm really trying to understand what the hell is happening. it seems to work _sometimes_*sigh*
<chino_>
i read something in the crystal c binding docs that types are not auto converted? would that even apply to simple types like converting a float to an int8 which the c call expects? i imagine that's where to_unsafe comes into place if it's implemented on those other types and is able to pickup the c call info
<jeromegn>
the lib only uses it in the specs though
<jhass>
chino_: try the following: echo "fun hello_world; 1; end; hello_world" > hello_world.cr then run crystal build --emit llvm-ir --prelude empty --no-codegen hello_world.cr and look at hello_world.ll
<jhass>
then the same for echo "lib Foo; fun hello_world : Int32; end; Foo.hello_world" > hello_world.cr
<BlaXpirit>
jeromegn, that class is crazy
<jeromegn>
hah
<BlaXpirit>
write is definitely broken
Ven has quit [Ping timeout: 265 seconds]
<BlaXpirit>
there are no bounds checking, and unless you clear it every time it makes no sense
<chino_>
I have a feeling I'll see what looks like a standard c function
<jeromegn>
alrght, I'll stop using it then...
<BlaXpirit>
jeromegn, i dont see any reason to not use StringIO
<jeromegn>
I thought it was messing with my bytes, but it might have been something else
<jeromegn>
I'll give it a whirl
<BlaXpirit>
oh maybe there is a reason :s
<jhass>
chino_: but more importantly look at how the call for hello_world is the same in both cases
<jhass>
all we do for C bindings is declare such a call, the rest happens in the linker
<BlaXpirit>
jeromegn, the thing is StringIO only supports UInt8 (and strings)
<jeromegn>
that's ok with me
Ven has joined #crystal-lang
<jeromegn>
BlaXpirit: ok, StringIO works fine
<jeromegn>
goddamnit
<jeromegn>
:P
<jeromegn>
spent so much time on this thinking it had mangled my bytes