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
marius has quit [Quit: baj]
marius has joined #crystal-lang
marius has quit [Client Quit]
marius has joined #crystal-lang
ashirase has joined #crystal-lang
Yxhuvud has quit [Quit: No Ping reply in 180 seconds.]
Yxhuvud has joined #crystal-lang
Cyrus1 has quit [Ping timeout: 276 seconds]
baweaver_away has quit [Excess Flood]
baweaver has joined #crystal-lang
baweaver has joined #crystal-lang
baweaver has quit [Changing host]
Cyrus1 has joined #crystal-lang
ukd1 has joined #crystal-lang
ukd1 has quit [Remote host closed the connection]
Cyrus1 is now known as Cyrus
qard has joined #crystal-lang
qard has quit [Quit: qard]
qard has joined #crystal-lang
qard has quit [Client Quit]
qard has joined #crystal-lang
qard has quit [Client Quit]
qard has joined #crystal-lang
qard has quit [Quit: qard]
qard has joined #crystal-lang
qard has quit [Quit: qard]
alex`` has joined #crystal-lang
* hightower2 misses a shard for gettext!
<hightower2> would be so great if there was one
<FromGitter> <bew> for what? what do you miss?
<hightower2> The bindings for gettext
<FromGitter> <bew> oooh ok, nvm
DTZUZO has quit [Ping timeout: 240 seconds]
baweaver is now known as baweaver_away
rohitpaulk has joined #crystal-lang
<FromGitter> <straight-shoota> hightower2 gettext bindings should be fairly easy, it literally just exposes a few functions. Your probably only going two need 1 or 2.
<FromGitter> <straight-shoota> But why use gettext?
<hightower2> straight-shoota: right, especially since the data types involved are also very simple. But, how do you mean, what would you use instead of it?
DTZUZO has joined #crystal-lang
Groogy has quit [Disconnected by services]
Groogy2 is now known as Groogy
<Groogy> Morning! o/
<FromGitter> <girng> Morning!!
<FromGitter> <girng> 12:57 am here xD
Groogy_ has joined #crystal-lang
<FromGitter> <straight-shoota> I would use some I18n library like Rails's. There are a few shards I think, but don't know how good they are
<FromGitter> <straight-shoota> I wouldn't recommend gettext
<FromGitter> <straight-shoota> There are other opinions, though
<hightower2> straight-shoota: ah that's what you mean. Yeah, we use TechMagister's I18n in one project, but I appreciate the ecosystem that exists around gettext
<hightower2> morning groogy'o
<FromGitter> <straight-shoota> The issue with gettext is that the source language is directly edited in the code. It's not easy to offload copywriting to non-devs. There are issues when the same text in source language is used at multiple locations but would need different translations depending on context, decent plural formatting etc.
<FromGitter> <straight-shoota> IMO it is a far better design to just declare in the source code that you need a text here and give it a descriptive, context-aware name.
<hightower2> Well, yeah, true... it's not easy to offload copywriting in the primary language because the primary language is specified in-place. But if I am not mistaken, what's preventing you from just using contextual name and providing even the primary translation in a translation file?
<FromGitter> <straight-shoota> You could probably do that but what would be the point in using gettext for this when there are far better designs for this?
<hightower2> Ok, thanks for the advice. (I always assumed other solutions were inferior to gettext. Will re-check)
rohitpaulk has quit [Ping timeout: 265 seconds]
<oprypin> straight-shoota, lol you could tell copywriters to translate to the same language as well. forcing them to be passive-aggressive with devs ;)
<oprypin> also i wouldn't trust anyone to write better UI labels than myself
<oprypin> and I don't see any advantage of using a fake identifier in place of real language even in source code
<oprypin> so, what exactly is that better design?
<FromGitter> <girng> can someone plz help me
<oprypin> girng, you can use `self.online_count += 1`
<FromGitter> <girng> got it, working now
<FromGitter> <girng> thanks @oprypin
<oprypin> seems not explained in docs
<oprypin> assignment defaults to local variables
<FromGitter> <girng> i like crystal bcz i was experiencing that in my main code. and i just whipped it a seprate example to isolate the case. syntax is joy to work with, easy to remember
<oprypin> good job
DTZUZO has quit [Ping timeout: 264 seconds]
<FromGitter> <straight-shoota> @oprypin Translations to not belong in the source code. If you provide an additional po file with a translation for the source language anyway, I really don't see any benefit for gettext. Different languages can behave differently depending on context. You need context to be able to properly translate something. You can use pgettext to add context, but again, if you do that (and you should for every
<FromGitter> ... translation string), you could diretly use something more appropriate for this. When using hierarchical, context-aware message IDs this is all enforced by the very design.
<FromGitter> <girng> for some reason, i did some more testing with a lot of connections. and it does seem like my ram usage goes down. im using WSL though, is that why?
<FromGitter> <straight-shoota> And gettext has considerable shortcomings. I don't think you can have a string with two different pluralizations?
<crystal-gh> [crystal] r00ster91 reopened pull request #5864: Add \a escape sequence (master...patch-8) https://git.io/vxRbf
<FromGitter> <girng> i loaded up 5k new tcp connections, of which all create a new Player class, my memory goes to 100mb ram, then when i disconnect them all, fluxuates around to around 40mb memory usage. and i rinse and repeat this, and memory usage keeps going back down. but i thought boehm's GC doesn't free memory back to the OS, what is going on??
<FromGitter> <girng> ok so i went up to 10k connections. it went up to 125mb ram or so, but now when all disconnect, it hovers to 70mb instead of 40. so, i think the "new connection sockets" in the TCP server internally get free'd up, but the objects that were created in crystal (all my player classes), are still there in memory ready to be re-used INSTANTLY
<oprypin> likely
<RX14> no
<RX14> it's the fiber stacks
<RX14> the fiber stacks get GC'd
<RX14> but the allocated memory for stuff on the heap used by those fibers does not
<RX14> now that's hard to explain
<FromGitter> <girng> in any caseim happy the memory usage does go down a bit when the tcp connections get dropped. i thought originally since boehm doesnt return any memory to OS, that the memory would be high that entire time
<RX14> boehm doesn't return memory to the OS
<RX14> it's just that some of the memory isn't allocated via boehm
<FromGitter> <girng> i thought crystal uses boehm
<RX14> it does
<RX14> but there's one specific small part that does not
<FromGitter> <girng> o, so that is what im experiencing
<RX14> yea
<FromGitter> <girng> ima tuck my tail in and get back to coding then was just kinda curious :O
<FromGitter> <girng> ROFL
<FromGitter> <girng> now, my server just went back to 25mb memory usage
<crystal-gh> [crystal] straight-shoota opened pull request #5928: Fix HTTP::ChunkedContent read incomplete chunks (master...jm/fix/5852) https://git.io/vxH9Z
mps has joined #crystal-lang
Groogy__ has joined #crystal-lang
Groogy_ has quit [Ping timeout: 240 seconds]
Jenz has joined #crystal-lang
<Jenz> when debugging with gdb, if I want to call list on the top level user code, what is the name of the function?
<Jenz> (to call list on)
<Jenz> E.g. with the program `puts "Hello"`, i want to call `list x` in gdb, and it would print `puts "Hello"`
<Jenz> (where what `x` is, is what i am wondering)
Jenz has quit [Ping timeout: 260 seconds]
<mps> I'm newbie to crystal, is there link or guide to basic keywords and syntax about language besides official docs on the crystal web site
<FromGitter> <girng> @mps the docs cookbook has a ton of syntax https://crystal-lang.org/docs/syntax_and_semantics/if.html then the API is here: https://crystal-lang.org/api/0.24.2/
<FromGitter> <faustinoaq> Hi community, Do you think would be possible to debug ECR templates? like this https://github.com/crystal-lang-tools/vscode-crystal-lang/issues/52 😅
<FromGitter> <girng> that should help i think
<FromGitter> <faustinoaq> I guess I can use `crystal tool expand` 😄
<mps> FromGitter: I read it but some things are confusing to me. I don't know ruby and looks like the docs written for those who are fluent in ruby, it's my impression
<FromGitter> mps, I'm a bot, *bleep, bloop*. I relay messages between here and https://gitter.im/crystal-lang/crystal
<FromGitter> <faustinoaq> but the expanded Crystal code is probably not very nice to read 😅
<FromGitter> <faustinoaq> Maybe I can use some kind of algorithm to compare the expanded code and the plain `.ecr` files ⏎ ⏎ BTW, I'm already able to debug `.cr` files, not perfect but at least is pretty usable ⏎ ⏎ ((https://camo.githubusercontent.com/43ebab443d553f69a6c59dc8bb575a67866cbcdd/68747470733a2f2f692e696d6775722e636f6d2f477347543168302e706e67)) [https://gitter.im/crystal-lang/crystal?at=5ac8afbf27c509a774e89f32]
<mps> huh, who answered my question, <girng>? if this is not some kind of robot :)
<FromGitter> <faustinoaq> mps, check this: https://www.youtube.com/watch?v=5-_CWyrpIBk
<FromGitter> <girng> @mps yah me, i use godot engine icon for my avatar xD. cuz i use tcp server with crystal :)
<mps> faustinoaq: I will, but I prefer to read because I'm bad with spoken english
<FromGitter> <faustinoaq> No problem, I mean, some docs are so similar to ruby, because ary copied them from ruby docs 😅
<mps> girng: ok, tnx for explanation. I understand most of language but some thing are new to me
<FromGitter> <faustinoaq> mps, Ary asked to Matz (Ruby creator) for permission to use the ruby docs 😉
<mps> faustinoaq: I looked to the ruby docs to see meaning of some crystal construct and that helped even if I don't knwo ruby
<mps> but explanation in some cases are helpful
<FromGitter> <faustinoaq> mps, Yeah, I didn't know Ruby neither, I was a C/Python guy, then I discovered crystal and finally learnt some Ruby 😄
<RX14> mps, what specifically is confusing not coming from ruby?
<RX14> I know it's a problem but it's hard to tell exactly what's confusing because you can't regain the outside perspective
<mps> for now I don't understand ' some::method do |x|' construct
<RX14> it passes a block of code into the method
<FromGitter> <faustinoaq> RX14 For me was the blocks, I didn't understand them, but once I learnt how they work, all was nice 👍
<RX14> I hope you're familiar with lambdas or functions
<mps> in my view 'do' is 'do ... end' loop construct, but I'm not sure
<RX14> well, they're not
<mps> RX14: sorry no
<RX14> what language do you come from?
<RX14> language(s)
<mps> I'm from C/Go/Perl and similar
<RX14> closure then?
<RX14> an anonymous function?
<FromGitter> <faustinoaq> The Tuple and NameTuple and struct thing was pretty familiar to Python and C
<mps> ah, that is some kinf of closure or anonimous function?
<FromGitter> <faustinoaq> mps Yeah
<RX14> do/end is just an alternative syntax for passing an anonymous function to a method mps
<RX14> let me just whip up an example
<mps> undertand
<mps> tnx
<FromGitter> <faustinoaq> mps, that because Ruby/Crystal doesn't have first class function, but blocks and procs
<RX14> mps, you understand this right? https://carc.in/#/r/3u9x
<mps> just small question (I hope it is small), parameter to closure are put in ||, right?
<RX14> this is exactly the same as the previous example just using blocks
<RX14> it's just a nicer syntax
<RX14> mps, yes, for blocks
<RX14> we have procs which are traditional closures
<RX14> and can be passed around like variables
<RX14> and blocks can be converted to/from them
<FromGitter> <girng> takes_block should be block right?
<RX14> that comes along later in the guide
<RX14> @girng yes oops
<FromGitter> <girng> i really like the blocks
<mps> I see
<RX14> mps, in crystal, passing closures to methods is really *really* common
<RX14> so having a special syntax (and performance enhancements that come with the special syntax) for it makes a lot of sense
<RX14> for example we don't have for loops in crystal
<mps> and we can put more parameters in the ||? like that |foo, bar|
<RX14> mps, yep
<RX14> || just act like ()
<RX14> a bit like
<mps> enlightened*
<mps> but for function and method call we can use ()
<RX14> for calling you always use ()
<mps> so, || is for closures only if I understand
<RX14> || is *only* for block arguments
<RX14> calling blocks? ()
<RX14> calling methods? ()
<RX14> calling procs? ()
<RX14> defining methods? ()
<RX14> defining block args? ||
<RX14> yeah, it's weird
<mps> ah, I see
<RX14> but () conflicts, it'd create ambiguous syntax
<mps> ok, I have to adapt my eyes to that
<RX14> consider foo { (arg1, arg2) }
<RX14> actually thats a bad example
<RX14> consider foo { (bar) }
<mps> ok
<RX14> that could be parsed as calling the method `foo`, with a block tat takes 1 argument named bar
<RX14> but it could also be parsed as calling the method `foo`, with a single call to the method `bar`
<RX14> e.g. treat `bar` as an expression, remove the unneccesary brackets
<mps> yes, I see
<RX14> yeah
<RX14> so ruby had to change the syntax to be weird
<RX14> glad you understand
<mps> RX14: thank you very much, you helped me a lot
<RX14> no problem
<mps> now I'm more confident to start crystal programming despite the fact I have to learn a lot
<RX14> yeah, ruby syntax is really a family of it's own, not similar to C at all
<RX14> or python
<mps> it was not so strange at the basic level to me because I know perl
<mps> I grasped basic in few hours
<RX14> cool
<Vexatos> Julia does it in a very similar way though, it also has special syntax for block args, although it is a keyword instead of a specific glyph
<mps> but some thing are really strange to me, don't have courage to ask about yield, yet :)
<RX14> at least C and Go will teach you strong typing, and Go will teach you goroutines/channels (which we call fibers/channels)
<RX14> so crystal should be fairly easy for you
<RX14> mps, yield is just the counterpart to blocks
<RX14> yield is how you call a block in the method
<RX14> you define a closure using ->(arg : Type) { code } right?
<mps> yes, that is true, fiber are like goroutine and channels looks nearly same
<RX14> and then you call the closure using `closure.call` method
<RX14> just as you define a block with `do/end` or `{/}`, you call a block with `yield`
<mps> RX14: please, don't try to educate me about yield right now
<RX14> aww but it's simple :(
<RX14> if you check the examples I gave above it should be clear
<mps> sorry, I wanted to make small non-offensive joke
<Vexatos> you have crystal shards and all, why didn't you also call channels after something related to crystals
<Vexatos> would have been funny
<oprypin> crystals are perfefct, they dont have channels
<oprypin> distribution channels?
<RX14> Vexatos, we don't make any crystal references in the syntax
<Vexatos> fair enough
<RX14> we just make it in the librry names and commandline tools
<mps> I think it is to soon for me to learn everything in one chat session
<RX14> sure, but we'll still be here if you have any more questions :)
<Vexatos> (unless an unfortunate incident or accident happens to occur)
<mps> you are very nice, tnx :)
<mps> I hope that I will continue with crystal, so you can expect some more questions from me
Jenz has joined #crystal-lang
Jenz_ has joined #crystal-lang
<Jenz> mps, welcome to Crystal!
Jenz_ has quit [Ping timeout: 240 seconds]
Jenz has quit [Ping timeout: 240 seconds]
return0e has quit [Remote host closed the connection]
return0e has joined #crystal-lang
foca has quit [Ping timeout: 240 seconds]
foca has joined #crystal-lang
hightower3 has joined #crystal-lang
hightower2 has quit [Ping timeout: 260 seconds]
<FromGitter> <girng> I love CRYSTAL!
<FromGitter> <Sjoerrdd> Same :D
<FromGitter> <Sjoerrdd> I joined yesterday
DTZUZO has joined #crystal-lang
<FromGitter> <Sjoerrdd> What was the previous language you fell in love with?
<FromGitter> <Sjoerrdd> @girng
<FromGitter> <girng> nodejs.. lol
<FromGitter> <girng> javascript*
<FromGitter> <girng> but i'm very past that now, crystal much better imo, and way easier / cleaner to read. (IMO)
<RX14> @girng what had you used before javascript?
<FromGitter> <girng> php *shutters in embarassment*
<RX14> lol
<Vexatos> At least it wasn't perl
<FromGitter> <Sjoerrdd> Php is my job
<FromGitter> <Sjoerrdd> Nodejs was an hobby
<FromGitter> <Sjoerrdd> Then I moved to Elixir
<FromGitter> <Sjoerrdd> But I didn't like Phoenix
<FromGitter> <Sjoerrdd> So I moved back to NodeJS
<FromGitter> <Sjoerrdd> And then I discovered Crystal
<txdv> when pain is your job and suffering is your hobby
<txdv> are you into bdsm?
<FromGitter> <Sjoerrdd> ..
<FromGitter> <Sjoerrdd> Btw
<FromGitter> <Sjoerrdd> I'm a student (17 y/o)
<FromGitter> <Sjoerrdd> And my mentor swears he is programming in php6
<txdv> i swear too when i have to program in php
<FromGitter> <Sjoerrdd> 😂😂
<FromGitter> <Sjoerrdd> Php isn't that bad
<FromGitter> <girng> i switched back to crystal. i made this post (https://elixirforum.com/t/how-to-read-a-32-bit-unsigned-integer-on-tcp-stream/13519), with elixir and tfinally got help and got it working. however, i went back to crystal because i gto most of my game server already written. but elixir community is very nice, but my mind doesn't grasp functional languages so i went back to crystal. but i did get elixir working
<FromGitter> ... with godot. i had to enable a dumb `big_endian` property. spent 2 days trying to fix that. if it takes me 2 days just to find that issue, then i don't have enough time to convert my game over. ⏎ ⏎ and plus, erlang's gen_tcp documentation is very confusing. crystal's cookbook, docs are much easier to read.
return0e has quit []
<FromGitter> <j8r> this is you server or client side of your game?
<FromGitter> <j8r> server I guess
<FromGitter> <girng> yah
ukd1 has joined #crystal-lang
ukd1 has quit [Client Quit]
ukd1 has joined #crystal-lang
ukd1 has quit [Client Quit]
ukd1 has joined #crystal-lang
ukd1 has quit [Client Quit]
ukd1 has joined #crystal-lang
ukd1 has quit [Client Quit]
rohitpaulk has joined #crystal-lang
ashirase has quit [Ping timeout: 265 seconds]
Creatornator has joined #crystal-lang
Creatornator has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
duane has quit [Ping timeout: 268 seconds]
duane has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 264 seconds]
alex`` has quit [Quit: WeeChat 2.1]
<crystal-gh> [crystal] chris-huxtable closed pull request #5558: OpenBSD Improvements (master...openbsd-improvements) https://git.io/vNtlx
<bmcginty_> I've got an Array(T), and I need to get T without nils, if that's possible. So if I've got Array(String|Int32|Nil), I'm needing String|Int32 frm inside the array. I might be asking for the impossible, though.
<oprypin> bmcginty_, certainly possible, there might even be a dedicated method for it
<oprypin> >> typeof([1, nil].compact)
<DeBot> oprypin: # => Array(Int32) - https://carc.in/#/r/3uap
<bmcginty_> oprypin: sweet. Thanks!
ashirase has joined #crystal-lang
Creatornator has joined #crystal-lang
Creatornator has quit [Client Quit]
_whitelogger has joined #crystal-lang
qard has joined #crystal-lang
qard has quit [Read error: Connection reset by peer]
ua_ has quit [Ping timeout: 265 seconds]
qard has joined #crystal-lang
<crystal-gh> [crystal] RX14 pushed 1 new commit to master: https://git.io/vxQqO
<crystal-gh> crystal/master 3138b52 Julien Reichardt: Add `Hash#last_key` and `Hash#last_value` (#5760)
<FromGitter> <faustinoaq> > If you're using an externally supplied package and worry that it might change in unexpected ways, the simplest solution is to copy it to your local repository. (This is the approach Google takes internally.) ⏎ ⏎ ^ https://golang.org/doc/faq#get_version ⏎ ⏎ ^ Really?, so no `major.minor.patch` versions? I'm trying to learn go and I found this when I was importing some dependencies 😅
<oprypin> faustinoaq, :/
<FromGitter> <faustinoaq> > New major versions of your package must have their own repository. Put simply, each major version of your package (following semantic versioning) would have its own repository and thus its own import path. e.g. github.com/jpoehls/gophermail-v1 and github.com/jpoehls/gophermail-v2. ⏎ ⏎ ^ http://zduck.com/2014/go-and-package-versioning/ ⏎ ⏎ Ok, that's odd 😟
ua_ has joined #crystal-lang
rohitpaulk has joined #crystal-lang
<FromGitter> <faustinoaq> Well, at least go is a worth learning I think 😅
<FromGitter> <faustinoaq> Oh, I found this: https://github.com/niemeyer/gopkg 😄
<oprypin> faustinoaq, stahp
<FromGitter> <girng> i tried golang
<FromGitter> <girng> but syntax too confusing, soi went back to crystal
rohitpaulk has quit [Ping timeout: 240 seconds]
<travis-ci> crystal-lang/crystal#3138b52 (master - Add `Hash#last_key` and `Hash#last_value` (#5760)): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/363587162
<DeBot> https://github.com/crystal-lang/crystal/pull/5760 (Add Hash#last_key and Hash#last_value)
<FromGitter> <j8r> someone's know a lang that is slick as C, fast as Ruby? :)
<FromGitter> <girng> PHP 😂
<FromGitter> <faustinoaq> lol XD
<RX14> lol
qard has quit [Quit: qard]
<FromGitter> <faustinoaq> Hey I you want to see a nice comparison between Ruby and other languages check this: https://pragtob.wordpress.com/2018/01/27/slides-where-do-rubyists-go/
<FromGitter> <girng> instructions unclear, installed rust
<FromGitter> <faustinoaq> Rust looks nice, I haven't tried it yet, though
<FromGitter> <girng> once im really done with ym gameserver i'll try other languages
<FromGitter> <girng> but too focused now, can't stop won't stop w/ crystal
<FromGitter> <faustinoaq> https://github.com/obskyr/hamtaro-in-pieces ⏎ ⏎ ^ Interesting, seems someone is experimenting with a lot of assembly and crystal 😄
Creatornator has joined #crystal-lang
<FromGitter> <j8r> rust is good for low level system, but you won't have the productivity of other GC langs :/
<FromGitter> <girng> damn that's way out of my league
<FromGitter> <girng> @faustinoaq
Creatornator has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
qard has joined #crystal-lang
ashirase has quit [Ping timeout: 264 seconds]
<FromGitter> <faustinoaq> ^ Interesting how Microsoft has an integrated Github feedback here
<FromGitter> <faustinoaq> ^ Does someone knows how to implement something similar in a website?
<FromGitter> <faustinoaq> Maybe using Github API from scratch 😅