ChanServ changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.29.0 | Fund Crystal's development: http://is.gd/X7PRtI | GH: https://github.com/crystal-lang/crystal | Docs: http://crystal-lang.org/docs/ | API: http://crystal-lang.org/api/ | Gitter: https://gitter.im/crystal-lang/crystal
snsei__ has joined #crystal-lang
snsei__ has quit [Remote host closed the connection]
snsei__ has joined #crystal-lang
snsei__ has quit [Remote host closed the connection]
snsei__ has joined #crystal-lang
snsei__ has quit [Remote host closed the connection]
snsei__ has joined #crystal-lang
snsei__ has quit [Remote host closed the connection]
snsei__ has joined #crystal-lang
snsei__ has quit [Remote host closed the connection]
snsei__ has joined #crystal-lang
snsei__ has quit [Remote host closed the connection]
snsei__ has joined #crystal-lang
snsei__ has quit [Remote host closed the connection]
snsei__ has joined #crystal-lang
snsei__ has quit [Remote host closed the connection]
snsei__ has joined #crystal-lang
snsei__ has quit [Remote host closed the connection]
snsei__ has joined #crystal-lang
snsei__ has quit [Remote host closed the connection]
snsei__ has joined #crystal-lang
snsei__ has quit [Remote host closed the connection]
snsei__ has joined #crystal-lang
snsei__ has quit [Remote host closed the connection]
snsei__ has joined #crystal-lang
snsei__ has quit [Remote host closed the connection]
snsei__ has joined #crystal-lang
snsei__ has quit [Ping timeout: 252 seconds]
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
laaron has joined #crystal-lang
snsei__ has joined #crystal-lang
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 248 seconds]
snsei__ has quit [Remote host closed the connection]
snsei__ has joined #crystal-lang
_whitelogger has joined #crystal-lang
snsei__ has quit [Remote host closed the connection]
snsei__ has joined #crystal-lang
snsei__ has quit [Remote host closed the connection]
snsei__ has joined #crystal-lang
snsei__ has quit [Remote host closed the connection]
snsei__ has joined #crystal-lang
snsei__ has quit [Remote host closed the connection]
snsei__ has joined #crystal-lang
snsei__ has quit [Remote host closed the connection]
snsei__ has joined #crystal-lang
snsei__ has quit [Remote host closed the connection]
snsei__ has joined #crystal-lang
snsei__ has quit [Remote host closed the connection]
snsei__ has joined #crystal-lang
snsei__ has quit [Remote host closed the connection]
snsei__ has joined #crystal-lang
snsei__ has quit [Remote host closed the connection]
snsei__ has joined #crystal-lang
snsei__ has quit [Remote host closed the connection]
snsei__ has joined #crystal-lang
snsei__ has quit [Remote host closed the connection]
snsei__ has joined #crystal-lang
snsei__ has quit [Remote host closed the connection]
snsei__ has joined #crystal-lang
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 246 seconds]
rohitpaulk has joined #crystal-lang
snsei__ has quit [Remote host closed the connection]
rohitpaulk has quit [Ping timeout: 248 seconds]
<FromGitter> <watzon> Added an issue to get Crystal support in Dependabot on Github dependabot/dependabot-core#1237
_whitelogger has joined #crystal-lang
_whitelogger has joined #crystal-lang
_whitelogger has joined #crystal-lang
DTZUZO has quit [Ping timeout: 245 seconds]
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 245 seconds]
<FromGitter> <girng> hi
<FromGitter> <girng> crystal time baby
<FromGitter> <bestwebua> Hello! Is it possible to use keywords args for methods, like in ruby
rohitpaulk has joined #crystal-lang
DTZUZO has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 244 seconds]
alex`` has joined #crystal-lang
<FromGitter> <bew> @bestwebua you can by default, just do `def foo(arg);end` then call it `foo(arg: 1)`
<FromGitter> <watzon> @bestwebua you can specify default arguments like this `def foo(bar = 2)` and then call them like this `foo(bar: 3)`. If you want any arguments to only be named, and not named or positional, you can do this `def foo(positional_argument, *, named_arg = 3, another = "foo")`
<FromGitter> <watzon> The `*` means "anything after me is named"
<FromGitter> <bestwebua> Thank you, @watzon!!
<FromGitter> <girng> what's the downside of storing 2 references to a class? https://play.crystal-lang.org/#/r/75uo
<FromGitter> <girng> looks like i just need to make sure to delete them both if i do, so gc can free em https://play.crystal-lang.org/#/r/75us
DTZUZO has quit [Quit: WeeChat 2.0]
DTZUZO has joined #crystal-lang
laaron- has joined #crystal-lang
laaron has quit [Ping timeout: 260 seconds]
yxhuvud has quit [Quit: No Ping reply in 180 seconds.]
alex`` has quit [Ping timeout: 268 seconds]
<FromGitter> <mwlang> @asterite How do you check the first token? ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ Results in: ```private method 'token' called for JSON::PullParser``` [https://gitter.im/crystal-lang/crystal?at=5d18d19affd4b84a8fdd6a89]
<FromGitter> <Blacksmoke16> `pull.kind`
<FromGitter> <Blacksmoke16> `pull.kind == :[`
<FromGitter> <Blacksmoke16> something like that
<FromGitter> <mwlang> that worked. thanks!
<FromGitter> <Blacksmoke16> np
<FromGitter> <girng> why do they have protected and public functions in languages
<FromGitter> <girng> for example, in crystal there is a protected keyword, what is the real-world usecase?
<FromGitter> <tenebrousedge> so that you can control how other people use your code
<FromGitter> <Blacksmoke16> usually something that would alter the function of a class but without allowing it to be invoked outside of that class
<FromGitter> <Blacksmoke16> i can make an example
<FromGitter> <tenebrousedge> something that's not public is to some degree considered an "implementation detail", which is subject to change without notice
<FromGitter> <tenebrousedge> a public interface is in some senses a contract between your code and other code that uses it
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/75vg
<FromGitter> <Blacksmoke16> not the best example, but the better way to think about it would be like
<FromGitter> <Blacksmoke16> `
<FromGitter> <Blacksmoke16> `
<FromGitter> <girng> is same?
<FromGitter> <Blacksmoke16> similar yes, but it prevents you from doing
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/75vt
<FromGitter> <Blacksmoke16> protected methods can only be used within the class or its children
<FromGitter> <Blacksmoke16> i have a better example in that comment
<FromGitter> <girng> what a ridiculous rule
<FromGitter> <girng> how is using a property outside of its class or children bad
<FromGitter> <tenebrousedge> inheritance is useful, for certain problems
<FromGitter> <Blacksmoke16> i mean its not really a crystal specific issue, this is more so general OOP
<FromGitter> <girng> with that said, ty for the example i get it a bit better now
<FromGitter> <Blacksmoke16> in crystal there isnt really a difference between private/protected methods tbh
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/75vw
<FromGitter> <Blacksmoke16> like this works just fine
<FromGitter> <girng> i think this is more of a feature if working in large teams or people, you might want some stuff protected
<FromGitter> <girng> but for 1 man show, where 1 dev knows his code, i think it's silly af
<FromGitter> <tenebrousedge> say you're working with a bunch of similar APIs, you would probably want an abstract `BaseAPI` class with a protected `base_url` property
<FromGitter> <Blacksmoke16> @girng i used the inheritance and stuff in the OOP approach to that guys game
<FromGitter> <Blacksmoke16> so you only needed 1 `def detail` to handle each attribute
<FromGitter> <girng> @tenebrousedge that makes sense
<FromGitter> <girng> @tenebrousedge good use case example
<FromGitter> <girng> @Blacksmoke16 yeah, great work doing that for that guy. that was very cool
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d18dbfc03d62b4d28b86f2b]
<FromGitter> <girng> oh god
<FromGitter> <Blacksmoke16> php doesnt treat private/protected the same
<FromGitter> <Blacksmoke16> but in crystal there isnt really a difference atm
<FromGitter> <girng> my php code is globals in every function, i don't think i have any OOP outside of google's re-captcha api
<FromGitter> <girng> to be fair here, it's built ontop of fluxbb which is like a decade+ old
<FromGitter> <Blacksmoke16> hehe
<FromGitter> <girng> i just love writing functions and passing stuff by reference
<FromGitter> <girng> shit just makes so much more sense to me lol
<FromGitter> <Blacksmoke16> now just start moving stuff to use objects and be even better 😉
<FromGitter> <girng> i love crystal's oop too, especially classes and properties. it's like a good mix, i can use procedural and oop.
<FromGitter> <girng> hits the sweet spot for me
<FromGitter> <tenebrousedge> globals in PHP D: D: D: D:
<FromGitter> <girng> :D
<FromGitter> <j8r> the `protected` keyword allows to call the method only in the same namespace
<FromGitter> <j8r> quite useful if you have several objects inside a module
<FromGitter> <girng> example?
<FromGitter> <j8r> https://carc.in/#/r/75vy
<FromGitter> <j8r> hum wait, the tap don't work
<FromGitter> <girng> 😆
<FromGitter> <j8r> but anyway doen't matter, you can call methods
<FromGitter> <j8r> (replace struct by class fix it btw)
<FromGitter> <j8r> You can also protect the initializer
<FromGitter> <girng> o really/
<FromGitter> <girng> from who
<FromGitter> <j8r> https://carc.in/#/r/75w6
<FromGitter> <girng> interesting
<FromGitter> <j8r> this way the user is forced to use a wrapper to get an object, no other way possible (except mokey-patching) :)
<FromGitter> <girng> life is too complicated sometimes
<rkeene> I just name the methods I don't want people using starting with an underscore to indicate its level of support is 0
<FromGitter> <girng> ^^
<FromGitter> <girng> anyone see the typo?
<FromGitter> <j8r> the point
<rkeene> " eacho" -> ".each", presumably
<rkeene> oops
<FromGitter> <girng> ;D took me a while to find it
<rkeene> " each" -> ".each", presumably
<FromGitter> <girng> i was like wtfffffffff lol
rohitpaulk has joined #crystal-lang
<FromGitter> <Blacksmoke16> `GC Warning: Repeated allocation of very large block (appr. size 536875008):` uh oh
<FromGitter> <watzon> I've seen that one!
<FromGitter> <watzon> You've got a memory leak m'friend
<FromGitter> <Blacksmoke16> :P
<FromGitter> <watzon> I have the same issue with my vector math library right now
<FromGitter> <Blacksmoke16> but im not even doing anything :p
<FromGitter> <Blacksmoke16> ill have to see if i can make a smaller example
t1|Mike has quit [Read error: Connection reset by peer]
<FromGitter> <Blacksmoke16> this python lib might tho
<FromGitter> <Blacksmoke16> parsing a 190mb JSON file, and its using 9 gigs of ram atm
<FromGitter> <watzon> Well it's python
t1|Mike has joined #crystal-lang
<FromGitter> <Blacksmoke16> seems a bit excessive
t1|Mike has quit [Read error: Connection reset by peer]
t1|Mike has joined #crystal-lang
<FromGitter> <j8r> wow
moei has joined #crystal-lang
<FromGitter> <Blacksmoke16> ikr?
<FromGitter> <Blacksmoke16> ended up taking 20 gigs and 13min
<FromGitter> <j8r> what's the json parser?
<FromGitter> <Blacksmoke16> not sure
<FromGitter> <Blacksmoke16> https://github.com/kislyuk/yq is this lib tho
<FromGitter> <Blacksmoke16> is there any concept of output streaming in crystal?
<FromGitter> <Blacksmoke16> doing a process.run on a process that will stream output as its ready, but the process is finishing and closing the output causing a broken pipe error
<FromGitter> <Blacksmoke16> trying to think of what my options are...
<FromGitter> <Blacksmoke16> besides just catching the exception and printing the output
alex`` has joined #crystal-lang
<FromGitter> <j8r> you can specify the IO
<FromGitter> <j8r> maybe with no buffer to solve your problem
<FromGitter> <Blacksmoke16> what would that look like?
<FromGitter> <Blacksmoke16> currently im just doing like
<FromGitter> <Blacksmoke16> ` run = Process.run("jq", args, input: input.rewind, output: output, error: err)` ⏎ where `output` is an `IO::Memory`
<FromGitter> <j8r> then you can't read the `output`, because it's closed?
<FromGitter> <j8r> ...I'm curious, why are you using jq?
<FromGitter> <Blacksmoke16> making a wrapper that allows giving it json/yaml (soon xml), transform it via jq, then output to json/yaml/xml
<FromGitter> <j8r> this is to support for the jq syntax, can't be done in pure Crystal?
<FromGitter> <Blacksmoke16> im sure it could, but that would be a lot of work
<FromGitter> <Blacksmoke16> for something that is already done and done well
<FromGitter> <j8r> what would be `args`, accessing to an arbitrary key?
<FromGitter> <j8r> What will be hard to do is all the filters :/
<FromGitter> <Blacksmoke16> args would just be the args passed to the binary
<FromGitter> <Blacksmoke16> ```$ echo '{"name": "Jim"}' | ./bin/oq --stream -c . ⏎ ["--stream", "-c", "."]``` [https://gitter.im/crystal-lang/crystal?at=5d190a4e490abf627a4dc66d]
<FromGitter> <j8r> of course
<FromGitter> <Blacksmoke16> and yea, jq has a bunch of shit
<FromGitter> <j8r> just curious what 's the usage of jq you will do
<FromGitter> <j8r> because accessing to a dynamic key path is already possible in Crystal, if that's all you want
<FromGitter> <Blacksmoke16> the main use case that started the idea was at work we have some feeds that allow partners to consume data from them
<FromGitter> <Blacksmoke16> currently we're using jq to format the data into the format the partner wants from a master list of data
<FromGitter> <Blacksmoke16> a new partner wanted xml, so ideally having a single binary that could do all the processing using shared filters and output to whatever format we want would be ideal
<FromGitter> <Blacksmoke16> vs having separate logic/libs etc for json vs xml
<FromGitter> <j8r> ok i sea
<FromGitter> <Blacksmoke16> but current lib we're using is that python one, and its not performant
<FromGitter> <Blacksmoke16> which i was like, hey i could do this in crystal and get a big boost in perf
<FromGitter> <Blacksmoke16> :P
<FromGitter> <j8r> not possible to avoid closing the IO for jq?
<FromGitter> <Blacksmoke16> just to be clear, the issue is only when using the `--stream` command and the `inputs` options, which makes jq do some work, then pause for a bit, then close
<FromGitter> <Blacksmoke16> but i think the `Process.run` when its done closes the output soon as it gets the data
rohitpaulk has quit [Remote host closed the connection]
<FromGitter> <Blacksmoke16> causing the error, but still has the correct data
<FromGitter> <Blacksmoke16> ideally id like to support jq `1:1` but for initial version its not a big deal imo
<FromGitter> <cfsamson> Is a pointer to a class a fat pointer in Crystal?
<FromGitter> <cfsamson> It looks like it, though...
<FromGitter> <Blacksmoke16> idk what that means so ill leave that for someone else
<FromGitter> <j8r> AFAIK Process.run don't close IO
<FromGitter> <Blacksmoke16> it does because of `#wait`
<FromGitter> <cfsamson> It probably is. Looks like the first is a pointer to the vtable and the second to the data.
<FromGitter> <j8r> @Blacksmoke16 so `Process.new`
<FromGitter> <j8r> don't wait to finish
<FromGitter> <Blacksmoke16> oh nice, yea that could work
<FromGitter> <j8r> hum in fact I always use `Process.new`
<FromGitter> <j8r> that's why for me I didn't have the issue
<FromGitter> <Blacksmoke16> hm, but how would you know when its done then?
<FromGitter> <Blacksmoke16> its like i need to wait for it to finish, but not close the ios
<FromGitter> <j8r> I use `wait` 😅
<FromGitter> <Blacksmoke16> like manually call wait
<FromGitter> <j8r> but I don't have any issue when doing `IO::Memory#to_s`
<FromGitter> <j8r> try with another binary like `ls`
<FromGitter> <j8r> it will work
<FromGitter> <j8r> or, do a custom `while` to wait
<FromGitter> <Blacksmoke16> my ios would get closed when the process exits or should i manually close them in like an ensure block?
<FromGitter> <Blacksmoke16> actually turns out the issue is coming from https://github.com/crystal-lang/crystal/blob/c943f43c932aef19143a4f0886a87a474fa3698d/src/process.cr#L349
<FromGitter> <Blacksmoke16> but i probably dont want to just comment that out...
<FromGitter> <j8r> I don't really know
<FromGitter> <Blacksmoke16> yea, i prob just let it become an issue
<FromGitter> <j8r> it seems like the IO is copied
alex`` has quit [Read error: Connection reset by peer]
<FromGitter> <Blacksmoke16> :S
<FromGitter> <j8r> sorry I don't know much about your issue
<FromGitter> <Blacksmoke16> me neither
<FromGitter> <Blacksmoke16> :P
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d191242490abf627a4e07be]
<FromGitter> <Blacksmoke16> and notice you see the output, then there is that delay until process finishes
<FromGitter> <Blacksmoke16> which that delay is the issue id imagine
alex`` has joined #crystal-lang
lucasb has joined #crystal-lang
<FromGitter> <girng> that json is huge wtf
<FromGitter> <j8r> ... :o
alex`` has quit [Ping timeout: 245 seconds]
<FromGitter> <watzon> That is one massive fucking file
<FromGitter> <Blacksmoke16> this is the thing that took the python thing 13min and 20 gigs of ram to do
alex`` has joined #crystal-lang
<FromGitter> <girng> LOOOOOOOOL
<FromGitter> <Blacksmoke16> that jq does in like 2 sec using 20mb of ram
<FromGitter> <girng> impressive
<FromGitter> <Blacksmoke16> yea it does something with the input so it streams it in, vs loading it all into memory
Jolav has joined #crystal-lang
Jolav has quit [Remote host closed the connection]
<FromGitter> <watzon> I feel like I've asked this before, but is it possible to build a binary together with dependencies like libssl?
<jokke> you mean static linking?
<jokke> watzon, you could try with alpine. I've statically linked several projects in alpine
<jokke> best build in a docker image
<FromGitter> <watzon> Good idea
moei has quit [Quit: Leaving...]
<jokke> i maintain an alpine based crystal image
<jokke> jreinert/crystal-alpine
<jokke> but there has been some kind of regression in alpine that causes it to fail decoding utf8
<jokke> so currently only jreinert/crystal-alpine:0.27.0 and lower work
<FromGitter> <watzon> Well that sucks
<jokke> yeah :/
<jokke> it also happens in a fresh alpine image
_whitelogger has joined #crystal-lang
lucasb has quit [Quit: Connection closed for inactivity]
<rkeene> What I did when I wanted to statically link was tell Crystal I was cross-compiling, then it gave me object files and I could do the final linking myself