jhass changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.7.6 | 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
strcmp1 has quit [Quit: Leaving]
blue_deref has quit [Quit: bbn]
qard has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
NeverDie has joined #crystal-lang
zamith has quit [Quit: Be back later ...]
NeverDie has quit [Client Quit]
strcmp1 has joined #crystal-lang
<crystal-gh> [crystal] jhass opened pull request #1258: add String#sub (master...string_sub) http://git.io/vsgc3
strcmp1 has quit [Quit: Leaving]
kyrylo has quit [Quit: Konversation terminated!]
kyrylo has joined #crystal-lang
<Kilo`byte> how do i create a thread? there doesn't seem to be anything on that in the api docs
<Kilo`byte> and ruby style Thread.new seems to not work
<jhass> >> Thread.new { sleep 1 }.join; puts "hm?"
<DeBot> jhass: Exception: Could not get the current fiber - more at http://carc.in/#/r/c8k
<jhass> sigh, we can't even sleep anymore
<jhass> >> Thread.new { 1+1 }.join; puts "hm?"
<DeBot> jhass: hm? - more at http://carc.in/#/r/c8l
<jhass> it does work but it's useless since you can't do IO currently
<jhass> try to use spawn + Channel
Sadin has quit [Ping timeout: 255 seconds]
kyrylo has quit [Ping timeout: 240 seconds]
dylanmei has joined #crystal-lang
<Kilo`byte> jhass: yeah, using spawn now
<Kilo`byte> after reading source where it actually is documented
NeverDie has joined #crystal-lang
dylanmei has quit [Quit: ZZZzzz…]
qard has joined #crystal-lang
tatey_ has joined #crystal-lang
NeverDie has quit [Client Quit]
blue_deref has joined #crystal-lang
_whitelogger has joined #crystal-lang
NeverDie has joined #crystal-lang
NeverDie has quit [Read error: Connection reset by peer]
NeverDie has joined #crystal-lang
havenwood has joined #crystal-lang
NeverDie has quit [Quit: I'm off to sleep. ZZZzzz…]
NeverDie has joined #crystal-lang
NeverDie has quit [Max SendQ exceeded]
NeverDie has joined #crystal-lang
havenwood has quit [Ping timeout: 240 seconds]
havenwood has joined #crystal-lang
dylanmei has joined #crystal-lang
dylanmei has quit [Quit: ZZZzzz…]
dylanmei has joined #crystal-lang
blue_deref has quit [Quit: bbn]
dylanmei has quit [Quit: ZZZzzz…]
dylanmei has joined #crystal-lang
dylanmei has quit [Quit: ZZZzzz…]
NeverDie has quit [Quit: I'm off to sleep. ZZZzzz…]
BlaXpirit has joined #crystal-lang
<manveru> jhass: any chance of switching to oniguruma from pcre?
elbow_jason has quit [Remote host closed the connection]
havenwood has quit [Ping timeout: 256 seconds]
<manveru> how do i tell crystal that i want to use a .so in the same directory that i build in? LIBRARY_PATH doesn't seem to work :(
<BlaXpirit> manveru, env LD_LIBRARY_PATH=. LIBRARY_PATH=.
<manveru> nope
<BlaXpirit> nope what
<manveru> it doesn't find the library
<BlaXpirit> or so you think
<manveru> i also tried with `crystal build --link-flags '-L.' file.cr`
<manveru> ld tells me it can't find the lib
<manveru> even tried absolute paths with env vars or the -L flag...
<BlaXpirit> ok
<BlaXpirit> now just post the output
<BlaXpirit> preferably including the line that you run
<BlaXpirit> manveru, ok, very clear
<manveru> i'm kinda out of flags to try... but -L is passed to cc
<BlaXpirit> gotta link "onig"
<manveru> wtf
<manveru> ok, that works
<manveru> i'll never understand C programmers :(
tatey_ has quit []
<manveru> do you also happen to know how to get from a Uint32* to a string?
<manveru> because the docs don't mention that
<manveru> and the link to type grammar from http://crystal-lang.org/docs/syntax_and_semantics/c_bindings/type.html is dead
<vegai> some early version of crystal was written on ruby, right?
<vegai> would it then be possible to use that version on ARM and walk the versions up until I get to current?
<vegai> or would it just be simpler to try to figure out crosscompilation. That's a bit of a magic dark area for me currently
<BlaXpirit> hm looks like quite a suboptimal way to do this, now that i'm more experienced
<BlaXpirit> i would store in an array and then join instead
<BlaXpirit> at the very least
<manveru> ok, gotta continue this when i got more time...
<BlaXpirit> in docs, how do i refer to a method of the same class and classmethod of the same class?
<BlaXpirit> `#meth` and `.clsmeth` ?
qard has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
<jhass> vegai: cross compilation would be easier, there are a commit or two that can't be build by the previous one
<jhass> vegai: bin/crystal build --cross-compile "linux i686" src/compiler/crystal.cr --target i686-pc-linux-gnu -o crystal32 change the arch, maybe you'll need --mcpu too, copy the resulting .o to the target system and invoke the linker command printed
<jhass> BlaXpirit: don't think we got references yet
<BlaXpirit> jhass, docs do it
<BlaXpirit> but i see only `#stuff`
<jhass> .stuff then?
<BlaXpirit> eh, it doesn't seem to work (no link)
<BlaXpirit> however, `stuff` gets changed to a link that looks like ".stuff"
<BlaXpirit> uhhhhh
<BlaXpirit> let's just assume this is an advanced system that "just works"
<BlaXpirit> i think not even `#stuff` is needed, just `stuff`
<BlaXpirit> manveru, i changed https://github.com/BlaXpirit/crsfml/search?q=text_get_unicode_string - much better now
<BlaXpirit> if you have both a pointer and length then maybe .to_slice(l).join would be good. https://github.com/BlaXpirit/crsfml/search?q=to_slice
kyrylo has joined #crystal-lang
<vegai> jhass: right
<vegai> No available targets are compatible with this triple, see -version for the available targets.
<vegai> I wonder where this comes from
<vegai> llvm?
<vegai> ah, llc I think
<vegai> bin/crystal build --cross-compile "linux arm64" src/compiler/crystal.cr --target arm64-unknown-linux-gnu -o crystal-arm-32
<vegai> llc -version reveals choices arm, arm64 and armeb
<jhass> on the host?
<vegai> on the box where I'm trying to crosscompile on
<vegai> hmm
<vegai> Default target: armv7l-unknown-linux-gnueabihf
<vegai> that might be useful
<vegai> that's the target
<vegai> nope, not a valid target either. But that's what llc -version says on my cubix
<crystal-gh> [crystal] technorama opened pull request #1259: Add IO timeouts, nonblocking connect() and nonblocking dns (master...f/io_timeout) http://git.io/vs28I
<jhass> hum
sleeper_ is now known as sleeper
Ven has joined #crystal-lang
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
jokke has joined #crystal-lang
<jokke> hi
<jhass> o/
<jokke> i'm on arch linux and can't get crystal to install
<jhass> try the repo!
<jokke> :: File /var/cache/pacman/pkg/crystal-0.7.6-1-x86_64.pkg.tar.xz is corrupted (invalid or corrupted package (checksum)).
<BlaXpirit> repo??
<jhass> :o
<BlaXpirit> repos aren't nice
<jhass> did OBS fuck that build up?
<jokke> no idea
bawNg has quit [Ping timeout: 246 seconds]
<jhass> so you're using the repo, right?
<BlaXpirit> lemme try
<jokke> and neither the crystal nor the crystal-git package from the aur build
<jhass> don't build means? I guess out of memory? :P
<jokke> no
<jokke> i have 12 gig
<jhass> then?
<jokke> should be enoug
<jokke> wait
<jokke> hm should i try -fPIC?
<jhass> jokke: ah, you have hardening-wrappers or whatever it was installed?
<jokke> yeah
<BlaXpirit> o.o
<jokke> seems so
<jokke> whatever for
<jhass> jokke: export PATH="$(echo "$PATH" | tr -s ':' '\n' | grep -v "hardening-wrapper" | tr -s '\n' ':')"
<jokke> wut
<jhass> disables it for that shell
<jokke> oh
<jokke> wow
<jokke> i'll get the git aur pkg and edit the PKGBUILD so it does that automatically
<jhass> mmh
<jhass> idk it's still kinda install specific
<jokke> just locally
<jhass> I'd rather like to get waj & asterite to ship -fPIC compatible libs
<jhass> BlaXpirit: so, repo works for you?
<BlaXpirit> jhass, i don't want no repos
<jhass> you said you'd try :P
<BlaXpirit> i meant pkgbuild
<jokke> jhass: now it's building
<BlaXpirit> and i didn't try even that :p
<jokke> only on one core though
<jokke> jhass: you're pretty active at #ruby, right?
<jhass> fairly
<jokke> so, what's your opinion on crystal?
<jokke> i've so far just skimmed through the docs and found it very appealing
<jhass> https://github.com/manastech/crystal/graphs/contributors does that answer the question? :P
<jokke> yeah i guess it does :)
<RX14> i've been trying to do something with crystal but keep getting distracted :(
<jokke> i'm gonna try to rewrite some of my simpler scripts for starters
<jhass> great
<jokke> how does crystal somescript.cr compare against ruby somescript.rb
<jokke> still faster?
<jokke> even though having to compile the thing first
<BlaXpirit> jokke, not faster only if it's something trivial because compilation takes some time
<jokke> yeah
<jokke> thought so
<jhass> but not slower IME
<jokke> ok
<jhass> the compiler is quite fast, most time is spent in LLVM translating the IR and linking
<jokke> llvm is so cool
<jokke> yay, it built!
<jhass> ffs the checksums don't match. OBS's Arch support is really subpar
<jhass> okay, I think that fixed it
<jokke> jhass: cool
<jokke> there's no heredoc in crystal?
<jhass> jokke: there is, <<-FOO
<jokke> oh
<jokke> ok with the -
<jhass> yeah
NeverDie has joined #crystal-lang
<dzv> jhass: read(slice, x) waits for x bytes. should read_partial be implemented to get any available data? thoughts?
<jhass> dzv: don't we already have read_nonblock for that?
<dzv> a) read_nonblock returns immediately and does not wait for any data. i want to wait for any available data, but not necessarily a whole slice worth b) read_nonblock looks like an old ruby ported method to me. it sets nonblocking every time directly through libc without using any existing methods.
<dzv> read_partial would wait and hook into the scheduler/libevent and return the first available data
<jhass> idk, you should discuss this with waj & asterite
Ven has joined #crystal-lang
Ven has quit [Client Quit]
Ven has joined #crystal-lang
Ven has quit [Client Quit]
<vegai> jhass: your branch got me a tad farther
<vegai> $ bin/crystal build --cross-compile "linux armv7l" src/compiler/crystal.cr --target armv7l-unknown-linux-gnueabihf -o crystal-arm-32
<vegai> Using compiled compiler at .build/crystal
<vegai> Unsupported ABI for target triple: armv7l-unknown-linux-gnueabihf
<vegai> I see target_mac.... yeah :)
<jhass> afraid you'll have to implement that
NeverDie has quit [Quit: I'm off to sleep. ZZZzzz…]
<ssvb> vegai: did you have a look at https://github.com/manastech/crystal/issues/324 ?
<vegai> llvm/abi/armv7l.cr or some such?
<vegai> ssvb: if that's the previous attempt to reach ARM, probably yes :)
<vegai> I should take another look at that
<ssvb> vegai: the point is that you have zero chances to succeed with unmodified crystal code, at least the arm abi support needs to be added
<jhass> idk, prolly specific to gnueabihf?
<vegai> the others seem to be ported from rust
<vegai> and afaik rust already has some support for arm
<vegai> so perhaps I could just try porting that
<jhass> yeah
<vegai> that's the casually lightest "just" I've used in a while
<ssvb> vegai: I would strongly suggest you to have a look at this previous attempt
<vegai> ssvb: ok, I wil
<jhass> ssvb: wasn't that prior we properly differentiated ABIs though?
<ssvb> jhass: what do you mean?
<ssvb> jhass: yes, these old commits add x86 abi support
<dzv> i'm having trouble diagnosing a bug on travis. can anyone w/ a mac help me reproduce a socket spec failure in this branch: https://github.com/manastech/crystal/pull/1259 ?
<ssvb> vegai: either way, it is very clear what needs to be done to get full arm support, and we are already kinda halfway there
<ssvb> vegai: if you are not scared to run an arm binary downloaded from the internet, you can already test it on your arm device - https://github.com/ssvb/crystal/releases/tag/20150627-crystal-0.7.3-for-armv7
<ssvb> vegai: like on throw-away temporary sd card setup with a bootable arm system, in the chroot or whatever
<ssvb> vegai: getting any kind of feedback would be surely welcome :-)
leafybasil has quit [Remote host closed the connection]
leafybasil has joined #crystal-lang
leafybasil has quit [Ping timeout: 246 seconds]
kulelu88 has quit [Quit: Leaving]
leafybasil has joined #crystal-lang
oal has joined #crystal-lang
tatey_ has joined #crystal-lang
_whitelogger_ has joined #crystal-lang
tliff_ has joined #crystal-lang
yie_ has joined #crystal-lang
juancate_ has joined #crystal-lang
_whitelogger has quit [Ping timeout: 240 seconds]
tliff has quit [Ping timeout: 240 seconds]
kyrylo has quit [Ping timeout: 240 seconds]
juancate has quit [Ping timeout: 240 seconds]
yie has quit [Ping timeout: 240 seconds]
NeverDie has joined #crystal-lang
NeverDie has quit [Read error: Connection reset by peer]
NeverDie has joined #crystal-lang
kyrylo_ is now known as kyrylo
dylanmei has joined #crystal-lang
strcmp1 has joined #crystal-lang
strcmp1 has quit [Client Quit]
strcmp1 has joined #crystal-lang
strcmp1 has quit [Client Quit]
grindhold_ has joined #crystal-lang
<Kilo`byte> can i define abstract methods?
<BlaXpirit> Kilo`byte, yes. modules can have abstract methods
<BlaXpirit> and probably classes too, i dont remember
<Kilo`byte> what about classes?
<Kilo`byte> how'd i do that?
strcmp1 has joined #crystal-lang
<Kilo`byte> ah thanks
<BlaXpirit> (bottom)
<vegai> ssvb: ah, that attempt was yours, sorry I didn't realize before :)
<vegai> seems like a few libs that are not generally available
<vegai> libgc, libpcl
<ssvb> vegai: they are the usual crystal dependencies, on x86 too
<ssvb> are you currently trying to use the compiler binary or compile it from sources?
<ssvb> what kind of linux distro is that?
<BlaXpirit> ssvb, what are you referring to?
<BlaXpirit> when you say "what kind of linux distro is that?"
<ssvb> BlaXpirit: vegai is trying to use crystal on arm hardware
<BlaXpirit> ok then I definitely have nothing to contribute to this conversation :p
<BlaXpirit> but I do want to note that right now crystal does use some quite new / quite rare libs
<BlaXpirit> even on ubuntu 15.04 there are problems
<BlaXpirit> compiling
<ssvb> yes, and this problem can be probably solved by pestering distro maintainers :)
<jhass> just archlinux everything :P
<strcmp1> jhass, reinstate the installer and i will
<jhass> strcmp1: try antergos
<strcmp1> yeah i think i did, i tried one of the installers
<strcmp1> /arch/setup was just fine :P
<jhass> meh, it's not like it's really hard now
<strcmp1> manually? no but its a pain in the ass tbh
<jhass> fdisk and mkfs the disk, mount, pacstrap, arch-chroot, configure hostname & network, install bootloader, done
<jhass> takes 5 minutes longer than ubuntu once you went through it once
<strcmp1> idk ubuntu is just click 'next' many times
<strcmp1> the effort is 0, it just takes time
<jhass> if you fear the wall of text of the beginner guide https://wiki.archlinux.org/index.php/Installation_guide
<jhass> or as said just antergos, it's arch + one extra repo and has an ubuntu like installler
<Kilo`byte> huh? doesn't crystal have .flatten?
<Kilo`byte> now i gotta implement that myself D:
<jhass> Kilo`byte: hf :P
<jhass> coming with 0.7.7
<BlaXpirit> Kilo`byte, yeah, it was implemented just the other day
<Kilo`byte> well, i have an Array(Array(Char))
<Kilo`byte> so it shouldn't be too hard for myself
<Kilo`byte> or i can just update crystal...
<BlaXpirit> (.map &.join) .join
<BlaXpirit> or somethin
<BlaXpirit> that's not right
<jhass> .map(&.join).join
<BlaXpirit> well yeah but that would give a string
<Kilo`byte> jhass: ah thanks
<ssvb> vegai: I guess, installing these libraries (or compiling them from the source tarballs) should not be a big problem, just let me know if you need some help or have questions
<jhass> .each_with_object([] of Char) {|chars, accum| accum.concat chars }
<Kilo`byte> jhass: speaking of which
<Kilo`byte> wait, thats like fold in other languages?
blue_deref has joined #crystal-lang
<jhass> fold is closer to reduce/inject
<Kilo`byte> also why does my program exit when the main thread exits even though other threads are running?
<Kilo`byte> how can i fix that (crystal seems to lack parameterless sleep)
<jhass> join them
<Kilo`byte> the are not directly acessible from main thread
<jhass> gotta change that
<Kilo`byte> also, do instance variables have ability for atomic integer operations?
<jhass> didn't see a SIMD library (or whatever it was called) library yet
<jhass> the atomic operation would be on the object/method call btw, not the variable
wherd has joined #crystal-lang
strcmp1 has quit [Quit: Leaving]
zamith has joined #crystal-lang
strcmp1 has joined #crystal-lang
strcmp1 has quit [Read error: Connection reset by peer]
zamith has quit [Quit: Be back later ...]
elbow_jason has joined #crystal-lang
wherd has quit [Quit: leaving]
kulelu88 has joined #crystal-lang
blue_deref has quit [Quit: bbn]
kulelu88 has left #crystal-lang ["Leaving"]
kyrylo has quit [Ping timeout: 255 seconds]
juancate_ is now known as juancate
juancate has quit [Changing host]
juancate has joined #crystal-lang
<RX14> it's a shame that googling crystal classes usually doesn't get you to the api
<BlaXpirit> that gives me an idea
<BlaXpirit> nope, nevermind
<RX14> >>
<BlaXpirit> RX14, u can make a custom google search with site:crystal-lang.org
<RX14> BlaXpirit, i know
<RX14> and the lack of docs is also annoying
<BlaXpirit> sure is
<BlaXpirit> no, that documentation is ok
<BlaXpirit> we're talking about api doc
<BlaXpirit> (i assume)
<RX14> yup
<RX14> that doc is great
<jhass> last paragraph in that section ;)
<RX14> the api is not
leafybasil has quit [Remote host closed the connection]
leafybasil has joined #crystal-lang
blue_deref has joined #crystal-lang
leafybasil has quit [Ping timeout: 250 seconds]
sleeper is now known as sleeper_
<RX14> are there plans for a ?. operator like in groovy and now C#? It only calls the method if the value to the left isn't null
<BlaXpirit> RX14, i think it's .try
<RX14> how does that work?
<BlaXpirit> let me try to remember/guess
<jhass> takes a block which is only called when the value is not nil
<jhass> >> nil.try &.upcase
<DeBot> jhass: # => nil - http://carc.in/#/r/c98
qard has joined #crystal-lang
<jhass> >> "foo".try &.upcase
<DeBot> jhass: # => "FOO" - http://carc.in/#/r/c99
<RX14> seems a bit ugly
<jhass> it's just a normal method call
<RX14> that would be nil?.upcase == nil
<RX14> "dsj"?.upcase == "DSJ"
<BlaXpirit> we get it
<RX14> jhass, i know it's a notrmal method call
<RX14> it's just uglier with try than ?.
<BlaXpirit> ok
<jhass> well, you should try to write code with less nil's anyhow
<jhass> so if dealing with them is annoying and ugly that might actually be good :P
<RX14> it's your HTTP::Request.body i'm dealing with
<RX14> there's no way to get around that
<RX14> also the LogHandler doesn't seem to compile, wth
NeverDie has quit [Quit: I'm off to sleep. ZZZzzz…]
<maxdeviant> Alpha is alpha?
<BlaXpirit> probably
<RX14> oh it's my fault
<jokke> hm
<jokke> there seems to be no yaml dump
<jokke> that's a problem :/
<jhass> >> require "yaml"; {"foo": "bar"}.to_yaml
<DeBot> jhass: Error in line 4: undefined method 'to_yaml' for Hash(String, String) - http://carc.in/#/r/c9a
<jhass> mmh
<jokke> oh to_yaml
<jokke> i see
<jokke> thanks :D
<jokke> oh
<jokke> no
<jokke> oooh
<jokke> you have an "interpreter"
<jokke> cool
<jokke> >> require "yaml"; YAML.methods
<DeBot> jokke: Error in line 4: undefined method 'methods' for YAML:Class - http://carc.in/#/r/c9b
<jokke> >> require "yaml"; YAML.dump({})
<DeBot> jokke: Syntax error in eval:4: for empty hashes use '{} of KeyType => ValueType' - http://carc.in/#/r/c9c
<jokke> >> require "yaml"; YAML.dump({foo: 'bar'})
<DeBot> jokke: Syntax error in eval:4: unterminated char literal, use double quotes for strings - http://carc.in/#/r/c9d
<jhass> no you're right, there's no serializer mapped out :/
<jokke> >> require "yaml"; YAML.dump({foo: "bar"})
<DeBot> jokke: Error in line 4: undefined method 'dump' for YAML:Class - http://carc.in/#/r/c9e
<jokke> yah
<jhass> time for your pull request! :P
<jokke> mmh
<jokke> that's not trivial
NeverDie has joined #crystal-lang
<jokke> any other user readable serialization except json?
<jhass> toml, kinda
<jhass> though not sure that has a generator either
<jokke> toml..?
<jhass> so nope, use JSON ;P
<jhass> or write a the generator for yaml
<jokke> jhass: hmm :/
<jokke> i don't think i'm capable of doing that
<willl> I still think toml is just an elaborate prank
<jhass> heh
tliff_ is now known as tliff
<jhass> I think it makes sense for user facing configuration
<jhass> json has issues with quoting that are hard to catch for inexperienced users
<jhass> yaml has the same with indentation
<jokke> json has no comments
<jokke> which is a major drawback
<jokke> imho
<willl> yeah json is bad for actually editing. i see the yaml indentation thing, but it seems alright
<jhass> so having something like a formalized ini instead of everybody reinventing the wheel a slightly different seems nice
<jokke> yeah a formalized ini would be great
<jhass> I guess the main issue is libyaml fails at user understandable error messages
<jhass> jokke: that's pretty much what TOML is
<jokke> ok
havenwood has joined #crystal-lang
<jokke> hm that's too bad :/ i heavily rely on user readable serialization
<willl> https://github.com/toml-lang/toml/issues/42 when they didn't take these things seriously is when I kinda lost interest in toml, i think they started working on them more recently from what I've heard, but haven't looked into it
<jokke> and since crystal is not ruby, i can't just make me a dsl for configuring my application
<jokke> :)
<jhass> so take a look at libyaml's serialization interfaces? sounds like it could be fun actually
<jhass> I also didn't check if TOML defines serialization properly
<jokke> i understand less than half when i look at the "low level" code of crystal
<jhass> or just parsing
<jhass> jokke: that can change!
<jokke> jhass: :)
<jokke> well it'd be really awesome to be part of this
<willl> yeah, it's practice by taking on things always a bit harder than you did before
<jhass> if you can understand why UInt8* is a C string I'm sure you can do it
<jokke> sure :)
<jokke> i've written a few drivers in C even
<jhass> eh, then it shouldn't be hard really
<jokke> (really basic ones, mind you) :D
<jokke> ok what do i need to get started?
<jokke> i'll just clone the repo and then?
<jhass> yeah, but understanding how to map C types & structs and how to map them to Crystal types gets you 90% there
<jokke> ok
<jhass> try if running make is enough for you
<jhass> http://crystal-lang.org/docs/syntax_and_semantics/c_bindings/index.html giving that a read would be good of course ;)
<jokke> ok
<jhass> and then look at the existing code, find a sample in C code of what you want to do and start by getting just that compile in Crystal
<jhass> mapping only what you need for the example for now
<jhass> that'll be a good first exercise and should give you some ideas on how to proceed
<jokke> okay
<jhass> you can reopen lib's, so don't even need to touch the repo for that part
strcmp1 has joined #crystal-lang
<jokke> ls
<jokke> whops
kyrylo has joined #crystal-lang
<jokke> jhass: if a c function requires a FILE type, what would i set the argument type in fun to?
<jhass> FILE sounds like a typedef (an alias), so we need to lookup what for
<jokke> FILE *output = fopen("...", "wb");
<jokke> so a filepointer
<jhass> I think it's just an fd
<jhass> mmh, is there an API that takes a string though?
<jokke> uh yeah m( that's what i meant :D
<jokke> yeah, that'd be better...
<jhass> passing an fd opened with crystals stdlib could be a bit messy, since that uses libevent to manage IO
<jhass> anyway, and fd would be LibC::Int
leafybasil has joined #crystal-lang
<jokke> yeh
<jokke> i think i'll just make it write to string
<jhass> and in theory you could pass the result of File.open("..").fd there
<jhass> mmh, on second thought didn't glibc do some magic on fopen so it's not quite what open returns? I don't remember
<jokke> yaml_emitter_set_output seems to take a function pointer to a write handle
<jokke> *handler
<jokke> not sure what void *ext is though
<jhass> just a void pointer
<jhass> Void* in crystal
<jhass> (shortcut to Pointer(Void) actually)
<jhass> so could be anything
<jhass> for callbacks you can match the signature for example with a Proc literal, some_c_func(->(ext : Void*) { ... })
<jhass> and fun some_c_func(cb : Void* -> ReturnType) for the declaration
<jhass> but there really is no API that emits you just say char* or that take preallocated char*'s and fill them?
<jhass> given it's by the pyyaml folk that's hard to believe
<jhass> okay, it's a callback API https://bitbucket.org/xi/libyaml/src/tip/include/yaml.h#yaml.h-1460
<jhass> I guess we could have a class that keeps a File open and implements a method with that signature
<jhass> >> class Foo; def bar(data : Void*, buffer : UInt8*, size : LibC::SizeT); puts "hey"; end; end; emitter = Foo.new; callback = ->emitter.bar(Void*, UInt8*, LibC::SizeT)
<DeBot> jhass: # => #<(Pointer(Void), Pointer(UInt8), UInt32 -> (Nil | Int32)):0x805bd20:closure> - http://carc.in/#/r/c9h
<jhass> we don't need the user data, so we can ignore the first arg, @file.write Slice.new(buffer, size) should be enough to write
<jhass> oh btw, map out any structs just as alias Foo = Void* unless you need to allocate them yourself, that is there's nothing like foo *make_me_foo(void)
qard has quit [Quit: Textual IRC Client: www.textualapp.com]
<jhass> there's also https://bitbucket.org/xi/libyaml/src/tip/include/yaml.h#yaml.h-1788 though I guess predicting a sane buffer size would be quite hard in practice
<RX14> so... how soon do you think you will be able to get multi-thread support?
<jhass> none of the two that will do it is here currently ;)
<BlaXpirit> what's the problem with multithread support anyway?
<BlaXpirit> can't you just run good old threads an the locks?
<BlaXpirit> is it the GC?
<RX14> well AFAIK it's green threads right now
<jhass> BlaXpirit: IO is broken outside the mainthread atm
<BlaXpirit> what kind of IO
<jhass> any
<RX14> does Thread.new create a system thread?
<jhass> >> Thread.new { puts "foo" }
<DeBot> jhass: # => #<Thread(Nil, Nil | Int32):0x9741fc8 @func=#<(Nil -> (Nil | Int32)):0x80503c0:closure>, @arg=nil, @detached=false, @th=Pointer(Void)@0xb63bdb40, @ret=nil, @exception=nil> - http://carc.in/#/r/c9z
<jhass> >> Thread.new { puts "foo" }.join
<DeBot> jhass: foo - more at http://carc.in/#/r/ca0
<jhass> mmh, interesting
<BlaXpirit> so uhh..???
<jhass> >> Thread.new { gets }.join
<DeBot> jhass: # => nil - http://carc.in/#/r/ca1
<jhass> something's broken there
<jhass> >> Thread.new { sleep 5 }.join
<DeBot> jhass: Error in line 7: undefined method 'inspect' for Void - http://carc.in/#/r/ca2
<jhass> wat
<BlaXpirit> seems good enough for me
<jhass> >> Thread.new { sleep 5 }.join; 1
<DeBot> jhass: Exception: Could not get the current fiber - more at http://carc.in/#/r/ca3
<jhass> you'll run into stuff like ^ all the time
<RX14> wait
<BlaXpirit> jhass, what if i use a 3rd party thread?
<BlaXpirit> from some C lib
<RX14> is Thread.new creating a system thread?
<RX14> like
<jhass> BlaXpirit: you'll need third party IO, not third party thread
<jhass> the pthread binding in stdlib is still fine
<RX14> if i do just computation in threads
<jhass> Thread.new is phtread_create, yeah
<RX14> will it actually use all of my cores?
<BlaXpirit> RX14, start 4 busyloop threads and see
<RX14> so how far are we from the HTTP server being multithreaded?
<strcmp1> but it is recommended to not use threads directly in crystal, and when you use them right now it will be a miracle if you dont segfault
<jhass> a bit, since the approach for that will be making a work stealing scheduler for the coroutines
<BlaXpirit> strcmp1, what if I use only a 3rd party library which itself provides threads?
<RX14> what does the http server do right now?
<jhass> RX14: single threaded coroutines
<strcmp1> BlaXpirit, im not sure about that, but maybe if you avoid calling into crystal code from the threads, its fine
<BlaXpirit> i'm just wondering how broken would it be if i just used the threads that SFML provides
<BlaXpirit> but there is of course crystal code + crystal wrapper code involved
<RX14> hmmn, hmmn
<jhass> again, as long as you don't use stdlib IO stuff you're fine
<jhass> no Socket, no File
<BlaXpirit> sounds good
<jhass> it was working on fine on 0.6.1, DeBot still runs that
<RX14> what's interesting is when I run a wrk test on a crystal webserver, it uses about 101% (1 core) but a single core on htop doesn't seem to be maxed
<BlaXpirit> :o
<jhass> sender thread, receiver thread, n processor threads
<crystal-gh> [crystal] jpellerin opened pull request #1260: Add flatten() for iterators (master...iterator-flatten-2) http://git.io/vsVbe
<jhass> the port to evented IO broke it
<jhass> with 0.7
<BlaXpirit> finally i know the secret
<BlaXpirit> of DeBot
<strcmp1> BlaXpirit, im not sure how it'd work out but everytime i see threads brought up on github its because they segfault on IO, and the response is to not use them, never directly anyway, because crystal will provide its own Go-like concurrency model
<jhass> BlaXpirit: you can do the same with coroutines just fine, I'm just too lazy to port it
<BlaXpirit> threads = [] of Thread; 3.times { threads << Thread.new { while true; end } }; threads.each &.join
<BlaXpirit> sure enough, this fully uses 3 cores
<BlaXpirit> RX14, you were interested
<jhass> no magic, as said it's just phtread_create really
<strcmp1> i dont think it matters if it used 100 cores, as soon as you do anything IO-related it'll segfault
<BlaXpirit> yeah just some confirmation
<BlaXpirit> IO-related or stdlib IO-related?
<jhass> stdlib IO
<BlaXpirit> ok
<BlaXpirit> thx for info
<strcmp1> all cases of IO i have seen, the french dude opened many issues about it
<jhass> I have some vague plan to do crystal-posix-io sometime
<RX14> nice
<jhass> mainly for that reason
<BlaXpirit> sounds like SFML would be just fine with threads
<jhass> BlaXpirit: as long as you don't File.write("savegame", savegame) :P
<strcmp1> i cant spell his name from memory :(
<RX14> I can get a good 23K rps from the crystal webserver
<jhass> RX14: built with --release ?
<RX14> don't know how optimised it is though
<RX14> jhass, yup
<RX14> it doesn't use all the 8 cores though
<RX14> neither does it max a single core
<jhass> yes, as said it's single threaded atm, see my link
<RX14> so i don't know what the bottleneck is
<jhass> it doesn't max out the core because it'll still have IO wait time
<RX14> but if it was singlethreaded, wouldn't 1 core be stuck at 100%
<RX14> hmmn...
<jhass> evented IO minimizes it, but doesn't eliminate
<jhass> you still have the IO inside the thread
<RX14> well, 23K is fast enough for me
<RX14> i can always scale out
<jhass> whereas with multithreaded one could shuffle the IO into the memory and the other could max out on CPU processing it
<jhass> you probably could squeeze out 100 r/s by pining it to a single CPU
<jhass> dunno, that number is out of my ass but some
<jhass> man taskset
<RX14> i get 26K
<RX14> up from 23K
<RX14> and a single core gets 100% when I use taskset
<RX14> so it was just the scheduler moving it around, okay
<jhass> nice, didn't really expect more than 500
kori has joined #crystal-lang
<RX14> i'm impressed with crystal's performance on just one core
<RX14> imagine if it scaled lineraly to 8
<RX14> would be over 200K rps
<jhass> well, the workstealing scheduler will introduce some overhead
<jhass> but my guts say 150K might be feasible
<RX14> well, i suppose we can only speculate until it's benchmarked
<RX14> can you profile crystal?
<kori> hello, I'm a new programmer and crystal caught my interest
<RX14> see what methods take the most time?
<jhass> kori: welcome!
<RX14> see where the bottlenecks are?
<kori> for now, I just wanted to say, nice job :D
<jhass> RX14: mmh, gprof might work, I think nobody tried yet
<kori> I haven't started with it yet, but how's the toolchain?
<kori> is it comparable to anything?
<RX14> i suppose you are focussing on making it work, not tuning your http server to perfection hehe
<jhass> kori: still building up, you can still become famous ;)
<kori> jhass: yes!
<kori> that's exactly one of the reasons I picked crystal haha
<RX14> haha
<kori> alright, cool
<jhass> kori: http://crystalshards.herokuapp.com/ is basically a list of github repos with crystal code
<kori> neat
<kori> well, I really really like the go toolchain
<RX14> is that automatic
<kori> and strongly dislike other toolchains I've used so far
<jhass> a lot of stuff is PoC/works for my usecase state though
<RX14> i wish there was a proper IDE
<RX14> vim with the basic completion is okay
<RX14> would like a semantic plugin for youcompleteme
<jhass> RX14: https://twitter.com/bcardiff/status/631691384735539200 some PoC stuff is there
<jhass> the hard part of such is parsing invalid code
<jhass> compilers just stop, IDEs do it all the time
<kori> jhass: I meant mostly the package management, actually
<RX14> yeah...
<kori> whoops
<RX14> well it's all a part of the toolchain
<RX14> I just use crystal deps
<RX14> it's kind of a package amnager
<kori> YES.
<kori> alright, cool
<RX14> "Each repo has a special branch (maybe _releases) with metadata for dependencies for each version. These are cummulative, so version 0.2 contains metadata for 0.1 and 0.2."
<RX14> I don't like this
<kori> same
<RX14> i think git tags
<kori> I don't like most of the things listed here
<RX14> with metadata in the git tags
<kori> but the fact there's no package manager yet is comforting
<kori> gotta get to work FAST
<RX14> would be nice if you could precompile the deps
<RX14> but it doesn't look like you can
<jhass> check shards (link at the bottom)
<jhass> lots of discussions in its issue tracker too
<kori> alright, cool
<kori> got crystal installed!
havenwood has quit [Ping timeout: 245 seconds]
<jhass> great!
<RX14> and another day passes where I get about 5 lines of crystal done
<RX14> i'm so distaracted
<RX14> the vim crystal plugin works great however
<kori> jhass: hrmm
<kori> -lgc is this? https://github.com/ivmai/bdwgc/
<jhass> yeah
<jhass> how did you install though? the official packages ship it
<kori> compiling from source
<jhass> ?libraries
<DeBot> You can find a list of all libraries required to compile the compiler and run the test suite at https://github.com/manastech/crystal/wiki/All-required-libraries
<kori> I don't use ubuntu or debian or redhat :D
<kori> ...or OS X
<jhass> LFS? :D
<kori> close enough
<kori> I use CRUX
<kori> I can make a package for crystal, I already help maintain a pretty large repo
<jhass> great
<jhass> my github has archlinux packages if that's any inspiration
<BlaXpirit> jhass, i queried you, do you see the message?
<jhass> BlaXpirit: yeah sorry, was half distracted
<BlaXpirit> np
<kori> hah!
<kori> jhass: alright, I'll link you the package file soon enough
<kori> if you'd like to add it to the wiki
<jhass> uh, it's a wiki ;P
<jhass> I have the same rights on it that you have ;)
<kori> I guess it is then
<kori> just a question, are the commands listed that way for any specific reason?
<RX14> what are all the macros for getters/setters and other kind of instance variables
<jhass> kori: not sure what you mean
<jhass> RX14: getter, getter?, getter!, setter, property, property?, property!
<RX14> where are they documented? i can't really see them in the docs
<kori> jhass: multiple commands
<kori> sudo apt-get install foo, sudo apt-get install bar
<jhass> RX14: Object I think
<kori> as opposed to sudo apt-get install foo bar
<kori> for example
<jhass> oh, no, I doubt there's a strong reason
<RX14> jhass, in the API?
<RX14> yup
<RX14> found them
BlaXpirit has quit [Quit: Konversation]
<RX14> so you can't do class << self in crystal... can't say I miss it
<jhass> yeah, no singleton classes
kyrylo has quit [Quit: Konversation terminated!]
kyrylo has joined #crystal-lang
<Kilo`byte> does crystal have a socks implementation yet?
<kori> aaaaaaand done :D
<jhass> Kilo`byte: watcha mean? TCP? SOCKS5?
<Kilo`byte> socks4/5
<jhass> didn't notice any
<Kilo`byte> meh, sounds like a fun project
<Kilo`byte> also, are there singleton objects?
<Kilo`byte> like, i define a "class" that extends another class and creates a single instance of said "class"
<Kilo`byte> in scala i'd do object MyObject extends OtherClass
<jhass> nope, no singleton classes, Ruby has them implicitly but Crystal doesn't
<Kilo`byte> too bad
<jhass> need to do an explicit subclass and singleton pattern
<Kilo`byte> yeah
<Kilo`byte> minor annoyance, would just have been a nice to have thing :P
<jhass> kori: interesting, the package manager figures out dependencies on its own?
<RX14> jhass, it has dependencies in the Pkgfile...
<jhass> oh
<jhass> in the comment
NeverDie has quit [Quit: I'm off to sleep. ZZZzzz…]
<jhass> the part below was so similar to PKGBUILD that I didn't notice :D
<RX14> yeah
NeverDie has joined #crystal-lang
<Kilo`byte> actually, when using modules instead of class, this should work, right?
<Kilo`byte> although idk if i can specify a module as a parameter type for like, a method
<jhass> I don't think we can extend on instances
<jhass> >> module Foo; def foo; 1; end; end; foo = "foo"; foo.extend(Foo)
<DeBot> jhass: Error in line 4: undefined method 'extend' for String - http://carc.in/#/r/cbw
<jhass> yeah, would've been highly surprised
NeverDie has quit [Client Quit]
<jhass> there's no "method binding" or any such either, no
<Kilo`byte> >> module Foo; def foo; 1; end; end; module Bar; extend Foo; end
<DeBot> Kilo`byte: # => nil - http://carc.in/#/r/cbx
<jhass> that makes foo available as Bar.foo
<Kilo`byte> thats what i want :P
<jhass> mmh
<jhass> why's that better than module Bar; def self.foo; 1; end; end; ?
<Kilo`byte> >> module Foo; def foo; 1; end; end; module Bar; extend Foo; end; Bar.is_a?(Foo)
<DeBot> Kilo`byte: # => true - http://carc.in/#/r/cby
<Kilo`byte> because that ^
<jhass> mmh
* jhass waits for the compiler crashes :P
<Kilo`byte> if that happens that just means i found yet another bug :P
<Kilo`byte> and every bug i find is one less bug that can annoy people
<jhass> kori: you need to make CRYSTAL_CONFIG_PATH="libs:/usr/lib/crystal"
<kori> oh, I see
<jhass> I don't even know what the default is atm
<jhass> probably nothing and the official packages rely on the wrapper setting CRYSTAL_PATH
<jhass> (CRYSTAL_CONFIG_ = compile time override, CRYSTAL_ = runtime override)
<kori> what is CRYSTAL_PATH, exactly?
<kori> for this arch linux PKGBUILD, it's set to the temporary build dir
<jhass> the search path for require
<kori> oh
<kori> shouldn't it be set to /usr/lib/crystal then?
<jhass> CRYSTAL_CONFIG_PATH is
<kori> I actually didn't look at the PKGBUILD
<jhass> that will become the baked in default for the resulting compiler
<jhass> the CRYSTAL_PATH is to make sure the current one uses the stdlib from the downloaded sources and not the one from the tarball with the binary
<jhass> it's all a bit confusing with self hosted stuff :P
<kori> hrm
<kori> it should be set to /usr/lib/crystal for this case
<kori> then
<Kilo`byte> whats getter/setter combined?
<kori> since the temporary dirs get purged
<jhass> Kilo`byte: property
<Kilo`byte> thanks
<kori> and require will try to search for that
<jhass> kori: yeah
<jhass> kori: and it should include libs: because that's what crystal deps relies on for now
<jhass> (it symlinks stuff into a local libs folder)
<jhass> that works? /usr/lib/crystal isn't populated at that point, no?
<jhass> you shouldn't need to set it if you use the stdlib from the release tarball
<jhass> I don't because I also want to copy the samples over which aren't included in the release tarballs
<jhass> so I build against the tarball I copy the samples from while I have downloaded it anyway
<jhass> er, I do set it I mean
<jhass> er, no, I don't was right, I mean I don't use the stdlib from the release tarball, m(, too tired
<Kilo`byte> jhass: do rubys pack/unpack exist? or how'd i interact with binary data
<kori> jhass: it is
<kori> it's populated by the stdlib
* Kilo`byte doesn't see them in the docs
<kori> from the src dir
<kori> that's the stdlib, right?
<jhass> Kilo`byte: nope, Crystals String is for strings, not for arbitrary data :P
<jhass> Kilo`byte: check Slice
<jhass> but not much help in decoding stuff there, you'll have to do some shifting/casting manually perhaps
<jhass> kori: but from the previously installed package, no?
<Netfeed> "you found a bug in the crystal compiler"
<Netfeed> interesting
<jhass> Netfeed: \o/, please try to find fairly minimal code and open an issue
<kori> jhass: no
<kori> it gets replaced every time
<Kilo`byte> jhass: looks like crystal needs a proper library for interaction with binary data
<kori> as the previous package is removed, and the new package is installed
<Netfeed> http://pastebin.com/7hfMszeQ <-- tried to do a singelton
<kori> the tarball is only downloaded for usage of the crystal binary
<Kilo`byte> myuint = bytestream.readUInt32
<Kilo`byte> like that
<Netfeed> seems like i failed :)
<jhass> kori: yes, but at built time, it's not populated or using the previous install
<kori> it's not
<kori> uhhhh
<kori> at build time
<kori> the git repo is cloned
<kori> the tarball for the current release is downloaded
<kori> the binary from the tarball is used with the libs of the repo (I think)
<kori> and then everything gets installed
<jhass> kori: yes, so /usr/lib/crystal doesn't exist in the system, yet
<kori> it exists as src
<kori> in the repo
<jhass> yes
<jhass> exactly my point
<jhass> CRYSTAL_PATH="/usr/lib/crystal"
<jhass> can't work then
<kori> oh, I see
<kori> right
<jhass> just drop it for your case
<jhass> and only keep CRYSTAL_CONFIG_PATH
<kori> CRYSTAL_CONFIG_PATH stays, though
<kori> aye
<kori> also, I realize I pushed to the wrong repo :P
<Kilo`byte> wat
<Kilo`byte> does socks seriously not specify endianess?
<Kilo`byte> or am i just missing it
<jhass> network byte order I guess?
<Kilo`byte> yay... that means i have to convert
<kori> alright
<kori> should be fine now then
<kori> ls
<jhass> yup, looks nice, thank you!
<Kilo`byte> can i have methods with type annotation?
<jhass> yes
<Kilo`byte> how'd i do that
<jhass> >> def foo(bar : String) : Int32; bar.size; end; foo("foo"
<DeBot> jhass: Syntax error in eval:6: expecting token ')', not 'end' - http://carc.in/#/r/cc1
<jhass> >> def foo(bar : String) : Int32; bar.size; end; foo("foo")
<DeBot> jhass: # => 3 - http://carc.in/#/r/cc2
<jhass> >> def foo(bar : String) : Int32; bar; end; foo("foo")
<DeBot> jhass: in line 4: type must be Int32, not String - http://carc.in/#/r/cc3
<jhass> >> def foo(bar : String) : Int32; bar.size; end; foo(1)
<DeBot> jhass: Error in line 4: no overload matches 'foo' with types Int32 - http://carc.in/#/r/cc4
<jhass> all optional of course
<jhass> an can take unions
<jhass> *and
zamith has joined #crystal-lang
<Kilo`byte> jhass: uh, i meant generic type type annotations
<Kilo`byte> like classes can have (see Array(T))
<jhass> yes
<jhass> we call them free variables
<Kilo`byte> that rings a bell
<jhass> >> def produce(bar : T); T.zero; end; foo(1)
<DeBot> jhass: Error in line 4: undefined method 'foo' - http://carc.in/#/r/cc5
<jhass> >> def produce(bar : T); T.zero; end; produce(1)
<DeBot> jhass: # => 0 - http://carc.in/#/r/cc6
<jhass> >> def produce(bar : T); T.zero; end; produce(1u64)
<DeBot> jhass: # => 0 - http://carc.in/#/r/cc7
<jhass> >> def produce(bar : T); T.zero; end; produce("foo")
<DeBot> jhass: in line 4: undefined method 'zero' for String:Class - http://carc.in/#/r/cc8
<jhass> just pick any undefined single letter constant
<Kilo`byte> this should work
tatey_ has joined #crystal-lang
<kori> alright... I don't really know where to get started
<jhass> kori: have some goal? know ruby?
dylanmei has quit [Read error: Connection reset by peer]
TheMysticWyvern has quit [Read error: Connection reset by peer]
dylanmei has joined #crystal-lang
zamith has quit [Quit: Be back later ...]
<Kilo`byte> now to figuring out how to convert an Int32 to an Int8
<jhass> to_i8
<Kilo`byte> crystal doesn't by any chance ship with ip parsing utils?
<jhass> grep -Rin says no
<Kilo`byte> hmm
<Kilo`byte> didn't expect it tbh, but you never know
<Kilo`byte> so another thing i gotta implement \o/
<Kilo`byte> and while at it, add ip serialization/deserialization to my binary stream lib
<Kilo`byte> can i find out the endianess of the host system at runtime btw? atm i assume little endian, idk if there are platforms that use big endian that crystal runs on
<jhass> atm crystal only runs on x86 and x86_64, so...
<Kilo`byte> not even arm? D:
* Kilo`byte removes plans to use crystal for web apps on his pi
<jhass> that's the WIP arm support
<Kilo`byte> ic
<willl> you also don't have to know the host endianness
<Kilo`byte> what type is Socket::Addr#ip_address?
<jhass> String?
<Kilo`byte> idk, class lacks type annotations D:
Codefriar has quit [Ping timeout: 272 seconds]
<jhass> String
<kori> jhass: 1. yes 2. no