RX14 changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.27.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
<FromGitter> <matthewmcgarvey> this has officially stumped me, but where/what is `parse_or` in the parser file https://github.com/crystal-lang/crystal/blob/master/src/compiler/crystal/syntax/parser.cr#L443 ⏎ it is only used twice in this file and it is no where else in the codebase
<FromGitter> <Bherivy> it's generated by macro?
<FromGitter> <matthewmcgarvey> Ahhh thank you!
<FromGitter> <matthewmcgarvey> What led you to find that? Or how should I have recognized it
<FromGitter> <Bherivy> I am new to Crystal 😂 But when I can't find something, my first thinking is it must be generated by macro
<FromGitter> <girng> lol
<FromGitter> <codematix> Hi, I have seen in many examples and libraries, Hash literals can be written Ruby style as in `{ one: 1, two: 2 }`. I however do not understand why the Crystal documentation does not mention this. Should this literal syntax no be used?
<FromGitter> <matthewmcgarvey> In crystal, those are not hashes but NamedTuples (https://crystal-lang.org/reference/syntax_and_semantics/literals/named_tuple.html)
<FromGitter> <codematix> ah I see
<FromGitter> <matthewmcgarvey> Should the section of the lexer building up a string be converted to using `String.builder` instead of `IO::Memory.new`? https://github.com/crystal-lang/crystal/blob/master/src/compiler/crystal/syntax/lexer.cr#L547
marmotini_ has joined #crystal-lang
DTZUZO_ has joined #crystal-lang
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
_whitelogger has joined #crystal-lang
marmotini_ has joined #crystal-lang
<FromGitter> <j8r> @matthewmcgarvey it can, good catch
<FromGitter> <j8r> `@token.value = String.build ...`
<FromGitter> <j8r> @codematix they are like immutable hashes. Usually, using structs are better for immutable data structures
<FromGitter> <j8r> Look also at the `record` macro
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
laaron has joined #crystal-lang
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
ashirase has quit [Ping timeout: 272 seconds]
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
ashirase has joined #crystal-lang
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
marmotini_ has quit [Ping timeout: 246 seconds]
marmotini_ has joined #crystal-lang
<FromGitter> <ArtLinkov> Hey all, I think there is a bug in the .from_json method while parsing both int and float in an array ⏎ Here is an example: https://play.crystal-lang.org/#/r/62i1
<FromGitter> <ArtLinkov> Is this a known issue?
<FromGitter> <girng> is it possible to add the total amount of time taken in --stats?
marmotini_ has quit [Ping timeout: 245 seconds]
<FromGitter> <bew> you can always use `time` before the command, to get time information on that command
rohitpaulk has joined #crystal-lang
<FromGitter> <proyb6> Which other WebSocket benchmark tool can I use since I think the Thor (NPM) isn't update to date now.
<FromGitter> <girng> @bew thanks i'll give that a shot
<FromGitter> <proyb6> @girng Kemal uses Thor seem broken on NPM now
<FromGitter> <girng> everything on npm is broken ™
<FromGitter> <girng> bahwhahhahah
<FromGitter> <proyb6> Oh this fix ```npm install -g https://github.com/observing/thor```
<FromGitter> <mavu> Why does this: ⏎ `require "yaml" ⏎ ⏎ module Sx10control ⏎ @@config = YAML::Any ... [https://gitter.im/crystal-lang/crystal?at=5c487763dab15872cedd8478]
<FromGitter> <mavu> Its declared one line above?
<FromGitter> <mavu> ```code paste, see link``` ⏎ ⏎ This works (without trying to make config a class property. [https://gitter.im/crystal-lang/crystal?at=5c4878738ce4bb25b8f98fde]
marmotini_ has joined #crystal-lang
<FromGitter> <mavu> could someone explain the difference to me?
<FromGitter> <matthewmcgarvey> This might work ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5c4878c40721b912a5c7053c]
<FromGitter> <mavu> Okay. It does in fact. but why? Whats happening there?
<FromGitter> <Blacksmoke16> id have to say that `@@` denotes a class variable, so that code was running on the class level, which that local var was out of scope
<FromGitter> <Blacksmoke16> can read class vars in class level stuff but ivar/local vars cant be read at class level
<FromGitter> <kinxer> @mavu I suspect it has something to do with the fact that you're in a module. I'd guess that class and instance variables are instantiated before other variables. See this forum topic (https://forum.crystal-lang.org/t/unclear-semantics-of-defs-inside-a-module-or-class/323/2).
<FromGitter> <kinxer> Or what @Blacksmoke16 said. Mine was just a guess.
<FromGitter> <kinxer> It does seem kind of odd to me to have a local variable in a module that isn't an instance or class variable... Are you just trying to make `@@config` more easily customizable in your code?
<FromGitter> <mavu> Ok, i think I'm using module wrong. I'm trying to make config globally accessible without passing it to the initializers of my different classes
<FromGitter> <mavu> I think I need a "anatomy of a Crystal program" kind of help. ⏎ crystal init creates a directory structure which has a .cr file under src/ and that contains ⏎ module projectname ⏎ end ⏎ ... [https://gitter.im/crystal-lang/crystal?at=5c487b6935350772cf78fab2]
<FromGitter> <kinxer> Yeah, you can do that with modules, using class variables as you're doing. What's weird is `config_file`.
marmotini_ has quit [Ping timeout: 240 seconds]
<FromGitter> <kinxer> Are you trying to discard that as soon as you use it?
<FromGitter> <mavu> ok, so the module should only contain class variables and functions, but not program logic, and local variables?
<FromGitter> <Blacksmoke16> also prob be a better idea to use a struct and read the yaml file in, then its type safe vs `@@config` being a bunch of `YAML::Any`
<FromGitter> <kinxer> ^
<FromGitter> <Blacksmoke16> could still use your module be do like
<FromGitter> <Blacksmoke16> ``` class_getter config : Config = Config.from_yaml File.read "path/to/file" ⏎ end``` [https://gitter.im/crystal-lang/crystal?at=5c487c11ba355012a485a91c]
<FromGitter> <Blacksmoke16> where you ofc have a `Config` struct with the properties in the yaml file
<FromGitter> <mavu> Ok, I think I understand that.
<FromGitter> <dscottboggs_gitlab> I don't see any reason to avoid putting logic into modules.
<FromGitter> <dscottboggs_gitlab> Modules allow for a bit of a simulation of a functional workspace if that's what's appropriate. But it is just a simulation: Crystal is a strictly OOP language.
<FromGitter> <mavu> @dscottboggs_gitlab functional workspace as in functional language?
<FromGitter> <kinxer> In terms of having a "main" (or "driver") file, this is the pattern I usually use: https://play.crystal-lang.org/#/r/62jm
<FromGitter> <dscottboggs_gitlab> yeah exactly
<FromGitter> <Blacksmoke16> why not just do
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/62jo
<FromGitter> <kinxer> @Blacksmoke16 That's indeed simpler in this case. My point was to keep logic in methods in the module.
<FromGitter> <Blacksmoke16> yea if its doing more than returning a class var thats prob the way to go
<FromGitter> <kinxer> So here's a more reasonable example: https://play.crystal-lang.org/#/r/62jp
<FromGitter> <mavu> ok, thank you all, that is interesting. I think I need a bit of time to restructure . ⏎ One more question: In the documentation of OptionParser ( https://crystal-lang.org/api/0.18.7/OptionParser.html)
<FromGitter> <mavu> the example of how to use it. how would that relate to packing things in a module and methods?
<FromGitter> <Blacksmoke16> could still call methods inside a module
<FromGitter> <Blacksmoke16> or to set settings from your settings struct
<FromGitter> <Blacksmoke16> well if you're doing that prob best to use a class not a struct
<FromGitter> <girng> i want to make a topic on the forum to get everyones results and time taken to do a benchmark script. and compare it to my system on WSL and see how fast the compiler is. but i believe there are too many variables that wouldn't create good data. any idea?
<FromGitter> <kinxer> @girng Do you mean too many variables about how fast it should be due to differences in everyone's system?
<FromGitter> <gildub> Hi, any idea how far Crystal is from production?
<FromGitter> <mavu> @girng I can run it on my raspberryPi if you want to know how slow it can get :P
<FromGitter> <girng> @kinxer yah exactly!
<FromGitter> <kinxer> @gildub Do you mean 1.0?
<FromGitter> <gildub> @kinxer, yes.
<FromGitter> <girng> like, i'm on a i7 2600. another user might be on raspberry PI, or a 8700k, etc lol
<FromGitter> <fridgerator> @gildub People are already using crystal in production
<FromGitter> <dscottboggs_gitlab> for certain workloads...
<FromGitter> <kinxer> @girng Well, you could have everyone tell you what OS they're on and with what resources (clock speed, ram, etc.).
<FromGitter> <gildub> @fridgerator, yes I know but is not until Windows is supported it won't be 1.0?
<FromGitter> <dscottboggs_gitlab> @gring I would get some weird results I'm on dual-10-year-old-xeons
<FromGitter> <girng> there is a user on the forum that said WSL hinders crystal's compilation process by a lot. just want to see how big of a difference. i guess the best way is to install linux on a separate SSD and just compare the time difference on WSL
<FromGitter> <dscottboggs_gitlab> I was reading earlier that there are some huge performance hits with WSL and IO
<FromGitter> <girng> @kinxer good idea i'll just ask for users to list their specs
<FromGitter> <fridgerator> @gildub I dont know what 1.0 means for the core team, probably windows support + other things
<FromGitter> <mavu> @dscottboggs_gitlab that does not surprise me at all.
<FromGitter> <kinxer> @gildub Are you just wanting to know when Windows will be supported, or are you just using that as an example of why it's now 1.0?
<FromGitter> <dscottboggs_gitlab> yes, from what I've read it's Windows support and Multiprocessing for 1.0, along with some other minor milestones
<FromGitter> <girng> with that said, what's a good generic benchmark script though? like parsing a huge json file with JSON.parse? or what lol i don't know how to make a fair one
<FromGitter> <gildub> @kinxer, if 1.0 means windows support then yes, when (roughly) would that happen? Until then it's not really realistic to propose crystal for a big project.
<FromGitter> <gildub> 839435
<FromGitter> <gildub> Oops
<FromGitter> <dscottboggs_gitlab> There is steady but slow progresss on it.
<FromGitter> <dscottboggs_gitlab> According to some core guys there's not gonna be any ETAs without a lot more funding
<FromGitter> <gildub> Yeah that's the impression I have following on the commits ^^.
<FromGitter> <gildub> I'm going to try bringing some funds (besides just my personal wallet)....
<FromGitter> <dscottboggs_gitlab> that would be awesome I'd love to see crystal gain some more traction
<FromGitter> <gildub> Absolutely!
<FromGitter> <mavu> Well, crystal has my 5$ per month now, so everything will be fine :)
<FromGitter> <j8r> @mavu on opencollective?
<FromGitter> <dscottboggs_gitlab> @mavu has saved the day!
<FromGitter> <mavu> link above that leads to bountysource
<FromGitter> <mavu> @dscottboggs_gitlab not only that, but I also tweeted it to all of my 3 followers!
<FromGitter> <j8r> My opinion - I prefer https://opencollective.com/crystal-lang
<FromGitter> <dscottboggs_gitlab> what's the difference? Maybe they should change the link in the info then
<FromGitter> <j8r> @dscottboggs_gitlab https://github.com/crystal-lang/crystal/issues/6051
<FromGitter> <girng> when doing `time crystal benchmark.cr`, it outputs: ⏎ ⏎ ```real 0m1.410s ⏎ user 0m0.578s ⏎ sys 0m1.000s``` ⏎ ⏎ which one is the time taken to complete execution form start to finish after all io is done in the console? [https://gitter.im/crystal-lang/crystal?at=5c4881f5c45b986d11a8fbb0]
<FromGitter> <dscottboggs_gitlab> @j8r that makes sense but if someone's already donating through bountysource I wouldn't discourage them from doing so. Perhaps someone with the authority to do so could change the link?
<FromGitter> <j8r> there is already a PR
<FromGitter> <j8r> from someone of opencollective
<FromGitter> <dscottboggs_gitlab> ah I was just about to look into that
<FromGitter> <dscottboggs_gitlab> but I meant in the chat info on gitter
<FromGitter> <girng> ROFL at the inactivity fee email
_whitelogger has joined #crystal-lang
<FromGitter> <girng> ok so real is the one i'm looking for, if comparing WSL crap io w/ crystal
<FromGitter> <girng> okay i got this benchmark script. fills up a hash 1 million times, then deletes them all. also parses some json
<FromGitter> <girng> gonna make a forum post and get others to post their results
marmotini_ has joined #crystal-lang
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/62ki
<FromGitter> <Blacksmoke16> basic WIP of that idea i had the other day
moei has joined #crystal-lang
marmotini_ has quit [Ping timeout: 246 seconds]
<FromGitter> <girng> go go go!
<FromGitter> <Blacksmoke16> how does that work, you didnt even `require "benchmark"`
<FromGitter> <Blacksmoke16> ah just based off `time`
<FromGitter> <girng> iuno what i'm doing just please post your results lol
<FromGitter> <girng> i'm very curious aobut the speed differences on other people's OS and cpus
<FromGitter> <Blacksmoke16> will do when i get home
<FromGitter> <girng> 🚀
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/62lp maybe a better example
<FromGitter> <Blacksmoke16> more complete at least
<FromGitter> <girng> omg those results :O
<FromGitter> <Blacksmoke16> RIP RPI
<FromGitter> <Blacksmoke16> you should say `crystal run --release benchmark.cr` btw
<FromGitter> <girng> oops
<FromGitter> <kinxer> Seconded on the RPI benchmark...
<FromGitter> <Blacksmoke16> now im getting curious what im going to get
<FromGitter> <mavu> Raspberry: ⏎ real 0m42.813s ⏎ user 0m49.750s ⏎ sys 0m1.210s [https://gitter.im/crystal-lang/crystal?at=5c4899d71cb70a372a26036a]
<FromGitter> <mavu> :P
<FromGitter> <j8r> RPI3?
<FromGitter> <j8r> Maybe using a 23 bit doesn't help, internally JSON use 64bit
marmotini_ has joined #crystal-lang
<FromGitter> <j8r> I go on Pine64
<FromGitter> <j8r> ```real 0m19.102s ⏎ user 0m18.710s ⏎ sys 0m0.388s``` [https://gitter.im/crystal-lang/crystal?at=5c489db50a491251e3429774]
<FromGitter> <j8r> Quite fast for the price :)
<FromGitter> <girng> @j8r is that your main OS?
<FromGitter> <girng> and CPU
<FromGitter> <j8r> And only 3 times slower than @girng WSL hehe
<FromGitter> <j8r> no, not my main one
<FromGitter> <girng> 😆 . the opensuse results (first post underneath), he got around 1.269 seconds...
<FromGitter> <girng> with i5-8300H
<FromGitter> <j8r> I've 0.50 difference by changing the scaling governor from powersave to performance
<FromGitter> <girng> nice, soon it's gonna be faster than WSL!
bmcginty has quit [Ping timeout: 245 seconds]
<FromGitter> <j8r> I've posted results on my work laptop
<FromGitter> <girng> 1) 55s nice
<FromGitter> <ilanusse> Hey guys!
<FromGitter> <Blacksmoke16> TIL you can add type restrictions to splats
<FromGitter> <Blacksmoke16> o/
<FromGitter> <ilanusse> Any way to calculate coverage on a lib?
<FromGitter> <ilanusse> Maybe a shard or sth?
<FromGitter> <Blacksmoke16> test coverage?
<FromGitter> <ilanusse> Yes, sorry, I wasn't too explicit
<FromGitter> <ilanusse> I'm thinking of porting the Twilio gem btw, if anyone's interested
<FromGitter> <ilanusse> Seems like it's just a copy-paste really
<FromGitter> <ilanusse> https://github.com/anykeyh/crystal-coverage looks promising, thanks @Blacksmoke16 👌
<FromGitter> <Blacksmoke16> np
marmotini has joined #crystal-lang
marmotini_ has quit [Ping timeout: 245 seconds]
rohitpaulk has quit [Remote host closed the connection]
marmotini has quit [Remote host closed the connection]
<FromGitter> <proyb6> I wonder if this benchmark has been changed? ⏎ https://gist.github.com/sdogruyol/bdd400a6eac13e26228e
<FromGitter> <proyb6> Kemal seems to use 500MB+ and Node.js seems to consume less at 100MB+
<FromGitter> <Blacksmoke16> that was quite a while ago so could have changed
<FromGitter> <Blacksmoke16> like over 3 years ago at this point
<FromGitter> <proyb6> Yeah, it's ideal we need a new WebSocket benchmark on Crystal
<FromGitter> <proyb6> To validate the memory usage is still correct or might be a bug
<FromGitter> <bew> @girng note that the compiler has almost no i/o, dont expect to spec that^^
<mps> girng: how to save that bencmark.cr, want to try on Alpine
<mps> copy-paste?
<FromGitter> <girng> @bew oo ⏎ @mps yeh
<mps> ok: 15.669u 1.119s 0:16.13 103.9% 0+0k 0+2232io 0pf+0w
<mps> Alpine on aarch64 on external sd card
bmcginty has joined #crystal-lang
<FromGitter> <mavu> Does crystal have something like Object.methods in Ruby?
<FromGitter> <Blacksmoke16> to return list of methods defined on self?
<FromGitter> <mavu> Just looking to list all properties defined on a class to save some repetition
<FromGitter> <Blacksmoke16> properties, i.e instance vars?
<FromGitter> <mavu> yes
<FromGitter> <Blacksmoke16> sec
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/62ps
<FromGitter> <mavu> Ohh! Perfect, exactly what i was looking for :)
<FromGitter> <mavu> thanks
<FromGitter> <Blacksmoke16> np
<FromGitter> <Blacksmoke16> https://crystal-lang.org/api/0.27.0/Crystal/Macros/TypeNode.html is a bunch of stuff you can access at compile time v
<FromGitter> <mavu> ahh, so thats a macro, creating the contents at compile time. neat. I'm starting to understand where they come into the language design.
<FromGitter> <mavu> Oh, holla there is a lot hidden under that unassuming heading in the documentation.
<FromGitter> <Blacksmoke16> yea, thats all the macro level types
ua_ has quit [Ping timeout: 246 seconds]
ua_ has joined #crystal-lang
<FromGitter> <Blacksmoke16> @girng added my stats