ChanServ changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.22.0 | 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
zipR4ND has joined #crystal-lang
whomp has joined #crystal-lang
snsei has quit [Remote host closed the connection]
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<FromGitter> <notnoyyyyy> Hi everybody xD
<FromGitter> <bigtunacan> @notnoyyyyy Welcome!!!!!!
snsei has joined #crystal-lang
whomp has quit [Quit: leaving]
<FromGitter> <notnoyyyyy> Who uses crystal language in production ?
bjz has joined #crystal-lang
<FromGitter> <MatthewBennington> Does anyone know of a way to select a random element of type T from an Array of T?
Raimondii has joined #crystal-lang
Raimondi has quit [Ping timeout: 268 seconds]
Raimondii is now known as Raimondi
zipR4ND has quit [Ping timeout: 272 seconds]
<FromGitter> <elorest> I use crystal in production.
<FromGitter> <fridgerator> @notnoyyyyy https://github.com/kemalcr/kemal/wiki/Kemal-Users
<FromGitter> <drosehn> FWIW, I have a chat system written in lambdaMOO, where 'MOO' means 'MUD, object-oriented'. It's been running for about 20 years now.
<FromGitter> <bigtunacan> Ooooh
<FromGitter> <bigtunacan> lambdas are awesome
<FromGitter> <bigtunacan> porting all of my systems to lambdaMOO RIGHT NOW!!!
<FromGitter> <bigtunacan> :)
<FromGitter> <bigtunacan> Link please?
<FromGitter> <drosehn> I could kinda say that I use crystal in production, although it's "personal production". I have several small crystal programs that I depend on, and use on a daily basis.
<FromGitter> <bigtunacan> I can't even say that yet.
<FromGitter> <bigtunacan> But I hope to soon.
<FromGitter> <bigtunacan> I'm working on my first Kemal site right now.
<FromGitter> <drosehn> lambdaMOO: http://www.moo.mud.org
<FromGitter> <drosehn> (that's the server software, but not the specific chat-system that I have been running)
<FromGitter> <bigtunacan> So is your chat server for the LambdaMOO game then?
<FromGitter> <drosehn> it's just a chat server, an alternative to IRC. we have a few games written into our chat server, but no one uses them any more.
<FromGitter> <bigtunacan> That's cool
<FromGitter> <bigtunacan> Chat has become a sad state of affairs these days.
<FromGitter> <bigtunacan> I have at least 7 chat apps installed right now
<FromGitter> <drosehn> It is, in many ways. But there hasn't been much development on it in the last 10 years. There's only a few people who had learned the lambdaMOO language well enough to get things done in it, and all of us are too busy doing work or with family life.
<FromGitter> <bigtunacan> I hear you there.
<FromGitter> <drosehn> However, there are still a few hundred people who use it on a weekly basis just for chatting.
<FromGitter> <bigtunacan> Between my day job, raising my 3 kids, and trying to help take care of my aging parents there isn't much time left.
<FromGitter> <bigtunacan> I think I've about reached that point where I've had too much to drink to continue programming.
<FromGitter> <bigtunacan> I was staring at the screen wondering why my view wasn't rendering correctly.
<FromGitter> <drosehn> We also made one fatal mistake in the mid-1990's. We were running on a NeXTstation, and NeXTSTEP had a rather obscure bug in it's handling of virtual memory which the lambdaMOO process managed to trigger on a regular basis. I'll skip the details, but the upshot was that at one point we got a *major* improvement by removing all the comments in the MOO-code which implements everything in the chat. And then the
<FromGitter> ... main developer lost track of the snapshot of the database which had all the comments.
<FromGitter> <bigtunacan> Then I finally realized in my ecr content_for I had typed `some_key` as the key instead of my actual key.
<FromGitter> <bigtunacan> :smile:
<FromGitter> <drosehn> heh.
<FromGitter> <drosehn> so we ended up with about 20,000 lines of code with zero comments in it, and then a few years later the main developer left (as he became too busy with "real life"). We've added some comments back as we figured things out.
<FromGitter> <bigtunacan> I think these days they call that "self documenting code"
<FromGitter> <bigtunacan> ;)
<FromGitter> <drosehn> One mistake I'll often make when I get too tired is to keep changing the source code for something, compiling that, and then executing a different copy of the program (which is not changing).
<FromGitter> <bigtunacan> I may have done that once or twice myself
<FromGitter> <drosehn> The youngest daughter of that developer started college just last year, I think.
<FromGitter> <bigtunacan> My oldest girl starts her last year of junior high next year
<FromGitter> <fridgerator> Same
sp4rrow has quit [Quit: Textual]
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
saadq has joined #crystal-lang
<FromGitter> <elorest> My oldest is in first grade next year.
Kug3lis_off is now known as Kug3lis
<FromGitter> <sdogruyol> I just got married 😂
Kug3lis is now known as Kug3lis_off
Kug3lis_off is now known as Kug3lis
Kug3lis has quit [Quit: Textual IRC Client: www.textualapp.com]
Philpax has quit [Read error: Connection reset by peer]
<saadq> hey all, just a guy from ##javascript saying hi
<FromGitter> <bew> Congrats :+1:
<saadq> looks like a pretty dope language
<FromGitter> <bew> Hi saadq :) it is!
bjz has joined #crystal-lang
bjz has quit [Read error: Connection reset by peer]
<FromGitter> <sdogruyol> @saadq hey welcome
bjz has joined #crystal-lang
<FromGitter> <bararchy> Hi saadq , welcome :)
<FromGitter> <bararchy> BTW , if I `fork` to another process , will it share the same Thread ? Or does it have it's own thread ?
Aytan72 has quit [Ping timeout: 246 seconds]
<oprypin> i don't get it
<FromGitter> <akzhan> @bararchy you got same process state.but only current thread will be not in suspended state. it’s by posix.
<FromGitter> <akzhan> some OSes has forkall sys call that save all threads (but didn’t test it).
<FromGitter> <bararchy> 1) The child process is created with a single thread—the one that ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5929540acb83ba6a4103f1f6]
<FromGitter> <bararchy> So this is from the man pages
<FromGitter> <bararchy> So it means fork would keep parent and child running on the same thread right ?
<oprypin> that is impossible
<FromGitter> <akzhan> fork did a copy of thread and other objects like semaphores etc.
<FromGitter> <akzhan> Anyway it is a copy (logically), not the same.
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
Qchmqs__ has joined #crystal-lang
<FromGitter> <bararchy> I think I'm causing confusion and not succeeding in asking my question hahah
<FromGitter> <bararchy> I'll try again,if i do 4.times do fork ...
<FromGitter> <bararchy> Do I actually start 4 new threads ?
<FromGitter> <akzhan> i create 4 new processes with one active thread per process.
<FromGitter> <akzhan> so yes, 4 new threads too.
<FromGitter> <akzhan> and no. process is hevyweight and thread is only part of its state.
<FromGitter> <akzhan> but no other threads will be forked.
<FromGitter> <bararchy> Cool , thanks @akzhan
Kug3lis has joined #crystal-lang
bjz has joined #crystal-lang
Philpax has joined #crystal-lang
Kug3lis is now known as Kug3lis_off
splitty__ has joined #crystal-lang
TheLemonMan has joined #crystal-lang
splitty___ has quit [Ping timeout: 240 seconds]
_whitelogger has joined #crystal-lang
Kug3lis_off is now known as Kug3lis
RX14 has quit [Excess Flood]
RX14 has joined #crystal-lang
bjz has quit [Remote host closed the connection]
bjz has joined #crystal-lang
_whitelogger has joined #crystal-lang
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
bjz has joined #crystal-lang
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
bjz has joined #crystal-lang
bjz_ has joined #crystal-lang
bjz has quit [Ping timeout: 240 seconds]
Raimondii has joined #crystal-lang
Raimondi has quit [Ping timeout: 268 seconds]
Raimondii is now known as Raimondi
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
<crystal-gh> [crystal] Sija opened pull request #4474: Add TypeNode#has_method? (master...fix-4472) https://git.io/vHnKz
bjz has joined #crystal-lang
bjz_ has quit [Ping timeout: 272 seconds]
Kug3lis is now known as Kug3lis_off
TheLemonMan has quit [Quit: "It's now safe to turn off your computer."]
Kug3lis_off is now known as Kug3lis
Qchmqs__ has quit [Ping timeout: 240 seconds]
snsei has quit [Remote host closed the connection]
Kug3lis is now known as Kug3lis_off
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
CodeArtisan has joined #crystal-lang
Kug3lis_off is now known as Kug3lis
Kug3lis is now known as Kug3lis_off
Kug3lis_off is now known as Kug3lis
<CodeArtisan> What's the idiomatic way to read a list of integers from a string? eg: toArrayOfInt("1, 2, 3") -> [1, 2, 3] A split followed by a mapping?
<RX14> split by ", " then map to_i
<RX14> >>"1, 2, 3".split(", ").map(&.to_i)
<DeBot> RX14: # => [1, 2, 3] - https://carc.in/#/r/23aw
<RX14> there
<RX14> >> "1, 2, 3".split(' ').map(&.to_i)
<DeBot> RX14: 0x0: ??? at ?? - https://carc.in/#/r/23ax
<RX14> yeah thought that didn't work
<CodeArtisan> thanks. i presume the temporary array of string is not optimized out
<FromGitter> <akzhan> thanks to @RX14 but just follow with assignment: ⏎ ⏎ https://carc.in/#/r/23az
<RX14> CodeArtisan, no, it's not
<RX14> @akzhan the regex there will make it super duper slow
<RX14> CodeArtisan, if you want speed you can use the block form of split
<RX14> >> a = Array(Int32).new; "1, 2, 3".split(", ") { |s| a << s.to_i }; a
<DeBot> RX14: # => [1, 2, 3] - https://carc.in/#/r/23b0
<RX14> but it's longer and possibly a premature optimization
<CodeArtisan> that will do. thanks.
<FromGitter> <akzhan> Anyone should review #4428 - it’s straitforward one.
<DeBot> https://github.com/crystal-lang/crystal/pull/4428 (Add limits to HTTP request parsing)
<RX14> i've already reviewed it lol
<CodeArtisan> Array(Int32).new or [] of Int32?
<RX14> i like the former
<RX14> but it's really an opinion thing
<RX14> i think the first one is more consistent with other generic types
<RX14> the latter looks nicer if you're used to ruby
<CodeArtisan> the second looks like a type definition
Philpax has quit [Ping timeout: 240 seconds]
<RX14> i guess
<RX14> thats why i said the first is more consistent
<RX14> you have to use Array(Foo) as the type syntax
<RX14> why not get used to it and stick foo on the end
<RX14> instead of adding an entirely new syntax
<RX14> but yeah
<RX14> s/foo/new
<FromGitter> <akzhan> Oops, ok ) missed )
zipR4ND has joined #crystal-lang
Kug3lis is now known as Kug3lis_off
rocky has joined #crystal-lang
Kug3lis_off is now known as Kug3lis
<zipR4ND> hey all, is there a way to call a proc with a different receiver like a block yield ?
<FromGitter> <akzhan> with yield
<zipR4ND> akzhan yes, but I have a proc stored in a variable ..
<zipR4ND> I have a proc that takes one argument and I want to wrap it in a proc that takes two and yields the inner proc with one if the args as default-receiver and the other as the proc arg
<RX14> zipR4ND, no the reciever has to be known to the compiler
<RX14> which is why it only works with yield
<CodeArtisan> couldn't find an answer in the doc; What does it do to prefix a procedure in a module with 'self.'?
<zipR4ND> yeah i see
<zipR4ND> I think I found a solution ..
<RX14> CodeArtisan, self.foo is used to define static methods
<RX14> on classes and modules
<FromGitter> <bew> zipR4ND what solution did you use?
<CodeArtisan> @RX14 but a module can not be instanced, right?
<RX14> yes
<RX14> static methods are on the class
<RX14> not the instance
<FromGitter> <akzhan> usually i made a hash like { what => &self->ever, … } but it is instance specific and syntax may differ.
<CodeArtisan> the module example in the doc has methods without the self prefix but there are modules in the standard library which have method with the self prefix
Kug3lis is now known as Kug3lis_off
<RX14> yes they're used for different things
<RX14> modules can be used as mixins or just namespaces for other classes and methods to live in
<RX14> self.foo in a module means you can call Module.foo
<RX14> just def foo in a module is a mixin which you can include
<CodeArtisan> understood
<rocky> Hi, I'm messing around with crystal fibers and I'm confused as to why when running this code, the program terminates instantly. I don't think anything is blocking, it's just a channel and two infinite loops sending and receiving data to one another. Code: https://pastebin.com/raw/VLhdkr9w
<rocky> ignore the sleep at the very end of the code, that is what I had to insert in order to get it to work, but I'm not sure I understand why I need it in this specific case.
<RX14> rocky, that code should never exit
<RX14> well
<RX14> with the sleep
<RX14> rocky, there is an explicit exit(0) at the end of the top-level code
<RX14> the program doesn't exit when all the fibers exit
<RX14> it exits when the main fiber exits
<RX14> so you need an infinite sleep to make the other fibers run at all
<CodeArtisan> RX14: i presume it's the same with module variables (@@ vs @)
<RX14> @@ is a class-level variable
<RX14> it's static, and again, it works in modules or classes
<RX14> same as self.
<rocky> RX14, thank you for explaining that to me.
<FromGitter> <sdogruyol> @zipR4ND how's your graphql project going :P
<RX14> s/explicit/implicit
* zipR4ND has to leave now ...
<RX14> but you get what i mean
* zipR4ND is working on introspection atm
<zipR4ND> 70-80% i'd say
<zipR4ND> sdogruyol you will be the first to know :)
<FromGitter> <sdogruyol> wow, thank you :)
<zipR4ND> because kemal will have to serve it
<FromGitter> <sdogruyol> yeah, definitely need that
<zipR4ND> check out the specs in the repo to see how far it is (introspection coming in the next days=
<zipR4ND> )
<FromGitter> <bew> Nice trick zipR4ND!
<zipR4ND> thxx
<FromGitter> <sdogruyol> we have @f who's pretty much deep into graphql
<zipR4ND> ok, I well need help anyway as soon as its "works on my machine"-ready
<zipR4ND> ok, bye
<FromGitter> <sdogruyol> see you
<RX14> i guess i should work on crane again
zipR4ND has quit [Ping timeout: 268 seconds]
<FromGitter> <sdogruyol> yeah
<FromGitter> <sdogruyol> crane is definitely needed
<FromGitter> <bew> zipR4ND your trick doesn't seems to work: https://play.crystal-lang.org/#/r/23c7
<CodeArtisan> could i have an example of a module with a variable, please? https://play.crystal-lang.org/#/r/23c9
<FromGitter> <bew> CodeArtisan https://play.crystal-lang.org/#/r/23ca
Kug3lis_off is now known as Kug3lis
Kug3lis is now known as Kug3lis_off
<RX14> wanted to work on windows support but... https://aww.moe/mdmagu.png
<FromGitter> <mgarciaisaia> Just Windows being Windows ;-)
<RX14> there's another 80 after this
<RX14> lol
<RX14> and than I can install visual studio
<RX14> and *then* I can link things
<RX14> or at least try to
<FromGitter> <mgarciaisaia> I've started using the MS official images for testing IE/Edge - they weight ~40G, but you have a legal, kind of up to date Windows VM easily
<FromGitter> <mgarciaisaia> But it's a VM - not native experience, of course
<FromGitter> <fridgerator> yeah those are handy
<FromGitter> <bew> nice "cheat"
<FromGitter> <mgarciaisaia> It's less ilegal than TPB, and they're ~ready to be used 🤷‍♂️
<FromGitter> <mgarciaisaia> Not sure if there are Vagrant boxes for win - maybe that'd work too
<RX14> I have a W7 liscence key from when I used W7 on my desktop
<RX14> so I just use that
<FromGitter> <bew> RX14 maybe it's possible to install only the windows compiler `msvc` without installing visual studio
<FromGitter> <fridgerator> its nice they made the iso availble to download if you have a key
<FromGitter> <fridgerator> this is also handy: https://github.com/felixrieseberg/windows-build-tools
<FromGitter> <fridgerator> node package
<RX14> it's been installing windows updates since 3pm
<RX14> and it's currently 7:30pm
<FromGitter> <fridgerator> lol
<RX14> and my linux package manager does it in 2 minutes
<RX14> i'd have trouble making it that slow
<RX14> i'd need to put effort into making it that slow
<RX14> how do they do ity
<FromGitter> <fridgerator> `sleep 600`
<FromGitter> <bew> :+1:
<FromGitter> <mgarciaisaia> Maybe they run it on Ruby 🤡
<FromGitter> <mgarciaisaia> jk
<FromGitter> <fridgerator> heyooooooo
TheLemonMan has joined #crystal-lang
<FromGitter> <molovo> The modern ie boxes do have vagrant images that work pretty well out of the box: https://github.com/markhuber/modern-ie-vagrant
Philpax has joined #crystal-lang
hako has joined #crystal-lang
hako has quit [Remote host closed the connection]
hako has joined #crystal-lang
<FromGitter> <drujensen> probably a dumb question but is there a way to grab the value of a local variable inside a macro?
<Papierkorb> drujensen, you can just access it
<Papierkorb> drujensen, macros are expanded right where they're "called", it's almost like copy/pasting the code in there
<FromGitter> <drujensen> gotcha, i think you answered my question
<FromGitter> <drujensen> thanks
bjz has joined #crystal-lang
TheLemonMan has quit [Quit: "It's now safe to turn off your computer."]
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
zipR4ND has joined #crystal-lang
braidn[m] has quit [Ping timeout: 245 seconds]
braidn_ has quit [Ping timeout: 240 seconds]
Papierkorb has quit [Ping timeout: 240 seconds]
<FromGitter> <delef> Hello, did anyone use the crypto in version 0.22?
<FromGitter> <delef> Error: Error in src/app.cr:3: while requiring "crypto/md5": can't find file 'crypto/md5' relative to '/home/user/apps/crystal/src'
<FromGitter> <bew> md5 is in `digest` not in `crypto` (https://crystal-lang.org/api/0.22.0/Digest/MD5.html)
Papierkorb has joined #crystal-lang
g3funk has joined #crystal-lang
<FromGitter> <delef> How to use it?
hako has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
CodeArtisan has left #crystal-lang [#crystal-lang]
braidn[m] has joined #crystal-lang
<FromGitter> <delef> @bew thanks!