ChanServ changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.21.1 | Fund Crystal's development: http://is.gd/X7PRtI | Paste > 3 lines of text to https://gist.github.com | GH: https://github.com/crystal-lang/crystal | Docs: http://crystal-lang.org/docs/ | API: http://crystal-lang.org/api/ | Logs: http://irclog.whitequark.org/crystal-lang
<FromGitter> <codingphasedotcom> how do you get user input in crystal
<FromGitter> <picatz> `user_input = gets`
<FromGitter> <picatz> In one line: `user_input = gets; puts user_input`
<FromGitter> <codingphasedotcom> ok so its just like ruby
<FromGitter> <codingphasedotcom> i was trying to find that info the documentation but couldnt find it
<FromGitter> <picatz> Yeah. That kind of stuff is going to be harder to google for I'd assume, since it's a newer language -- I'd assume that kind of stuff could be blogged about or something to communicate those ideas.
<FromGitter> <picatz> *I wonder how hard it could be to, like, quantify that stuff.* Which is a different thought entirely. :smile:
<FromGitter> <codingphasedotcom> @picatz thanks
<FromGitter> <codingphasedotcom> what would be the best uses for crystal lang? I'm more of a web developer and wondering what would be the best scenarios to use crystal
shelvac2 has quit [Quit: Goodbye for now]
shelvacu has joined #crystal-lang
<FromGitter> <redcodefinal> @codingphasedotcom Ruby isn't fast enough and you are not worried about using a statically typed language (if you are coming from ruby there are some differences and oddititys). I mainly came to crystal because I wanted to write games and ruby is too slow. Crystal is blazingly fast if you are coming from a language like JavaScript, Ruby, or Python. If you use Ruby On Rails we have many MVC frameworks to use.
<FromGitter> <redcodefinal> @codingphasedotcom but crystal is a really fun language in a lot of ways and I'm super excited it's around, I've felt we needed speedier alternatives to ruby and I think this language will be able to over take it eventually.
<FromGitter> <codingphasedotcom> @redcodefinal cool was wondering what others were using it for
<FromGitter> <redcodefinal> @codingphasedotcom you can check out our version of rubygems @ http://crystalshards.xyz
<FromGitter> <redcodefinal> You can see what shards are the most popular that way
blufor has quit [Ping timeout: 240 seconds]
olek_poz has joined #crystal-lang
FromGitter has quit [Ping timeout: 240 seconds]
FromGitter has joined #crystal-lang
olek_poz has quit [Ping timeout: 260 seconds]
bungoman has quit [Ping timeout: 240 seconds]
bungoman has joined #crystal-lang
Qchmqs has joined #crystal-lang
olek_poz has joined #crystal-lang
bungoman has quit [Ping timeout: 255 seconds]
mark_66 has joined #crystal-lang
Raimondii has joined #crystal-lang
Raimondi has quit [Ping timeout: 268 seconds]
Raimondii is now known as Raimondi
<kodo[m]> What's the best way to get byte array from hex string?
Yxhuvud has quit [Read error: Connection reset by peer]
Yxhuvud has joined #crystal-lang
<kodo[m]> heh .scan(/.{2}/).map(&.[0]).map(&.to_i(16))
<kodo[m]> works but kinda ugly
bjz has joined #crystal-lang
<FromGitter> <codenoid> awesome
<FromGitter> <codenoid> i love crystal
<FromGitter> <sdogruyol> <3
<kodo[m]> .to_u8 is what it should be
Ven has joined #crystal-lang
Ven is now known as Guest52333
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
bjz has joined #crystal-lang
Guest52333 has quit [Ping timeout: 255 seconds]
Ven_ has joined #crystal-lang
Ven_ has quit [Ping timeout: 255 seconds]
Ven_ has joined #crystal-lang
<FromGitter> <lhz> I'd use `.scan(/[[:xdigit:]]{2}/)`
<FromGitter> <lhz> Scratch that, I'd actually use String#hexbytes (https://crystal-lang.org/api/0.21.1/String.html#hexbytes%3ABytes-instance-method)
NIk-- has joined #crystal-lang
NIk-- has quit [Client Quit]
Ven_ has quit [Read error: Connection reset by peer]
Ven has joined #crystal-lang
Ven is now known as Guest42930
<RX14> yeah...
<RX14> hexbytes is actually performant
<RX14> I wrote the hexbytes inner loop I think
<RX14> yeah it's copy and pasted from camo.cr <3
Guest42930 has quit [Ping timeout: 240 seconds]
Ven_ has joined #crystal-lang
splitty_ has joined #crystal-lang
gloscombe has joined #crystal-lang
Ven_ has quit [Ping timeout: 255 seconds]
Ven_ has joined #crystal-lang
<FromGitter> <sdogruyol> lol
<FromGitter> <sdogruyol> @RX14 i'm sad that you stopped working on crane :(
<FromGitter> <sdogruyol> i don't want to use crenv
<RX14> i'd love to work on it
<RX14> i'm just a bit busy
<FromGitter> <sdogruyol> that's good to hear
<RX14> you could work on it :)
<RX14> it's open source
Ven_ has quit [Ping timeout: 255 seconds]
Ven has joined #crystal-lang
Ven is now known as Guest11277
Guest11277 has quit [Ping timeout: 255 seconds]
<FromGitter> <sdogruyol> yeah that's true but i'm not good at that kind of stuff :P
sz0 has joined #crystal-lang
Ven_ has joined #crystal-lang
bungoman has joined #crystal-lang
Ven_ has quit [Ping timeout: 240 seconds]
zipR4ND has joined #crystal-lang
<zipR4ND> hey all, trying to get LibPCRE's copy substring to work (hoping it is faster than Regex::Matchdata[]? is atm.). don't know how to interpret the result as String.. https://play.crystal-lang.org/#/r/1ucg
Ven_ has joined #crystal-lang
<RX14> buffer{} is the string
<RX14> well
<RX14> kinda
<RX14> the string is in buffer
<RX14> you just need to turn it into a crystal string
<zipR4ND> RX14: by casting it?
<RX14> you got a -7
<RX14> which is PCRE_ERROR_NOSUBSTRING
<RX14> so you used the API wrong
<zipR4ND> ok thx
<RX14> `man pcreapi` will tell you how to use that call
<RX14> and give you the error codes
<zipR4ND> I have to call it with a buffer and the buffers size but I have no idea how big the buffer needs to bee
<RX14> i really doubt that []? isn't the fastest way
<RX14> zipR4ND, pcre_copy_substring does the exact same as []?
<RX14> it won't make you faster
<zipR4ND> ok
<RX14> infact it's likely to be slower if anything
<RX14> because LLVM can't inline external calls
<zipR4ND> I'm trying to make a lexer
<zipR4ND> and I figured I can make it faster by joining all the regexps into one big one
<zipR4ND> but then I need the number of the capture group to figure which callback to use to create a token
<zipR4ND> It turns out extracting the matched string from the matchdata takes as much time as the exec call itself which seems odd to me
Ven_ has quit [Ping timeout: 240 seconds]
Ven has joined #crystal-lang
Ven is now known as Guest90388
<RX14> that doesn't make sense
<zipR4ND> ok, I try to provide an example
<RX14> i'd be suspicious of your benchmark
<zipR4ND> this is kind of a big example for a graphql lexer
<RX14> isn't this all premature optimization?
<zipR4ND> so this is way faster, because I use a dummy text. the regexp matching still takes place: https://play.crystal-lang.org/#/r/1ucx
<zipR4ND> this is like the 3rd version of the lexer. I think its the right time to optimize
<zipR4ND> :)
<zipR4ND> I am comparing against libgraphql (facebooks c version, so I can only loose I guess :D)
<RX14> you can win
<RX14> but not by using pcre
<zipR4ND> RX14: yeah, by creating a finite state machine i guess, right?
<RX14> well
<FromGitter> <mverzilli> there's a great example of an idiomatic lexer written in Crystal
<FromGitter> <mverzilli> which is Crystal's lexer :P
<FromGitter> <sdogruyol> hahaha
<FromGitter> <sdogruyol> nice one @mverzilli :D
<zipR4ND> I thought, that's what pcre does internally anyway ..
<RX14> I was about to bring that up haha
<zipR4ND> that was a bot?
<zipR4ND> I already looked at the crystal lexer
<FromGitter> <sdogruyol> who?
<RX14> FromGitter,
<FromGitter> RX14, I'm a bot, *bleep, bloop*. I relay messages between here and https://gitter.im/crystal-lang/crystal
<zipR4ND> the thing is, I'm working with the cltk framework, so I'm looking at a way to keep the nice api I have there ...
<RX14> there aren't meany rules
<RX14> so it's probably quite okay to do what crystal's lexer does
<RX14> but it is a bit messy
<zipR4ND> hmm, yeah writing a custom lexer would be a way to become fast, but what I would like to have is a lexer generator that offers cltks nice api and still creates a super fast lexer ..
<RX14> well the long and short of it is that pcre is slow
<RX14> you can write a fast lexer but it can't use pcre
<RX14> well, eat leat not in the hot path
<zipR4ND> ok, so I need a parser that parses a subset of regex and builds up it's own state machine ..
<RX14> you could write something that generated crystal code
<RX14> like traditional parser generators which generated C
<zipR4ND> like something that gets fed to the run macro?
<RX14> yeah
<RX14> something like that
<zipR4ND> hmm, I was looking for a lexer generator written in ruby or a language that I can easily understand to have an example but it seems all ruby lexer generators use regex ...
<RX14> zipR4ND, are you making a graphql library?
<zipR4ND> yes
<RX14> why not use libgraphql?
<zipR4ND> because this is my project: https://github.com/ziprandom/cltk and I want to use it and I would really like to see it evolve into something that is usable for production needs
<RX14> oh, cltk is yours?
<zipR4ND> yes
<zipR4ND> this is the results so far, which is not too bad considering the fact, that my parser is created using the framework ...
<RX14> yeah I think making cltk compile down to a state machine somehow would be best
<zipR4ND> but at least half of the time is used lexing so I would really like to improve this
<zipR4ND> It already does for the parser
<zipR4ND> I was already thinking of creating a lexer state machine using the parser logic of the framework ..
<RX14> I have no idea how lexer generators work so...
<FromGitter> <sdogruyol> @zipR4ND great work there
<zipR4ND> thanks sdogruyol!
<FromGitter> <sdogruyol> wtf https://github.com/goruby/goruby
<FromGitter> <fridgerator> ha
Guest90388 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
McSoFake has joined #crystal-lang
<FromGitter> <sdogruyol> @zipR4ND i really think that having something useful as cltk is a great achievement for the language at this early days
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
olek_poz has quit [Ping timeout: 245 seconds]
<zipR4ND> @sdogruyol cool, I'm still quite unsure as its my first project with the language and noone has used it until now. I'm thinking of writing a tutorila implementing a little toy language with it. still thinking about which language ..
<FromGitter> <mverzilli> here's some really cool material for inspiration: http://www.craftinginterpreters.com/
<zipR4ND> thxx mverzilli, that's very interesting
<FromGitter> <fridgerator> @zipR4ND a small tutorial would be great!
Elias_ has joined #crystal-lang
<FromGitter> <mverzilli> btw, are you the guy who met @spalladino at Manas offices?
Elias_ has quit [Client Quit]
<zipR4ND> @mverzilli yes
<zipR4ND> been to bsas twice
<zipR4ND> do you work there two?
<FromGitter> <mverzilli> yeah, I was the guy sitting to your right. just trying to prove I'm not a bot :P
<zipR4ND> ha, right already figured out this gitter thing ..
<FromGitter> <mverzilli> :)
<FromGitter> <KCreate> Is it possible to use memory mapped files in crystal?
<FromGitter> <KCreate> I'm looking for a way to share memory between two crystal processes
sz0 has quit [Quit: Connection closed for inactivity]
leonardschuetz has joined #crystal-lang
<FromGitter> <mverzilli> looks like we already use `mmap` for fibers
olek_poz has joined #crystal-lang
<leonardschuetz> Yea found that, now i'm trying to map a file opened with `File.open`
leonardschuetz is now known as KCreate
<KCreate> changed my nick from leonardschuetz to KCreate
mark_66 has quit [Quit: Leaving.]
<KCreate> @mverzilli: Why is the fd of the mmap call set to -1? Is that some special file?
pduncan has joined #crystal-lang
Qchmqs has quit [Ping timeout: 252 seconds]
KCreate has quit [Ping timeout: 255 seconds]
KCreate has joined #crystal-lang
<FromGitter> <mverzilli> it seems we use it with MAP_ANON, so that param is basically ignored
<FromGitter> <asterite> Also on mmap on mac: >``` MAP_ANON Map anonymous memory not associated with any specific file. The offset argument is ignored. Mac OS X specific: the file descriptor used for creat- ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=58ebbbc1a0e4856242ee9875]
KCreate has quit [Ping timeout: 240 seconds]
KCreate has joined #crystal-lang
zipR4ND has quit [Ping timeout: 255 seconds]
KCreate has quit [Ping timeout: 255 seconds]
KCreate has joined #crystal-lang
<KCreate> Okay I managed to map a file into memory :)
<FromGitter> <mverzilli> nice!
<KCreate> LibC.mmap(nil, file.size, LibC::PROT_READ | LibC::PROT_WRITE, LibC::MAP_SHARED, file.fd, 0)
<KCreate> then cast to a Pointer(UInt8) and read it into a slice for further processing
<KCreate> Was confused at first because all docs or websites talked about aliging something with the memory page size
<KCreate> I guess that only needs to be done when supplying the address manually and not letting the kernel do it
<crystal-gh> [crystal] asterite pushed 1 new commit to master: https://git.io/vSiUy
<crystal-gh> crystal/master 9713e42 Ary Borenszweig: Compiler: fix bug in type filtering regarding not (!). Fixes #4243
<crystal-gh> [crystal] bcardiff pushed 1 new commit to master: https://git.io/vSiTn
<crystal-gh> crystal/master cf207b0 TSUYUSATO Kitsune: Add simplest TTY detection for Colorize (#4075)...
<FromGitter> <elorest> Is there a list or count anywhere of everyone going to crystal codecamp.
zipR4ND has joined #crystal-lang
bungoman has quit [Ping timeout: 240 seconds]
<FromGitter> <mverzilli> we can't disclose the names of the people who signed up without their consent, so if you're here say hi :)
<FromGitter> <sdogruyol> hi :D
<FromGitter> <mverzilli> well, you're on the page so I wasn't speaking about you :D
<FromGitter> <fridgerator> lol
<FromGitter> <sdogruyol> haha
<FromGitter> <mverzilli> there are 6 confirmed attendees
<FromGitter> <sdogruyol> Attendee.count.except(:serdar)
<FromGitter> <sdogruyol> :D
<FromGitter> <elorest> Cool. Thanks.
<FromGitter> <mverzilli> so there are 10 vacancies
<FromGitter> <sdogruyol> @elorest have you registered yet?
<FromGitter> <elorest> I'll do it today.
<FromGitter> <mverzilli> \o/
<FromGitter> <sdogruyol> great! It's gonna be legendary :)
<FromGitter> <elorest> was working on it last week but trying to find hotels was sort of turning me off it.
<FromGitter> <sdogruyol> i'm also looking for a place to stay
<FromGitter> <sdogruyol> to airbnb or not to
<FromGitter> <elorest> We should all find a big airbnb
<FromGitter> <sdogruyol> that really makes sense, you know
<FromGitter> <elorest> airbnb is written in rails so sort of worth supporting.
<FromGitter> <sdogruyol> i'd support if it was written in Kemal :D
<FromGitter> <elorest> that would be cooler but still at least it's not coldfusion.
<FromGitter> <sdogruyol> hahaha
<FromGitter> <sdogruyol> btw finding a big airbnb and staying all together sounds fun
<FromGitter> <sdogruyol> :D
<BlaXpirit> ok now im jealous :p
<FromGitter> <elorest> I'm totally down. If you find any leads hit me up.
gloscombe has quit [Remote host closed the connection]
<jhass> is anybody using the really old versions on carc.in/play.crystal-lang.org still?
<crystal-gh> [crystal] asterite pushed 1 new commit to master: https://git.io/vSiql
<crystal-gh> crystal/master b7e048b Ary Borenszweig: Fixed #4242: while and until don't restrict variables after them
<FromGitter> <sdogruyol> it's really sad that i can't build a program in --release on a 512MB instance
<FromGitter> <elorest> If you add a large 2GB swapspace you can.
<FromGitter> <elorest> I've done it on digital ocean.
KCreate has quit [Ping timeout: 240 seconds]
<FromGitter> <fridgerator> I usually build locally then just deploy the binary
<BlaXpirit> jhass, well probably not but it's a really valuable ability
<crystal-gh> [crystal] asterite pushed 1 new commit to master: https://git.io/vSiWV
<crystal-gh> crystal/master bd09177 Ary Borenszweig: Macro run: fixed incorrect escaping of arguments
<crystal-gh> [crystal] asterite pushed 1 new commit to master: https://git.io/vSilH
<crystal-gh> crystal/master c4bbb59 Ary Borenszweig: Removed old "see also" doc. Fixes #4267
bungoman has joined #crystal-lang
zipR4ND has quit [Ping timeout: 260 seconds]
<FromGitter> <elorest> @sdogruyol have you tried compiling it with a swapspace?
<FromGitter> <elorest> that's worked fine for us here at nikola.
zipR4ND has joined #crystal-lang
McSoFake has quit [Quit: No reason]
<FromGitter> <drosehn> Hmm. Looks like there is no `find` module, like there is in ruby? (I can write something easy enough, but if crystal has a `find` then I should use that...)
<FromGitter> <chuckremes> @drosehn Do you mean this? https://crystal-lang.org/api/0.21.1/Enumerable.html#find%28if_none%3Dnil%2C%26block%29-instance-method
<jhass> BlaXpirit: can't get 0.7.7 or 0.7.6 running under playpen anymore on the new VM, so back to 0.8.0 must be enough
<BlaXpirit> that's pretty good, thanks
bjz has joined #crystal-lang
_bowser_ has joined #crystal-lang
<FromGitter> <drosehn> No. In ruby, there is a `Find` module which can be pulled in via `require 'find'`. What it implements is a ruby-way to search one or more directories in the file system, the way that you'd do with the `find` command on unix.
<FromGitter> <drosehn> If it was not a separate module (the way it is in ruby), I'd expect to see it under `Fileutils` or maybe `File` or `Dir`.
<_bowser_> So, I'm toying with crystal and building a pipeline thing
<_bowser_> And I'm curious, is there a placeholder type that the compiler will actually accept?
<_bowser_> e.g.
<_bowser_> `_` in scala, haskell(?)
<_bowser_> I need to keep a reference to a prior type, but one of the type parameters is inconsequential
<FromGitter> <drosehn> It might be that you want to look at "generics".
<FromGitter> <drosehn> (but I have never used them, so I won't be much help other than saying the word "generics")
<_bowser_> well, while you are correct - what I am doing uses generics (too much, perhaps)
<_bowser_> the compiler doesn't seem to be friendly to unbound types in certain scenarios
<_bowser_> I think I've figured a type hierarchy that will please the compiler
<_bowser_> in doing this, I have also managed to terribly upset the vim plugin, so I guess I'll have to fix that
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<FromGitter> <drosehn> Hmm. Looks like the `Find` module didn't appear in ruby until version 1.9.
<FromGitter> <elorest> Ticket purchased.
<FromGitter> <elorest> Also in response to `crystal build --release app.cr` ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=58ec054f4cb8d091737a8556]
zipR4ND has quit [Ping timeout: 240 seconds]
m94asr has quit [Quit: Lost terminal]
bjz has joined #crystal-lang
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
olek_poz has quit [Ping timeout: 260 seconds]
<FromGitter> <drosehn> Ah. I thought I had used it before 1.9, but the version of pickaxe that I'm looking at has a "1.9" marker on it.