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