jhass changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.13.0 | Fund Crystals 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
pawnbox has quit [Ping timeout: 250 seconds]
A124 has quit [Quit: '']
A124 has joined #crystal-lang
Gasher has joined #crystal-lang
<jokke> asterite: hey, i'm writing my thesis in large parts with crystal and thought to ask you about some good materials for citations. :) Since crystal is so young it's very hard to find anything. If you have any kind of benchmarks or statistics of any kind at manastec that you could share and think could be of use please give me a shout! :)
Raimondi has joined #crystal-lang
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 248 seconds]
tomchapin has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
rok has joined #crystal-lang
perks has joined #crystal-lang
perks has quit [Client Quit]
rok has quit [Quit: rok]
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 244 seconds]
onec has joined #crystal-lang
Gasher has quit [Quit: Leaving]
mgarciaisaia has joined #crystal-lang
pawnbox has joined #crystal-lang
mgarciaisaia has left #crystal-lang [#crystal-lang]
pawnbox has quit [Ping timeout: 244 seconds]
greengriminal has quit [Quit: This computer has gone to sleep]
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 244 seconds]
greengriminal has joined #crystal-lang
tomchapi_ has quit [Ping timeout: 276 seconds]
mgarciaisaia1 has joined #crystal-lang
mgarciaisaia1 has quit [Read error: Connection reset by peer]
mgarciaisaia1 has joined #crystal-lang
mgarciaisaia1 has left #crystal-lang [#crystal-lang]
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 276 seconds]
Philpax has joined #crystal-lang
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 248 seconds]
tomchapin has joined #crystal-lang
A124 has quit [Quit: '']
A124 has joined #crystal-lang
pawnbox 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
pawnbox has quit [Ping timeout: 252 seconds]
marcosdsanchez has quit [Read error: Connection reset by peer]
marcosdsanchez has joined #crystal-lang
pawnbox 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
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
onec has quit []
Philpax has quit [Ping timeout: 260 seconds]
Philpax has joined #crystal-lang
greengriminal has quit [Quit: Leaving]
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
Philpax has quit [Ping timeout: 260 seconds]
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
trapped has joined #crystal-lang
davidbackeus has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
Philpax has joined #crystal-lang
Philpax has quit [Client Quit]
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
alsm has joined #crystal-lang
fg has joined #crystal-lang
rok has joined #crystal-lang
davidbackeus has quit [Remote host closed the connection]
davidbackeus 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
bjz has joined #crystal-lang
davidbackeus has quit [Remote host closed the connection]
davidbackeus has joined #crystal-lang
davidbackeus has quit [Remote host closed the connection]
davidbackeus has joined #crystal-lang
<BlaXpirit> So I'm trying to use crystal_lib and it seems to ignore enums, which isn't nice :|
Gasher has joined #crystal-lang
fg has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
fg has joined #crystal-lang
<crystal-gh> [crystal] MakeNowJust opened pull request #2307: Fix IO#gets_to_end example (master...fix/gets-to-end-doc) https://git.io/vaBjP
ponga has joined #crystal-lang
rok has quit [Quit: rok]
pawnbox has quit [Remote host closed the connection]
davidbackeus 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
<travis-ci> MakeNowJust/crystal#a987b1b (master - Compiler: use block return type for captured blocks): The build passed. https://travis-ci.org/MakeNowJust/crystal/builds/116082444
fg has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
<jokke> hi
<jokke> has something changed with how blocks are handled in macros?
<jokke> i get the following error: https://p.jreinert.com/rInU/
<jokke> here's the actual macro: https://p.jreinert.com/F1pM/crystal
<jokke> here's the actual macro: https://p.jreinert.com/F1pM/ruby
<jokke> this used to compile just fine
davidbackeus has joined #crystal-lang
<jokke> hm ok it's not the syntax
pawnbox has quit [Remote host closed the connection]
davidbackeus has quit [Client Quit]
pawnbox has joined #crystal-lang
<jokke> this is really really important. i need to finish my thesis by monday. :/
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
<RX14> what's it on?
<jokke> RX14: the thesis?
<RX14> yea
<jokke> RX14: about a reactive cms based on redux (flux) in the frontend and crystal with a performant json api serializer with builtin caching in the backend
<RX14> cool
<jokke> RX14: unfortunately it's in german :P
<jokke> it's really annoying because most of the computer science terms are in english
<RX14> well, it's a cool idea regardless of the langauge
<jokke> yeah i like it too, was fun
<jokke> most of it is open source
<jokke> check out crystal-jsonapi and crouter
<jokke> aww come on... i reverted back to v0.11 which compiles it but now something else regarding yaml doesn't work: https://p.jreinert.com/HHA7/
<RX14> yeah
<RX14> uninstall hardening-wrapper
fg has joined #crystal-lang
<RX14> then it should work
<crystal-gh> [crystal] asterite pushed 1 new commit to master: https://git.io/vaR4l
<crystal-gh> crystal/master 61ba23a Ary Borenszweig: Added `Digest::SHA1` (pure Crystal implementation)
fg has quit [Ping timeout: 248 seconds]
davidbackeus has joined #crystal-lang
<jokke> RX14: what do you mean?
<RX14> last time I saw the -fPIC erorr
<RX14> it was because hardening-wrapper was installed on my arch machine
<RX14> it got fixed in the later crystal builds
<jokke> ah ok
<RX14> but if you downgraded the package
<RX14> you might need to remove the hardening-wrapper package
<jokke> THANK GOODNESS
<jokke> thanks RX14
<jokke> i was really starting to panic
<jokke> now i compile the bin and never touch it again before the thesis :D
<RX14> well I submitted the bug report, but jhass figured out it was hardening-wrapper
<RX14> so you should thank him
<jokke> oh noes.. :/
<jokke> now i can't parse the yaml
<jokke> says expected MAPPING_START but was SCALAR at 7:110
<jokke> *11
<jokke> ah
<jokke> aaah
<jokke> never mind
<RX14> empty production: tag?
<jokke> yupp
<RX14> eheheh
<jokke> (i made it so that if you build with --release it takes the production mapping
<jokke> ok phew
<jokke> everything working now
<RX14> yay
pawnbox has quit [Remote host closed the connection]
<travis-ci> crystal-lang/crystal#61ba23a (master - Added `Digest::SHA1` (pure Crystal implementation)): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/116106378
davidbackeus has quit [Remote host closed the connection]
davidbackeus has joined #crystal-lang
<rkeene> Hmm, where is the API documentation for LibC.* ?
luislavena has joined #crystal-lang
<BlaXpirit> rkeene, well for lib documentation can't even be generate
<BlaXpirit> d
ponga has quit []
pawnbox has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
miketheman has quit [Quit: ZNC - http://znc.in]
miketheman has joined #crystal-lang
<BlaXpirit> ok the biggest mystery is how can I try out crystal_lib without writing anything to /usr/include
<crystal-gh> [crystal] asterite closed pull request #2307: Fix IO#gets_to_end example (master...fix/gets-to-end-doc) https://git.io/vaBjP
trapped_ has joined #crystal-lang
trapped has quit [Read error: Connection reset by peer]
davidbackeus has quit [Remote host closed the connection]
rok has joined #crystal-lang
davidbackeus has joined #crystal-lang
davidbackeus has quit [Remote host closed the connection]
mgarciaisaia has joined #crystal-lang
mgarciaisaia has left #crystal-lang [#crystal-lang]
tomchapin has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
tomchapin has joined #crystal-lang
<donpdonp> how is a method parameter type defined as an array of things?
tomchapin has quit [Read error: Connection reset by peer]
tomchapi_ has joined #crystal-lang
<donpdonp> @bids = [] of Order => OK. def add(orders : [] of Order) => Error
<jeromegn> donpdonp: def add(orders : Array(Order))
<jeromegn> or def add(orders = [] of Order)
<jeromegn> if you want a default value
<BlaXpirit> >> [] of Order == Array(Order).new , as simple as that, donpdonp
<DeBot> BlaXpirit: Syntax error in eval:21: expecting token 'CONST', not 'that' - https://carc.in/#/r/u99
Excureo has quit [Read error: Connection reset by peer]
<BlaXpirit> >> [] of Int32 == Array(Int32).new
<DeBot> BlaXpirit: # => true - https://carc.in/#/r/u9a
Excureo has joined #crystal-lang
marcosdsanchez has quit [Ping timeout: 264 seconds]
<donpdonp> jeromegn, BlaXpirit: thx. that works, its surprizing to have two ways to do it. '[] of Class' is nice and reable.
marcosdsanchez has joined #crystal-lang
<BlaXpirit> donpdonp, Class.new is universal and looks nice to me. [] of is a special syntax for arrays
<BlaXpirit> also note this not-so-popular property:
<BlaXpirit> >> [12, 34] of UInt8
<DeBot> BlaXpirit: no overload matches 'Pointer(UInt8)#[]=' with types Int32, Int32 - https://carc.in/#/r/u9b
<BlaXpirit> okay then, i'll show myself out
<BlaXpirit> but this really should work
<donpdonp> BlaXpirit: Array() looks easier to parse at any rate.
<donpdonp> is there a repl? i was hoping 'crystal repl' would work
<BlaXpirit> donpdonp, this is very difficult to make for a compiled language
<donpdonp> BlaXpirit: ahh right. this isnt interpreted land anymore
<BlaXpirit> just run short snippets of code on your computer or https://carc.in/
<BlaXpirit> donpdonp, although there is https://github.com/greyblake/crystal-icr
<BlaXpirit> but don't expect flawless work
<donpdonp> thx.
<donpdonp> is there a web frame work?
<BlaXpirit> donpdonp, that's the #1 hot topic
<BlaXpirit> but i'm not following them.
<donpdonp> I was trying to think of a punny name. Crystal on Cogs was the best I could think of (though its a blatent ripoff of Cobol on Cogs)
alsm has quit [Ping timeout: 252 seconds]
<crystal-gh> [crystal] asterite pushed 4 new commits to master: https://git.io/va09n
<crystal-gh> crystal/master c96ae92 Marcelo Boeira: Make it possible to use Int8 and Int16 with JSON Mappings...
<crystal-gh> crystal/master 60f7fe6 Marcelo Boeira: Make it possible to use Int8 and Int16 with YAML Mappings...
<crystal-gh> crystal/master cc13714 Marcelo Boeira: Use macros to define mapping initializers
<donpdonp> I want to look at the channel sync'ing, so I though I'd make a thread.
<donpdonp> Thread.new { puts "In thread" }; puts "After thread"
<donpdonp> [err] event_queue_insert: 0x180edf0(fd 1) already on queue 2
<donpdonp> is that still under development?
davidbackeus has joined #crystal-lang
davidbackeus has quit [Client Quit]
<BlaXpirit> donpdonp, basically you can only do computations and use mutex when it comes to threads
<BlaXpirit> Thread is not part of the official API
* donpdonp nods
<BlaXpirit> donpdonp, basically, officially there is no multicore processing
<BlaXpirit> but there is some concurrency, using Fibers, spawn
<donpdonp> great writeup. thx.
<travis-ci> crystal-lang/crystal#4a22c66 (master - Merge pull request #2304 from marceloboeira/new-json-types): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/116184088
trapped_ is now known as trapped
<jeromegn> BlaXpirit: thanks, reading :)
Renich has joined #crystal-lang
sp4rrow has joined #crystal-lang
<sp4rrow> does crystal have any concurrency models yet?
<sp4rrow> I am building something any only found fibers
<BlaXpirit> sp4rrow, there is no official way to do multicore processing
<BlaXpirit> Fibers work for I/O intensive use cases
<BlaXpirit> jhass, this may be a problem https://travis-ci.org/BlaXpirit/crystal-lib#L220
<sp4rrow> interesting
<sp4rrow> yeah this is a board game AI
<BlaXpirit> sudo: required, dist: trusty
<sp4rrow> just as a project
<BlaXpirit> sp4rrow, well this is not fun
<sp4rrow> but it would need multicore processing
<BlaXpirit> sp4rrow, I tried something here but it's buggy, although the bugs may not be in multithreading itself https://github.com/BlaXpirit/crystal-nonograms/blob/master/nonogram_solver.cr#L139
marcosdsanchez has quit [Read error: Connection reset by peer]
marcosdsanchez has joined #crystal-lang
<BlaXpirit> basically you are very limited in synchronization primitives and in what you can do inside threads (standard library mostly breaks)
<sp4rrow> oh wow
<sp4rrow> cool
<sp4rrow> so there is a thread class you can call new on?
<BlaXpirit> sp4rrow, yes, it's undocumented, not meant to be used
<sp4rrow> ok thanks
<sp4rrow> is there a queue yet?
<BlaXpirit> sp4rrow, no
<sp4rrow> ok thanks
<sp4rrow> I will see if I can do this then
<sp4rrow> that is really cool
<sp4rrow> I might be able to use that
<sp4rrow> thanks so much man
<sp4rrow> I see the doc in the thread class about using spawn
<sp4rrow> but that is not multicore yet right?
<sp4rrow> that is where I started with "fibers"
<BlaXpirit> sp4rrow, spawn, channels, fibers are friends, they are not multicore yet
<sp4rrow> ok thanks
Renich has quit [Quit: leaving]
greengriminal has joined #crystal-lang
sp4rrow has quit [Quit: The Internet needs a break and I need a cookie]
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
bjz has joined #crystal-lang
matp has quit [Ping timeout: 244 seconds]
bjz has quit [Client Quit]
matp has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
bjz has joined #crystal-lang
bjz has quit [Ping timeout: 260 seconds]
sp4rrow has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
<RX14> BlaXpirit, is there any reason channels aren't multicore apart from fibers not being multicore?
<BlaXpirit> RX14, I don't know
<RX14> probably not really
<RX14> hmmn
marcosdsanchez has quit [Ping timeout: 244 seconds]
marcosdsanchez has joined #crystal-lang
<donpdonp> How could a crystal app listen to two websocket connections for messages simultaneously?
<RX14> two websocket servers?
<donpdonp> as soon as websocket1.run is called, it blocks
<RX14> donpdonp, your code?
<donpdonp> RX14: websocket1.run is my code :)
<donpdonp> im asking how such a setup might be done. doesnt sound like its possible in crystal currently.
<RX14> as websocket1 isn't a variable from the standard library - obviosuly not
<RX14> but you'll want to use spawn websocket1.run
<donpdonp> assume websocket1 is an instance of HTTP::WebSocket
<RX14> probably
<donpdonp> same for websocket2
<donpdonp> hmm. spawn.
<RX14> fibers
<RX14> like threads
<RX14> but
<donpdonp> fibers block, too
<RX14> different
<RX14> depends what you mean by block
<RX14> spawn doesn't block the caller
<donpdonp> yeah where are the docs for spawn?
<donpdonp> i dont see it in the docs page or API page
<RX14> there isn't any docs
<donpdonp> o_O
<BlaXpirit> donpdonp, spawn &websocket1.run
<BlaXpirit> runs in background, until the rest of your program finishes
<RX14> BlaXpirit, it should work without the &
<BlaXpirit> no
<BlaXpirit> ok maybe
<RX14> :3
<BlaXpirit> >> spawn puts
<DeBot> BlaXpirit: # => #<Fiber:0x878bee0 @proc=#<( -> Void):0x805e7d0>, @stack=Pointer(Void)@0xb5418000, @stack_top=Pointer(Void)@0xb5c17fd8, @stack_bottom=Pointer(Void)@0xb5c18000, @next_fiber=nil, @prev_fiber=#<Fiber:0x878bf18 @proc=#<( -> Void):0x805e4b0>, @stack=Pointer(Void)@0xb5c18000, @stack_top=Pointer(Void)@0xb6417fd8, @stack_bottom=Pointer(Void)@0xb6418000 ... - https://carc.in/#/r/ua4
<BlaXpirit> that's nice
<RX14> sure is
<donpdonp> ok thx for the pointers.
<RX14> >> spawn puts "arg"; nil
<DeBot> RX14: # => nil - https://carc.in/#/r/ua5
<BlaXpirit> RX14, uhm https://carc.in/#/r/uaa
<BlaXpirit> ooh right
<RX14> yeah
<BlaXpirit> >> spawn puts "arg"; sleep 1
<DeBot> BlaXpirit: arg - more at https://carc.in/#/r/uac
<RX14> aha
<RX14> there should be a wait_forever macro because making a sleep loop on the main thread because of fibers is a common thing
<BlaXpirit> RX14, actually there should be a way to wait for a fiber to end
<BlaXpirit> which would serve the same purpose here
<RX14> yeah
<RX14> or wait a bunch of them
sp4rrow has quit [Quit: The Internet needs a break and I need a cookie]
<RX14> is there a way to end a fiber like exit()?
<BlaXpirit> RX14, ugh perhaps use 'next'
<RX14> BlaXpirit, but exit() can be used n levels deep
<RX14> in functions
<RX14> wherever
<RX14> next isn't really a replacement
greengriminal has quit [Quit: Leaving]
<BlaXpirit> RX14, I thought exit would work differently but indeed it quits a fiber
<RX14> eh?
<RX14> what
<RX14> so there's no way for a fiber to stop the whole program
<BlaXpirit> there are at least a few workaround ways
<RX14> yeah
<RX14> LibC.exit
<RX14> will do the trick
<RX14> and
<RX14> Process.exit
<RX14> will exit the process
<RX14> exit will exit the fiber
<RX14> cool
<BlaXpirit> very cool
<BlaXpirit> now we just need multicore processing
<BlaXpirit> and windows support :|
<BlaXpirit> i mean honestly i dont even care about the rest
<RX14> yeah
<RX14> like really
<RX14> those two things should be all that anyone is working on
<RX14> because after those are achieved, then I guess there will be a load more people who arrive
<RX14> it's the two deal-breakers for most people
<RX14> esp. windows support
marcosdsanchez has quit [Ping timeout: 240 seconds]
rok has quit [Quit: rok]
onec has joined #crystal-lang
<onec> Is there a method to sort an array of strings? The #sort method doesn't do it.
luislavena has quit [Quit: Leaving]
<BlaXpirit> >> a = ["ba", "ab"]; a.sort; a
<DeBot> BlaXpirit: # => ["ba", "ab"] - https://carc.in/#/r/uam
<BlaXpirit> onec pls
<BlaXpirit> >> a = ["ba", "ab"]; a.sort!; a
<DeBot> BlaXpirit: # => ["ab", "ba"] - https://carc.in/#/r/uan
<BlaXpirit> >> a = ["ba", "ab"]; a = a.sort; a
<DeBot> BlaXpirit: # => ["ab", "ba"] - https://carc.in/#/r/uao
<RX14> >> ["a", "b", "z"].sort
<BlaXpirit> onec, I hope this clears things up. slightly confusing indeed
<DeBot> RX14: # => ["a", "b", "z"] - https://carc.in/#/r/uap
<BlaXpirit> RX14, epic fail
marcosdsanchez has joined #crystal-lang
<RX14> >> ["a", "z", "b"].sort
<DeBot> RX14: # => ["a", "b", "z"] - https://carc.in/#/r/uaq
<RX14> works
<RX14> >> ["abb", "aaa", "zaa", "bdd"].sort
<DeBot> RX14: # => ["aaa", "abb", "bdd", "zaa"] - https://carc.in/#/r/uar
<onec> Oh my bad... I forgot the !
<onec> So I started learning Crystal and Ruby today and created a short model of a bio lab we are doing currently. While it works how I want it to so far, I feel like this is extremely badly written Crystal. How should I change this? https://gist.github.com/justinpchang/1b25d318ebed0c9ac4a2
Gasher has quit [Ping timeout: 276 seconds]
Gasher has joined #crystal-lang
<jokke> well
<jokke> first of all, i'd indent my code with 2 spaces
<jokke> and you're using so many global variables, it makes my head spin :D
<jokke> onec:
<jokke> if else assignments you can shorten with a ternary operator
<onec> Ah sorry about the tabs, GitHub isn't updating the file when I change tab spacing.
<onec> So how would I work with local variables if I want to be able to access all of my the variables I had made global?
<jokke> you use object oriententation
<jokke> *orientation
trapped has quit [Read error: Connection reset by peer]
<onec> So like each allele, gamete, and generation would be an object with getters for the variables I need? Would that in any way slow the program down?
<jokke> also working with symbols instead of strings if you use them like you do (no string manipulation) would be advisable
<jokke> also performance wise
<jokke> onec: it would, if they would be instanciated in the millions
<jokke> you could also use struct
<jokke> which get's passed by value
<onec> Ah ok, I see that page in the docs.
<jokke> also i don't know how random your random should be but keep in mind rand is just pseudorandom
<jokke> but then again using SecureRandom (which would provide much better random data) is a lot slower
<onec> So overall, is the flow of the program okay in terms of sequential methods? That seems clunky to me. And ok, I'll keep that in mind
<jokke> it's very imperative
<jokke> also the assignment in line 34 doesn't make much sense
<jokke> same thing in 25
<onec> Would that not create two different alleles with two different method calls, or does that only create 1?
stef__ has joined #crystal-lang
<onec> Also, is imperative programming encouraged in Crystal?
<jokke> no
<jokke> crystal is very deeply object oriented
<jokke> even nil is an object
<jokke> the method would create two different alleles with two different method calls, as it does now
stef__ has quit [Client Quit]
zodiak has joined #crystal-lang
<jokke> also consider something like [:A, :B].sample in line 25
<jokke> the while loop in 40 is bloat too