ChanServ changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.31.1 | 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
alex`` has quit [Quit: WeeChat 2.6]
<FromGitter> <asterite> I'll probably code aoc2019 in Crystal again, so happy to share and compare solutions :-)
<hypercore> is crystal good at multicore/processes?
<hypercore> how does it compare to elixir in this regard?
<hypercore> pubsub/realtime stuff
f1refly has quit [Ping timeout: 252 seconds]
f1reflyylmao has joined #crystal-lang
sagax has quit [Remote host closed the connection]
sagax has joined #crystal-lang
<FromGitter> <tenebrousedge> it was just added recently; it's behind a compiler flag at the moment
<FromGitter> <tenebrousedge> I assume Elixir is better, for those people who think that Elixir is a good idea
chemist69 has quit [Ping timeout: 276 seconds]
chemist69 has joined #crystal-lang
ht_ has joined #crystal-lang
ht_ has quit [Quit: ht_]
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Remote host closed the connection]
absolutejam has joined #crystal-lang
absolutejam has quit [Ping timeout: 276 seconds]
absolutejam has joined #crystal-lang
absolutejam has quit [Ping timeout: 265 seconds]
rohitpaulk has joined #crystal-lang
t1|Mike has quit [Quit: ZNC 1.7.1 - https://znc.in]
t1|Mike has joined #crystal-lang
rohitpaulk has quit [Remote host closed the connection]
DTZUZO has quit [Ping timeout: 265 seconds]
<FromGitter> <yxhuvud> @asterite Yeah, me too :)
t1|Mike has quit [Quit: ZNC 1.7.1 - https://znc.in]
absolutejam has joined #crystal-lang
<FromGitter> <bararchy> @asterite \ @bcardiff , is this a bug: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d9aeab9e8de6f3ca0539ad0]
<FromGitter> <yxhuvud> If the scheduler tries to resume a dead fiber, that looks like a bug, yes.
t1|Mike has joined #crystal-lang
dwdv has joined #crystal-lang
<repo> hmm is 5.minutes nowadays returning a float?
<repo> what happened to Time::Span
<repo> oh never mind
<repo> it seems that playground is just pretty printing it as such
<dwdv> What's the GC's collection behaviour? Is it collecting in certain time intervals, possibly after each allocation once certain conditions are met, is it a mixture of both, or a completely different strategy?
absolutejam has quit [Ping timeout: 240 seconds]
absolutejam has joined #crystal-lang
<dwdv> Ah, I see: "GC_malloc will invoke the garbage collector when it determines this to be appropriate" and "garbage collections run mostly incrementally, with a small amount of work performed in response to each of a large number of GC_malloc requests"
gangstacat has quit [Quit: Ĝis!]
return0e has joined #crystal-lang
absolutejam has quit [Ping timeout: 250 seconds]
absolutejam has joined #crystal-lang
<repo> hmmmm
<repo> i get the following error compiling on alpine:
<repo> any ideas?
<repo> ah ok
<repo> there's no 0.31.1 on alpine yet
gangstacat has joined #crystal-lang
alex`` has joined #crystal-lang
tdc has joined #crystal-lang
alex`` has quit [Ping timeout: 245 seconds]
alex`` has joined #crystal-lang
alex`` has quit [Ping timeout: 268 seconds]
alex`` has joined #crystal-lang
_whitelogger has joined #crystal-lang
rohitpaulk has joined #crystal-lang
absolutejam has quit [Ping timeout: 268 seconds]
absolutejam has joined #crystal-lang
<FromGitter> <ImAHopelessDev_gitlab> @hypercore https://crystal-lang.org/2019/09/06/parallelism-in-crystal.html still behind compiler flag as Kai Leahy has stated, but it's def workign nicely. i don't know about performance vs elixir. all i kjnow is some single threaded benchmarks using websockets here (https://kemalcr.com/blog/2016/11/13/benchmarking-and-scaling-websockets-handling-60000-concurrent-connections/).
<FromGitter> <ImAHopelessDev_gitlab> LOL https://www.youtube.com/watch?v=-AQfQFcXac8
HumanG33k has joined #crystal-lang
Human_G33k has quit [Read error: Connection reset by peer]
rohitpaulk has quit [Ping timeout: 240 seconds]
<FromGitter> <bararchy> Is there a way to give a Fiber higher priority over other Fibers? (when this Fiber wake up, make sure it's the next one to schedule)
<FromGitter> <bararchy> @bcardiff is this thing possible?
dwdv has quit [Quit: quit]
alex``` has joined #crystal-lang
alex`` has quit [Ping timeout: 246 seconds]
jrayhawk has quit [Ping timeout: 276 seconds]
jrayhawk has joined #crystal-lang
ternarysolo has quit [Read error: Connection reset by peer]
erdnaxeli has quit [Read error: Connection reset by peer]
beepdog has quit [Write error: Broken pipe]
olbat[m] has quit [Remote host closed the connection]
HumanG33k has quit [Quit: Leaving]
alex``` has quit [Ping timeout: 276 seconds]
alex``` has joined #crystal-lang
DTZUZO has joined #crystal-lang
<FromGitter> <SewerynKaminski> ```a = a.map {|v| [v[0], v[1].to_i] } ⏎ ``` [https://gitter.im/crystal-lang/crystal?at=5d9b4f3f37073b36a0883489]
<FromGitter> <SewerynKaminski> Is there a better way to express this?
<FromGitter> <Blacksmoke16> what is `a`, an array i assume?
<FromGitter> <tenebrousedge> ```a.map! {|(a, b)| [a, b.to_i] }```
<FromGitter> <SewerynKaminski> a = [ ["q", "1"], ["w",2]]
<FromGitter> <Blacksmoke16> what he said ^
<FromGitter> <SewerynKaminski> too many block arguments (given 2, expected maximum 1)
<FromGitter> <Blacksmoke16> you sure? `a.map! {|(a, b)| [a, b.to_i] }`works fine
<FromGitter> <SewerynKaminski> wait a minute
<FromGitter> <SewerynKaminski> ```a=a.map{ | (a,b) | [a, b.to_i] }``` is fine
<FromGitter> <SewerynKaminski> thx
<FromGitter> <tenebrousedge> reassignment should be avoided
<FromGitter> <SewerynKaminski> but ``` a.map!{ | (a,b) | [a, b.to_i] }``` give Error: no overload matches 'Pointer(Array(String))#[]=' with types Int32, Array(Int32 | String)
<FromGitter> <Blacksmoke16> with what input?
<FromGitter> <SewerynKaminski> ```a = [ ["q", "1"], ["w", "2"]]```
ht_ has joined #crystal-lang
<FromGitter> <Blacksmoke16> ah interesting, it works if you make one of the numbers not a string
<FromGitter> <SewerynKaminski> yes
<FromGitter> <Blacksmoke16> or add a ` of Array(String | Int32)`
<FromGitter> <Blacksmoke16> basically is just a typing issue
<FromGitter> <tenebrousedge> ^
<FromGitter> <tenebrousedge> https://play.crystal-lang.org/#/r/7q2a
<FromGitter> <alehander42> you dont need that if you use map {} tho i guess
<FromGitter> <alehander42> map! updates in place
<FromGitter> <SewerynKaminski> ? dont update in place
<FromGitter> <Blacksmoke16> using `map!` will most likely be more performant
<FromGitter> <Blacksmoke16> the issue is `map` returns a new array with a diff type, since `map!` updates self, the original array must be typed so that it can handle the change in type
<FromGitter> <SewerynKaminski> @tenebrousedge thx for the trick witch ```of Array(String | Int32) ```
<FromGitter> <tenebrousedge> if you're continuing the function chain, `map` is fine. But reassigning variables is something of a code smell
<FromGitter> <alehander42> sorry https://crystal-lang.org/api/0.31.1/Array.html#map!(&block)-instance-method
<FromGitter> <Blacksmoke16> i.e. going from `Array(Array(String))` to `Array(Array(String | Int32))`
<FromGitter> <alehander42> but indeed, it sounds weird
<FromGitter> <alehander42> overally i'd use tuples
<FromGitter> <alehander42> if your 0-st element is always string
<FromGitter> <alehander42> and second int
<FromGitter> <alehander42> String | Int32 for both fields isn't very specific
<FromGitter> <SewerynKaminski> i'm reading te data from file
<FromGitter> <SewerynKaminski> and then convert string + int
<FromGitter> <tenebrousedge> so the string value can't be avoided
<FromGitter> <Blacksmoke16> or even just read it in as structs, and convert the input of `b` to `Int32` on initialize
<FromGitter> <tenebrousedge> hmm, that's a thing
<FromGitter> <alehander42> yeah, what are you using to deserialize
<FromGitter> <alehander42> from the file
<FromGitter> <SewerynKaminski> the file is text file
<FromGitter> <SewerynKaminski> every line contain diferent length
<FromGitter> <SewerynKaminski> ex. Faerun to Tristram = 65
<FromGitter> <alehander42> great
<FromGitter> <alehander42> and what do you do, do you just split each line
<FromGitter> <Blacksmoke16> prob each line split('=')
<FromGitter> <SewerynKaminski> always <string> to <string> = <int>
<FromGitter> <SewerynKaminski> yes, after split i have ["Faerun to Tristram", "65"]
<FromGitter> <SewerynKaminski> and here is te fun!
<FromGitter> <SewerynKaminski> how to get ["Faerun to Tristram", 65]
<FromGitter> <SewerynKaminski> thx guys for your help!
<FromGitter> <absolutejam_gitlab> > Faerun to Tristram
<FromGitter> <absolutejam_gitlab> Nice
<FromGitter> <alehander42> i'd map it to a new structure
<FromGitter> <absolutejam_gitlab> Toril to Earth
<FromGitter> <alehander42> later it would be much easier to use
<FromGitter> <alehander42> because you'll know which [0] or .name is string and which number
<FromGitter> <alehander42> i really feel people overuse A | B
<FromGitter> <alehander42> but i am not a good crystal coder, so take this with much salt :P
<FromGitter> <SewerynKaminski> structures are nice
<FromGitter> <alehander42> you can even have a tuple, if a structuree feels over the top
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/7q2m could do something like that
<FromGitter> <Blacksmoke16> depends what the end goal is
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/7q2o sorry had the regex backwards
<FromGitter> <SewerynKaminski> nice :)
absolutejam has quit [Ping timeout: 268 seconds]
<FromGitter> <Blacksmoke16> might be able to do something more performant if you need, with like `Char::Reader` or whatever
<FromGitter> <Blacksmoke16> but as i said, depends on what the end goal/use case of it is
<FromGitter> <SewerynKaminski> for me this is fine :)
<FromGitter> <Blacksmoke16> 👍
<FromGitter> <ImAHopelessDev_gitlab> :D
beepdog has joined #crystal-lang
<FromGitter> <ImAHopelessDev_gitlab> First time I self-referenced a TYPE!!!
<FromGitter> <ImAHopelessDev_gitlab> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d9b6b6f04592546720de675]
<FromGitter> <tenebrousedge> could that be a `Struct` ?
<FromGitter> <ImAHopelessDev_gitlab> Works great! classes are sooo nice
<FromGitter> <ilanpillemer> trees are done that way
<FromGitter> <ImAHopelessDev_gitlab> @tenebrousedge i think so
<FromGitter> <ilanpillemer> classes are references and strucrs are values, right?
<FromGitter> <kinxer> Can structs self-reference now?
<FromGitter> <tenebrousedge> yes
<FromGitter> <firejox> you can use pointer
<FromGitter> <ilanpillemer> how do you specifiy a pointer? &?
<FromGitter> <ilanpillemer> *?
<FromGitter> <ImAHopelessDev_gitlab> lol i always forgot about structs cuz i've been using classes so much
<FromGitter> <ImAHopelessDev_gitlab> @j8r better not c this :laugh:
<FromGitter> <firejox> pointerof or use the trick of proc
<FromGitter> <kinxer> @firejox Trick of `proc`?
<FromGitter> <firejox> (->self.itself).closure_data
<FromGitter> <firejox> that return self pointer
<FromGitter> <tenebrousedge> huh
<FromGitter> <ilanpillemer> could you alias that?
<FromGitter> <ilanpillemer> so its nicer looking?
<FromGitter> <firejox> the type is Pointer(Void), easy to alias
<FromGitter> <ilanpillemer> thanks!
<FromGitter> <firejox> I have tried this to write some linked list
rohitpaulk has joined #crystal-lang
<FromGitter> <ilanpillemer> ring?
<FromGitter> <firejox> yes, it's ring.
<FromGitter> <ilanpillemer> nice
DTZUZU has quit [Quit: WeeChat 2.2]
<FromGitter> <nsuchy> We open sourced our Docker & Shards Configuration based on Debian Stable for those interested https://github.com/ulayer/DockerCrystalAmber, we removed the built-in postgres server as we have a central server with all databases and disabled auto migrate in favor of manual hands on migrations. It includes hash checking to make sure the file hasn't somehow changed since we last reviewed Amber and a Crystal version
<FromGitter> ... :) ⏎ ⏎ Would appreciate any feedback the community has.
erdnaxeli has joined #crystal-lang
olbat[m] has joined #crystal-lang
ternarysolo has joined #crystal-lang
<FromGitter> <ImAHopelessDev_gitlab> nice
<FromGitter> <ImAHopelessDev_gitlab> ii've never used docker, but if it's crystal related it deserves a star
<FromGitter> <tenebrousedge> @nsuchy shouldn't this be `node_modules` ? ⏎ `RUN rm -rf /app/node_module`
<FromGitter> <tenebrousedge> the `groupadd` stuff should be at the beginning of the Dockerfile for best performance
<FromGitter> <tenebrousedge> and it's probably a better idea to use `USER` to switch user at the beginning rather than `chown` at the end
<FromGitter> <tenebrousedge> running as root the whole time within the container is not usually the best option
DTZUZU has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 240 seconds]
<FromGitter> <tenebrousedge> for my projects I allow $USER_ID and $GROUP_ID to be passed in, that way any files they create can be owned by my local user -- otherwise you tend to leave a bunch of root-owned files lying around the local filesystem
<FromGitter> <tenebrousedge> if there's not a good reason to use docker-compose config version 2, use the current version
<FromGitter> <Blacksmoke16> also don't forget about `.dockerignore`
<FromGitter> <tenebrousedge> I would probably have the `install` scripts handle their own dependencies
<FromGitter> <tenebrousedge> but that may not be good for performance; I'm not sure
<FromGitter> <Blacksmoke16> could also use multiple images, i.e. start off with a base crystal image, then from there you can define other images based on that with additional stuff
<FromGitter> <Blacksmoke16> so that if you need to add something common to all images it would just work
dannyAAM has quit [Quit: znc.saru.moe : ZNC 1.6.2 - http://znc.in]
dannyAAM has joined #crystal-lang
absolutejam has joined #crystal-lang
<FromGitter> <ImAHopelessDev_gitlab> hey @Blacksmoke16
<FromGitter> <Blacksmoke16> hi
absolutejam1 has joined #crystal-lang
absolutejam has quit [Ping timeout: 240 seconds]
absolutejam2 has joined #crystal-lang
absolutejam1 has quit [Ping timeout: 276 seconds]
<FromGitter> <ilanpillemer> man, initialize is so easy to misspell
<FromGitter> <ilanpillemer> why cant it be init?
<FromGitter> <tenebrousedge> because Ruby
<FromGitter> <ilanpillemer> so are Rubyists really good spellers of long words?
Nekka has quit [Quit: zzz]
<FromGitter> <tenebrousedge> no, probably Ruby got it from Smalltalk
<FromGitter> <ilanpillemer> So its Alan Kay’s fault?
<FromGitter> <tenebrousedge> most likely
Nekka has joined #crystal-lang
<FromGitter> <ImAHopelessDev_gitlab> lol
<FromGitter> <bew> @ilanpillemer I never type it manually, I configured my editor to have a snippet on `ini` that expands to an initialize definition :P
<FromGitter> <ImAHopelessDev_gitlab> @bew is alive, wow
<FromGitter> <ilanpillemer> Acme doesnt work that way
<FromGitter> <ilanpillemer> its one of the things I have to give up to get others things I like
<FromGitter> <ilanpillemer> so I *have* to type it
<FromGitter> <ilanpillemer> ok. I guess I could create something that generates me an template with the word initialize in it..
<FromGitter> <ilanpillemer> but I doubt I will
<FromGitter> <ImAHopelessDev_gitlab> guard clauses > all
<FromGitter> <ImAHopelessDev_gitlab> eZ
Nekka has quit [Ping timeout: 245 seconds]
<FromGitter> <ilanpillemer> I am having a go at the binary tree exercism now
<FromGitter> <ilanpillemer> tahts huge
<FromGitter> <Blacksmoke16> release mode?
Nekka has joined #crystal-lang
<FromGitter> <ilanpillemer> is the total 233MB?
<FromGitter> <bararchy> it's just RAM
<FromGitter> <Blacksmoke16> ^
<FromGitter> <bararchy> the bin size is really small
<FromGitter> <ilanpillemer> phew
<FromGitter> <bararchy> it's not Go ;)
<FromGitter> <bararchy> or Rust TBH which also somehow produces huge bins
<FromGitter> <ilanpillemer> my Go binaries tend to be about 7MB at the moment
<FromGitter> <ImAHopelessDev_gitlab> @Blacksmoke16 first (https://i.gyazo.com/9f0ba58d7981a6b59a9d426a2927cb64.png) time with --release, second time (https://i.gyazo.com/d9cb109a7d3e5bd1fdb77638ba13c917.png) with --release (no files changed)
<FromGitter> <Blacksmoke16> i could believe it
<FromGitter> <Blacksmoke16> i bet its WSL slowing it down a bit tho
<FromGitter> <Blacksmoke16> i dont have a large codebase to test stuff on, suppose building the compiler would be the most standardized one
<FromGitter> <ImAHopelessDev_gitlab> oh yeah for sure. after looking at the wsl benchmark thread on forum, wsl for compiling is very slow in comparison
<FromGitter> <ImAHopelessDev_gitlab> i just wanted to show those s/s at first, because i added in that Total Time line :)
Nekka has quit [Ping timeout: 240 seconds]
<FromGitter> <Blacksmoke16> ah nice one :slight_smile:
<FromGitter> <ImAHopelessDev_gitlab> thx :)
<FromGitter> <Blacksmoke16> going to make a PR?
<FromGitter> <ImAHopelessDev_gitlab> maybe ahah
<FromGitter> <ImAHopelessDev_gitlab> @Blacksmoke16 did you know, WSL added a editing server for unix files lol. i got to fiddle around inside compiler.cr and progress_tracker.cr in crystal's source
<FromGitter> <ImAHopelessDev_gitlab> was pretty fun/interesting
<FromGitter> <Blacksmoke16> why couldn't you have done that before?
<FromGitter> <Blacksmoke16> not really any diff than editing files locally and running a program no?
<FromGitter> <ImAHopelessDev_gitlab> i'd have to edit the files in console or something which i don't know how to use, much easier to edit them vscode
<FromGitter> <Blacksmoke16> why would you have to do that?
<FromGitter> <Blacksmoke16> i.e. you would just fork the repo and pull it down locally and then its just like any other crystal shard?
<FromGitter> <ImAHopelessDev_gitlab> to modify crystal's src to re-compile
<FromGitter> <tenebrousedge> nano is pretty easy to use if you have to
<FromGitter> <ImAHopelessDev_gitlab> @Blacksmoke16 i think u know this already, but basically it's cause on WSL, previously you were not allowd to edit unix files on windows with an editor, because of potential corruption
ht_ has quit [Quit: ht_]
<FromGitter> <Blacksmoke16> oh, then how do you edit your other crystal files?
<FromGitter> <ImAHopelessDev_gitlab> but now, since the new editing server, it's just like you are editing a windows file, but the file is inside ubuntu's directory
<FromGitter> <ImAHopelessDev_gitlab> those are in a seperate folder on desktop, outside of the mounted ubuntu os
<FromGitter> <ImAHopelessDev_gitlab> lol sht. i hope i'm explaining it correctly
<FromGitter> <absolutejam_gitlab> what's the proper term for a question method?
<FromGitter> <bararchy> `def bool?`
<FromGitter> <Blacksmoke16> the api docs use `query getter method`
<FromGitter> <bararchy> like this you mean?
<FromGitter> <absolutejam_gitlab> yeah
<FromGitter> <Blacksmoke16> https://crystal-lang.org/api/master/Object.html#getter?(*names,&block)-macro
<FromGitter> <ImAHopelessDev_gitlab> how (https://i.gyazo.com/ae158c0c75a4ed0a2bcc4c7039245e15.png) it looks like with the new editing server, how (https://i.gyazo.com/b8b26afd96569f5ffb6bbc004716546c.png) i could edit my source .cr files before.
<FromGitter> <absolutejam_gitlab> wow... catchy
<FromGitter> <ImAHopelessDev_gitlab> my resulting executable is 6.1MB (--static, --release)
<FromGitter> <ilanpillemer> nice!
<FromGitter> <ilanpillemer> that is a good size for a microservice
<FromGitter> <Blacksmoke16> its prob not really statically linked tho, just a heads up ^
<FromGitter> <Blacksmoke16> i.e. do a `ldd ./myApp`
<FromGitter> <ImAHopelessDev_gitlab> i got json, mysql some other goodies in there as well
<FromGitter> <ImAHopelessDev_gitlab> what's ldd
<FromGitter> <Blacksmoke16> could also do `--no-debug` for a prod ready binary, would make it a bit smaller
<FromGitter> <Blacksmoke16> could even follow up with `strip ./myApp`
<FromGitter> <ImAHopelessDev_gitlab> ` not a dynamic executable`
<FromGitter> <ImAHopelessDev_gitlab> @Blacksmoke16 , from `ldd`
<FromGitter> <Blacksmoke16> uh
<FromGitter> <ImAHopelessDev_gitlab> @ilanpillemer thx. yeah, i usually just --static, and --release, and drag n drop it into my vps and it runs perfect
<FromGitter> <tenebrousedge> @absolutejam_gitlab a predicate method, technically
<FromGitter> <ImAHopelessDev_gitlab> omg when I run ./GameServer it's like instant fast
<FromGitter> <ImAHopelessDev_gitlab> oh derp, no compiler
<FromGitter> <ImAHopelessDev_gitlab> i want to try that lto thing
Nekka has joined #crystal-lang
<FromGitter> <ImAHopelessDev_gitlab> `: Use ThinLTO, improving performance on release builds.`
<FromGitter> <ImAHopelessDev_gitlab> how important is this?
<FromGitter> <absolutejam_gitlab> ty @tenebrousedge
<FromGitter> <ImAHopelessDev_gitlab> wow, with `--no-debug`, went from 6.1MB to 4.1MB
<FromGitter> <ilanpillemer> is that calling out to c libraries?
<FromGitter> <ilanpillemer> or is everything in the binary?
<FromGitter> <Blacksmoke16> there are prob some system dependencies since its not fully statically linked
<FromGitter> <ImAHopelessDev_gitlab> wow!! just did `strip`, and it went from 4.1MB to 2.9MB
<FromGitter> <ImAHopelessDev_gitlab> how low can this baby go?
<FromGitter> <Blacksmoke16> if you dont statically link it would be less
<FromGitter> <Blacksmoke16> since it wouldn't have to include some libs in the binary itself
<FromGitter> <ImAHopelessDev_gitlab> do i need to static link if i'm using the mysql/db shard?
<FromGitter> <Blacksmoke16> static linking just includes required libs in the binary itself, i.e. making it more portable
<FromGitter> <Blacksmoke16> but it shouldnt matter if your host and server have the same deps/libs installed
<FromGitter> <ImAHopelessDev_gitlab> oh, yeah i think static linkking is what i need. cause i don't install crystal on vps
<FromGitter> <ImAHopelessDev_gitlab> i just drop it in and it's good to go i liek that
<FromGitter> <Blacksmoke16> not quite the same
<FromGitter> <Blacksmoke16> crystal is used to compile the binary, its not used itself
<FromGitter> <Blacksmoke16> i mean things like `lib-xml` or `lib-yaml`
<FromGitter> <ImAHopelessDev_gitlab> oh
<FromGitter> <ImAHopelessDev_gitlab> iuno, last time i tried without static linking, i had errors when i executed it on the vps
<FromGitter> <ImAHopelessDev_gitlab> so i just static link now, this filesize is fine anyway it's so low alredy
<FromGitter> <Blacksmoke16> fair enough
<FromGitter> <ImAHopelessDev_gitlab> that's kinda cool, though. it's like all there
<FromGitter> <ImAHopelessDev_gitlab> in one executable, all my code
<FromGitter> <ImAHopelessDev_gitlab> all my work
<FromGitter> <ImAHopelessDev_gitlab> all the shards from other users
<FromGitter> <ImAHopelessDev_gitlab> i just signed up on exercism
<FromGitter> <ImAHopelessDev_gitlab> who creates the "Crystal Tracks"?
<FromGitter> <ilanpillemer> each with object lets you add an accumulator?
<FromGitter> <ilanpillemer> @tenebrousedge have you done the binary tree?
<FromGitter> <ilanpillemer> busy trying to get my head around how to implement `each`
<FromGitter> <ImAHopelessDev_gitlab> i'm watching https://www.khanacademy.org/math/pre-algebra/pre-algebra-factors-multiples/pre-algebra-factors-mult/v/finding-factors-of-a-number and working on the raindrops example
<FromGitter> <ilanpillemer> if you divide a number by `f` and there is no remainder.. its a factor. Also a factor will never be greater than half the number.
<FromGitter> <tenebrousedge> @ilanpillemer yes, and maybe, but the code isn't on this computer
<FromGitter> <tenebrousedge> I remember it as a pain in the butt
<FromGitter> <ilanpillemer> where in the standard library source code are examples?
<FromGitter> <tenebrousedge> for `each` I would do something like: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d9baae8464b432fc1d93782]
<FromGitter> <tenebrousedge> examples maybe take a look at `Range`
<FromGitter> <ImAHopelessDev_gitlab> so it can't have a remainder to be a factor?
<FromGitter> <ilanpillemer> by definition
<FromGitter> <ImAHopelessDev_gitlab> wait so why does khan stop at 10 in that video
<FromGitter> <ilanpillemer> I dont know as I dont use Khan academy
<FromGitter> <ImAHopelessDev_gitlab> bascially, he's using factors of `120`
<FromGitter> <ilanpillemer> 60 is a factor
<FromGitter> <ilanpillemer> and that is bigger than 10
<FromGitter> <kinxer> You can find all the factors by checking the numbers whose squares are smaller or equal to the number you're factoring.
<FromGitter> <kinxer> I haven't watched the video, but I'd guess he stops at 10 because you can use the quotient as the other factor.
<FromGitter> <ilanpillemer> is 60 not a factor?
<FromGitter> <kinxer> 60 is a factor, which you can find by dividing by 2.
<FromGitter> <ilanpillemer> ok
<FromGitter> <ImAHopelessDev_gitlab> so let me get this straight. factors are basically numbers that can "EVENLY" be multiplied into a whole number without a remainder???
<FromGitter> <kinxer> That's a way of saying that, yes.
<FromGitter> <ilanpillemer> how you multiply oddly?
<FromGitter> <ImAHopelessDev_gitlab> floats?
<FromGitter> <ilanpillemer> are right
<FromGitter> <ImAHopelessDev_gitlab> haha iuno
<FromGitter> <ImAHopelessDev_gitlab> @kinxer thanks. okay ithink i got them now
<FromGitter> <kinxer> No problem. I'm glad things are clear.
<FromGitter> <ilanpillemer> I am getting quite confused trying to work out how to implement each
<FromGitter> <kinxer> This is for a Binary Search Tree?
<FromGitter> <ilanpillemer> yes
<FromGitter> <ImAHopelessDev_gitlab> @kinxer i'm working on the Raindrops example on Exercism ^^
<FromGitter> <ilanpillemer> I cant seem to call each on the sub trees from within each
<FromGitter> <ilanpillemer> tells me its infinite
<FromGitter> <ilanpillemer> because it inlines
<FromGitter> <ilanpillemer> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d9baedf7aa5602ffc88632e]
<FromGitter> <ilanpillemer> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d9baf91940b4c2fc091f100]
<FromGitter> <tenebrousedge> you can't use `each` within `each`
<FromGitter> <tenebrousedge> you need a `browse` method
<FromGitter> <kinxer> Could you make an Iterator (https://crystal-lang.org/api/0.31.1/Iterator.html) for it?
<FromGitter> <tenebrousedge> yes
<FromGitter> <tenebrousedge> but it's also not pretty
<FromGitter> <tenebrousedge> `Range` has an example of that
<FromGitter> <kinxer> Would `browse` recursively build some kind of `Enumerable` to `#each` on?
<FromGitter> <kinxer> @ImAHopelessDev_gitlab Remember that `%` is your friend.
<FromGitter> <ilanpillemer> I tried that and got same error
<FromGitter> <ilanpillemer> ```code paste, see link```
<FromGitter> <ilanpillemer> ok. so I was trying to do the impossible.
<FromGitter> <ilanpillemer> at least that explains it
<FromGitter> <tenebrousedge> `browse` would walk the tree with an accumulator
<FromGitter> <ilanpillemer> yes, I get it now
<FromGitter> <ilanpillemer> I am busy doing that now. :)
<FromGitter> <tenebrousedge> I was responding to kinxer
<FromGitter> <kinxer> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d9bb395940b4c2fc0920e39]
<FromGitter> <tenebrousedge> something like that, yeah
<FromGitter> <kinxer> That's what I was thinking (in terms of greedy enumeration)
<FromGitter> <kinxer> The upside of the `Iterator` is primarily memory usage, I'd assume
<FromGitter> <tenebrousedge> probably
<FromGitter> <ilanpillemer> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d9bb4225173c33ca18721b0]
<FromGitter> <tenebrousedge> you can't just do `traverse.each do |v|` ?
<FromGitter> <ilanpillemer> yes you can
<FromGitter> <ilanpillemer> now it does
<FromGitter> <ilanpillemer> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d9bb4770e67130aae31282c]
<FromGitter> <tenebrousedge> rather than casting you might do `left.try &.traverse(acc)`
<FromGitter> <kinxer> @tenebrousedge Is there a benefit to using the accumulator rather than creating a new array in each call? Less allocation?
<FromGitter> <Blacksmoke16> i think he means why not just do all that within .each
<FromGitter> <kinxer> I actually think it's cleaner as he has it. You need that much to be happening in `#traverse` either way.
<FromGitter> <ilanpillemer> so `left.try` checks for `nil` and the casts?
<FromGitter> <tenebrousedge> `try` basically is a no-op if the value is nil
<FromGitter> <ilanpillemer> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d9bb5105173c33ca187297e]
<FromGitter> <tenebrousedge> @kinxer you'd end up creating fewer objects, yes
<FromGitter> <tenebrousedge> those have to be GC'd at some point
<FromGitter> <tenebrousedge> LGTM @ilanpillemer
<FromGitter> <ilanpillemer> so succinct when you get the syntax right
<FromGitter> <ilanpillemer> I was wondering how to do the `Nil` check less clumsily. 👍
<FromGitter> <tenebrousedge> Crystal and Ruby are languages for lazy typists :)
<FromGitter> <ImAHopelessDev_gitlab> ^^
<FromGitter> <ilanpillemer> expect for `initialize`
<FromGitter> <ImAHopelessDev_gitlab> 😆
<FromGitter> <tenebrousedge> touché
<FromGitter> <ilanpillemer> now for `delete`
<FromGitter> <ImAHopelessDev_gitlab> I DID IT
<FromGitter> <ImAHopelessDev_gitlab> @kinxer
jhass has quit [Quit: Bye]
asterite has quit [Quit: Bye]
DeBot has joined #crystal-lang
absolutejam3 has joined #crystal-lang
absolutejam2 has quit [Ping timeout: 245 seconds]
<FromGitter> <ImAHopelessDev_gitlab> i think i broke crystal playground
<FromGitter> <Blacksmoke16> thats not real hard to do :P
<FromGitter> <ImAHopelessDev_gitlab> lol
absolutejam4 has joined #crystal-lang
absolutejam3 has quit [Ping timeout: 240 seconds]
<FromGitter> <ImAHopelessDev_gitlab> hopefully i did it right..
<FromGitter> <Blacksmoke16> why are you using repl.it?
<FromGitter> <Blacksmoke16> its using a quite old version btw
<FromGitter> <ImAHopelessDev_gitlab> crystal playground not loading
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/cr ?
DeBot has quit [Quit: Crystal IRC]
<FromGitter> <ImAHopelessDev_gitlab> yah just spins
<FromGitter> <Blacksmoke16> carc.in spins, playground loads fine or me
<FromGitter> <ImAHopelessDev_gitlab> wtf
<FromGitter> <Blacksmoke16> er playground doesnt execute the code it seems
<FromGitter> <ImAHopelessDev_gitlab> carc spinning (https://i.gyazo.com/11572737595ef57dd5102d4ac004cf0d.gif) for me
<FromGitter> <ilanpillemer> not working for me either
<FromGitter> <ImAHopelessDev_gitlab> i was trying to get my factor_list method working and screwd up with my while loop a couple times, forgot to break out of it and my tab froze
<FromGitter> <ilanpillemer> and you broke the internets
<FromGitter> <ImAHopelessDev_gitlab> basically
<FromGitter> <ImAHopelessDev_gitlab> 😆
<FromGitter> <ImAHopelessDev_gitlab> in any event, that was kinda fun although it took me forever.
<FromGitter> <ImAHopelessDev_gitlab> that's the first 'exercise' i've ever done
<FromGitter> <ImAHopelessDev_gitlab> does it get better???
<FromGitter> <Blacksmoke16> whats the goal of that raindrop thing?
<FromGitter> <ilanpillemer> I thinking I am too tired to do delete and iterators for binary trees.. not sure this one should be classified as `easy`
absolutejam4 has quit [Ping timeout: 276 seconds]
<FromGitter> <Blacksmoke16> build a string based on factors of a number?
<FromGitter> <ilanpillemer> @ImAHopelessDev_gitlab give this a spin https://adventofcode.com/
<FromGitter> <ImAHopelessDev_gitlab> @Blacksmoke16 am not sure. i just saw @ilanpillemer and @tenebrousedge post their solutions to some asnwers
<FromGitter> <elorest> It's an advanced fizzbuzz
<FromGitter> <ImAHopelessDev_gitlab> i'm terrible at puzzle solving cuz my mind reads into things too much and i overthink
<FromGitter> <ilanpillemer> do day 15 of advent of code 2018 if you want to cry
<FromGitter> <elorest> You really should overthing raindrops lol
<FromGitter> <ImAHopelessDev_gitlab> isn't that what asterite does
<FromGitter> <ilanpillemer> https://adventofcode.com/2018/day/15
<FromGitter> <ImAHopelessDev_gitlab> @elorest LOL
<FromGitter> <ImAHopelessDev_gitlab> @ilanpillemer that's too much 4 me
<FromGitter> <ImAHopelessDev_gitlab> i can display the grid and put the G/E on there in the console, but other than that. i have no idea what to do
<FromGitter> <ilanpillemer> well first thing you do is cry
<FromGitter> <ImAHopelessDev_gitlab> 😆
<FromGitter> <ilanpillemer> And then you just keep at it until you work it out
DeBot has joined #crystal-lang
<FromGitter> <ImAHopelessDev_gitlab> i like raindrops exercises better
<FromGitter> <ImAHopelessDev_gitlab> LOL
<FromGitter> <ilanpillemer> I am working through all the exercism too
<FromGitter> <ilanpillemer> though probably only finish binary search tomorrow I suppose. This is the first one that is taking a while
<FromGitter> <ilanpillemer> exercises are good.. its like gym for programmers!
<FromGitter> <Blacksmoke16> `(1..num).select { |val| (num % val).zero? }`
<FromGitter> <Blacksmoke16> would work as well
<FromGitter> <ilanpillemer> nice as succinct!
<FromGitter> <ilanpillemer> though you have to exclude num
<FromGitter> <Blacksmoke16> `(1...num).select { |val| (num % val).zero? }`
<FromGitter> <Blacksmoke16> fixed
<FromGitter> <ilanpillemer> :)
<FromGitter> <ilanpillemer> I like how you can be really succint in Crystal
<FromGitter> <asterite> there's also `divisble_by?`
<FromGitter> <ilanpillemer> is that less typing?
<FromGitter> <Blacksmoke16> `(1...num).select { |val| num.divisible_by? val }`
<FromGitter> <ilanpillemer> more typing!
<FromGitter> <Blacksmoke16> bit more clear tho
<FromGitter> <Blacksmoke16> if you do this a low you would prob define a factors method on Number
<FromGitter> <Blacksmoke16> like
<FromGitter> <ilanpillemer> I am so used to checking with % that `num % factor == 0` is very clear to me…
<FromGitter> <ilanpillemer> but thats probably just me
<FromGitter> <Blacksmoke16> on is more english than the other
<FromGitter> <Blacksmoke16> one*
<FromGitter> <ilanpillemer> but, yes its probably more self documenting
<FromGitter> <ilanpillemer> shows the intent clearly
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d9bc630b385bf2cc6907468]
<FromGitter> <ilanpillemer> might as well just open Int?
<FromGitter> <Blacksmoke16> that would prob make more sense yea
<FromGitter> <Blacksmoke16> you get the point :p
<FromGitter> <ilanpillemer> do you need to specify the return value?
<FromGitter> <Blacksmoke16> not required no
<FromGitter> <ImAHopelessDev_gitlab> rip my code ;p
<FromGitter> <tenebrousedge> the one thing you can't do is: ⏎ ⏎ ```def raindrops(n) ⏎ DROPS.select(&->n.divisible_by?(Int32)) ⏎ # etc``` [https://gitter.im/crystal-lang/crystal?at=5d9bc864464b432fc1da13db]
DeBot has quit [Quit: Crystal IRC]
<FromGitter> <Blacksmoke16> 👍
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d9bc8b6940b4c2fc092aba6]
<FromGitter> <Blacksmoke16> rip @ImAHopelessDev_gitlab
<FromGitter> <ImAHopelessDev_gitlab> wow is it really that much
DeBot has joined #crystal-lang
<FromGitter> <ImAHopelessDev_gitlab> nearly 9x slower, wow
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d9bc8f20459254672109a4a]
<FromGitter> <Blacksmoke16> oh wait
<FromGitter> <Blacksmoke16> its never clearing the array
<FromGitter> <Blacksmoke16> sec
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d9bc929874aeb2d230831d9]
<FromGitter> <tenebrousedge> generating a list of all factors isn't necessary for the problem anyway
<FromGitter> <Blacksmoke16> got worse since it has to allocate the array every time
<FromGitter> <Blacksmoke16> 1) 67x slower now
<FromGitter> <ImAHopelessDev_gitlab> i'm a simple man, when i see a while loop it just makes sense
<FromGitter> <ImAHopelessDev_gitlab> although, select makes sense to me too lol.
<FromGitter> <ImAHopelessDev_gitlab> i don't know
<FromGitter> <Blacksmoke16> most of the time there is a better iterator to use
<FromGitter> <Blacksmoke16> that does prob what you want already
Nekka_ has joined #crystal-lang
<FromGitter> <tenebrousedge> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d9bc9c3940b4c2fc092b352]
Nekka has quit [Ping timeout: 276 seconds]
Nekka_ is now known as Nekka
<FromGitter> <Blacksmoke16> *magic*
<FromGitter> <ilanpillemer> can you just set something to nil? will that get it garbage collected etc?
<FromGitter> <tenebrousedge> you can set it to nil, and then its value will be nil
<FromGitter> <tenebrousedge> but it won't be GC'd unless it's out of scope
<FromGitter> <tenebrousedge> not that I know anything about the GC
<FromGitter> <ilanpillemer> ``` if @left.try &.value == v ⏎ left = nil ⏎ end``` [https://gitter.im/crystal-lang/crystal?at=5d9bcc0692920c36a12d2973]
<FromGitter> <ilanpillemer> this doenst seem to set it to nil
<FromGitter> <tenebrousedge> `left` is a local variable there
<FromGitter> <tenebrousedge> unless you defined a property
<FromGitter> <ilanpillemer> I did
<FromGitter> <ilanpillemer> well a `getter`
<FromGitter> <Blacksmoke16> ```if (l = @left) && (l.value ==v) ⏎ @left = nil ⏎ end``` [https://gitter.im/crystal-lang/crystal?at=5d9bcc4b49c7720aaf835944]
<FromGitter> <tenebrousedge> a `getter` doesn't let you set values
<FromGitter> <tenebrousedge> you need `property`
<FromGitter> <ilanpillemer> still doesnt work
<FromGitter> <tenebrousedge> 👀
<FromGitter> <tenebrousedge> what about Blacksmoke's version?
<FromGitter> <ilanpillemer> that worked?
<FromGitter> <ilanpillemer> why?
<FromGitter> <tenebrousedge> using the property directly should always work
<FromGitter> <ilanpillemer> it doesnt seem to be
<FromGitter> <ilanpillemer> l = left is only true if @left is not nil too I suppose
<FromGitter> <tenebrousedge> does using `self.try &.left=(nil)` work?
<FromGitter> <tenebrousedge> that's explicitly calling the method defined by `property`
<FromGitter> <ilanpillemer> yes it works
<FromGitter> <ImAHopelessDev_gitlab> @tenebrousedge nice
<FromGitter> <tenebrousedge> what about `if @left.try &.value==(v); self.left = nil; end ` ?
<FromGitter> <ilanpillemer> yes, that works too
<FromGitter> <tenebrousedge> so just using the bare `left` seems to be referring to an instance variable
<FromGitter> <tenebrousedge> er
<FromGitter> <tenebrousedge> local variable
<FromGitter> <ilanpillemer> yes, its shadowing for some reason
<FromGitter> <tenebrousedge> well, it should
<FromGitter> <ilanpillemer> I find that unintuitive though. I guess because its in a different scope
<FromGitter> <tenebrousedge> the `property=` is only called if you're outside the object, or explicitly invoking it
<FromGitter> <ilanpillemer> same as `items = items + item` thing
<FromGitter> <tenebrousedge> it's fine to define local variables with the same name as instance variables
<FromGitter> <ilanpillemer> caught my twice now
<FromGitter> <ilanpillemer> ``` if left.try &.value == v ⏎ self.left = nil ⏎ end``` [https://gitter.im/crystal-lang/crystal?at=5d9bcedf9735874673145d25]
<FromGitter> <ilanpillemer> this works
<FromGitter> <tenebrousedge> well, I had to think through this one too
<FromGitter> <ilanpillemer> ``` self.left = nil if left.try &.value == v```
<FromGitter> <tenebrousedge> sure
<FromGitter> <tenebrousedge> I would be tempted to write that as `&.value==(v)` just to make things clear to the reader
<FromGitter> <ilanpillemer> well unlikely to get me three times!
<FromGitter> <ilanpillemer> why is the clearer?
<FromGitter> <tenebrousedge> because otherwise the order of execution might be unclear
<FromGitter> <tenebrousedge> what's being compared there?
<FromGitter> <ilanpillemer> v and value
<FromGitter> <tenebrousedge> is it (left.try &.value) == v ?
<FromGitter> <ilanpillemer> the left.try is just the nil check
<FromGitter> <tenebrousedge> yes
<FromGitter> <tenebrousedge> I'm aware
<FromGitter> <tenebrousedge> someone else might not be
<FromGitter> <ilanpillemer> is it ever used for something else?
<FromGitter> <tenebrousedge> no, but the execution isn't obvious, and the `&.` syntax isn't found in other languages
<FromGitter> <ilanpillemer> yeah its normally `_`
<FromGitter> <Blacksmoke16> hm?
<FromGitter> <ilanpillemer> I think?
<FromGitter> <tenebrousedge> `_` is usually an unused variable
<FromGitter> <tenebrousedge> or lodash
<FromGitter> <ilanpillemer> probably not `_` then.. I am sure Scala has something
<FromGitter> <ilanpillemer> memory is foggy
asterite has joined #crystal-lang
jhass has joined #crystal-lang
<FromGitter> <ilanpillemer> yeah I am right
<FromGitter> <ilanpillemer> ```val evens = x.filter(_ % 2 == 0)```
<FromGitter> <ilanpillemer> that is Scala