ChanServ changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.24.2 | 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> <sherjilozair> @Blacksmoke16 R&M
<FromGitter> <Blacksmoke16> 👏
<FromGitter> <sherjilozair> @girng I think you might be overestimating it a bit. Try Unity. It comes with convenient functions like LookAt, etc. which allow you to not worry about quaternion/vector math.
<crystal-gh> [crystal] asterite closed pull request #6024: Don't automatically virtualize two types in the same hierarchy, unless one is deeper than the other (master...feature/dont_virtualize) https://git.io/vp4k5
<FromGitter> <sherjilozair> If you wanna do it properly and learn linear algebra, I'd recommend GIlbert Strang: https://www.youtube.com/watch?v=ZK3O402wf1c
<FromGitter> <sherjilozair> And if you have the time, that is. But I'm guessing you do.
<FromGitter> <sherjilozair> Good grasp on Linear Algebra would help you in games, machine learning, stats, bunch of stuff.
<FromGitter> <sherjilozair> When did this become a gamedev channel though? :D
<FromGitter> <sherjilozair> Btw, found this to be a nice read about OOP: http://journal.stuffwithstuff.com/2012/12/19/the-impoliteness-of-overriding-methods/
<FromGitter> <sherjilozair> Curious to know if people have opinion on this.
<FromGitter> <sherjilozair> HN comments: https://news.ycombinator.com/item?id=16951470
kurko__ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<travis-ci> crystal-lang/crystal#d02c267 (master - Merge pull request #6024 from crystal-lang/feature/dont_virtualize): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/372841303
<DeBot> https://github.com/crystal-lang/crystal/pull/6024 (Don't automatically virtualize two types in the same hierarchy, unless one is deeper than the other)
<FromGitter> <faustinoaq> hehe seems crystal name is more common than I thought 👉 http://www.crystaldb.com/
<FromGitter> <Blacksmoke16> can i assign a variable in an if statement then do additional logic with that var?
<FromGitter> <Blacksmoke16> like
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5ae6814a6d7e07082b4a0add]
<FromGitter> <Blacksmoke16> im thinking no and move the 2nd part to inline
<FromGitter> <Blacksmoke16> yea nvm i like that better
<FromGitter> <Sevensidedmarble> Is it possible to do any interop from rust or go (any low level compiled languages) to crystal the way you can with c?
<FromGitter> <Blacksmoke16> how do i use `JSON::PullParser` with JSON.mapping converter to alter an array of values
<FromGitter> <bew> @Blacksmoke16 yes: `if (param = get_params) && params.size > 0`
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5ae68a586d7e07082b4a2260]
<FromGitter> <Blacksmoke16> think im setting up the block wrong? as the error is ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5ae68aa9109bb04332154fb6]
<FromGitter> <Blacksmoke16> and, nice thanks @bew
<FromGitter> <bew> If you want to read the array but do modifications on it, you can do (in your from_json): read the array first: `Array(Int32).new pull` (pull is the pull parser)
<FromGitter> <bew> Then modify and return the modified array
<FromGitter> <bew> I suggest you to change the pull parser argument from `json` (on your snippet) to `pull`, to better describe what it actually is
<FromGitter> <bew> @Sevensidedmarble yes, the same way you do with C :P
_illy_ has quit [Remote host closed the connection]
<FromGitter> <Blacksmoke16> that worked, thanks again
<FromGitter> <Blacksmoke16> what is the `pull.read_array` for then? just reading the data?
<FromGitter> <Blacksmoke16> still wondering why it errored since the docs says it takes a block
<FromGitter> <Sevensidedmarble> Sorry if it's a dumb question I'm pretty c inept
<crystal-gh> [crystal] MakeNowJust opened pull request #6031: Mark .editorconfig as root (master...fix/editorconfig/root) https://git.io/vpBKs
<FromGitter> <bew> @Blacksmoke16 it takes a block, yes, but with no arguments
<FromGitter> <bew> This is the block's responsibility to read the array's element
<FromGitter> <Sevensidedmarble> What would really be god tier is crystal to webassembly
<FromGitter> <bew> Checkout the array initializer implementation for more info @Blacksmoke16
<FromGitter> <Blacksmoke16> 👍 thanks
<FromGitter> <bew> Wasm can't support languages like crystal yet @Sevensidedmarble
Nathanaelle has joined #crystal-lang
baweaver is now known as baweaver_away
Jenz has joined #crystal-lang
<FromGitter> <girng> @sherjilozair thanks, i'll take a look at the algebra video
<Jenz> Any chance we're going to get `module EnumerableWrapper(T : Enumerable)` kind of syntax?
<Jenz> Would be practical
<FromGitter> <girng> is it possible to send binary over tcp before converting it to string? this way, just convert it to string from client side
<Jenz> That's already what happens is it not?
<FromGitter> <girng> also i think i asked this before but i kinda forgot. ⏎ is it better to have a 15hz tick rate timer in separate fibers? or to use ONE 15hz tick rate game loop
<Jenz> Im no tcp expert, but tcp-socket and server inherits from io, which writes and reads binary
<Jenz> If I haven't misunderstood
<FromGitter> <girng> @jenz ok, thx. seems like i'll keep the same methods: socket.write_bytes, socket.send
<FromGitter> <bararchy> @girng is your initiail data String or Slice ?
<FromGitter> <girng> `payload_size = socket.read_bytes(Int32)` what's that return?
<FromGitter> <girng> slice?
<FromGitter> <bararchy> it returns Int32
<FromGitter> <bararchy> :)
Jenz has quit [Ping timeout: 260 seconds]
<FromGitter> <girng> so i guess, neither
<FromGitter> <girng> hahaha
<FromGitter> <girng> Int32! :D
<FromGitter> <bararchy> I mean, the payload size is just the size, what do you read next?
<FromGitter> <girng> string, raw_message = socket.read_string(payload_size)
<FromGitter> <girng> but, u said "initial" data, so i thought htat's what u meant sorry
<FromGitter> <bararchy> all good, I mean, you said "convert to byte or string" so my question was, what was it originally
<FromGitter> <girng> ```code paste, see link``` ⏎ ⏎ this is part of my Client class. this is fine for my master game server. but for game instance servers with a tick rate, i was thinking maybe i shouldn't use to_json [https://gitter.im/crystal-lang/crystal?at=5ae6d2522b9dfdbc3ae35124]
<FromGitter> <girng> what do you think i should do?
<FromGitter> <girng> if i define structs with json.mappings. is using `to_json` even that bad?
<FromGitter> <bararchy> we had this conversation before XD
<FromGitter> <bararchy> 3 times now I think hahahah
<FromGitter> <bararchy> anyway, the point being is that JSON => easier to understand, but much bigger and harder for computer to parse ⏎ struct => more diffecult to understand, easier for computer and is of minimal size
<FromGitter> <bararchy> for a TCP protocol using JSON makes no sense, for HTTP you already have the overhead of that so it makes more sense
<FromGitter> <bararchy> you only sometime want it to be humand redable
<FromGitter> <bararchy> wow that last sentance is unreadable
<FromGitter> <girng> i understand
<FromGitter> <bararchy> cool :)
<FromGitter> <girng> ok i'll use more structs then for game instance server. i'll stick with to_json for master server
<FromGitter> <bararchy> rule of thumbs is "structs => performance, JSON => readability and easier use"
<FromGitter> <girng> got it, yeah
<FromGitter> <girng> cool!!
<FromGitter> <girng> @bararchy ok, now for tick rate. more appropiate for ONE 15hz tick rate, or put the tick rates in their own fiber, per game?
<FromGitter> <girng> Problem is, for example if 100 games are open, that's a total of 1,500 operations per second, compared to just ONE 15hz tick rate
<FromGitter> <girng> But those 1,500 operations per second are spread out in 16 fibers
<FromGitter> <girng> cause 6 players can join a game, 100/6 = 16
<FromGitter> <girng> 1 fiber per game tick rate, or just do one global tick rate at 15hz, that manages the games
<FromGitter> <girng> loops through them, etc
<crystal-gh> [crystal] veelenga opened pull request #6032: Allow to visit cond node in case (master...fix/visit-when-cond) https://git.io/vpB7J
<FromGitter> <girng> wow, fail. not 1,500 operations per second, it would only be 240!
<FromGitter> <girng> but still, that's far more than just 1 15hz tick rate, but those 240 operations per second are all spread out between 6 fibers.... so how in the hell do i know which way is the right way :O
<FromGitter> <bararchy> Experiment ✨
<FromGitter> <girng> ima do ONE 15hz tick rate first. basically what i did with my nodejs game instance server rofl
<FromGitter> <girng> but i mean, fibers ARE POWERFUL!
<FromGitter> <girng> i feel like if i don't use em im doing something wrong
Jenz has joined #crystal-lang
<FromGitter> <bararchy> well, you should use them to handle incoming clients if you want your gameserver to be able to handle more then 1 connecting client at a time
<Jenz> 244! = Infinity
* Jenz eyes
<FromGitter> <bararchy> ```spawn(server.accept) do |client| ⏎ handle_client ⏎ end ⏎ ``` [https://gitter.im/crystal-lang/crystal?at=5ae6d86e2b9dfdbc3ae36a1c]
<FromGitter> <bararchy> etc..
<FromGitter> <girng> @bararchy well yah. im going to use the same thing as the tcp server example
<FromGitter> <girng> but im talking about a fixed timestep game loop it runs separately
<FromGitter> <girng> it handles monster AI, player movement, etc
<FromGitter> <girng> it runs in a 15hz loop
<FromGitter> <girng> 15 times per second
<FromGitter> <bararchy> I have no idea regarding those things, but my intuition says that the more the game gets big (more mobs, more players) this will be the bottleneck right ?
<FromGitter> <girng> yah
<FromGitter> <bararchy> does any of it relies on IO ?
<FromGitter> <bararchy> or just computational stuff ?
<FromGitter> <girng> yep, 15x messages per second, per player
<FromGitter> <girng> LOL
<FromGitter> <bararchy> oh
<FromGitter> <bararchy> so yeha Fiber it
<FromGitter> <bararchy> it will give you better performance
<FromGitter> <girng> kk
<FromGitter> <girng> :D :D
<FromGitter> <girng> Structs gonna be my best friend :D :D
<FromGitter> <girng> im hungry..gonna make me 2x hotdog
Jenz has quit [Ping timeout: 260 seconds]
<FromGitter> <bararchy> Yeha, it's 12:10pm here, I'll go make me launch also
<FromGitter> <girng> closing spree :D
<FromGitter> <girng> nice one
<FromGitter> <bararchy> yeha
<FromGitter> <bararchy> closing my old stale issues
<FromGitter> <bararchy> if @asterite is going to help close all issues I can at least help a little by closing mines
<FromGitter> <girng> you're a good human
<FromGitter> <bararchy> lol, tbh i'm just selfish
<FromGitter> <bararchy> for me Crystal == profit, i'm doing my best to help Crystal grow
<FromGitter> <girng> =]
<crystal-gh> [crystal] r00ster91 opened pull request #6033: Fix typo in lexer_string_spec.cr (master...patch-14) https://git.io/vpBdR
<FromGitter> <codenoid> hi @Papierkorb
<FromGitter> <codenoid> where i can read a whole crystal qt5 API
<FromGitter> <codenoid> i can't find related function / class inside `src/`
<FromGitter> <sdogruyol> @bararchy everyone's selfish on their own way :P
<FromGitter> <codenoid> i don't like fish
<FromGitter> <codenoid> but i like fish fillet /w chicken fillet
<FromGitter> <girng> i love ariana grande :D
<FromGitter> <bararchy> @sdogruyol lol yeha, it's the Crystal agenda pushing us all forward XD
<FromGitter> <sdogruyol> it's great to see things marching forward 👍
<FromGitter> <girng> if we run another crystal app in 1 server, that uses 2 cores. will both of them each use only 1 core?
<FromGitter> <sdogruyol> Just seen sonicri https://github.com/mjago/sonicri , it's super cool 💯 Congrats @mjago
<FromGitter> <sdogruyol> girng we're currently single-threaded so
<FromGitter> <girng> i was thinking do i really need to have separate game instance servers. i could just use a dedicated server or something, and run another crystal instance
<FromGitter> <girng> have 1 crystal app running for master server, have another crystal app running for game instance
<FromGitter> <girng> if the dedicated server has 4 cores, it would be more than enough
<FromGitter> <girng> but then you can't really horizontally scale
<FromGitter> <sdogruyol> well, you can do that...but it's not so fault-tolerant in case of any failure
<FromGitter> <girng> true
kurko_ has joined #crystal-lang
<FromGitter> <girng> can't wait for my keyboard coming today!!!
<FromGitter> <girng> reallyneed toget this dumb space bar key fixed
shalmezad has joined #crystal-lang
Ven`` has joined #crystal-lang
<FromGitter> <j8r> `Process.pid`/``Process.ppid` returns `Int32` - Should them instead return `UInt16`?
<FromGitter> <sdogruyol> @j8r why?
<FromGitter> <drum445> When creating a lib, what should go in the main.cr file? I'm making this: https://github.com/drum445/finance/tree/master/src ⏎ ⏎ But I don't see what I would ever put in finance.cr except the require?
<FromGitter> <drum445> thanks in advance
<FromGitter> <drum445> Or would I just delete it, and have each file in the root of src?
<z64> depends how you intend your library to be used i guess. if all your libs files are intended to be loaded at once, or individually, thats what having that file will accomplish
<FromGitter> <sdogruyol> it depends
<FromGitter> <sdogruyol> for example we have this in Kemal https://github.com/kemalcr/kemal/blob/master/src/kemal.cr#L9-L86 @drum445
<z64> yeah, thats the other thing. if you library provides some kind of runtime, typically that would be laid out in the "main" file and the internal folders would be all the library code to make it work
<z64> really up to you / how you intend your lib to be used / what it does
<FromGitter> <drum445> ah ok, there isn't any runtime it's just a collection of functions really
<FromGitter> <drum445> so my layout would be ok in that case, with just the root file having one line being the require?
<z64> sure
<FromGitter> <drum445> great, cheers
<z64> the nice thing is that crystal won't codegen things that your programs don't use, so there isn't really a practical cost in requiring everything
<FromGitter> <drum445> So would it be better to just have my payment file in the src folder?
<FromGitter> <drum445> or does it need that finance.cr file and the finance folder?
<FromGitter> <drum445> or just leave as is?
<FromGitter> <asterite> sdogruyol is there any reason why you have to explicitly write Kemal.run at the end? I think it can be done with at_exit
<z64> @drum445 the way you have it right now, users will just have to do `require "finance"` to have your whole library available. if you change it so `payment.cr` is in src, they will have to `require "finance/payment"` explicitly to use it
<FromGitter> <drum445> Ah cool, it's better to have the entire lib available after ```require "finance"``` I reckon, you agree?
<z64> yeah thats usually what i always do, unless i have some strong reason to do otherwise
<FromGitter> <codenoid> hi
<FromGitter> <codenoid> what a fast and easiest way to make a GUI program
<FromGitter> <drum445> cheers @z64
<FromGitter> <codenoid> *fastway
<FromGitter> <girng> Godot
<FromGitter> <j8r> @codenoid what type of GUI program, there are plenty. The really simplest/basic is to use `zenity` for dialog boxes
<FromGitter> <j8r> But back in Crystal, https://github.com/Papierkorb/qt5.cr is nice!
<FromGitter> <codenoid> just like when i make with ms visual basic 2.0
<FromGitter> <r00ster91> https://github.com/sombrastudios/Glass looks interesting too
<FromGitter> <codenoid> https://github.com/Papierkorb/qt5.cr i can't find any API Doc :(
<FromGitter> <j8r> You can use the official QT docs, this is "_just_" a binding
<FromGitter> <bararchy> If it's something simple you can use ncurse :)
Ven`` has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<FromGitter> <codenoid> omg
<FromGitter> <codenoid> yeah
<FromGitter> <codenoid> Fushion/libui has many and good example
<FromGitter> <codenoid> and it was easy
<crystal-gh> [crystal] esse opened pull request #6035: Add Char#code_point method (master...master) https://git.io/vpRZC
<FromGitter> <girng> :D
<FromGitter> <girng> i LOVE CRYSTAL!
<FromGitter> <girng> i split that string up real nice :D
<FromGitter> <j8r> little note: you can use a char instead of a stirng ;-)
<FromGitter> <girng> ty
<FromGitter> <girng> rofl, i used `port_name`. should just be `port` :D
<FromGitter> <j8r> why a String instead of an Hash/Array?
<FromGitter> <girng> well, for now im storing the game instance servers in a GameServers.txt file
<FromGitter> <girng> just 1 server:port per line
<FromGitter> <j8r> A simple INI will be better
<FromGitter> <j8r> but a txt is also fine for this
<FromGitter> <sdogruyol> @asterite it used to use `at_exit` but that has it's own problems
<FromGitter> <girng> puts "Active Game Servers:" ⏎ ⏎ ```puts servers ``` ⏎ ⏎ These lines never get called [https://gitter.im/crystal-lang/crystal?at=5ae71d012d0e228d7bc984f1]
<FromGitter> <sdogruyol> why not?
<FromGitter> <girng> no idea. i think it's cause the tcpsocket deosn't make a connection, and blocks the execution?
<FromGitter> <j8r> `File.open` will be better than `File.read` i think
<FromGitter> <girng> kk changed
<FromGitter> <j8r> because you don't need to return the content, just parse it
<FromGitter> <j8r> I say this but I'm used to use `File.read` for everything :-|
<FromGitter> <stern0> how do I perform a post request with json
<FromGitter> <stern0> ```HTTP::Client.post("www.example.com", body: "{"hello":"world"}")```
<FromGitter> <stern0> is the above correct??
<FromGitter> <j8r> not use with all this quotes `"`
<FromGitter> <stern0> @j8r ???
<FromGitter> <j8r> I've always miss tap in my keyboard :-(
<FromGitter> <j8r> You need to escape this backslashes, or use a variable before
<FromGitter> <girng> can u do body: %s({JSONHERE}) ?
<z64> yes ^, you can omit `s` too, `%({"hello":"world"})`
<FromGitter> <stern0> ```HTTP::Client.post("www.example.com", body: %s("{"hello":"world"}"))```
<FromGitter> <j8r> escape the quotes I would like tos say
<FromGitter> <stern0> can you write an example?
<FromGitter> <girng> z64 just did do that ^^
<FromGitter> <j8r> `%()` is nice 👍
<FromGitter> <stern0> ok thanks
<FromGitter> <j8r> nice stats on Crystal https://github.com/crystal-lang/crystal/pulse :-D
<FromGitter> <girng> okay: https://play.crystal-lang.org/#/r/3z3b so anything after the File.open block doesn't get run. How cna i detect if there is no connection to the server?
<FromGitter> <girng> im browsing here: https://crystal-lang.org/api/0.24.2/TCPSocket.html
<FromGitter> <girng> wait, is new the same as open? https://crystal-lang.org/api/0.24.2/TCPSocket.html#open%28host%2Cport%2C%26block%29-class-method
<FromGitter> <girng> im just creating the class, not actually OPENING a connection
<FromGitter> <girng> i think?
Ven`` has joined #crystal-lang
<FromGitter> <girng> GOT IT
<FromGitter> <girng> `TCPSocket.new(server_name, port.to_i, 0, 1)`. hajve to specify a connection timeout
<FromGitter> <girng> if you don't, it'll block forever lol
<FromGitter> <girng> i'll be use default connection timeout of 3-5 seconds. should be more than enough to establish.
<FromGitter> <girng> `cr:3: undefined constant Nill (did you mean 'Nil')`ROFL fail!!
<FromGitter> <girng> tmw the compiler knows more than a human, feelsbadman
greengriminal has joined #crystal-lang
<FromGitter> <stern0> I need some help with post json data
<FromGitter> <stern0> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5ae730611130fe3d3631ae72]
<FromGitter> <stern0> the above returns `"Invalid JSON input"`
<crystal-gh> [crystal] RX14 closed pull request #5881: Spec: add expectations starts_with, ends_with (master...add_spec_starts_with) https://git.io/vxaaw
Ven`` has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<FromGitter> <bararchy> I want to work on a small game where I use Evolutionary Strategy algorithm to improve the opponent , I think it will be interesting
<FromGitter> <bararchy> The AI will start weak and stupid as hell but should become unstoppable after enough gaming experience
<FromGitter> <girng> will it be top down, or like text based, or?
<FromGitter> <girng> @bararchy your idea sounds interesting, i like it
<travis-ci> crystal-lang/crystal#3e88a62 (master - Spec: add expectations starts_with, ends_with (#5881)): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/373075342
<DeBot> https://github.com/crystal-lang/crystal/pull/5881 (Spec: add expectations starts_with, ends_with)
Ven`` has joined #crystal-lang
<FromGitter> <girng> hey
<FromGitter> <girng> https://i.gyazo.com/1b6565c907717776218846de0954b125.png is this the inheritance list?
<FromGitter> <girng> so i can use methods from ipsocket, socket io and reference on my TCPSocket, correct?
<oprypin> girng, correct
<FromGitter> <girng> thx. just curious what's the difference between remote and local_address?
<FromGitter> <girng> ok, tested local_address, gave me a weird port number. gonna use remote_address
<FromGitter> <asterite> sdogruyol: what problems? I think there were problems at crystal 0.17, but now those problems should be gone. I really encourage you to try it without `Kemal.run` because I'm pretty sure it will work. When you write specs there's also an `at_exit` handlers that runs them and it works just fine. No need to write `Spec.run` at the end.
<FromGitter> <asterite> barachy: I don't think I will be able to close all issues, some issues are impossible to close (or at least that's the way I see it)
<FromGitter> <girng> what happens when you put a spawn inside a spawn
<FromGitter> <girng> is it like a domino effect last one closes, and then the other follows?
<crystal-gh> [crystal] esse opened pull request #6036: Remove `Tempfile#unlink` dead alias (master...remove_tempfile_unlink) https://git.io/vpR6E
baweaver_away is now known as baweaver
<FromGitter> <sdogruyol> @asterite interesting
<z64> @girng not quite, no - https://carc.in/#/r/3z5e
<FromGitter> <girng> interesting thx for the example
<z64> remember that in your top level program you're already in a fiber. spawning a fiber does not block, spawning inside another fiber is no different unless you introduce some means of blocking
<z64> with a Channel or similar
<FromGitter> <girng> and when a fiber returns false it's removed/cleared?
<FromGitter> <girng> developer doesn't have to manage them?
<z64> ex with a channel to introduce blocking: https://carc.in/#/r/3z5h
<z64> well what a fiber returns is irrelevant, but yes - once it reaches the end of its execution it will eventually be garbage collected
<FromGitter> <girng> tyhat's what i meant yeah
<FromGitter> <girng> ok cool
<FromGitter> <girng> yeah, if you use channels, it makes the code look more synchronous, which is nice
<z64> the concurrency guide in the lang reference is amazing, i strongly encourage giving it a read if you haven't - https://crystal-lang.org/docs/guides/concurrency.html
<FromGitter> <girng> is it ok for me to think of fibers as kinda like a nodejs callback?
<z64> you can use fibers/channels in a nodejs callback way, sure. i dont know enough though about nodejs to draw a meaningful comparison though
Ven`` has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<FromGitter> <girng> @z64 for example, when I start my GameSever, i do a `spawn connect_to_game_instance_servers`. and then inside that method, i connect to 3-4 servers, which use another spawn for `handle_connection`. jus tlike how the tcp server in docs use it. ⏎ ⏎ and it works rather quite well because my gameserver initiation isn't BLOCKED at all. everything continues to run smoothly even when it's connecting to the
<FromGitter> ... instance servers. cause I used a fiber forit
<z64> yeah, sure. i dont know enough about your use case to say whether thats apropriate, but you have the idea
<FromGitter> <girng> basically, i need my MasterServer to connect to the game instance servers while they are alive. so when a user creates a game, they'll be put onto the right instance server IP
<z64> if you're interested in more "concurrency patterns" i highly recommend this Google I/O video of a talk that reviews concurrency patterns in Go, which has an extremely similar concurrency model https://www.youtube.com/watch?v=f6kdp27TYZs
<z64> i've been meaning to write up a companion blog post to this video which shows the examples he gives in crystal:)
<FromGitter> <girng> cool. yeah i kinda understand fibers
<FromGitter> <girng> i mean, my app is working nicely and it compiles so im obviously doing someright right
<FromGitter> <girng> something right*
<z64> lol :D
<FromGitter> <girng> i jsut alt-tab, change as much stuff as i can to get compiler errors gone
<FromGitter> <girng> trial n error :D
<FromGitter> <girng> how i learn
<FromGitter> <j8r> How can I transform an Array (here `/proc/1/stat`) to a NamedTuple?
<FromGitter> <j8r> I know that `[0]` is pid, `[1]` is comm, `[3]` state, etc
<z64> you would just instantiate it with each value
<oprypin> j8r, `{pid: a[0], comm: a[1]`
<oprypin> is that what u mean?
<FromGitter> <j8r> I must do the classic way `{pid: array[0].to_i, comm: array[1]}`
<z64> yes exactly
<oprypin> it cant even get better than that
<FromGitter> <j8r> I can't set a "mapping" for an Array
<z64> there isn't anything stdlib for that, no afaik
<FromGitter> <j8r> ok, fine thx ;-)
<FromGitter> <girng> should use Struct instead
<FromGitter> <girng> im jk LOLL
<oprypin> funny cuz it's true
<FromGitter> <girng> hahahahaha my eyes wet
<FromGitter> <girng> dat was funny
<FromGitter> <j8r> /proc/1/stat in an Struct? Not sure, we may have the need to serialize it to a JSON or whatever
<crystal-gh> [crystal] esse closed pull request #6035: Add Char#code_point method (master...master) https://git.io/vpRZC
Ven`` has joined #crystal-lang
<z64> what do you mean o:..? you can json.mapping a struct, as you would any other type
<FromGitter> <girng> i realy want to try `crystal MasterServer.cr` on an actual linux machine instead of WSL. do you think there would be any performance advantages?
<FromGitter> <j8r> yes, with json.mapping. With a namedtuple, we don't have to use mappings right?
<z64> sure, but namedtuple has its own shortcomings depending on what you're doing. its a namedtuple, not a StatData
<z64> well, i suppose you could alias
<FromGitter> <girng> `Unhandled exception in spawn:` does this mean i need to use rescue outside of the spawn?
<FromGitter> <girng> but how do you do that when it's inside a while loop.do it outside of the while loop or inside?
<FromGitter> <j8r> With actualy the `stat` method that needs to be refactored
<z64> it just means an exception was raised in another fiber and not the main one
<FromGitter> <girng> for example, in this example: https://crystal-lang.org/api/0.24.2/TCPServer.html where would you put the rescue exception handling at? inside the while loop or out of it
<FromGitter> <j8r> I will try to do a Struct
<z64> yeah, i don't know @j8r. i just find struct more pleasant to use (as a user) and expand upon later if i need to. i.e. `pid.stat.utime` vs `pid.stat[:utime]`
<FromGitter> <j8r> You're right, but is it fine he we have hundreds of PID? hundreds of structs will be created each 0.5 seconds
<z64> structs are extremely fast to allocate
<FromGitter> <j8r> I don't know if NamedTuple is better/worse that creating a Struct
<FromGitter> <girng> hahahaha
<FromGitter> <j8r> I will go for struct so
<FromGitter> <girng> i love it
<FromGitter> <j8r> I guess both are in the stack
<z64> from https://crystal-lang.org/docs/guides/performance.html: struct 430.82M (+/- 6.58%)
<z64> (class vs struct example)
<FromGitter> <j8r> of course, vs class. I use primilarly structs
<z64> yeah for sure; just to show, "hundreds" is nothing to 430.82M :)
<z64> @girng - it depends. conceptually, a fiber that you spawn should have a specific "job" right? to own some tcp connection, process some files, etc. exceptions that job should expect in its own work should be caught in its fiber. critical exceptions - like the worker itself dying - need to be handled in the main thread, and maybe restarted/reconnected for example
<FromGitter> <j8r> I reorganize again the project: `Hardware::PID` will be a module with inside `Stat` for stat and `Info`
<z64> sounds good
<FromGitter> <j8r> that's better yes. But for `/proc/1/status` I still need a `Hash(String, String)` because structure changes between Linux versions :-|
<FromGitter> <girng> https://play.crystal-lang.org/#/r/3z5v if you don't remove the "return" it causes an infinite loop
<FromGitter> <girng> why?????
<FromGitter> <girng> if you remove the return**
<z64> @j8r i wonder that you couldnt detect the OS then and serve a specific type (compile time macro? i dont know)
<z64> never really done a 'cross-platform' thing like that
<FromGitter> <stern0> what is wrong with this method
<FromGitter> <stern0> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5ae74dec2d0e228d7bca8817]
<FromGitter> <stern0> can anyone tell me what is wrong with this method above
<FromGitter> <j8r> same case for `/proc/meminfo` with MemAvailable https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=34e431b0ae398fc54ea69ff85ec700722c9da773 ⏎ Meh, I will need to check the kernel version, so need https://github.com/ysbaddaden/posix
<FromGitter> <j8r> But not at compile time, because I've always in mind to compile statically an deploy in all Linuxes
<z64> right
<FromGitter> <girng> whoa, there is a type `Socket::IPAddress` lol
<FromGitter> <girng> i was using a String 😄
<FromGitter> <j8r> For now I can do the most with the (I think) standarly serializable statm, everything's good. Only the the calculation of the System's global CPU needs a little Hash - that's not a big deal vs if we had to do this with hundreds of PIDs
<FromGitter> <j8r> Lets create 52 `getter`s :-D
<z64> haha
<FromGitter> <drum445> Is there a decimal type in Crystal or is float64 accurate for financials?
<z64> there is BigDecimal, and other Big* types as well
<FromGitter> <drum445> ah ok tah, can you make a method private in a method
<FromGitter> <drum445> so you can't call it outside of the mhetod
<z64> yes
<z64> `private def foo(arg)` etc :p
<FromGitter> <drum445> When I do that, I can still call that outside
<FromGitter> <drum445> :(
<z64> from inside the same type, yes.. the point of `private` is that it cannot be called outside of the type
<z64> what would be the point if it couldn't be called from anything
<FromGitter> <drum445> oh I'm lying anyway
<z64> oh
<FromGitter> <drum445> pmsl, apologies
<FromGitter> <drum445> It works fine haha
<z64> okay lol.
Ven`` has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
greengriminal has quit [Quit: This computer has gone to sleep]
greengriminal has joined #crystal-lang
willamin has joined #crystal-lang
<FromGitter> <j8r> @s64 I think I will use NamedTuple, because with Struct I will need lots of getters, lots of `var = array[i].to_i` + a define a mapping to serialize to JSON/YAML
Ven`` has joined #crystal-lang
<oprypin> j8r, namedtuple is literally not better at anything than struct
Groogy has quit [Quit: WeeChat 2.1]
<z64> woops, *z64 lol
<z64> remember there is also `record` macro, and `JSON.mapping` defines getters/setters
greengriminal has quit [Quit: This computer has gone to sleep]
greengriminal has joined #crystal-lang
greengriminal has quit [Client Quit]
<FromGitter> <j8r> but I can use a `to_json`
<FromGitter> <j8r> `record` can't help me - I will need to pass 52 arguments :-o
Ven`` has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<RX14> ...how
<FromGitter> <sherjilozair> Can we run code on require? If yes, is that bad practice?
<FromGitter> <j8r> I will use both :-D
<FromGitter> <j8r> hum no wrong idea
duane has joined #crystal-lang
Ven`` has joined #crystal-lang
omninonsense has quit [Read error: Connection reset by peer]
greengriminal has joined #crystal-lang
duane has quit [Ping timeout: 255 seconds]
sz0 has joined #crystal-lang
greengriminal has quit [Quit: This computer has gone to sleep]
<FromGitter> <girng> im trying to CLEAR a Socket::IPAddress from a property
<FromGitter> <girng> how can i remove/set the ip address to nil
<oprypin> girng, well you set it to `nil` and not an empty string
<oprypin> and the member type has to allow for that
<oprypin> see also: https://crystal-lang.org/api/0.24.2/Object.html#property%21%28%2Anames%29-macro
<FromGitter> <girng> got it,thank you
<FromGitter> <girng> i have a question about the compiler
<z64> FWIW, `Nil` unions can be very common. in short you can write `Socket::IPAddress?` instead of `Socket::IPAddress | Nil`
<FromGitter> <girng> oh really?
<FromGitter> <girng> same effect?
<z64> yes
<FromGitter> <girng> ok that's cool, have a bunch of | Nils lol
<FromGitter> <girng> ty for dat tip ^^
<z64> np
<FromGitter> <girng> my compiler question: when you run build, or just the regular `crystal app.cr` command. does the compiler utilize ALL your CPU cores, or only 1? basically, the more cores you have, the faster it will compile? Or, the fewer cores, but HIGHER frequency will do better?
<z64> i believe, at least the llvm phases of the compiler, take advantage of multiple cores
<FromGitter> <girng> ok awesome
<FromGitter> <j8r> but not the crystal compiler itself
<FromGitter> <girng> how much is that compared to llvm, % wise?
<FromGitter> <girng> proportion
<z64> you can even change this; `crystal build --threads 1 foo.cr` etc
<z64> well you remember when you looked at `--stats` the other day
<FromGitter> <girng> oh yeah
<FromGitter> <girng> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5ae774de5d7286b43a8430b6]
<z64> the long final codegen phases is when the compiler passes the LLVM IR off to LLVM to do its thing
<FromGitter> <girng> `Codegen (crystal): 00:00:00.707127000 ( 139.64MB)` this part?
<z64> basically those last three yes
<FromGitter> <girng> those take the longest, lol
<FromGitter> <girng> hahahaha
<z64> lol :p
<FromGitter> <girng> so, im guessing since the compiler portion uses 1 core.. probably a higher frequency CPU would be better
<z64> for those other phases yes
willamin has quit [Quit: Connection closed for inactivity]
<FromGitter> <girng> yeah, which are th eslowest
<FromGitter> <girng> so the biggest perf improvement
<FromGitter> <girng> im on a 3.4hz i7 2600 right now
<FromGitter> <girng> if it was 4.5ghz, i bet it be noticable faster
<FromGitter> <girng> what's your CPU?
<z64> don't lose perspective either that you only have to compile once, then deploy to any machine; i.e., you can compile with a more powerful machine and deploy the binary to weaker production ones
<FromGitter> <girng> oh yah im fine with the --build speedtimes
<FromGitter> <girng> it's fast af.
<z64> i have an i5 base 3.5ghz oc'd at something stupid, 4.8 iirc
<FromGitter> <girng> im just saying for development, it's gone up from 1-2seconds to 5 seconds now
<FromGitter> <girng> when doing crystal app.cr
<FromGitter> <girng> oh nice, 4.8
<FromGitter> <girng> that's a good OC
faustinoaq has quit [Quit: IRC client terminated!]
<oprypin> i'm a pleb without OC. i'm guessing it's the same CPU as z64's though
<FromGitter> <girng> my mobo is from 2011 lol
<FromGitter> <girng> still working hahaha
<FromGitter> <girng> that reminds me, i should make a backup..
<FromGitter> <bew> it's not the last 3 steps (from --stats), only the last 2 are on llvm side, the `Codegen (crystal)` is the generation of LLVM IR (so still single core)
<z64> it was sort of an accident. i did some studying about OC, and wanted to get more out of my mobo's default OC profile. i bumped it up - apparently - to 4.2 in the bios to start. but i logged on, started a game, and it was up there.. and stable lol. had zero issues so i just left it
Ven`` has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
__marty__ has joined #crystal-lang
<z64> ah thank you @bew :) wasn't 100% on that
<FromGitter> <girng> @bew ok
<FromGitter> <girng> this is accurate?
<oprypin> i think so
<FromGitter> <girng> TOP PART = single core
<oprypin> i think so
<FromGitter> <girng> BOTTOM PART = Multiple cores
<oprypin> i think so
<FromGitter> <girng> lol
<FromGitter> <girng> @z64 yeah, if it's stable it's beautiful oc
<FromGitter> <bew> what is 'oc' ?
<oprypin> overclocking for cpu
<FromGitter> <girng> well, if if my math checks out (Adding those times in --stats). getting more cores and higher frequency CPU will actually net the most results
<FromGitter> <girng> who would have thought.. god im slow
<oprypin> lol
<FromGitter> <girng> im waiting for ram prices to go down before i upgrade..
ua_ has quit [Ping timeout: 240 seconds]
ua_ has joined #crystal-lang
<FromGitter> <straight-shoota> `Codegen (linking)` should be the linker, not LLVM
<FromGitter> <codenoid> are you use windows linux sub system that install linux under windows to run linux ubuntu within windows ?
<FromGitter> <girng> yah
<FromGitter> <straight-shoota> I think you can run any linux nowadays
<FromGitter> <straight-shoota> not just ubuntu
<FromGitter> <straight-shoota> I hope so much that the spring update for win 10 fixes a bug in WSL that has been haunting me for months
<FromGitter> <r00ster91> which bug?
<FromGitter> <r00ster91> i hope that the spring update adds that you dont need to use xming to connect bash to the windows windowing system
<FromGitter> <straight-shoota> WSL randomly crashes with error 0x80070040
<FromGitter> <straight-shoota> can't use it until reboot
<FromGitter> <r00ster91> huh this never happened to me before
<FromGitter> <straight-shoota> I don't think there will be a x interface
_whitelogger has joined #crystal-lang
shalmezad has quit [Quit: Leaving]
<FromGitter> <girng> @RX14 omg.. just got my new keyboard, it feels so weird. the keyboard is so much higher up off the ground lol
<FromGitter> <girng> the keys are hella easier to press! this is cool, but i need to get used to it. my wrists are angled up a lot higher...
<crystal-gh> [crystal] sdogruyol opened pull request #6038: Remove SemanticVersion (master...remove-semantic-version) https://git.io/vp0mf
faustinoaq has joined #crystal-lang
andrewzah has joined #crystal-lang
andrewzah is now known as nominal
nominal is now known as nominalbear
faustinoaq has quit [Quit: IRC client terminated!]
greengriminal has joined #crystal-lang
<crystal-gh> [crystal] asterite pushed 2 new commits to master: https://git.io/vp0Zu
<crystal-gh> crystal/master ee20101 Ary Borenszweig: Merge pull request #6032 from veelenga/fix/visit-when-cond...
<crystal-gh> crystal/master ca60b77 Vitalii Elenhaupt: Allow to visit cond node in when
alex`` has quit [Quit: WeeChat 2.1]
alex`` has joined #crystal-lang
alex`` is now known as alexherbo2
alexherbo2 is now known as alex``
FromGitter has quit [Ping timeout: 265 seconds]
FromGitter has joined #crystal-lang
FromGitter has quit [Remote host closed the connection]
FromGitter has joined #crystal-lang
FromGitter has quit [Remote host closed the connection]
FromGitter has joined #crystal-lang
<oprypin> ok something is seriously wrong with irc bridge
FromGitter has quit [Remote host closed the connection]
FromGitter has joined #crystal-lang
FromGitter has quit [Remote host closed the connection]
<oprypin> or is it just gitter being down
FromGitter has joined #crystal-lang
FromGitter has quit [Remote host closed the connection]
FromGitter has joined #crystal-lang
<oprypin> gitter doesnt ping from 2 different locations
FromGitter has quit [Remote host closed the connection]
FromGitter has joined #crystal-lang
FromGitter has quit [Remote host closed the connection]
FromGitter has joined #crystal-lang
FromGitter has quit [Remote host closed the connection]
FromGitter has joined #crystal-lang
FromGitter has quit [Remote host closed the connection]
FromGitter has joined #crystal-lang
FromGitter has quit [Remote host closed the connection]
That_Guy_Anon has joined #crystal-lang
<oprypin> welp systemd doesnt have exponential backoff so i need to shut off the service and start it when i wake up
pabs has quit [Ping timeout: 248 seconds]
That_Guy_Anon has quit [Remote host closed the connection]
That_Guy_Anon has joined #crystal-lang
pabs has joined #crystal-lang
<travis-ci> crystal-lang/crystal#ee20101 (master - Merge pull request #6032 from veelenga/fix/visit-when-cond): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/373257545
<DeBot> https://github.com/crystal-lang/crystal/pull/6032 (Allow to visit cond node in case)
That_Guy_Anon has quit [Quit: Leaving]
emilsp has quit [Ping timeout: 612 seconds]
emilsp_ble has joined #crystal-lang
pabs has quit [Ping timeout: 264 seconds]
pabs has joined #crystal-lang
Nathanaelle has quit [Ping timeout: 256 seconds]
bew has joined #crystal-lang
<bew> it's just me or gitter.im is down?