jhass changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.9.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
glenab has joined #crystal-lang
bcardiff has joined #crystal-lang
glenab has quit [Ping timeout: 250 seconds]
tomchapin has quit [Quit: Textual IRC Client: www.textualapp.com]
tomchapin has joined #crystal-lang
tomchapin has quit [Client Quit]
bcardiff has quit [Ping timeout: 265 seconds]
qard has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
xdougx has joined #crystal-lang
xdougx has quit [Ping timeout: 264 seconds]
elia has quit [Quit: Computer has gone to sleep.]
tomchapin has joined #crystal-lang
tomchapin has quit [Quit: Textual IRC Client: www.textualapp.com]
tomchapin has joined #crystal-lang
tomchapin has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
datanoise has quit [Ping timeout: 265 seconds]
asbradbury has quit [Remote host closed the connection]
datanoise has joined #crystal-lang
datanoise has left #crystal-lang [#crystal-lang]
glenab has joined #crystal-lang
xdougx has joined #crystal-lang
xdougx has quit [Ping timeout: 244 seconds]
globalkeith has quit [Ping timeout: 240 seconds]
glenab has quit [Remote host closed the connection]
rmosolgo has joined #crystal-lang
glenab has joined #crystal-lang
glenab has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
glenab has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
glenab has quit [Remote host closed the connection]
glenab has joined #crystal-lang
rmosolgo has quit [Remote host closed the connection]
glenab has quit [Remote host closed the connection]
ponga has quit [Quit: Connection closed for inactivity]
pawnbox has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
Sadin has quit [Quit: Leaving]
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
Renich has quit [Quit: leaving]
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
trapped has joined #crystal-lang
reed_ has joined #crystal-lang
trapped has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
unshadow_ has joined #crystal-lang
trapped has joined #crystal-lang
unshadow has quit [Ping timeout: 240 seconds]
unshadow_ has quit [Ping timeout: 240 seconds]
xdougx has joined #crystal-lang
reed_ has quit [Ping timeout: 260 seconds]
xdougx has quit [Ping timeout: 246 seconds]
Ven has joined #crystal-lang
trapped has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
ssvb has quit [Ping timeout: 268 seconds]
fowlduck has joined #crystal-lang
Philpax has joined #crystal-lang
BlaXpirit has joined #crystal-lang
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
elia has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
Ven has joined #crystal-lang
edaaa_ has joined #crystal-lang
Ven has quit [Client Quit]
fowlduck has quit [Remote host closed the connection]
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
<edaaa_> is there a way to specify types explicitly in crystal?
<BlaXpirit> edaaa_, uh yes
<BlaXpirit> depends on situation
<edaaa_> care to explain more?
Ven has joined #crystal-lang
<edaaa_> or point me to a link or something
PragTob has joined #crystal-lang
<edaaa_> BlaXpirit, tnx
xd1le has joined #crystal-lang
Philpax has quit [Ping timeout: 265 seconds]
ssvb has joined #crystal-lang
Philpax has joined #crystal-lang
leafybasil has quit [Remote host closed the connection]
Philpax has quit [Ping timeout: 244 seconds]
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Ven has joined #crystal-lang
leafybasil has joined #crystal-lang
leafybasil has quit [Remote host closed the connection]
leafybasil has joined #crystal-lang
Philpax has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Ven has joined #crystal-lang
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
ssvb has quit [Ping timeout: 256 seconds]
xdougx has joined #crystal-lang
reed_ has joined #crystal-lang
xdougx has quit [Ping timeout: 240 seconds]
globalkeith has joined #crystal-lang
reed_ has quit [Ping timeout: 250 seconds]
reed_ has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
reed_ has quit [Ping timeout: 250 seconds]
trapped has joined #crystal-lang
Ven has joined #crystal-lang
xdougx has joined #crystal-lang
trapped has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
xd1le has quit [Quit: ERC (IRC client for Emacs 24.5.1)]
globalkeith has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
rmosolgo has joined #crystal-lang
rmosolgo has quit [Remote host closed the connection]
rmosolgo has joined #crystal-lang
sm0ke has joined #crystal-lang
Philpax has quit [Quit: Leaving]
<sm0ke> Hello just installed 0.9x crystal i had a 0.7x version before
<jhass> yep, we broke everything! :P
<sm0ke> i was benchmarking a simple http ping pong end point, and i see the performance drop
<sm0ke> it used to be ~54k req/sec now its around ~46k
<jhass> mmh
<jhass> well we got cookie and query param parsing now, though that should be lazy
<sm0ke> hurmm not sure i a very new to crystal
<sm0ke> i was benchmarking a few langs for http performance
<sm0ke> e.g. rust, nim , etc
<sm0ke> crystal just kicks ass
<sm0ke> it would be nice if people also run benchmarks on regular basis?
<sm0ke> i used `wrk` for benchmarking
<jhass> well, it's kinda annoying unless automated
<sm0ke> hurmm agreed
<jhass> but tbh I expected the earlier benchmarks to go down as the implementation gets more feature complete
ssvb has joined #crystal-lang
<sm0ke> seeing the language goals it should increase :D
<jhass> if you go through https://github.com/manastech/crystal/commits/master/src/http you can see the changes
<jhass> bisecting to where the drop occurs could be interesting, if you want to go through that work
<sardaukar> hey all
<jhass> it's probably properly handling gzip and properly handling the headers
<sardaukar> anyone with Channel experience around?
<jhass> sardaukar: just ask you question, if anyone is around that can answer it, they will
<sardaukar> ok, ok
<sm0ke> thanks for the pointer jhass
<sardaukar> I'm trying to create an HTTP server with channels. Looking to just dispatch incoming request onto a channel, and then SELECTing from a bunch of output channels and return HTTP::Responses from whichever one is ready to be consumed
<sardaukar> is this possible? because the HTTP::Server handler method always expects a response
<sardaukar> so no code path can be "open" like this, right?
<jhass> sardaukar: Channel.select (and its convenience wrappers) block the current coroutine until there's a result, http/server spawns a coroutine for each accepted client and calls the handler inside it
<jhass> so yes, that should just work
<sardaukar> so, the select should be inside the server's handler method?
<jhass> well yes?
<sm0ke> one stupid question, why is http built-in in crystal?
<sardaukar> jhass: yeah, makes sense
<sardaukar> gonna try it, thanks
<sm0ke> i mean its only good, but its something i have never seen in many langs
<jhass> sm0ke: we believe the language should come with commonly used libraries
<sm0ke> what else is there in crystal?
<sardaukar> sm0ke: yeah, same reason JSON and Hash are builtin
<jhass> so? at least python & ruby do too
<sardaukar> sm0ke: I use this as a guide: https://github.com/manastech/crystal/tree/master/src
<jhass> sm0ke: http://crystal-lang.org/api/ scroll through ;)
<sardaukar> and then I go spelunking through the code :D
benoist has joined #crystal-lang
<sm0ke> not sure if how this works, but what if do not have openssl installed
<sm0ke> wouldnt this break a core api?
<jhass> then you can't compile code that depends on the openssl stdlibb
<sm0ke> jhass: are crystal regex implemented natively or via pcre?
<jhass> and depends as to what you define core api as ;)
<jhass> libpcre atm
<sm0ke> wow crystal is fascinating
<jhass> though I wouldn't say switching to say oniguruma is out of question yet
<sm0ke> how is the current state of GC?
<jhass> it's bdw-gc
<jhass> but fairly easy to swap too
<sm0ke> ah
<jhass> doing a native GC is kinda a long term goal, bdw-gc works well for us for now
<sm0ke> is there a package manager/ project manager kind of thing for crystal?
<jhass> crystal deps just delegates to it
<sm0ke> awesome
<sm0ke> cliche question, are people using it in production already?
<sm0ke> crystal i mean
<jhass> depends on your definition of production, for hobby projects yes, some internal tools I've heard
<jhass> for example for my projects DeBot here is written in Crystal, http://carc.in is, http://p.jhass.eu is
<benoist> I'm using it in production
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<sm0ke> i am definitely going to spend some time on crystal now
<sm0ke> i wanted something which does not require a stupid vm
<benoist> it requires some extra maintenance that you wouldn't get with a stable language but so far no complaints
<jhass> the language is still evolving though, you can expect most releases to break at least something in a 1000+ loc project
<sm0ke> lua was pretty close but compiling lua to a single standalone is a pain
<sm0ke> benoist: what kind of project is it?
<benoist> it's a project that handles custom analytics
<benoist> the calculation is handled by crystal
<sm0ke> interesting? why would you pick crystal?
<sm0ke> interesting!*
Ven has joined #crystal-lang
<benoist> well the first version was released a year ago and because it was merely a POC we used ruby
<sm0ke> i see
<benoist> but as the client that uses it was starting to generate over 1M events per day calculations were slowing down
<xdougx> im build an internal processor development stage, but soon will be in production
<benoist> when I came across crystal I started experimenting with it
<sm0ke> hurmm i can guess how ideal it would be for a ruby shop, its unfortunate i come from jvm land
<benoist> managed to rewrite the whole calculator in a few weekends by copying a lot of the ruby code
<sm0ke> benoist: so you just copied ruby code to crystal and it was way faster?
<benoist> yeah about 8x faster
<sm0ke> did you leverage some native C api?
<sm0ke> wtf!
<benoist> for my specific usecase
<benoist> calculations that took over a minute to perform could be done in a matter of seconds
<xdougx> 8 times? i've tested some iterations while ruby was on 100k crystal was performed 2kk
<sm0ke> jhass: when are you going to add sqlite to core ?
<sm0ke> :D
<benoist> fyi we're using the sqlite :)
<sm0ke> benoist: open source it :D
<jhass> sm0ke: well that's up to asterite & waj actually ;)
<benoist> i don't think it's a requirement for stdlib
<benoist> we're using the manastech sqlite shard
<sm0ke> well neither was openssl i guess?
<benoist> well thats different
<sm0ke> i think crystal aims practicality, and sqlite is damn pracitcal
<jhass> a simple "download this website over https" requires openssl already
<benoist> HTTP and definitely HTTP2 will depend on it
<sm0ke> hurmm
<benoist> I hardly ever use sqlite for my ruby projects
<benoist> xdougx: what kind of iterations were you doing?
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<xdougx> benoist: ruby test https://gist.github.com/xdougx/18049b33f6059d2df8f5 30 seconds to process and got 2gb ram
globalkeith has joined #crystal-lang
<xdougx> the same test in crystal run 2kk times in 30 seconds and not even get half ram then ruby
<benoist> oh yes i'm sure it will :)
<benoist> but dealing with IO will level it out a bit more so I'm still VERY happy with 8x speed improvements
<xdougx> thats why i started to play with crystal, wanna do heavy jobs :)
<benoist> also the memory consumption dropped dramatically for our project as well
<xdougx> faster then light hahaha
<benoist> about 400x less memory
<xdougx> also i need to learn the spec framework, im missing it developing my app
<benoist> running spec's in crystal is also a big speed improvement over ruby
<benoist> our suite runs in MS instead of minutes :)
<xdougx> gonna test it soon as possible
sm0ke has quit [Ping timeout: 240 seconds]
<xdougx> Hash respond or have an method like compact! in ruby?
<benoist> compact is there for array if im not mistaken, dont know for hashes
<jhass> don't see any, but you can do .reject! {|_, v| v.nil? } of course
<jhass> Hash#compact! is activesupport in Ruby
sm0ke has joined #crystal-lang
<xdougx> sorry, sorry its an array not hash
<xdougx> yeah, thanks
<bougyman> jhass: why pcre and not oniguruma?
<bougyman> or whatever they renamed oniguruma to.
<jhass> easier to install and better documented for now, I guess
<xdougx> having some trouble with Hash(YAML::Type, YAML::Type) it dont respond to each method
<xdougx> also map
<jhass> xdougx: probably still a YAML::Type actually, check with typeof, not class
<jhass> that is try (whatever as Hash).each
<xdougx> got typeof(config) = Hash(YAML::Type, YAML::Type)
<jhass> mmh
<jhass> got some minimal example to reproduce?
<sardaukar> jhass: going back to that select example, another question
<sardaukar> if inbound requests go into a channel, and then I just wait for a reply, how can I be sure the reply I get is for my request?
<jhass> well, you can't
<sardaukar> is it possible to decouple the server from the request/reply lock?
<jhass> what's the point of sending it to a channel if you need to?
<sardaukar> threading?
<jhass> App.call(request)
<sardaukar> ?
<sardaukar> I just thought of using channels to simplify the code
<jhass> as said, HTTP::Server already spawns a coroutine for each accepted client
<jhass> blocking inside the handler will not block accepting other clients
<xdougx> in connection string
<sardaukar> hmm, I see
<jhass> xdougx: could you add a file to the gist with the full error output? since I can't run that myself this way
<sardaukar> I just wanted to have the server have 2 parts: accept requests, and reply to them - separately
<sardaukar> so, having an inbound channel that takes requests and funnels them through appropriate coroutines
<jhass> sardaukar: not sure what you hope to gain?
<sardaukar> and an outbound channel that sends back whatever the outbound channel spwes out
<sardaukar> be able to have multiple workers (threads) per "segment" of functionality
<sardaukar> as an example: the server expects /<whatever> PUT requests with a JSON payload
<jhass> xdougx: you can edit gists and add multiple files to them ;)
<sardaukar> those requests get committed to DB
<xdougx> i just forgot about it XD
<sardaukar> but PUTs to /_sys/<whatever> are handled differently
<sardaukar> I'd like to send requests (based on path) to different coroutines
<jhass> but why...
<sardaukar> first, to simplify the code - the handlers consume from a channel and put the result back into another one
<jhass> https://github.com/jhass/crpaste/blob/master/src/crpaste.cr here's a simple pastebin using artanis
<sardaukar> secondly, you can control the number of threads per functionality in the server
<jhass> coroutines != threads
<sardaukar> thirdly, to see if it works :D
<sardaukar> do I need another reason? :X
<jhass> while we plan to have them basically run on a thread pool, you'll never gain a higher parallelism by simply using more
<jhass> but atm it's all single threaded anyhow
<sardaukar> I wanted to experiment coding using methods as sockets :D
<sardaukar> I know it is atnm
<sardaukar> ok, so HTTP is pretty much locked into the req/reply paradigm
<sardaukar> what if I use a normal TCPServer?
<jhass> you could carry the socket around over channels I guess
<sardaukar> ok, but one thing you said - each request starts a new coroutine on HTTP::Server, right?
<jhass> right
<xdougx> jhass: https://gist.github.com/xdougx/379c8092981b066bb950 all needed files added
<sardaukar> so I *can* be sure that, if I use select on my handler, that the reply I get from a channel is the one pertaining to the current request
<sardaukar> or I just timeout
<sardaukar> I mean no, it can be from another (faster) request...
<sardaukar> yep, yep I see
<jhass> xdougx: there's still no toplevel code I could just run. Could you just add the error output you gt?
<jhass> *get
<jhass> sardaukar: yeah, you can't
<jhass> sardaukar: you'd have to tag the request and read responses, check if the tag matches and if not push them back onto the queue
<jhass> which is probably just slow
<xdougx> added the log error
<sm0ke> ahem ahem guess what people
<sm0ke> i was compiling without --release
unshadow has joined #crystal-lang
<sm0ke> i am getting ~71k req/sec now on 0.9.x
<jhass> sm0ke: and still 46k? nice :D
<sm0ke> i am wondering what it will be on 0.7.x
<jhass> good, I had a hunch my new header handler was actually faster :P
<jhass> oh, you never did release on 0.7.x?
<sm0ke> nah i was just doing `crystal build server.cr`
<sm0ke> let me bump back the version
<jhass> xdougx: okay, that's probably a compiler bug, let me see if I can reduce it
<xdougx> i could reduce it
<sm0ke> with 0.7.x its like around 5-10k more i guess
<jhass> xdougx: http://carc.in/#/r/joc
<sm0ke> but yeah i think i may be micro optimizing now
<jhass> xdougx: type inference doesn't consider next when doing typeof(yield) apparently
<xdougx> jhass: http://carc.in/#/r/jod
<sm0ke> wow 70k req / sec for a 500k binary is not bad at all!
<xdougx> jhass: i can change this implementation for now
<xdougx> i can concat manually
<jhass> xdougx: yeah, gonna report an issue, want to see if I can produce it without stdlib first
<jhass> xdougx: next "" if ... should work too
<xdougx> jhass: no probleman :)
<jhass> xdougx: or actually http://crystal-lang.org/api/Enumerable.html#compact_map%28%26block%29-instance-method
<jhass> but I guess Hash doesn't have that
<xdougx> yeah if v != "" then do_some works and the compact too
<jhass> maybe it's indeed intentional
<jhass> ah
benoist has quit [Quit: http://www.kiwiirc.com/ - A hand crafted IRC client]
<jhass> there we go, that's the bug http://carc.in/#/r/joj
<xdougx> wow
pawnbox has quit [Remote host closed the connection]
greengriminal has joined #crystal-lang
<sm0ke> what are the concurrency constructs in crystal?
<BlaXpirit> sm0ke, fibers
<jhass> sm0ke: the user facing things are spawn & Channel, which is similar to goroutines. There's Thread which is a pthread mapping, but that's considered semi internal atm and fully internal in the future (eg. IO won't work inside a new thread)
<sm0ke> jhass: are they implemented natively or based on libmill ?
<sm0ke> i man the goroutines
<sm0ke> mean*
<jhass> we currently use libpcl for coroutines but will swap that out for some inline assembler soonish
<sm0ke> nice, why is Thread based on pthread? what would you do for windows users?
<jhass> well, we have no windows support yet
<sm0ke> oh
<jhass> https://github.com/manastech/crystal/tree/new-fibers is the WIP branch for the libpcl replacement
<jhass> I suspect Thread could abstract over pthread and whatever one would use on windows
<sm0ke> or may be openmp based?
<jhass> isn't openmp a preprocessor or something?
<sm0ke> yeah most compilers have implemented it already
<xdougx> mention windows, crystal can run smoothly in windows?
<sm0ke> http://crystal-lang.org/api/Channel.html are these the only docs for channel usage?
<sm0ke> yeah i am also wondering why isnt crystal supported on windows?
<jhass> sm0ke: well, crystal is written entirely written in crystal
<jhass> because non of the highly active people use windows, mainly
<sm0ke> so the first version was not compiled for windows?
<jhass> no
<sm0ke> i see
<sm0ke> so there is no going back now?
<jhass> sure there is, you can still port
<jhass> it's just a whole bunch of effort
<jhass> ?windows
<DeBot> Windows support is currently developed at https://github.com/xwanderer/crystal/tree/win32/win32
<xdougx> if i need to run crystal on windows will nee a vm
<jhass> well, it staled
<jhass> sm0ke: regarding docs, yeah. Those APIs are not fully finalized either yet
<sm0ke> hurmm i see crystal as great lang for developing tools, so now window support kind of hurts
<jhass> tbh it's probably not going to happen before 1.0, as said nobody here is really familiar with the windows environment and we're just too much of a moving target atm
<jhass> heck, I couldn't even find a public CI service with windows support
<sm0ke> :)
<xdougx> lol hahahahahaha
<sm0ke> yeah its a lot of work
<sm0ke> LOOOTTTSSS would be a better word
<BlaXpirit> jhass, why are you so optimistic on windows support
<BlaXpirit> (or pessimistic on 1.0 release date)?
<jhass> BlaXpirit: I never said it's going to happen (instantly) with 1.0?
<jhass> just that it's not very realistic prior
<BlaXpirit> ooooh i missed the not "not"
<sm0ke> i guess with the rate of release you will hit 1.0 by 2016 begining?
<BlaXpirit> the "not"
<jhass> sm0ke: 0.10 will follow on 0.9
<sm0ke> ouch!
<sm0ke> so 1.0 will be by 2030?
<jhass> hehe I hope not
<jhass> but I'm not sure about 2016
<sm0ke> well HBase took 10 years for 1.0
<jhass> and we're in now what? 3?
<jhass> 5 years is not unrealistic I guess
<sm0ke> hurmm i hope windows die before crystal hits 1.0
<xdougx> crystal goes from 0.8 to 0.9 less then one year
greengriminal has quit [Quit: This computer has gone to sleep]
<xdougx> which goals is needed to acomplishe to become 1.0.0 ?
<jhass> so 3 years and 1.5 months ;)
greengriminal has joined #crystal-lang
<xdougx> jhass: this roadmap is for 1.0.0?
bcardiff has joined #crystal-lang
<jhass> roughly, yes. But note I don't decide that at all ;)
sm0ke has quit [Ping timeout: 260 seconds]
<BlaXpirit> wait, Random interface is on the roadmap?
<jhass> ironing out its design that is I guess
<BlaXpirit> but i thought there was no interest in this kind of lib
trapped has joined #crystal-lang
BlaXpirit has quit [Read error: Connection reset by peer]
bcardiff has quit [Quit: bcardiff]
olek_poz has joined #crystal-lang
sm0ke has joined #crystal-lang
xdougx has quit [Remote host closed the connection]
xdougx has joined #crystal-lang
xdougx has quit [Remote host closed the connection]
xdougx has joined #crystal-lang
<olek_poz> XML::Node has method xpath_nodes which selects nodes, but when I use "//*[@class='class']" it selects all from root.
<olek_poz> xpath_nodes("/descendant::node()/*[@class='class']") has identical effect
<jhass> olek_poz: try .// or ./ respectively
<olek_poz> thx!
greengriminal has quit [Ping timeout: 244 seconds]
greengriminal has joined #crystal-lang
NeverDie has quit [Quit: http://radiux.io/ -> Manhattan Project]
<sardaukar> is there a better way to write this? https://gist.github.com/sardaukar/5eab1712beafe80b4bad
<sardaukar> I feel like I do a lot of this type checking
<sardaukar> hoping for a more Crystal-way of doing this
<jhass> mmh, payload.is_a? Hash && payload["message"] should expand to payload.is_a?(Hash && payload["message"]), no?
NeverDie has joined #crystal-lang
<jhass> why are you unsure of what type db is?
<sardaukar> if I don't do it, Crystal complains that #exec is not a method in Nil
<sardaukar> the compile-time type is PG::Connection?
<jhass> how sure are you db is not nil at this point?
<jhass> or why do you not set @db in all initialize methods?
<rmosolgo> (Seeing more of the class and its usage might help)
<jhass> so how does .new get called, why do you pass it a potential nil?
<sardaukar> I call it with TopicRequestHandler.new( @db ).handle req
<sardaukar> on the main Server class
<jhass> and how does @db get set there?
<sardaukar> @db is set on a method called by the initializer on Server
<sardaukar> should I do @db = init_db instead of what I have now init_db
<jhass> probably
<jhass> I think there's an open issue somewhere about tracing instance vars set in methods called from initialize
<jhass> but for now that will give you less headaches
<jhass> that should get us rid of the potential nil for @db
<sardaukar> yeah, now it's not a potential nil
<sardaukar> makes sense, should've seen that
<jhass> should allow you to use @db directly everywhere
trapped has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
<jhass> next please use bind params, VALUES ($1, $2, now())", topic, message)
<jhass> (or {topic, message}? let me look it up)
<jhass> mh, got an array, but maybe the tuple works too
<jhass> also for the now() you probably could set a column default
<sardaukar> true
<sardaukar> thanks!
<jhass> since a non-hash payload doesn't seem to make sense for you and you already validate it is before calling commit, I'd do the cast at the callside
<jhass> commit({topic, payload as Hash})
<sardaukar> how so?
<sardaukar> ah ok
<jhass> which should make message = payload["message"]
<jhass> the "#{message.to_s}" was redundant btw, #{} calls to_s for you, but given it can be nil/null now, for the bind param call you do want to keep it, so VALUES ($1, $2)", {topic, message.to_s})
<jhass> else crystal-pg would insert you NULL there
<jhass> which otoh could be actually wanted too
<sardaukar> I don't get the commit({topic, payload as Hash})
<sardaukar> I'm getting an overload mismatch
<sardaukar> no overload matches 'Clog::Handlers::TopicRequestHandler#commit' with types {String, Hash(K, V)}
<jhass> what's Message?
<sardaukar> alias Message = Tuple( String, JSONType )
<sardaukar> alias JSONType = Nil | String | Int64 | Float64 | Bool | Hash(String, JSON::Type) | Array(JSON::Type)
<jhass> well, but you can only handle Hash
<jhass> so make it {String, Hash(String, JSONType)} ?
<sardaukar> yeah, having trouble working with JSON and express it porperly
<jhass> if you have a strict thing to accept JSON.mapping provides a nicer way to work with it usually
<sardaukar> yeah, I use YAML.mapping for the config already
<sardaukar> will look into it
<sardaukar> just didn't want to define a structure this early
reed_ has joined #crystal-lang
hangyas has joined #crystal-lang
<sardaukar> jhass: thanks for all the pointers
<jhass> yw
<hangyas> hi, is there a reason why Char#+(str : String) doesn't exist?
<jhass> I think there's an issue about that, let me see
<jhass> ah well, related https://github.com/manastech/crystal/issues/1730 but not the same
<jhass> >> "foo" + 'f'
<DeBot> jhass: # => "foof" - http://carc.in/#/r/jpa
<jhass> mmh
<jhass> since it returns a new object, could be argued that it should indeed be commutative
<jhass> mind opening an issue or just a PR?
<hangyas> i will, thanks
<sardaukar> btw, what's this? HTTP::Headers{ "Content-Type": "text/plain" }
<sardaukar> why does it work?
<sardaukar> is it sugar for .new( ?
<jhass> sardaukar: it's sugar for x = ....new; x[a] = b; x[c] = d; ...
<sardaukar> cool
<sardaukar> is it anywhere on the docs?
<sardaukar> are there more sugary treats hiding?
NeverDie has quit [Quit: http://radiux.io/ -> Manhattan Project]
NeverDie has joined #crystal-lang
bcardiff has joined #crystal-lang
olek_poz has quit [Read error: No route to host]
pawnbox has joined #crystal-lang
elia has quit [Quit: Computer has gone to sleep.]
Ven has joined #crystal-lang
globalkeith has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
Ven has quit [Client Quit]
<xdougx> in the early beginnin crystal was wrote in ruby?
leafybasil has quit [Remote host closed the connection]
<jhass> xdougx: yes, it was bootstrapped in Ruby
<xdougx> i would like to contribute to the project, but i don't even known 5% about what is to develop a programming language
<jhass> xdougx: standard library has plenty of work without
<jhass> tons of docs to be written still too
PragTob has quit [Remote host closed the connection]
<jhass> but then the compiler is just a program that parses text and does stuff depending on that, basically
trapped has joined #crystal-lang
<xdougx> gonna read it slowly
<xdougx> but i identify some thing goes wrong with property
BlaXpirit has joined #crystal-lang
<xdougx> when i call super inside of a method, super give it http://carc.in/#/r/jpn
<xdougx> throws*
<jhass> xdougx: super is for inheritance, here you simply override the method, so you have to use previous_def: http://carc.in/#/r/jpo
<xdougx> previous_def == super in ruby, thats ok
<jhass> xdougx: no it's not
<jhass> in Ruby you would have no direct ability to call the previous definition in that situation (without getting a backup with alias_method first that is)
<jhass> xdougx: http://carc.in/#/r/jpq
<xdougx> i just done the same thing right now hehehe
<xdougx> jhass: why when i do [1,2] + [1,3] = [1,2,1,3] and when i do [1,2,1,3] - [1,2,3] = [] plus is merge and minus is remove the equal element independently if is duplicanted?
unshadow has quit [Ping timeout: 244 seconds]
gamemanj has joined #crystal-lang
<jhass> mmh, right, + shouldn't be concat
<jhass> though Ruby does that too
manveru has quit [Ping timeout: 240 seconds]
<jhass> so it's symmetric behavior or a false friend
CompanionCube has quit [Ping timeout: 240 seconds]
<jhass> eh, not symmetric behavior or a false friend
<asterite> >> [1, 2] | [1, 3]
<DeBot> asterite: # => [1, 2, 3] - http://carc.in/#/r/jq2
<jhass> could debate finding another operator for -
* gamemanj thought que was looking at #esoteric for a second...
manveru has joined #crystal-lang
<xdougx> in crystal is possible to check block_given?
CompanionCube has joined #crystal-lang
trapped has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
CompanionCube has quit [Changing host]
CompanionCube has joined #crystal-lang
sm0ke has quit [Quit: leaving]
<jhass> xdougx: whether a method yields or not goes into its method signature, so you can just define another overload
wmoxam has quit [Ping timeout: 240 seconds]
<xdougx> understood, i forgot about overload
<jhass> xdougx: http://carc.in/#/r/jq6
wmoxam has joined #crystal-lang
Sadin has joined #crystal-lang
blue_deref has joined #crystal-lang
konflikt has joined #crystal-lang
globalkeith has joined #crystal-lang
<konflikt> after upgrading to Crystal 0.9.0 (prev. 0.8.x), started getting this error ld: library not found for -levent
<jhass> all those poor OS X people ...
<konflikt> mac: el capitan (10.11), llvm: 3.6.2
<konflikt> Warning: bdw-gc-7.4.2 already installed Warning: gmp-6.0.0a already installed Warning: libevent-2.0.22 already installed Warning: libpcl-1.12 already installed Warning: libxml2-2.9.2 already installed Warning: libyaml-0.1.6_1 already installed
trapped has joined #crystal-lang
<jhass> waj: ^ around?
<jhass> konflikt: well, this has come up a couple times now, could you open an issue?
<konflikt> ok
<crystal-gh> [crystal] asterite pushed 2 new commits to master: http://git.io/vW3Tq
<crystal-gh> crystal/master d0dd8ce Ary Borenszweig: Fixed #1796: inferred proc return type doesn't respect next calls
<crystal-gh> crystal/master 363c170 Ary Borenszweig: Fixed #1797: proc return type inference requires procs with arguments
<travis-ci> manastech/crystal#363c170 (master - Fixed #1797: proc return type inference requires procs with arguments): The build passed. https://travis-ci.org/manastech/crystal/builds/86675537
<DeBot> https://github.com/manastech/crystal/issues/1797 (proc return type inference requires procs with arguments)
globalkeith has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
hangyas has quit [Ping timeout: 260 seconds]
hangyas has joined #crystal-lang
hangyas has quit [Client Quit]
rmosolgo has quit [Remote host closed the connection]
rmosolgo has joined #crystal-lang
bcardiff_ has joined #crystal-lang
rmosolgo has quit [Ping timeout: 256 seconds]
bcardiff has quit [Ping timeout: 272 seconds]
bcardiff_ is now known as bcardiff
<xdougx> exists I18n for crystal?
<jhass> didn't see any yet
<jhass> wonder whether we should go that route or the gettext route
rmosolgo has joined #crystal-lang
<xdougx> hummmm
<havenwood> gettext!
<jhass> the format is archaic, but the integrations are way better still
NeverDie has quit [Quit: http://radiux.io/ -> Manhattan Project]
NeverDie has joined #crystal-lang
NeverDie has quit [Max SendQ exceeded]
pawnbox has quit [Remote host closed the connection]
fowlduck has joined #crystal-lang
greengriminal has quit [Quit: This computer has gone to sleep]
greengriminal has joined #crystal-lang
greengriminal has quit [Client Quit]
NeverDie has joined #crystal-lang
<konflikt> export LIBRARY_PATH="$LIBRARY_PATH:/usr/local/lib" thing which @TBD mentioned also worked for me (in case someone else having the same issue on MacOS)
konflikt has quit [Ping timeout: 246 seconds]
greengriminal has joined #crystal-lang
globalkeith has joined #crystal-lang
<xdougx> jhass: i have a probleman with json parse, i have a file with {"sheet": [[554498950337.0]} but then it is parsed it becomes 5.59999e+12 and i dont want i need the full number
<xdougx> when*
<jhass> >> puts 5.59999e+12
<DeBot> jhass: 5.59999e+12 - more at http://carc.in/#/r/jqp
<jhass> mh
<jhass> >> puts "%d" % 5.59999e+12
<DeBot> jhass: -2147483648 - more at http://carc.in/#/r/jqq
<jhass> >> puts "%d" % 5.59999e+12u64
<DeBot> jhass: Syntax error in eval:21: unexpected token: u64 - http://carc.in/#/r/jqr
<jhass> meh
<jhass> but that should work^
<jhass> 5.59999e+12 is just a representation
<jhass> >> 554498950337.0
<DeBot> jhass: # => 5.54499e+11 - http://carc.in/#/r/jqs
<jhass> >> "%d" % 554498950337.0
<DeBot> jhass: # => "-2147483648" - http://carc.in/#/r/jqt
<jhass> meh, %d interprets it as Int32?
<xdougx> >> 5.59999e+12 as Int32
<DeBot> xdougx: can't cast Float64 to Int32 - http://carc.in/#/r/jqu
<jhass> >> "%f" % 554498950337.0
<DeBot> jhass: # => "554498950337.000000" - http://carc.in/#/r/jqv
<jhass> >> puts "%f" % 5.59999e+12f64
<DeBot> jhass: 5599990000000.000000 - more at http://carc.in/#/r/jqw
<jhass> anyway, it's the same value, it's just representation
globalkeith has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
<xdougx> yeap, but i need to convert it to string and its a phone number, when i import it from xls it becomes a number instead of string even setting as a text column, no idea why Roo do this
globalkeith has joined #crystal-lang
<jhass> a float even? very weird
<jhass> >> 554498950337.0.to_u64
<DeBot> jhass: # => 554498950337 - http://carc.in/#/r/jqx
<jhass> >> 5.59999e+12.to_u64
<DeBot> jhass: # => 5599990000000 - http://carc.in/#/r/jqy
<xdougx> it losses a number
<jhass> mmh
<xdougx> 554498950337.0 != 5599990000000
<jhass> >> JSON.parse(%(554498950337.0))
<DeBot> jhass: undefined constant JSON - http://carc.in/#/r/jqz
<jhass> >> require "json"; JSON.parse(%(554498950337.0))
<DeBot> jhass: in line 21: can't require dynamically - http://carc.in/#/r/jr0
<jhass> meh
<xdougx> JSON.parse("554498950337.0") = 5.54499e+11
<jhass> xdougx: http://carc.in/#/r/jr4
<xdougx> >> "%f" % 554498950337.0
<DeBot> xdougx: # => "554498950337.000000" - http://carc.in/#/r/jr5
Sadin has quit [Ping timeout: 250 seconds]
<xdougx> that code can help
<xdougx> its going to give me some extra work
<jhass> xdougx: well, phone numbers really should be handled as strings everywhere, you should try to fix the export
<xdougx> "%f" % 554498950337.0 will help
<jhass> it's just a workaround of a bug in the export though
<xdougx> if not, i'will need to work on import
<jhass> >> 554498950337.0.to_u64.to_s
<DeBot> jhass: # => "554498950337" - http://carc.in/#/r/jr6
greengriminal has quit [Quit: Leaving]
<BlaXpirit> what are u all doing?
<crystal-gh> [crystal] davydovanton opened pull request #1800: Fix typo in Formatter comment (master...doc-fix-typo-formatter) http://git.io/vW3dg
<sardaukar> I've found a compiler bug, but can't reduce the code
<sardaukar> this is the code that triggers it http://carc.in/#/r/jro/edit (line 29)
<jhass> BlaXpirit: wondering why excel exports phone numbers as float
<sardaukar> error msg: Bug: `typeof(JSON.parse(body))` at has no type
<sardaukar> I've tried reducing it to http://carc.in/#/r/jrn/edit
<sardaukar> but it works on carc.in
<BlaXpirit> jhass, maybe it exports anything that contains only numbers as float
<jhass> BlaXpirit: which would be quite stupid, still
<jhass> sardaukar: well, can't help with at least something that reproduces
<sardaukar> jhass: maybe by looking at my class you can see what I'm missing?
<sardaukar> error is on line 29
<jhass> sardaukar: it's a weird thing to do in the first place, but no
<xdougx> BlaXpirit: even setting up on excel column type as text, the import comes as float
<jhass> sardaukar: exp as typeof(exp) should be a noop normally
<sardaukar> yeah, that's what I figured
<BlaXpirit> phone numbers should start with a + anyway :|
<jhass> that is if it doesn't trigger that bug it has no effect
<sardaukar> not that the compiler would blow up :D
<jokke> jhass: i dropped you're name today at a ruby meetup in frankfurt :)
<xdougx> BlaXpirit: unfortunately i need to workaround on it, and has no + thats my problem since the beginning
<jhass> oh no, I'm getting famous now or something? ugh
<jokke> as the crazy dude with > 2k contributions per year and yet writing his thesis :D
<BlaXpirit> xdougx, well it's too bad the json parser isn't extensible (or is it?)
<jokke> jhass: was a nice meetup
<jokke> i also promoted crystal of course :)
<jokke> we had a little rust vs crystal comparison
<jokke> crystal naturally getting more sympathy points from the rubyists
<xdougx> BlaXpirit: i have to many possibilities and at least more then a million itens in that work sheet,
<BlaXpirit> xdougx, https://docs.python.org/3/library/json.html#json.JSONDecoder :|
<jokke> many didn't know it yet
<jokke> so i'm hoping for more users and more contributions :)
<xdougx> BlaXpirit: neet it with ruby
<xdougx> need*
<crystal-gh> [crystal] jhass closed pull request #1800: Fix typo in Formatter comment (master...doc-fix-typo-formatter) http://git.io/vW3dg
<BlaXpirit> xdougx, what kind of solution are you looking for?
<BlaXpirit> parse all floats as strings?
<xdougx> i think this is the best way to work atm
<BlaXpirit> eh i thought i could hack inside the json parser, but no
<xdougx> my fear is, iterate a json with a million lines to make everything as string and take too much time
<jokke> i think it'd be nice to have json_mapping to support calling coercing methods with the values
<xdougx> this will be good jokke
<jhass> jokke: it kinda has, converter: Foo will call Foo.new(pull)
<jokke> oooh
<jokke> true
<jhass> and you can implement Foo.new to do whatever as long as it returns what you point to type:
<jokke> forgot about that
rmosolgo has quit [Remote host closed the connection]
<jhass> brb
<jokke> yeah and converter could be used to handle nested json mapping, right
<jokke> if Foo also has json_mapping
<xdougx> gonna parse before generate final json
<jokke> xdougx: sorry i missed the conversation earlier.
<jokke> i don't really know what you're trying to do
<xdougx> np :)
rmosolgo has joined #crystal-lang
aaed_ has joined #crystal-lang
<travis-ci> manastech/crystal#267bcc5 (master - Merge pull request #1800 from davydovanton/doc-fix-typo-formatter): The build passed. https://travis-ci.org/manastech/crystal/builds/86700350
<DeBot> https://github.com/manastech/crystal/pull/1800 (Fix typo in Formatter comment)
globalkeith has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
<xdougx> solved :D parsed all lines before generate a json, wrosest workaround ever, but works
canhtak has joined #crystal-lang
slash_nick is now known as slash_quit
<xdougx> why JSON parse dont give me directly Hash(String, String) instead of Hash(String, JSON::Type)
xdougx has quit [Remote host closed the connection]
xdougx has joined #crystal-lang
<fowlduck> the value could be a bunch of different things?
xdougx has quit [Ping timeout: 250 seconds]
<jhass> jokke: mappings nest naturally
<jhass> you can just specify another mapping as type
xdougx has joined #crystal-lang
reed_ has quit [Ping timeout: 260 seconds]
trajing has joined #crystal-lang
globalkeith has joined #crystal-lang
gamemanj has quit [Ping timeout: 250 seconds]
<trajing> is there any sort of ETA on windows support?
<CompanionCube> doesn't the compiler need to be bootstrapped somehow
<BlaXpirit> CompanionCube, bootstrapping is done
<BlaXpirit> trajing, windows support is not being worked on by anyone as far as i'm aware
<BlaXpirit> it was abandoned pretty much
<trajing> blargh
<trajing> another project that I'd like to use but can't then, I guess
<RX14> trajing, basically waiting for someone to come along who cares enough...
<trajing> RX14: I would help
<trajing> emphasis on would
<trajing> but there is no contributor's guide
<trajing> well
<trajing> fine
<RX14> considering that it's not an easy task for the people here who know both crystal and LLVM
<RX14> you would have your work cut out
<trajing> guess which two things I don't know?
<trajing> Hint hint? It's those two things.
<RX14> that was my whole point trajing
<trajing> well yeah
<trajing> and I'm a snarky person who already knows you
<sardaukar> I can't do HTTP client requests
<sardaukar> doesn't work on carc.in
<sardaukar> but locally I get a SocketError (mac os x)
<jhass> ?windows trajing
<DeBot> trajing: Windows support is currently developed at https://github.com/xwanderer/crystal/tree/win32/win32
<sardaukar> getaddrinfo: nodename nor servname provided, or not known (Socket::Error)
<jhass> that has some pointers as how to bootstrap
<trajing> mhm
<trajing> I don't really know compiler writing
<trajing> like at all
<trajing> that's the issue
<jhass> ?windows=You can find some initial work on Windows support at https://github.com/xwanderer/crystal/tree/win32/win32
<DeBot> jhass: Set windows.
fowlduck has quit [Remote host closed the connection]
<trajing> I would help if I could, but it's not a learning curve I'm ready to break yet
<sardaukar> the compiler is already written, right? it just needs a port :D
<jhass> trajing: you don't really, it's stdlib port 98%
<trajing> ah
<trajing> okay
<BlaXpirit> also merging "10 commits ahead, 1472 commits behind" xD
<sardaukar> it's mostly going from POSIX primitives to win32 ones
<sardaukar> (is win32 still a thing?)
<BlaXpirit> yes
<sardaukar> wow
<BlaXpirit> i think even 64 bit windows is win32
<jhass> a few compiler level thing re building paths and C ABI, but that's all and I think basically done in the above branch
<BlaXpirit> and many, if not most applications still run on 32bit
fowlduck has joined #crystal-lang
<sardaukar> Windows up to 2000 had Interix's POSIX subsystem
<sardaukar> but that's gone now
<jhass> sardaukar: what kind of socket error?
<sardaukar> getaddrinfo: nodename nor servname provided, or not known (Socket::Error)
<sardaukar> is my code missing something?
<jhass> it sounds like you can't resolve?
<jhass> ah
<sardaukar> curl works
<jhass> it should be URI.parse(url); uri.host
<sardaukar> ah
<RX14> Well... I would really like to make windoiws apps in crystal TBH
<jhass> client.get uri.path
<jhass> etc
<jhass> there's also some wrappers that take URI's I think
<BlaXpirit> RX14, so would i
<RX14> it would be nice to get that as a goal for a lot of people to work on, I think it would bring a lot more people to the project
<jhass> I think all the windows people should properly team up
<BlaXpirit> u need a lot of knowledge for that
rmosolgo has quit [Remote host closed the connection]
<jhass> make a github fork and coordinate
<sardaukar> jhass: http://pastebin.com/znm9xHfc
<sardaukar> :(
<BlaXpirit> what kind of people would you even call "windows people"?
<RX14> people porting crystal to windows...
<BlaXpirit> windows people dont care about this, they just make their enterprise .net applications
<jhass> right, we should make uri.path not nilable again, it's annoying
<trajing> ugh
<jhass> BlaXpirit: all the people coming here and screaming for windows support
<sardaukar> BlaXpirit: windows support would get a lot more ppl coding Crystal
<sardaukar> I wish I knew Windows more
<jhass> sardaukar: uri.path.not_nil! for now
<trajing> look, I want to write portable stuff
<trajing> that's the main reason why windows support matter
<BlaXpirit> no windows support is a showstopper for me
<trajing> s/matter/matters
<sardaukar> jhass: same error
<trajing> I need my portability for all major platforms
<BlaXpirit> people screaming for windows support really doesn't mean they use windows at all
<sardaukar> maybe look for a guy to do the work, and do an IndieGogo ?
<jhass> sardaukar: meh the host is nilable too I guess
<jhass> .host.not_nil! then
<jhass> I'll try to remember looking into a workaround for that
<sardaukar> jhass: thanks!
<sardaukar> a really lame state of affairs for HTTP::Client :D
<jhass> well, the problem is rather URI throwing nilables around everywhere
<sardaukar> I have issues with that in the code everywhere :/
<sardaukar> always checking if types are not nil
<sardaukar> my cyclomatic complexity is up a few notches with all these if/eles
<sardaukar> *elses
<sardaukar> I have yet to the enlightened
<jhass> well, make sure you ivars are initialized in all initializers
<jhass> getter! / property! can help if that's really not possible
<sardaukar> jhass: you working on that Crystal book already? :D
<sardaukar> I'll buy it
<jhass> I'm not a good author
<sardaukar> rip off a Ruby book and tweak it a bit
<BlaXpirit> that's no good from all points of view
<sardaukar> BlaXpirit: yeah, I know ;)
<sardaukar> it's possible to embed assets on a binary, right?
<sardaukar> like, you could scan a folder at compile time and create objects containing the data of files in a certain folder, for example
<sardaukar> rtight?
fowlduck has quit [Remote host closed the connection]
<jhass> sardaukar: there's no native compiler support, but you could use macros to reads stuff into literals
<sardaukar> have to experiment with that
<jhass> since there's no real "arbitrary byte sequence" literal (yet), it can be a bit tricky though
<sardaukar> what about slices?
<jhass> slices have no literal
<sardaukar> dunno what you mean, but I read binary files into slices now
<jhass> a literal is something the parser can understand
<sardaukar> ah I see
<jhass> like 1, 1.0, :foo, "foo", ["foo"], {"foo": "bar"} and so on
<sardaukar> still, you can feed some proxy object's #data method to an IO
<sardaukar> and it mimics a File being read
<sardaukar> right?
<jhass> I don't follow
<sardaukar> imagine you need to read PNGs
<sardaukar> and your lib to do so needs byte data from a file
<sardaukar> you could read it into a PNGHolder object at compile time
fowlduck has joined #crystal-lang
<sardaukar> and then go through all of those objects and call .data (or whatever) to feed their content into the PNG lib's read method
<sardaukar> right?
NeverDie has quit [Quit: http://radiux.io/ -> Manhattan Project]
<BlaXpirit> sardaukar, you could, if you could
<sardaukar> BlaXpirit: -_-'
<BlaXpirit> i have no idea how, jhass seems unsure if it's doable
<BlaXpirit> in Nim it's very easy
<sardaukar> BlaXpirit: yeah, I need to give it a shot, too
<sardaukar> my idea is to create something like Love2D's games
<sardaukar> that have all assets inside a zip file
<jhass> sardaukar: currently you need to find a representation of it that the crystal parser accepts
canhtak has quit [Quit: canhtak]
<BlaXpirit> nim is an interesting experience to expand your view but i wouldn't recommend it otherwise
nakilon has joined #crystal-lang
<sardaukar> having everything in a zip file would be hard to do, since the goal is for the game to be runnable without the love interpreter
<BlaXpirit> sardaukar, well you could always modify the binary afterwards
<sardaukar> yeah, true
<BlaXpirit> with my minimal knowledge i thought of this
<sardaukar> but then I'd have to work with ELFs and Mach-Os :/
<sardaukar> I'd rather have Crystal do it for me :D
<BlaXpirit> have an array with some random data like [245245, 245636, 4563767, 542467, 3452367, 124276, 3456267357]
<BlaXpirit> then use arr[3] as a pointer to memory
<sardaukar> oooh pointers
<sardaukar> then I'd have 2 problems :D
<BlaXpirit> then append binary data to your executable and replace the byte sequence produced by [245245, 245636, 4563767, 542467, 3452367, 124276, 3456267357] with the byte sequence produced by [245245, 245636, 4563767, length_of_file, 3452367, 124276, 3456267357]
<BlaXpirit> yes, i'm crazy
<BlaXpirit> this is probably not how binaries work, but i tried
<BlaXpirit> yeah, it probably segfaults
<sardaukar> a better idea would probably be release the game binary with a single assets.zip file
<BlaXpirit> well probably
<sardaukar> but then you need a sort of virtual filesystem to refer to the assets inside the zip...
NeverDie has joined #crystal-lang
<BlaXpirit> sfml can read stuff from memory or streams
<sardaukar> are there binding for crystal?
<trajing> well
<BlaXpirit> sardaukar, yeah, i annoy everyone telling them to use sfml
<sardaukar> oh there are
<trajing> to be fair a virtual filesystem sounds like an interesting project
<sardaukar> authored by you lol
<sardaukar> trajing: yeah, it does
<sardaukar> have *no* idea how that would work
<sardaukar> I mean, I have some ideas on how to organize objects around it
<trajing> well
<sardaukar> but not how to make every other Crystal lib use it transparently
<trajing> I'd assume it would abstract stuff saway so everything'd just be under some sort of "assets directory"
<trajing> like, say, /assets
<sardaukar> yeah
<sardaukar> BlaXpirit: why SFML over SDL?
<BlaXpirit> just has a better object-oriented API
<BlaXpirit> and i think nobody managed to make good sdl bindings for crystal
NeverDie has quit [Max SendQ exceeded]
NeverDie has joined #crystal-lang
<BlaXpirit> sardaukar, yeah, my approach would work, except instead of pointers you just open the file for reading and seek to the offset
<sardaukar> trajing: actually, I think I know how a VFS could work
<sardaukar> you load a Zip file (or whatever), extract all files into Directory and File objects (with proper folder structure)
rmosolgo has joined #crystal-lang
<sardaukar> and then do File.read Asset.get("/path/to/file")
<sardaukar> not sure if performant
<BlaXpirit> that's not really it
<sardaukar> how come
<BlaXpirit> is this what you want? https://docs.python.org/3/library/zipfile.html#zipfile.ZipFile.open
<sardaukar> kinda
<BlaXpirit> you shouldn't just extract everything at once, that defeats the point
<sardaukar> I'd like to open it at startup, and then use it everywhere on the code
<sardaukar> not extract, just list
<BlaXpirit> ok
<sardaukar> that would work
<sardaukar> I think...?
<sardaukar> (man, could never get into Python syntax)
<sardaukar> hmm datanoise's zlib doesn't seem to be able to list zip file content
<sardaukar> oh well, a custom file format with the listing embedded would work too
<BlaXpirit> sardaukar, i think that library is for gzip, which is a format that compresses one file
<sardaukar> ach right
<RX14> hmmn, you can't define new types in macros right?
<sardaukar> so it seems a libzip or something binding is needed before
<BlaXpirit> RX14, depends on what that means :p
<RX14> just an abitrarily generated class
<BlaXpirit> RX14, sure you can define types that will be used at runtime
<RX14> ehh!
<BlaXpirit> sardaukar, you don't need to use an archive at all
<RX14> hmmn
<RX14> BlaXpirit, could you theoretically make a crystal macro which automatically generated library bindings?
<RX14> C bindings*
<BlaXpirit> RX14, i really really really doubt it
<sardaukar> BlaXpirit: the alternative is concat-ing all files and have an index with offsets and lengths
<RX14> sounds fun though
<sardaukar> right?
<BlaXpirit> yeah, sardaukar
<BlaXpirit> and then you append that to the executable :3
<RX14> someone was telling me luajit's c interop was amazing because you just fed it header file strings, and I was thinking you might be able to macro that up in crystal
<sardaukar> BlaXpirit: a compressed file just seems better at it, though
<BlaXpirit> compression doesn't work on typical assets
<sardaukar> depends
<BlaXpirit> audio and pictures are already compressed by special algorithms
<sardaukar> works well for BMPs, WAVs, MIDs
<BlaXpirit> who would use thart
<sardaukar> BlaXpirit: lots of people! :D
nakilon has quit [Ping timeout: 252 seconds]
nakilon has joined #crystal-lang
<CompanionCube> A .h file to C bindings would be sweet
<CompanionCube> (I've tried crystalize.py already)
bcardiff has quit [Quit: bcardiff]
leafybasil has joined #crystal-lang
nakilon has quit [Ping timeout: 252 seconds]
<BlaXpirit> CompanionCube, well thats what it does
<BlaXpirit> and there are plans to implement this in the crystal compiler
trapped has quit [Quit: Textual IRC Client: www.textualapp.com]
aaed_ has quit [Remote host closed the connection]
fowlduck has quit [Remote host closed the connection]
BlaXpirit has quit [Quit: Konversation]
Excureo has quit [Read error: Connection reset by peer]
Excureo has joined #crystal-lang
walkingtoast has joined #crystal-lang
walkingtoast has quit [Client Quit]
globalkeith has quit [Quit: Textual IRC Client: www.textualapp.com]
globalkeith has joined #crystal-lang
rmosolgo has quit [Remote host closed the connection]
rmosolgo has joined #crystal-lang
rmosolgo has quit [Ping timeout: 240 seconds]
globalkeith has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
Excureo has quit [Quit: No Ping reply in 180 seconds.]
Excureo has joined #crystal-lang
Excureo has quit [Read error: Connection reset by peer]
rmosolgo has joined #crystal-lang
rmosolgo has quit [Remote host closed the connection]
NeverDie has quit [Quit: http://radiux.io/ -> Manhattan Project]
rmosolgo has joined #crystal-lang
rmosolgo has quit [Remote host closed the connection]