jhass changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.28.0 | Fund Crystal's development: http://is.gd/X7PRtI | GH: https://github.com/crystal-lang/crystal | Docs: http://crystal-lang.org/docs/ | API: http://crystal-lang.org/api/ | Gitter: https://gitter.im/crystal-lang/crystal
lucasb has quit [Quit: Connection closed for inactivity]
<FromGitter> <mwlang> @jaydorsey yes, sir!
<FromGitter> <jaydorsey> that’s crazy!
<FromGitter> <mwlang> Ruby is not exactly known for crunching numbers.
<FromGitter> <mwlang> and that's exactly what's going on with computing stock indicators.
<FromGitter> <mwlang> Bollinger was a good one for me to test because it repeatedly needs to look back X data points to do mean, then square differences of price and mean squared, and then finally do another mean of that to arrive at a rolling standard deviation.
greengriminal has joined #crystal-lang
<FromGitter> <mwlang> woah, just boosted performance again by using a struct to hold each data point in the bollinger series:
<FromGitter> <mwlang> 1) 920000 0.020000 1.940000 ( 1.756997)
<FromGitter> <mwlang> any guidance on setting up a crystal project so that compiled modules end up in their own folder instead of living alongside the sources?
<FromGitter> <mwlang> or is that a necessary evil (I seem to recall C object and executables also lived alongside their sources when compiled).
<FromGitter> <Blacksmoke16> could make them shards then require them
<FromGitter> <Blacksmoke16> then each "module" would go into its own dir under lib/
<FromGitter> <mwlang> πŸ‘
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
laaron has joined #crystal-lang
alexherbo29 has joined #crystal-lang
alexherbo2 has quit [Ping timeout: 246 seconds]
f1refly has quit [Ping timeout: 268 seconds]
f1refly has joined #crystal-lang
greengriminal has quit [Quit: This computer has gone to sleep]
alexherbo29 has quit [Ping timeout: 244 seconds]
return0e has quit [Read error: Connection reset by peer]
return0e has joined #crystal-lang
rohitpaulk has joined #crystal-lang
<FromGitter> <elankvitko> hey everyone! Happy to join this room and meet you all. I love this project and I hope it’s ok if I ask questions from time to time.
_whitelogger has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 252 seconds]
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 246 seconds]
sgt_chuckles has joined #crystal-lang
<sgt_chuckles> When does Crystal 1 come out?
<Yxhuvud> whenever it is done.
sgt_chuckles has quit [Quit: AndroIRC - Android IRC Client ( http://www.androirc.com )]
Flipez has quit [Quit: The Lounge - https://thelounge.github.io]
Flipez has joined #crystal-lang
Flipez has quit [Client Quit]
Flipez has joined #crystal-lang
<FromGitter> <bew> @elankvitko welcome ;) we're here to help!
<FromGitter> <kaukas_gitlab> Hi! I am tinkering with bindings to a C library. Could anyone please point me to any documentation on how I could release and reschedule the current fiber upon call to or return from the C lib?
_whitelogger has joined #crystal-lang
hightower3 has joined #crystal-lang
<FromGitter> <j8r> @mwlang you can also have in your `shard.yml` something like ⏎ ⏎ ```targets: ⏎ dppm: ⏎ main: src/main.cr``` ⏎ ⏎ then compile with `shards build` [https://gitter.im/crystal-lang/crystal?at=5ccbfd563b6cb0686a959557]
<FromGitter> <j8r> the binary will be `bin/myapp`
<FromGitter> <bew> @kaukas_gitlab what do you mean? When you call an external function (from a lib), it blocks the current thread until the function returns, and all fibers currently runs on a single thread,
<FromGitter> <bew> *.
<FromGitter> <kaukas_gitlab> @bew, not necessarily, if a C library takes a callback (https://docs.datastax.com/en/developer/cpp-driver/2.9/topics/basics/futures/#callbacks) it might call us back when a result is available, potentially on a different thread.
ashirase has quit [Ping timeout: 245 seconds]
ashirase has joined #crystal-lang
<mps> j8r: straight-shoota: during preparing and building crystal 0.28.0 I noticed 'signal 11' few times on both arch's (x86_64 and aarch64)
<mps> also, another developer informed me that he saw the same, and last night x86_64 had this in first build try
<mps> I don't know deeply crystal internals and didn't tried to find a bug (or what is it) so, please if you notice the same on alpine inform me to have at least some notes about that
<FromGitter> <bew> @kaukas_gitlab oh right, in that case I think you'll have to play with channels.. But beware that crystal code will fail at you if it's executed on another thread (e.g it won't be able to find the gc, or the sceduler..)
<FromGitter> <bew> scheduler*
<FromGitter> <kaukas_gitlab> Is there a somewhat safe way to ping the current thread to resume, from another one (preferably in Crystal)?
<FromGitter> <j8r> mps: good! Don't know what's producing the segfault :/
<mps> I didn't noticed it anytime when build crystal programs, only when building/compiling crystal apk
azuri5 has joined #crystal-lang
<FromGitter> <bew> @kaukas_gitlab I don't know the details for that, maybe @RX14 @straight-shoota @ysbaddaden @asterite might be able to help? *if they see this msg*
<FromGitter> <kaukas_gitlab> Thank you!
<RX14> Use channels
<RX14> There's no real safe way to do it
<FromGitter> <kaukas_gitlab> I'll give it a try, thank you!
<RX14> Since 0.28.0 the gc works on other threads
<RX14> So you could potentially use threads for blocking C calls
<RX14> If I read correctly that that's your problem
<FromGitter> <straight-shoota> mps is there any more detailed output than on the error?
<RX14> mps: that is weird, I haven't seen any segfaults so far
<mps> straight-shoota: RX14: I will try later again and make build log and post it
_whitelogger has joined #crystal-lang
alexherbo2 has joined #crystal-lang
<FromGitter> <mavu> @kaukas_gitlab I have asked a similar question on the forum: https://forum.crystal-lang.org/t/help-c-binding-of-function-that-takes-callback/325/6
<FromGitter> <mavu> @kaukas_gitlab not exactly the same, but maybe it helps. Ihave the code running, and it seems to work fine.
<FromGitter> <kaukas_gitlab> @mavu, with a `channel.send(nil)` in a callback I get `Failed to raise an exception: END_OF_STACK`. So it seems very similar. Reading your whole thread now, thank you!
<FromGitter> <kaukas_gitlab> @mavu, like you, I have a situation where the callback fires in a different thread, and `Channel` does not support inter-thread communication. Unlike your wPi problem I can't go through OS sockets, that would mostly defeat the purpose. I'm interested if there's anything like `Channel` but with inter-thread support. Since Crystal officially does not support MT yet the hope is low.
<FromGitter> <j8r> We can segfault with circle dependencies
<FromGitter> <j8r> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5ccc37cc8790b0307e44d531]
<FromGitter> <bew> Segfault or stack overflow?
<FromGitter> <j8r> In local I've another problem, which segfault. I cannot reproduce it, and got this issue by trying to
<FromGitter> <j8r> This one is maybe stack overflow, don't know. ⏎ But on a different issue, I got ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5ccc39464b4cb471d99e5114]
<FromGitter> <Blacksmoke16> thats similar to what i been getting https://github.com/crystal-lang/crystal/issues/7728
<FromGitter> <Blacksmoke16> @j8r ^
<FromGitter> <Blacksmoke16> super annoying, cant seem to work around it :/
<FromGitter> <j8r> not really sure
greengriminal has joined #crystal-lang
lucasb has joined #crystal-lang
greengriminal has quit [Quit: This computer has gone to sleep]
greengriminal has joined #crystal-lang
<FromGitter> <asterite> If you use different block argument names, for some reason it works
<FromGitter> <Blacksmoke16> or remove the `M` generic on `ColumnInfo` @asterite
<FromGitter> <asterite> Oooooh... I think I found the problem
<FromGitter> <Blacksmoke16> \o/
hightower3 has quit [Ping timeout: 258 seconds]
jeremycw has joined #crystal-lang
<FromGitter> <bew> was it you last dark-magic pr?
rohitpaulk has joined #crystal-lang
azuri5 has quit [Quit: azuri5]
rohitpaulk has quit [Remote host closed the connection]
rohitpaulk has joined #crystal-lang
alexherbo29 has joined #crystal-lang
alexherbo2 has quit [Ping timeout: 246 seconds]
<FromGitter> <Blacksmoke16> ill have to test it when i get home, can continue working w/o trying to work around it :s
azuri5 has joined #crystal-lang
<FromGitter> <asterite> Haha, yes, that was it
rohitpaulk has quit [Ping timeout: 255 seconds]
<FromGitter> <vladfaust> Hey guys, I've written an article about Crystal using Sorbet as occasion. I'd be happy if you fact-checked it -- https://medium.com/@vladfaust/sorbet-is-cool-but-polished-crystal-is-better-d16f4a920108
<FromGitter> <Blacksmoke16> damn, got me excited for ice cream
<FromGitter> <jwoertink> @vladfaust looks good!
olbat has joined #crystal-lang
alexherbo29 has quit [Read error: Connection reset by peer]
alexherbo29 has joined #crystal-lang
<FromGitter> <Blacksmoke16> could add Athena if you want ;) something like `an REST/API oriented framework`
<FromGitter> <vladfaust> Yes, sure
<FromGitter> <Blacksmoke16> <3 cheers
<livcd> vladfaust: i think that comparison is a bit unfair because the Ruby team said they would change the way how this will work once merged upstream
<livcd> so sorbet is more of a band aid than anything
<livcd> but obviously Stripe cant wait and needs the solution now
<z64> "the IIRC Ruby team clearly has an intention to merge it into the core"; is there a citation on this? i know they want to add type annotations in some form, and rbi files were a candidate, but not including what stripe builds on top of rbi in regular .rb files
<z64> additionally, you have a choice with sorbet to only use the static checker. you don't need to run with the sorbet runtime, so "a program utilizing Sorbet would run a bit slower due to runtime type checking" isn't exactly clear on this
<z64> i agree that its an unfair comparison. ruby has a problem that crystal doesn't; years and years and years of existing ruby code to maintain bw compatibility with
<z64> and crystal has plenty of disadvantages
<FromGitter> <vladfaust> Um.
<FromGitter> <vladfaust> > so "a program utilizing Sorbet would run a bit slower due to runtime type checking" ⏎ ⏎ Thanks, gonna change this
<z64> yeah. check the top of here for a quick breakdown of sorbet's tools; https://sorbet.org/docs/overview - srb is the static checker, and there is a *seperate* gem for the runtime
<z64> "The resource footprint becomes even heavier..."; making suggestions like these without data to back it up doesn't look very good. what this paragraph says is true for just about any new sufficiently complex tool you add to your app, regardless of language. nothing powerful is truly free; you need to make some trade offs somewhere, and data informs whether those tradeoffs are worth it
<FromGitter> <vladfaust> Right, I've removed that paragraph
<FromGitter> <vladfaust> I've applied changes regarding to ⏎ ⏎ > "a program utilizing Sorbet would run a bit slower due to runtime type checking"
<FromGitter> <vladfaust> You're talking about unfair comparison, but isn't that clearly stated in the article that Sorbet is only for type-checking? I fully understand this and use the hype train to advertise Crystal
<z64> what i don't like is you open talking about sorbet but it runs away trying to dismantle ruby as a whole. ruby has tons of advantages over crystal in other areas, and crystal is presented without the same critical obvservations you gave to ruby
<FromGitter> <vladfaust> Yeah, that's true. I'm biased with Crystal
<z64> which is fine - sharing the romantic view of the language is great, showing that it has a clear direction that really inspires people. i just recommend adding some of the usual precautions - it's a 0.X language (but we have an active community to help you keep up with changes); the package ecosystem is weaker than ruby's (which mens plenty of opportunities for the reader to contribute)
<FromGitter> <vladfaust> Will do, thanks
<z64> yw
bars0 has joined #crystal-lang
greengriminal has quit [Quit: This computer has gone to sleep]
<FromGitter> <straight-shoota> @vladfaust Maybe you could insert a code example for using Sorbet, before talking about it's syntax
<FromGitter> <straight-shoota> I don't know how sorbet looks, but you're already talking about the discrepancies
laaron has quit [Remote host closed the connection]
<FromGitter> <vladfaust> There is one
laaron has joined #crystal-lang
<FromGitter> <straight-shoota> Yes, but it's 2 pages after the first mention
return0e has quit [Remote host closed the connection]
<FromGitter> <straight-shoota> But yeah, it could be difficult to fit that in there
<FromGitter> <straight-shoota> Maybe just change the intro: "With all those signatures ..."
<FromGitter> <straight-shoota> This is a reference to something you assume the reader to know about, when in fact he might not.
<FromGitter> <nsuchy> I have a JSON array see https://hacks.sm64hacks.com/api/hack/1/versions, how do I loop over each key in the array (e.g. object 1, object 2, etc) and do something with the value?
<FromGitter> <Blacksmoke16> 2 ways
<FromGitter> <nsuchy> I tried version_data.each do |hack_version| # actions end
<FromGitter> <nsuchy> where
<FromGitter> <nsuchy> version_response = HTTP::Client.get "https://hacks.sm64hacks.com/api/hack/#{i}/data" ⏎ ⏎ ``` version_data = JSON.parse(version_response.body)``` [https://gitter.im/crystal-lang/crystal?at=5ccca78bb489bb6ed70e2fa0]
<FromGitter> <Blacksmoke16> ```JSON.parse(your_json_string).as_a.each do |obj| ⏎ # do something with obj ⏎ end``` [https://gitter.im/crystal-lang/crystal?at=5ccca7911cd0b8307db9ca60]
<FromGitter> <Blacksmoke16> or look into https://crystal-lang.org/api/0.28.0/JSON/Serializable.html then could do something like
<FromGitter> <nsuchy> thanks
<FromGitter> <Blacksmoke16> `Array(Hack).from_json version_response.body`
<FromGitter> <nsuchy> the .as_a method is what I was looking for
<FromGitter> <nsuchy> thank you
<FromGitter> <Blacksmoke16> the 2nd option would make everything easier for you overall
<FromGitter> <vladfaust> Thanks, @straight-shoota, I'll try to see what I can do
<FromGitter> <straight-shoota> You could change it to something like this, which reads better (shorter sentences) and adresses al readers without prior knowledge ⏎ ⏎ > It adds a lot of signatures, mandatory `T::Sig` extensions, magic comments (`# typed: true`) and separate `.rbi` files. This makes Ruby loose its beauty and expressiveness. It's becoming more enterprise like Java, where safety and confidence are crucial.
<FromGitter> <straight-shoota> (shorter sentences are better as well)
<FromGitter> <straight-shoota> Also, what's the "IIRC Ruby team"? Can't find anything on google.
<FromGitter> <straight-shoota> And "clearly has an intention" should be backed up by a citation
<FromGitter> <vladfaust> Yeah I feel that I have problems with short sentences. That's because in Russian we got used to express our thoughts in complex ones :)
<FromGitter> <nsuchy> looks like I might need the second option
<FromGitter> <Blacksmoke16> apparently it thinks your data is a hash
laaron has quit [Remote host closed the connection]
<FromGitter> <vladfaust> > Also, what's the "IIRC Ruby team"? Can't find anything on google. ⏎ ⏎ Thats what a Ruby comitter said in our Crystal Telegram hash. I guess I have to look for origin, that's true
<FromGitter> <nsuchy> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5ccca88d8446a6023ebf5345]
<FromGitter> <nsuchy> Could it be a hash?
laaron has joined #crystal-lang
<FromGitter> <nsuchy> where i in this case is 1
<FromGitter> <straight-shoota> Haha, I'm german. And German loves lots of subclauses :D
<FromGitter> <Blacksmoke16> sec
<FromGitter> <nsuchy> okay wait
<FromGitter> <nsuchy> I am an idiot
<FromGitter> <nsuchy> I was pulling the wrong api endpoint
<FromGitter> <nsuchy> :|
<FromGitter> <Blacksmoke16> that would do it
<FromGitter> <Blacksmoke16> but for reals, id look into option 2
<FromGitter> <nsuchy> I was pulling /data
<FromGitter> <nsuchy> and not /versions
<FromGitter> <Blacksmoke16> will be easier on you so you dont have to do like `.as_` or `as_i` everywhere
<FromGitter> <Blacksmoke16> plus gives you actual objects so can have methods on them etc
<FromGitter> <nsuchy> maybe after I get everything imported
<FromGitter> <nsuchy> I'm weeks behind
<FromGitter> <nsuchy> been so busy studying for finals
<FromGitter> <straight-shoota> > Thats what a Ruby comitter said... ⏎ ⏎ Basing such a strong claim solely on someone's word is not a good idea. If you don't get your facts right, people wont believe you
<FromGitter> <Blacksmoke16> fair enough
<FromGitter> <nsuchy> haven't had as much time for crystal stuff
<FromGitter> <Blacksmoke16> 😒
<FromGitter> <straight-shoota> Another one: ⏎ ⏎ > have many Ruby developers with different skill levels. ⏎ ⏎ I'd say even experienced devolpers don't always get their types right. Typechecking is good for everyone. [https://gitter.im/crystal-lang/crystal?at=5ccca98a8446a6023ebf5a52]
<FromGitter> <nsuchy> Anyways I finally have the import script written meaning I can pull production data then deploy tonight and copy data from my laptop to the server
<FromGitter> <nsuchy> 😁😁😁
<FromGitter> <Blacksmoke16> nice
<FromGitter> <vladfaust> https://youtu.be/cmOt9HhszCI?t=2151 found
<FromGitter> <straight-shoota> @vladfaust And: ⏎ ⏎ > Crystal is a front-end for LLVM ⏎ ⏎ This presents Crystal as a minor addition, on top of LLVM. Obviously, LLVM does the heavy lifting of Crystal's performance, there is no need to argue against. But when promoting Crystal it's better to say `Crystal uses an LLVM backend`. This is more accurate, because LLVM could (theoretically) be swapped out without changing the
<FromGitter> <vladfaust> > I'd say even experienced devolpers don't always get their types right. Typechecking is good for everyone. ⏎ ⏎ Noted,!
<FromGitter> <vladfaust> Isn't it *the* LLVM backend?
<FromGitter> <vladfaust> Nope, it's *an*, I got it. LLVM is framework, the code has to be written for it
<FromGitter> <vladfaust> Thanks for notes, Johannes!
<mps> maybe it will be possible one day to use gcc as 'backend' although I wouldn't count on that
<oprypin> for the last few releases of Crystal i kept checking my projects in case something broke. but nothing ever did. so that's cool
azuri5 has quit [Quit: azuri5]
Yxhuvud has quit [*.net *.split]
beepdog has quit [*.net *.split]
oprypin has quit [*.net *.split]
issyl0 has quit [*.net *.split]
<FromGitter> <bararchy> so... this is unexpected: https://play.crystal-lang.org/#/r/6u07
ashirase has quit [Ping timeout: 255 seconds]
ashirase has joined #crystal-lang
<FromGitter> <jwoertink> yeah, I've been bitten by that too. Because it always returns a `JSON::Any`
<FromGitter> <jwoertink> so looks like a `nil`, but it's not
<FromGitter> <bararchy> yeha :\
<FromGitter> <bararchy> which is strange, because `.inspect` returns => nil
<FromGitter> <jwoertink> what got me one time was seeing that, and calling `.nil?` and it returns false
<FromGitter> <bararchy> yeha
<FromGitter> <bararchy> lol
<FromGitter> <bararchy> `nil : JSON::Any`
<FromGitter> <bararchy> XD
<FromGitter> <bararchy> so it's a nil but of class JSON::Any so it's not falsy
<FromGitter> <bararchy> hmmm
<FromGitter> <jwoertink> but you can do `falsy == nil`
<FromGitter> <jwoertink> or maybe not?
<FromGitter> <jwoertink> it's not great, but it "works"
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/6u0h ?
<FromGitter> <bararchy> Oh, why would unless work
<FromGitter> <Blacksmoke16> nvm, seems to always go to else case
<FromGitter> <Blacksmoke16> even when doing like `JSON.parse("123")`
<FromGitter> <bararchy> yeha, it's always true
<FromGitter> <bararchy> it's not a real `nil` so never false
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/6u0o works tho
<FromGitter> <Blacksmoke16> but ofc it would fail if you gave it a float and tried to cast it to an int
beepdog has joined #crystal-lang
issyl0 has joined #crystal-lang
bazaar has quit [Ping timeout: 250 seconds]
bazaar_ has joined #crystal-lang
return0e has joined #crystal-lang
FromGitter has quit [Ping timeout: 264 seconds]
FromGitter has joined #crystal-lang
bazaar_ has quit [Quit: Reconnecting]
bazaar has joined #crystal-lang
<FromGitter> <jwoertink> I have this error where I'm assigning an instance variable a value, casting it, and saying it's not nil, but it still seems to think it's nil
<FromGitter> <jwoertink> I know on line 18 I can do `@bar.as(Foo::Bar).call` which is fine
<FromGitter> <jwoertink> but I'm curious why when I assign this value, it still doesn't know about it? Does the casting part info not get stored in the variable?
moei has quit [Quit: Leaving...]
jeremycw has quit [Ping timeout: 244 seconds]
<FromGitter> <Blacksmoke16> well `@bar` is typed to `Foo::Bar | Nil`
<FromGitter> <jwoertink> Right. But when I finally assign the value to it, I tell it `@bar = Foo.run.as(Foo::Bar).not_nil!`
<FromGitter> <Blacksmoke16> still doesnt mean it couldnt be nil
<FromGitter> <Blacksmoke16> i.e. if you dont call preload
<FromGitter> <jwoertink> ah
<FromGitter> <jwoertink> right.
<FromGitter> <jwoertink> So the compiler says that no matter what, the type is always `Foo::Bar?`, it's just when doing the `as` part, you're just saying which part of the union you're using at that moment
<FromGitter> <jwoertink> I understood what it was doing, just not how to explain why it was doing that. So that makes sense. now. Thanks
<FromGitter> <Blacksmoke16> yes, np
<FromGitter> <Blacksmoke16> rip, @asterite i still get ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5cccc7b7a4ef09747145367e]
<FromGitter> <Blacksmoke16> prob is a diff issue than that one :/
<FromGitter> <Blacksmoke16> ill see if i can reproduce
<FromGitter> <Blacksmoke16> jesus, thats prob not normal :s