ChanServ changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.20.3 | 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
<schnittchen> I have init'ed an app, how do I build it? I can only find compiling single files...
mgarciaisaia has joined #crystal-lang
<FromGitter> <Sija> @schnittchen: that’s what you do :)
<FromGitter> <Sija> @schnittchen: `crystal build --help`
m94asr_ has quit [Ping timeout: 260 seconds]
m94asr has joined #crystal-lang
<FromGitter> <andyfleming> Why is `match.size` `0`? Shouldn't it be 1? or 2?
<FromGitter> <andyfleming> Is it because there are no groups?
<FromGitter> <Sija> @andyfleming: https://crystal-lang.org/api/0.20.3/Regex/MatchData.html#size%3AInt32-instance-method
<FromGitter> <Sija> > Returns the number of capture groups, including named capture groups.
<FromGitter> <andyfleming> Scratch that. Found the answer rereading the docs
<FromGitter> <andyfleming> > Returns the number of capture groups, including named capture groups.
<FromGitter> <Sija> :)
<FromGitter> <andyfleming> Oops, yeah, beat me to it :-P
<FromGitter> <andyfleming> Is there a way to match all occurrences in a string?
<FromGitter> <Sija> seconds! :D
schnittchen has quit [Ping timeout: 240 seconds]
<FromGitter> <andyfleming> or would I just need to recursively process a string?
<FromGitter> <Sija> wouldn’t match do the job?
<FromGitter> <andyfleming> I guess I might not understand its API fully. I've been reading the API docs and git book, trying to follow, but it is still a bit foggy.
<FromGitter> <andyfleming> After I understand it more, I planned to help contribute to the docs around it to help others in the future.
<FromGitter> <andyfleming> Does /example/.match("string example with multiple example matches") return multiple matches or just the first?
<FromGitter> <andyfleming> (from what I can tell it returns a single MatchData object which only carries a single match, unless I'm missing some sort of iterator interface)
<FromGitter> <Sija> @andyfleming: try using `String#scan` method
<FromGitter> <Sija> as follows: `"Hello World".scan(/\w+/).not_nil!`
<FromGitter> <Sija> https://crystal-lang.org/api/0.20.3/String.html#scan%28pattern%3ARegex%29-instance-method
<FromGitter> <Sija> > Searches the string for instances of pattern, returning an array of Regex::MatchData for each match.
<FromGitter> <andyfleming> Perfect
<FromGitter> <andyfleming> That and `gsub` look like what I'm looking for.
<FromGitter> <andyfleming> I think it would be helpful to have some examples of string and array manipulation in the docs somewhere. Do you agree? Where would be the best place to add that?
<FromGitter> <Sija> I agree, but I can’t rly find the proper place in crystal-book to put it
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
schnittchen has joined #crystal-lang
<FromGitter> <andyfleming> It could be added to the pages about each type literal, but that might be a little overkill.
Raimondi has joined #crystal-lang
<FromGitter> <andyfleming> There could be a section to house titles such as "Working with Arrays" or "Manipulating Strings". Similarly, examples of comparison of those types could be helpful as well.
<FromGitter> <Sija> I was thinking about the same
<FromGitter> <andyfleming> Each of those pages could be linked to from their type literal page, as well as they could link to the relevant API docs.
schnittchen has quit [Ping timeout: 240 seconds]
<FromGitter> <andyfleming> I may try to throw together a few ideas into a PR for crystal-book
<FromGitter> <Sija> gr8 :)
<FromGitter> <andyfleming> Thanks for the help @Sija
<FromGitter> <andyfleming> :)
Philpax has joined #crystal-lang
tatey_ has joined #crystal-lang
tatey_ has quit [Client Quit]
martinium has joined #crystal-lang
pawnbox has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
martinium has quit [Ping timeout: 256 seconds]
dtzu has joined #crystal-lang
<TheGillies> is there a way to do something like def foo({"baz" => qux}) and then call foo({"baz" => 42})
<TheGillies> similar to elixir
mgarciaisaia has quit [Ping timeout: 252 seconds]
mgarciaisaia has joined #crystal-lang
mgarciaisaia has quit [Client Quit]
pawnbox has joined #crystal-lang
bjz has joined #crystal-lang
<TheGillies> TIL crystal doesn't like it when you spin up 10_000 fibers at once
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
bjz has joined #crystal-lang
vivus-ignis has joined #crystal-lang
<FromGitter> <andyfleming> @TheGillies I don't believe there is hash/object destructuring, but there are named parameters: https://crystal-lang.org/docs/syntax_and_semantics/default_and_named_arguments.html
lacour has quit [Quit: Leaving]
soveran has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
pawnbox has quit [Read error: Connection reset by peer]
pawnbox has joined #crystal-lang
soveran has quit [Remote host closed the connection]
splitty_ has quit [Quit: Leaving]
splitty_ has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
<TheGillies> Is there a difference between type and class in crystal?
soveran has joined #crystal-lang
matp has joined #crystal-lang
soveran has quit [Remote host closed the connection]
miketheman has quit [Quit: ZNC - http://znc.in]
miketheman has joined #crystal-lang
Raimondii has joined #crystal-lang
Raimondi has quit [Ping timeout: 244 seconds]
Raimondii is now known as Raimondi
Ven has joined #crystal-lang
<Yxhuvud> TheGillies: Union types are not classes.
<Yxhuvud> And I don't think value types like structs or tuples should be considered classes, either.
<TheGillies> Ah thanks
<Yxhuvud> But as the difference is just where instances are allocated, if the distinction matters is probably not always obvious.
DeBot has quit [Quit: Crystal IRC]
DeBot has joined #crystal-lang
DeBot has quit [Client Quit]
DeBot has joined #crystal-lang
DeBot has quit [Quit: Crystal IRC]
DeBot has joined #crystal-lang
schnittchen has joined #crystal-lang
bjz_ has joined #crystal-lang
bjz has quit [Ping timeout: 268 seconds]
<FromGitter> <andyfleming> Is there a target for 1.0? months away? years away?
<FromGitter> <raydf> @andyfleming, there's no date for 1.0 release. The core teams prefers to release 1.0 when ready. let's hope it can be released in 2017.
<FromGitter> <raydf> But if you're willing to take risks and maybe fix libraries on each new releases you can use crystal in production environment.
<FromGitter> <raydf> For example i have a service running with crystal-pg and crystal-redis and with the new crystal 0.20.3 the crystal-redis shard is still outdated. The crystal-pg shard also was outdated but already fixed by now.
<crystal-gh> [crystal] yxhuvud opened pull request #3794: Move Array#product to Enumerable (master...master) https://git.io/vMTcK
<DeBot> https://github.com/crystal-lang/crystal/pull/3794 (Move Array#product to Enumerable)
schnittchen has quit [Ping timeout: 240 seconds]
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
schnittchen has joined #crystal-lang
vivus-ignis has quit [Ping timeout: 260 seconds]
<crystal-gh> [crystal] MakeNowJust opened pull request #3795: Implement missing Iterator::SingletonProc#rewind (master...fix/iterator/singleton-proc) https://git.io/vMTlB
<DeBot> https://github.com/crystal-lang/crystal/pull/3795 (Implement missing Iterator::SingletonProc#rewind)
bjz has joined #crystal-lang
bjz_ has quit [Ping timeout: 248 seconds]
schnittchen has quit [Ping timeout: 240 seconds]
schnittchen has joined #crystal-lang
<crystal-gh> [crystal] MakeNowJust opened pull request #3796: Add Iterator#auto_rewind? and auto_rewind= (master...feature/iterator/auto-rewind) https://github.com/crystal-lang/crystal/pull/3796
<DeBot> https://github.com/crystal-lang/crystal/pull/3796 (Add Iterator#auto_rewind? and auto_rewind=)
<crystal-gh> [crystal] yxhuvud opened pull request #3797: Makefile: Fix typo in intructions. (master...make) https://git.io/vMTRJ
<DeBot> https://github.com/crystal-lang/crystal/pull/3797 (Makefile: Fix typo in intructions.)
vivus-ignis has joined #crystal-lang
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
schnittchen has quit [Ping timeout: 240 seconds]
schnittchen has joined #crystal-lang
damireh has joined #crystal-lang
<damireh> hello
<damireh> im learning crystal and im having a hard time understanding types
<damireh> I have a class that looks like this https://gist.github.com/damireh/dff40817e47f9ca441dfad1082a4a863
<damireh> and im wondering why it cant properly infer the type of my instance vars
<damireh> I would assume that setting the type to Array(String) would allow it to infer that the ivars are strings no?
vivus-ignis has quit [Ping timeout: 258 seconds]
schnittchen has quit [Ping timeout: 240 seconds]
<Papierkorb> damireh: Currently not, so you have to do this: https://gist.github.com/Papierkorb/e0312e532c849d9bc24e36562b091b3d
<Papierkorb> damireh: However, that code is not really crystal-y anyway
Philpax has quit [Ping timeout: 264 seconds]
<FromGitter> <raydf> @damireh, maybe you can use https://crystal-lang.org/api/master/OptionParser.html
<damireh> @Papierkorb hmm thats what I ended up with; thanks!
<damireh> can you explain why its not crystal-y though?
<damireh> @raydf oh this is exactly what im looking for; thanks!
<Papierkorb> damireh: An Array has no known length at compile-time, which leaves a sour taste. it's fine in ruby, there's no better way for this exact case
<jhass> well, what's wrong with a two element tuple or just individual arguments
<Papierkorb> damireh: If you end up with something like this without wanting to parse arguments, see Tuple, as you can splat tuples in Crystal. Tuples are also the way to return 'multiple' values from a method, instead of an Array (like in Ruby)
<damireh> Papierkorb thanks for the explanation; will take a look at Tuple
<Papierkorb> damireh: But as jhass said, avoid this (also in Ruby) if you can avoid it using something better suited for the job, like OptionParser in your case
damireh has quit [Quit: My iMac has gone to sleep. ZZZzzz…]
miketheman is now known as miketheman_
miketheman_ is now known as miketheman
<FromGitter> <fridgerator> does this mean crystal is driving towards a 1.0 release soon or am I reading into this wrong?
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
schnittchen has joined #crystal-lang
schnittchen has quit [Changing host]
schnittchen has joined #crystal-lang
triangles has joined #crystal-lang
_jungh4ns has quit [K-Lined]
soveran has joined #crystal-lang
soveran has joined #crystal-lang
soveran has quit [Changing host]
matp has quit [Read error: Connection reset by peer]
soveran has quit [Remote host closed the connection]
matp has joined #crystal-lang
triangles has quit [Quit: Leaving]
<FromGitter> <fridgerator> ah ok
<FromGitter> <jwoertink> I just get `Program received and didn't handle signal TRAP (5)` when running it...
<RX14> well its a debugger breakpoint
<RX14> you run it in gcc
<RX14> gdb*
<RX14> sorry
<RX14> and then when it reaches `debugger` is's like you set a breakpoint
<RX14> or lldb of course
<FromGitter> <jwoertink> Ok, so that sounds like exactly what I'm looking for, but I've never really used gdb (at least outside of xcode)
<FromGitter> <jwoertink> Are there docs anywhere on how to use it?
<RX14> probably
<RX14> not sure where though
<FromGitter> <jwoertink> like, do I just build crystal with `crystal build --debug whatever.cr` and make sure I have a line of `debugger` in my code?
<RX14> then run gdb ./whatever
<RX14> and then type start
<FromGitter> <jwoertink> ah
<FromGitter> <jwoertink> thanks. I'll try that
<RX14> and then when you get to the breakpoint
<RX14> you start to google
<RX14> bt gives backtrace
<RX14> and you should be able to step and continue
<RX14> also there's an assembly view
<RX14> forgot how to get to it though
<FromGitter> <martinium> How do I access specific JSON elements from the response of the following function?
<RX14> gdb is a large subject
<FromGitter> <jwoertink> I figured. That at least gets me on the right track though
<FromGitter> <martinium> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5863fe819e6f00e74ad03641]
<FromGitter> <martinium> I am trying to learn how to work with JSON data
<RX14> well
<FromGitter> <jwoertink> @martinium You probably want to get rid of that `p` before the JSON.parse.
<RX14> JSON.parse returns a JSON::Any
<FromGitter> <martinium> lets say I only wanted to access this part of the response ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5863ff059e6f00e74ad03808]
<RX14> well
<RX14> the response is an array of those objects
<RX14> so the question is "which one"
<FromGitter> <jwoertink> `fundingBody["timestamp"]`
<FromGitter> <martinium> for this example “symbol”
<FromGitter> <martinium> fundingBody is the parsed JSON response
<FromGitter> <martinium> would I access it like an array?
<RX14> oh, so it would be for example fundingBody[0]["symbol"]
<RX14> for the symbol of the first one
<RX14> in the array
<FromGitter> <martinium> wouldn’t it be 1 instead of 0 since the timestamp is first?
<RX14> no
<RX14> because the response is an array of those json objects
<RX14> you access the first object in the response
<RX14> then you access the "symbol" key of it
<FromGitter> <martinium> so the timestamp wouldn’t count as the first item of the array then?
<RX14> you could do fundingBody.each { |funding| funding["symbol"] }
<RX14> @martinium no because the timestamp isn't in the array
<RX14> it's an array of objects
<RX14> each object has a timestamp, symbol etc
<FromGitter> <martinium> ah
<FromGitter> <martinium> that makes sense
<RX14> so you first select the first object
<RX14> and then select whatever data you need from that object
<FromGitter> <martinium> let me try to selectively pick what I want to see
<FromGitter> <martinium> |funding| in your above example is a closure?
<RX14> the {} is a block passed to #each
<RX14> I would learn the basic language syntax before learning how to parse JSON
<FromGitter> <martinium> trying to learn by doing :-p
<RX14> but essentially it's a block of code passed to each which is executed for every item in the array
<RX14> the |funding| is the arguments for the block
<FromGitter> <martinium> ah
<FromGitter> <martinium> enlightening
<FromGitter> <martinium> It appeared to be that way but the syntax I’m not used to etc
<FromGitter> <martinium> @RX14 thanks for you help so far :)
<RX14> crystal/ruby has some quite foreign concepts so I would recommend at least skimming the language docs
<RX14> for example blocks and how they work with next/break etc
<RX14> and it's sort of like a closure
<RX14> but not really, in that it's actually inlined when compiling
<RX14> so there's zero cost in using blocks at all
<RX14> #each is exactly as fast as writing a while/for loop by hand
<FromGitter> <martinium> zero cost is a beautiful thing
<RX14> you can capture blocks to create a closure (called Proc in crystal) though
<RX14> which has a few restrictions which are also in the docs
<FromGitter> <martinium> ===each method explains why they didn’t include a for loop in this language===
<FromGitter> <martinium> oops
<RX14> yes
<FromGitter> <martinium> “#each"
<RX14> each is implemented using while
<RX14> so there's no need for for
<FromGitter> <martinium> why do they note methods with a hash in front
<RX14> #each is an instance method
<FromGitter> <martinium> I know that’s from Ruby
<RX14> .each is a class method
<FromGitter> <martinium> so instance methods in documentation have hash in front
<RX14> yes
<FromGitter> <martinium> that would be the same as @each?
<RX14> @each is an instance variable
<RX14> npt a function
<FromGitter> <martinium> ah okay good
<FromGitter> <martinium> good to not get those mixed up
<FromGitter> <martinium> in the actual code do you call the instance variable with the hash notation at all?
<RX14> what programming languages ahve you used before?
<RX14> the # function notation is purely for docs and text
<RX14> it's not used in the language
<RX14> # is for comments in crystal
<RX14> unless in a string etc
<FromGitter> <martinium> I’ve only dabbled the fundamentals in a few languages but haven’t full fledged learned one so to speak. Have only created small simple programs with C, C++, Python, now have decided to concentrate on Nim and Crystal
<FromGitter> <martinium> was just making sure about the hash notation as I only ever used it for comments and only see it in docs
<FromGitter> <martinium> but I am glad you mentioned that it notates that its for instance methods
<RX14> well class notation has a direct relation to the syntax of calling class methods
<RX14> in that Class.method is how you call one
<RX14> but the # notation does not
<RX14> it would be Class.new(whatever).method
<FromGitter> <martinium> yeah, that I have noticed and seen
<FromGitter> <martinium> with a proper web framework this language might be able to take a chunk of Rails devs and should outperform elixir/phoenix
<FromGitter> <martinium> I was looking at crystal benchmarks and it makes small binaries on top of them being fast. Performs neck and neck with Nim and not far from C performance for higher-level syntax.
<RX14> yeah that's easier said than done!
<FromGitter> <martinium> of course it is
<RX14> Kemal is really nice for simple things
<FromGitter> <martinium> those frameworks take a lot of work and fine-tuning
<FromGitter> <martinium> to create etc
<FromGitter> <martinium> Kemal looks very nice
<FromGitter> <martinium> but at the moment there is no batteries included framework for Crystal for creating web apps
<FromGitter> <martinium> Amethyst seems to have been abandoned
<RX14> yeah, we have a lot of web-related libraries
<RX14> and you can string something together
<FromGitter> <martinium> which was supposed to be the Rails of Crystal
<RX14> but nothing batteries included
pawnbox has quit [Remote host closed the connection]
<FromGitter> <martinium> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=58640504c895451b752e5e82]
<FromGitter> <martinium> thats error I am getting when I try to select the json object
<RX14> what that error means is that your code for traversing the json is incorrect
<RX14> JSON::Any wraps raw crystal objects
<RX14> so when you do Any#[](String) it expects a Hash in the JSON::Any
<RX14> but it's getting a string
<RX14> can you give me some code that you're using
<FromGitter> <martinium> yeah I’ll show you full code
<FromGitter> <martinium> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5864060caf6b364a29067b32]
<RX14> ok
<FromGitter> <martinium> the 1 I just switched to test
<FromGitter> <martinium> had a [0]
<RX14> in your second method, `fundingBody[1]["symbol"]` will return "XBTUSD"
<FromGitter> <martinium> should I just keep it as p fundingBody[1]["symbol”]?
<RX14> well actually "XBTUSD" wrapped in a JSON::Any
<RX14> @martinium yes
<FromGitter> <martinium> symbol being the key I want to access
<FromGitter> <martinium> k
<RX14> so the second item's symbol is XBTUSD
<FromGitter> <martinium> it’s actually much further down but I just want to get a filtered value before I worry about the actual array position at this point
<FromGitter> <martinium> got it to work!
<FromGitter> <martinium> wooooo
<FromGitter> <martinium> good feeling
<FromGitter> <martinium> item 19 in array aka position 18
<RX14> item 19 aka there are 18 items before it
<RX14> is a nice way to think of it
<FromGitter> <martinium> can I chain together more keys?
<FromGitter> <martinium> for example
<FromGitter> <martinium> if I want “symbol”, “fundingRate”, “fundingRateDaily"
ponga has quit []
<FromGitter> <martinium> would I have to instead use the .each version?
<FromGitter> <martinium> to loop through?
<FromGitter> <martinium> err iterate
<RX14> no you would assign fundingBody[n] to a variable
<RX14> then use ["symbol"] and ["fundingRate"] on that
<FromGitter> <martinium> @RX14 what about if I want to select the entire object in the array at position 18 while ignore all other array objects
<RX14> that would be fundingBody[17]
<FromGitter> <martinium> you mean 18
<FromGitter> <martinium> :)
<FromGitter> <martinium> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=586409ccc02c1a3959c136b3]
<FromGitter> <martinium> final working method
<RX14> depends what you mean by position 18
<FromGitter> <martinium> @RX14 I really appreciate your help. You have helped me wrap my head around seemingly obvious but hard to find information
<RX14> one more thing
<RX14> I would return fundingBody[17].as_h there
<RX14> because JSON::Any#[] returns a JSON::Any
<RX14> you want the raw Hash type underneath
<FromGitter> <martinium> for speed?
<RX14> just for cleanliness
<FromGitter> <martinium> or just to avoid type mismatches?
<RX14> yes
<FromGitter> <martinium> okay cool
<RX14> methods will accept Hashes
<RX14> but not usually JSON::Any
<RX14> but thats more of an issue with Strings
<FromGitter> <martinium> saving me future headache there
<RX14> you definitely want a string or number
<RX14> instead of a JSON::Any of a string or number
<RX14> so you would do as_s to get a string
<FromGitter> <martinium> for my code the to_h fails
<RX14> it should be as_h
<RX14> for JSON::Any
<FromGitter> <martinium> ah
hako has joined #crystal-lang
<RX14> as_h is used instead of to_h because it's not really "converting" it to a Hash
<RX14> it's already a hash
<FromGitter> <martinium> yeah as_h worked
<RX14> and because as_h will fail if it doesn't contain a hash
<FromGitter> <martinium> to_s worked as well
<FromGitter> <martinium> but as_h is what I want as it remains pretty printed
<RX14> but that gives you something which isn't really useful
<FromGitter> <martinium> the string version?
<FromGitter> <martinium> I am keeping it as a hash via as_h
<RX14> yes a string is useful only for displaying
hako_ has joined #crystal-lang
hako has quit [Ping timeout: 258 seconds]
soveran has joined #crystal-lang
<FromGitter> <martinium> yeah that makes sense
<FromGitter> <martinium> @RX14 how many years have you been programming?
<FromGitter> <martinium> I’d wager 5-10 years
<RX14> maybe 5
<RX14> 4-5
<FromGitter> <martinium> nice
<FromGitter> <martinium> you code everyday I bet
<FromGitter> <martinium> that’s what I am trying to do
<RX14> not every day
<FromGitter> <martinium> code daily to learn things well and get experience
<RX14> i think about code every day i'm sure
<FromGitter> <martinium> probably solving problems in code while you are on the couch
<RX14> well i'm sitting on the sofa right now
<FromGitter> <martinium> :-D
<FromGitter> <martinium> is the http client asynchronous by default in crystal or do we have to add code to make it asynchronous?
<RX14> it's asynchronous by default
<RX14> well
<RX14> sort og
<RX14> it blocks the fiber but other fibers can still run
<FromGitter> <martinium> okay basically no extra code needed
<RX14> yes
<RX14> but you need to use `spawn` to take advantage of it
<RX14> there's a docs section on that too
<FromGitter> <martinium> prob going to start blogging what I learn as I learn it
<TheGillies> what is an example of an algorithm that needs parallelism? My understanding is that most blocking things are IO and aren't aided by parallelism.
<RX14> well when you use nonblocking IO, your bottlenecks are usually the bits of computation that you do need to do
<RX14> and obviously using more cores would speed that up
<RX14> so even a very simple HTTP benchmark would be sped up by parallelism
<RX14> but doing havy computation does occur
<RX14> and it's a good idea to schedule that kind of stuff over multiple cores
<TheGillies> Ah thanks
bjz has joined #crystal-lang
vivus-ignis has joined #crystal-lang
<FromGitter> <andyfleming> @raydf — Thanks for the answer! I figured it was something along those lines. Might be worth noting somewhere so it's google-able.
<FromGitter> <andyfleming> So, @RX14, is HTTP blocking then? If I make a request to another API, am I blocking the whole thread? Or will it create multiple fibers automatically?
soveran has quit [Remote host closed the connection]
vivus-ignis has quit [Ping timeout: 258 seconds]
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<RX14> no the call blocks
<RX14> it blocks the fiber
<RX14> but not the thread
soveran has joined #crystal-lang
<RX14> where thread is the OS thread
<RX14> fibers are unlike threads in that they're incredibly leightweight and you can have hundreds of thousands of them, and spawn hundreds of thousands of them per second
<RX14> so if you served HTTP requests in a fiber per HTTP requests
<RX14> do all the blocking HTTP calls in that fiber
<RX14> the code looks nice because it's blocking
<RX14> but it's not blocking the whole program
<RX14> other HTTP requsts will still be served
<RX14> if you want to do multiple HTTP requests in parallel and then collect the results again you will need to spawn fibers yourself and coordinate them with channels
<FromGitter> <andyfleming> Does Kemal use fibers?
<FromGitter> <martinium> I’ve read they are working on creating a GC just for crystal so that they can parallelize the language
<FromGitter> <martinium> hopefully that releases in 2017 as parallel code is the future
<RX14> @andyfleming the HTTP server in the stdlib creates a fiber for each HTTP request
<RX14> kemal is built on that HTTP server
<RX14> so the answer is yes
<RX14> @martinium we shouldn't need a new GC just for parallelism, though our current GC will probably show it's slowness
<FromGitter> <martinium> Boehm GC is cookie cutter GC isn’t it
<FromGitter> <martinium> so to speak
<RX14> it's brebuolt yes
<RX14> prebiuilt*
<RX14> sorry i can't type today...
bjz has joined #crystal-lang
<FromGitter> <andyfleming> Oh cool. Thanks
<RX14> i'm sure crystal will eventually get it's own GC
<RX14> but it's not a priority yet
<RX14> the current one is "good enough"
<FromGitter> <martinium> yeah for now
<Papierkorb> What are the drawbacks of the current one?
<RX14> i don't think the current one works very well when multi threaded
<Papierkorb> iirc GCJ also uses Boehm
<RX14> i'm pretty sure it can't stop the world
<RX14> but idk
<Papierkorb> Didn't D lang too?
<RX14> oh, boehm uses signal handlers to stop the world
<RX14> interesting
schnittchen has quit [Ping timeout: 240 seconds]
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
soveran has quit [Remote host closed the connection]
bjz has joined #crystal-lang
hako_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<FromGitter> <martinium> Boehm is a single threaded process
<FromGitter> <martinium> they need to parallelize so stdlib can be made thread safe and prevent data races in future
<FromGitter> <martinium> the earlier the better
<FromGitter> <martinium> they are probably working on it as we speak
<RX14> boehm works fine multi threaded
<RX14> no current work is being done on parallelism in the stdlib afaik
<RX14> but it will be soon
<RX14> roadmapwill be incoming in the next few weeks
<FromGitter> <martinium> cool
<RX14> and I dont think we have the goalof preventing data races
<RX14> unfortnately
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
soveran has joined #crystal-lang
<FromGitter> <martinium> if they parallelize that will be a big deal
<FromGitter> <martinium> referring to the thread safety etc
<FromGitter> <martinium> I’m sure you guys will take care of it the best way possible etc
<FromGitter> <martinium> programmers have to code in a way that they don’t cause the data races and thats fine
<FromGitter> <martinium> :)
schnittchen has joined #crystal-lang
<RX14> i'm sure we'll do just fine
<FromGitter> <martinium> right now the performance and the fact that it does native code is amazing
<FromGitter> <martinium> the web server benchmarks really put it in perspective
<FromGitter> <martinium> I’ve personally wanted compiled high level languages for a long time because I figured they would be much faster
<FromGitter> <martinium> :)
<FromGitter> <martinium> Crystal proves it
<FromGitter> <martinium> @RX14 how can I load another crystal files functions into my program
<FromGitter> <martinium> what does the require syntax look like for that?
<RX14> require "./foo"
<RX14> loads foo.cr in the same directory
<RX14> well#
<RX14> requires
<RX14> you can give require a relative path and it'll work
<RX14> or just a library name and it'll find the library in the load path
<TheGillies> Can i bind c++ libs with crystal or just C?
schnittchen has quit [Ping timeout: 240 seconds]
<Papierkorb> TheGillies: If you mean C++ libs as in a C++ lib without "C bindings", then .. well you could, but it's not fun, due to the name mangling of the C++ compiler
<Papierkorb> TheGillies: "Yes, but not easily", also not stable (over time the mangled names may change)
<Papierkorb> With new compiler versions etc
soveran has quit [Remote host closed the connection]
<TheGillies> ah
<TheGillies> ok this project is written in c++ but exposes a "c api" i guess that is a common thing so nevermind
<Papierkorb> That you can interface with :)
<TheGillies> crystal c interfacing is so smooth
<TheGillies> especially since LibC is a type heh
<TheGillies> or class or module or whatever it is
soveran has joined #crystal-lang
soveran has quit [Ping timeout: 246 seconds]
<RX14> Papierkorb, even with name mangling isn't the C++ call conventioin different?
<RX14> even C++ compilers dont attempt to be compatible with each other
<Papierkorb> ^ I didnt say otherwise, I even mentioned that a later version of a compiler may have a new version of the name mangling (or even ABI)
<Papierkorb> RX14: For GCC, thiscall is basically cdecl with the this pointer as invisible argument https://en.wikipedia.org/wiki/X86_calling_conventions#thiscall
<Papierkorb> For MS .. well, they wouldn't be MS if they wouldn't do it differently
<Papierkorb> iirc RDI is the this pointer for C++ on non-MS x64 systems
<Papierkorb> For MS, well..
splitty_ has quit [Read error: Connection reset by peer]
soveran has joined #crystal-lang
splitty_ has joined #crystal-lang
soveran has quit [Ping timeout: 260 seconds]
Ven has joined #crystal-lang
<FromGitter> <RicoAntonioFelix> \\\\\\\\\\\
soveran has joined #crystal-lang
soveran has joined #crystal-lang
soveran has quit [Changing host]
soveran has quit [Remote host closed the connection]
schnittchen has joined #crystal-lang
soveran has joined #crystal-lang
soveran has joined #crystal-lang
soveran has quit [Changing host]
Philpax has joined #crystal-lang
Philpax_ has joined #crystal-lang
Philpax has quit [Ping timeout: 268 seconds]