jhass changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.8.0 | Fund Crystals development: http://is.gd/X7PRtI | Paste > 3 lines of text to https://gist.github.com | GH: https://github.com/manastech/crystal | Docs: http://crystal-lang.org/docs/ | API: http://crystal-lang.org/api/ | Logs: http://irclog.whitequark.org/crystal-lang
<dzv> i've never seen anything use clone directly except pthreads
ssvb has joined #crystal-lang
<chino_> so I mean since you suggested Go before does Crystal support a goroutine like feature?
<dzv> chino spawn { }
vikaton has quit [Quit: Connection closed for inactivity]
<chino_> hm it's a little hard to search the api/docs cause typing in spawn gets me no results
<jhass> dzv: mmh, I guess the after fork output gets captured since the invocations are through `
<jhass> chino_: yeah, we'll need a full index search
<dzv> it's a macro. maybe those aren't in the docs? usage is: spawn { block to run in new fiber }
<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
<willl> unauthed github api has pretty low rate limits
<jhass> mmh, makes you wonder if it makes any difference coming from EC2
<willl> depends on how many other travis jobs hit it unauthed :)
<jhass> more like whether github has higher or lower rate limits there ;)
<willl> ah
<jhass> but yeah, I see your point
<jhass> willl: mmh, another approach http://stackoverflow.com/a/27869453/2199687
<willl> that one is neat
<jhass> so curl -s -L https://github.com/ysbaddaden/shards/releases/latest | egrep -o '/ysbaddaden/shards/releases/download/v[0-9.]*/shards.*linux_amd64.tar.gz'
<jhass> eh, \.]
<jhass> | wget | tar xz -C ~/.bin, patch $PATH done
<dzv> jhass: do you have an links for embedding crystal in other languages or programs?
<jhass> what kind of embedding?
<dzv> unreal
<jhass> more like developing a library to link against with crystal or embedding the parser/codegen or ...
<dzv> call crystal from unreal. call unreal from crystal.
<jhass> the crystal compiler or code compiled by the crystal compiler
<dzv> code. i assume there are compiler hooks in unreal to run other programs
Philpax has joined #crystal-lang
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
kulelu88 has joined #crystal-lang
<travis-ci> manastech/crystal#a2cb6db (master - Fixed #1526: improve error message for undefined type vars in generics): The build passed. https://travis-ci.org/manastech/crystal/builds/81221527
buggs has quit [Quit: WeeChat 0.4.2]
<wmoxam> I've been struggling to pass a string to an external C-lib which uses it, then frees it. Basically, doing this: https://gist.github.com/wmoxam/2b4e3bda54e9f788f1e5
<wmoxam> What am I doing wrong?
<jhass> wmoxam: just returning s.to_unsafe does not work?
waj has joined #crystal-lang
<wmoxam> jhass: no
<wmoxam> (same issue)
kulelu88 has quit [Quit: Leaving]
jeromegn has quit [Quit: jeromegn]
<wmoxam> I made a little test project that demonstrates the issue: https://github.com/wmoxam/crystal-lib-callback-problem
waj has quit [Remote host closed the connection]
<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|m> hm actually probably not
waj has joined #crystal-lang
Neverdie has quit [Quit: http://radiux.io/]
waj has quit [Remote host closed the connection]
waj has joined #crystal-lang
<chino_> hm method_missing isn't supported?
waj has quit [Remote host closed the connection]
<BlaXpirit|m> chino_, it is supported
<chino_> hm maybe I'm doing something wrong then
<chino_> hm apparently it's a macro instead
BlaXpirit has joined #crystal-lang
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
buggs has joined #crystal-lang
trapped has joined #crystal-lang
apt-get has joined #crystal-lang
waj has joined #crystal-lang
waj has quit [Ping timeout: 268 seconds]
apt-get_ has joined #crystal-lang
apt-get has quit [Ping timeout: 246 seconds]
apt-get_ has quit [Quit: Quit]
apt-get has joined #crystal-lang
<jokke> hmm there's no queue in crystal?
<jhass> well, Channel is essentially a queue
<BlaXpirit> jhass, what kind of queue?
<jokke> a thread safe blocking queue
apt-get has quit [Ping timeout: 250 seconds]
<BlaXpirit> ok
<BlaXpirit> threads are not used
<jokke> nice, thanks :)
apt-get has joined #crystal-lang
nakilon has quit [Ping timeout: 265 seconds]
leafybasil has quit [Remote host closed the connection]
leafybasil has joined #crystal-lang
Philpax has quit [Ping timeout: 240 seconds]
Philpax has joined #crystal-lang
<wmoxam> BlaXpirit: Thanks! I'll try Clib malloc later today
Philpax has quit [Ping timeout: 265 seconds]
leafybasil has quit [Remote host closed the connection]
Philpax has joined #crystal-lang
jeromegn has joined #crystal-lang
leafybasil has joined #crystal-lang
<jokke> asterite: any ideas why this isn't working? https://p.jreinert.com/7wN67c/ruby
havenwood has joined #crystal-lang
nakilon has joined #crystal-lang
<jokke> ooh
<jokke> cool
<jokke> no
trapped has quit [Read error: Connection reset by peer]
waj has joined #crystal-lang
gamemanj has joined #crystal-lang
<gamemanj> Is the ".pkg" file an Arch Linux package?
<gamemanj> (on GitHub releases page)
<jhass> gamemanj: no, an OS X package
<jhass> gamemanj: crystal 0.7.7 is in community, you can get 0.8.0 from the AUR or my OBS repo for now
<jhass> (from the AUR via crystal-git)
havenwood has quit [Ping timeout: 268 seconds]
ljfa has joined #crystal-lang
ssvb has quit [Ping timeout: 264 seconds]
<RX14> https://gist.github.com/gamemanj/d2e29c69dbfdcee0f245 now count the things gamemanj has done wrong :P
<ljfa> meanie RX14 :P
<crystal-gh> [crystal] asterite pushed 1 new commit to master: http://git.io/vnciv
<crystal-gh> crystal/master 5535362 Ary Borenszweig: Fixed #1534: more `String#underscore` cases
<jhass> this smells like a meetup :P
<RX14> nah, just a bunch of people in another channel in another network
<jhass> why don't you use spawn?
<RX14> because gamemanj doesn't know about it :P
<jhass> and loop do ;P
<jhass> and puts instead of adding \n manually
<jhass> also concurrent should be in the prelude (no need for an explicit require) iirc
<RX14> this is what I came up with
apt-get has quit [Ping timeout: 250 seconds]
<jhass> well, I hate the empty () but otherwise lgtm :P
<RX14> oh, forgot that
<jhass> mmh
<jhass> are you really sure about the root fiber?
<RX14> no idea
<RX14> carc.in time
<RX14> wait
<RX14> but I can't test it
<RX14> yeah
<RX14> hmmn
<RX14> i suppose gamemanj is wromng then :P
<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 %}`
<jhass> jokke: the {% %} code is run when the macro is invoked, so before TEST is defined (since that's done after the macro was expanded)
<jokke> hm ok
<jokke> ok makes sens
<jokke> e
<jhass> print_test is like TEST = ["foo"] expanded after the included hook is expanded
<jhass> so it works
Philpax_ has joined #crystal-lang
<gamemanj> RX14-meanie!
apt-get has joined #crystal-lang
Philpax has quit [Ping timeout: 265 seconds]
<jhass> 69,369,856 4% 116.31kB/s 3:33:12 # well, this is gonna take a while
<RX14> hmmn, does crystal compile using sse/avx on? and can you use intrinsics/align memory?
<RX14> basically, has anyone manged sse/avx in crystal?
<gamemanj> (He wants to accelerate his IRC lib even more.)
<RX14> muhahahha
<gamemanj> (He's completely nuts, as you can see.)
<jhass> gamemanj: figured as much since long ;)
<jhass> RX14: I think there's a thread about SSE on the ML
<RX14> there's a ml?
<RX14> :/
<RX14> the search says no?
<RX14> i suppose you can use compiler instrinsics with the C interface...
<RX14> dunno if it inlines though
<jhass> mmh, phantom memory I guess
apt-get has quit [Quit: Quit]
apt-get has joined #crystal-lang
apt-get_ has joined #crystal-lang
Philpax_ has quit [Ping timeout: 265 seconds]
apt-get has quit [Ping timeout: 246 seconds]
waj has quit [Remote host closed the connection]
<RX14> so aparrently this macros wrongly
<RX14> to spawn do; run(); end
<jhass> heh, I guess
<jhass> the argument versions is not very elaborate yet, in doubt use the block version
<RX14> just add { ... }
<gamemanj> This is a complete example to trigger it: https://gist.github.com/gamemanj/23858428e5f4f62ca2a4
<RX14> gamemanj, indentation pls
<gamemanj> also, there's something it doesn't like about the "loop" thing
<RX14> really?
<gamemanj> Error in line 10: instantiating 'loop()'
<jhass> that's just the trace, the error is below
<gamemanj> ah
<RX14> crystal's compiler errors are amazingly detailed
<RX14> does make them a bit long and verbose, but I like them
<ljfa> detailed and long and verbose? sounds like C++ template errors :P
<RX14> but are C++ template errors actually very useful?
<ljfa> no often not..
Ven has joined #crystal-lang
havenwood has joined #crystal-lang
Ven has quit [Ping timeout: 264 seconds]
Ven has joined #crystal-lang
ssvb has joined #crystal-lang
Ven has quit [Read error: Connection reset by peer]
<BlaXpirit> wmoxam, here it is, working https://bpaste.net/show/26682c2f99c1
waj has joined #crystal-lang
<BlaXpirit> hmm that's wrong
<BlaXpirit> that's better https://bpaste.net/show/8a8ed7c55c57
<BlaXpirit> i already got tripped up by the name "size"
vegai has joined #crystal-lang
greengriminal has joined #crystal-lang
<greengriminal> hey all, has anyone done any benchmarking with crystal against elixir?
gamemanj has quit [Read error: Connection reset by peer]
gamemanj has joined #crystal-lang
apt-get_ has quit [Ping timeout: 240 seconds]
Neverdie has joined #crystal-lang
Neverdie has quit [Max SendQ exceeded]
Neverdie has joined #crystal-lang
<jhass> greengriminal: not aware of any
trapped has joined #crystal-lang
waj has quit [Remote host closed the connection]
<jeromegn> jhass: could printing something interfere with its pointer? I mean, with my IO stuff, I get different result with the same calls...
<jeromegn> I'll try and make a minimal example
<jeromegn> I suspect this is the issue...
<jeromegn> >> n = 100.to_f64; Slice(UInt8).new(pointerof(n) as UInt8*, sizeof(typeof(n)))
<DeBot> jeromegn: # => [0, 0, 0, 0, 0, 0, 89, 64] - http://carc.in/#/r/g8s
<jhass> "interfere with its pointer" is too vague of a problem description I'm afraid
<jeromegn> >> n = 100.to_f64; p Slice(UInt8).new(pointerof(n) as UInt8*, sizeof(typeof(n)))
<DeBot> jeromegn: [0, 0, 0, 0, 0, 0, 89, 64] - more at http://carc.in/#/r/g8t
<jeromegn> >> n = 100.to_f64; s = Slice(UInt8).new(pointerof(n) as UInt8*, sizeof(typeof(n))); p s
<DeBot> jeromegn: [0, 0, 0, 0, 0, 0, 89, 64] - more at http://carc.in/#/r/g8u
<jeromegn> are those the correct bytes for 100 as a Float64?
<jeromegn> jhass: yea sorry, I don't have the vocabulary for some of these things (yet)
<jhass> it's been some time since I did IEEE7whatever by hand
<jeromegn> why does that return two different things...
ljfa has quit [Quit: Leaving]
<jhass> jeromegn: n is a local variable, it's gone when the function returns
<jeromegn> I see
<BlaXpirit> >> p 5
<DeBot> BlaXpirit: 5 - more at http://carc.in/#/r/g8w
<BlaXpirit> ok then
<BlaXpirit> this confused me
<jeromegn> jhass: but even if the variable is gone, the slice has been created and returned, but it contains different bytes
<BlaXpirit> jeromegn, slice is just a pointer+size
<jeromegn> I mean, every time the function is ran, n assigns to self and should point to the correct pointer, no?
<BlaXpirit> jeromegn, n is a copy which gets deleted
<jeromegn> so if that part of the memory is reused, the slice still has the same pointer but the bytes have changed in memory?
<BlaXpirit> yes
<jhass> yes
<jeromegn> ah
<jeromegn> that explains ALOT
<jeromegn> I thought it made a copy of the bytes
<jeromegn> I guess I need something else then...
<jeromegn> Array(UInt8) I suppose
<jeromegn> or StaticArray
<BlaXpirit> probably
<jeromegn> I think a StaticArray also just points to a buffer
<jeromegn> I mean...
<jeromegn> I think I'd have the same issue
<BlaXpirit> no, jeromegn
<BlaXpirit> i wish i could explain it in a simple way
<jeromegn> heh
<BlaXpirit> but even a pointer actually can own memory.....................
<BlaXpirit> anyhow, Pointer is just a memory address, Slice is a memory address and size
<BlaXpirit> and Arrays actually own memory
<BlaXpirit> that's it
<chino_> any plan on supporting tail call optimization?
<BlaXpirit> the thing I said about pointer owning memory - that happens when you call GC.malloc or something
apt-get_ has joined #crystal-lang
<jhass> chino_: haven't heard any, but also none to not support it ;)
<jhass> but I think we want to stablize the language design first before doing the optimizations
<chino_> yea would be pretty awesome
gamemanj has quit [Remote host closed the connection]
gamemanj has joined #crystal-lang
<jeromegn> >> typeof UInt[0xC0u8]
<DeBot> jeromegn: Syntax error in eval:4: expecting token '(', not 'UInt' - http://carc.in/#/r/g92
<jeromegn> >> typeof(UInt8[0xC0u8])
<DeBot> jeromegn: # => Array(UInt8) - http://carc.in/#/r/g93
Ven has joined #crystal-lang
<jeromegn> hmm
<jhass> that's UInt8.[](0xC0u8)
<jhass> it's only the static array short hand in the type grammar
<jeromegn> right
<BlaXpirit> >> UInt8.[](0xC0)
<DeBot> BlaXpirit: # => [192] - http://carc.in/#/r/g94
<jhass> >> foo :: UInt8[0xC0]; typeof(foo)
<DeBot> jhass: # => StaticArray(UInt8, 192) - http://carc.in/#/r/g95
<wmoxam> BlaXpirit: Thanks again
Ven has quit [Ping timeout: 264 seconds]
greengriminal has quit [Quit: This computer has gone to sleep]
chino_ has quit [Ping timeout: 246 seconds]
greengriminal has joined #crystal-lang
chino_ has joined #crystal-lang
<jhass> dzv: http://cloud.aeshna.de/u/mrzyx/crystal_sandbox.ova made a VM to reproduce the issue (1.5G download, didn't get it any smaller, sorry). All passwords are crystal.
apt-get_ has quit [Quit: Quit]
apt-get has joined #crystal-lang
Ven has joined #crystal-lang
greengriminal has quit [Quit: This computer has gone to sleep]
leafybas_ has joined #crystal-lang
leafybasil has quit [Ping timeout: 272 seconds]
<chino_> so if crystal isn't written in c/ruby anymore then how does it bind to c stdlib and other libraires? llvm supposedly facilitates that?
leafybas_ has quit [Ping timeout: 240 seconds]
<jhass> LLVM IR has some constructs to define functions and call functions
<jhass> clang does generate those constructs
<jhass> we do the same
<jhass> so all we do in the compiler is saying "there exists a function with the following name and signature"
<jhass> and generate a call to it
<jhass> the linker will then patch that up with the C library
<jeromegn> does it make any sense here that the SliceIO is incrementing its bytesize? I feel like it was probably meant to be @pos here: https://github.com/benoist/msgpack-crystal/blob/master/src/slice_io.cr#L25
<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
<jhass> dzv: sorry, had to change the link http://cloud.aeshna.de/d/crystal_sandbox.ova
leafybasil has joined #crystal-lang
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Ven has joined #crystal-lang
Ven has quit [Ping timeout: 246 seconds]
chino_ has quit [Ping timeout: 246 seconds]
havenwood has quit [Quit: Textual IRC Client: www.textualapp.com]
Ven has joined #crystal-lang
Ven has quit [Ping timeout: 250 seconds]
kulelu88 has joined #crystal-lang
<jeromegn> I guess StringIO is fine after all
<jeromegn> it makes no sense for it to be put as a string, but the basic functionality of it works.
<jeromegn> apparently, instantiating a StringIO is costly
<jeromegn> when done 1 million times
<jeromegn> if I supply a StringIO that's been rewind, instead of instantiating one, I gain double the perf in my benchmarks
<jeromegn> rewinded or cleared
<jhass> yes, doing allocations is expensive
<jeromegn> indeed :)
<jeromegn> I guess that's a fairer comparison with the bson ruby implementation, since they allocate a new "StringIO" on every to_bson call
<jeromegn> unless one is supplied
BlaXpirit has quit [Quit: Konversation]
gamemanj has quit [Ping timeout: 256 seconds]
qard has joined #crystal-lang
greengriminal has quit [Quit: This computer has gone to sleep]
apt-get has quit [Remote host closed the connection]
<caryanne> congratz on 0.8
<caryanne> having a gin a juice to celebrate
trapped has quit [Read error: Connection reset by peer]
nakilon has quit [Ping timeout: 265 seconds]
nakilon has joined #crystal-lang
chino_ has joined #crystal-lang
<chino_> jhass: I tried to run that example you gave me earlier but it wouldn't generate an .ll file given --no-codegen
nakilon has quit [Ping timeout: 268 seconds]
<chino_> hm strangely i made a little test using usleep() which takes an uint32 so I used UInt32 but the IR seems to say i32
waj has joined #crystal-lang
justinmcp has joined #crystal-lang
chino_ has quit [Ping timeout: 246 seconds]