RX14 changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.27.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
<FromGitter> <iambudi> Is there a way to define default value for JSON.mapping if key in json string does not exist?
<FromGitter> <iambudi> got it. nevermind
<FromGitter> <Blacksmoke16> https://github.com/Blacksmoke16/CrSerializer might be worth checking out if you doing a lot of serialization stuff
laaron- has joined #crystal-lang
laaron has quit [Ping timeout: 256 seconds]
<FromGitter> <iambudi> > https://github.com/Blacksmoke16/CrSerializer might be worth checking out if you doing a lot of serialization stuff ⏎ ⏎ Thank you.
_whitelogger has joined #crystal-lang
johndescs has quit [Ping timeout: 244 seconds]
laaron- has quit [Quit: ZNC 1.7.1 - https://znc.in]
johndescs has joined #crystal-lang
laaron has joined #crystal-lang
<FromGitter> <Blacksmoke16> Np, feedback welcomed @iambudi
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
laaron has joined #crystal-lang
<FromGitter> <girng> how come the second instance of player has the same array as the first instance of player?
<FromGitter> <dscottboggs_gitlab> wtf
<FromGitter> <dscottboggs_gitlab> It looks like when you set `Player#char_img`, it's changing where DEFAULT_CHAR_IMG_ARRAY points to
<FromGitter> <dscottboggs_gitlab> but DEFAULT_CHAR_IMG_ARRAY is a constant, so why is it being changed??
<FromGitter> <dscottboggs_gitlab> OH SHIT
<FromGitter> <dscottboggs_gitlab> I see it
<FromGitter> <dscottboggs_gitlab> DEFAULT_CHAR_IMG_ARRAY is a constant array. that means there's a constant pointer allocated on the stack to a mutable array on the heap.
<FromGitter> <dscottboggs_gitlab> https://play.crystal-lang.org/#/r/625e
<FromGitter> <dscottboggs_gitlab> since you don't change what `Player#char_img` points to at the beginning, it's still pointing to DEFAULT_CHAR_IMG_ARRAY, which is what you change in `modify_char_img`
<FromGitter> <girng> O_o
<FromGitter> <dscottboggs_gitlab> You didn't say "I want to set `char_img`" you said "I want to change the contents of `char_img`" which is very different in this particular case
<FromGitter> <girng> yeah it's a Constant so why is it being modified?
<FromGitter> <girng> i thought those are immutable
<FromGitter> <girng> or am i thinking of tuples
<FromGitter> <dscottboggs_gitlab> The thing that's constant in this case is the pointer, not what the pointer points to
<FromGitter> <dscottboggs_gitlab> so you can't set DEFAULT_CHAR_IMG_ARRAY twice, but you can change the contents of the array because an array is a class, which is a reference type
<FromGitter> <girng> got it i think
<FromGitter> <girng> i understand better now ty
<FromGitter> <girng> i was thinking each new player instance got it's own char_img that was a Constant
<FromGitter> <girng> didn't know it would change, yikes glad i found this early on
<FromGitter> <dscottboggs_gitlab> yes that could've been nasty to find in a larger code-base. But using `#clone` or `#dup` should get you the results you're looking for
<FromGitter> <dscottboggs_gitlab> I don't think there's an immutable Array type in crystal
<FromGitter> <girng> i can just use a tuple right?
<FromGitter> <dscottboggs_gitlab> tuples' values are mutable, but they would be more appropriate in this case
<FromGitter> <girng> i thought tuples were immutable
<FromGitter> <girng> wtf
<FromGitter> <dscottboggs_gitlab> shit, I might be wrong
<FromGitter> <dscottboggs_gitlab> yep
<FromGitter> <dscottboggs_gitlab> You're right
<FromGitter> <girng> oh hahha i went to google it instantly
<FromGitter> <dscottboggs_gitlab> not to the docs (https://crystal-lang.org/api/0.27.0/Tuple.html)?
<FromGitter> <dscottboggs_gitlab> ;)
<FromGitter> <girng> well i just go new tab, type crystal tuple and go first link which is doc lol
<FromGitter> <girng> although i should bookmark it so it's faster
<FromGitter> <girng> then just type in search box on top left
<FromGitter> <dscottboggs_gitlab> yes I think tuple is exactly what you're looking for if you want th ewhole thing to be immutable. but then `modify_char_img` won't work because it's mutating the values..but you know that haha
<FromGitter> <girng> yeah was just thinking of that. your example is what i need
<FromGitter> <dscottboggs_gitlab> What should I name my video streaming server app guys?
<FromGitter> <dscottboggs_gitlab> @gring maybe use a StaticArray since you know how many values there will be? or something like...
<FromGitter> <girng> no idea, is that gonna be coded in crystal?
<FromGitter> <girng> your video streaming server?
<FromGitter> <dscottboggs_gitlab> yes, it is, crystal and react
<FromGitter> <dscottboggs_gitlab> https://github.com/dscottboggs/flix.cr
<FromGitter> <girng> is it gonna be like streamable?
<FromGitter> <girng> that's pretty cool i starred it
<FromGitter> <dscottboggs_gitlab> thanks, yeah, you can try it out, there's a demo site linked at the top of the github readme
<FromGitter> <dscottboggs_gitlab> @gring why not use a struct? https://play.crystal-lang.org/#/r/625m
<FromGitter> <girng> can't access property with [] notation to modify it
<FromGitter> <dscottboggs_gitlab> I mean, technically you can, but now you've got me curious why need that specifically
<FromGitter> <girng> yeah with overloads, etc
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
<FromGitter> <girng> i just do namedtuple, simple for me
laaron has joined #crystal-lang
* FromGitter * dscottboggs_gitlab shrugs
<FromGitter> <girng> how come this doesn't work?
<FromGitter> <girng> isn't it doing `property char_img = [0, 0, 0, 0, 0, 0, 0, 0, 0]`?
<FromGitter> <dscottboggs_gitlab> What?? what is define_method supposed to do??
<FromGitter> <girng> copy and paste `property char_img = [0, 0, 0, 0, 0, 0, 0, 0, 0]` in the class
<FromGitter> <girng> https://play.crystal-lang.org/#/r/626j/edit this doesn't work either
<FromGitter> <dscottboggs_gitlab> 1: what for? ⏎ 2: consider this https://play.crystal-lang.org/#/r/626m
<FromGitter> <dscottboggs_gitlab> also this https://play.crystal-lang.org/#/r/626u
<FromGitter> <girng> i give up... i'll just use your clone way but it's confusing to me
<FromGitter> <dscottboggs_gitlab> I don't understand what that macro was supposed to do
<FromGitter> <dscottboggs_gitlab> clone creates a new array with the contents of the original, rather than just having another variable point at the same chunk of data
<FromGitter> <girng> instead of the clone way, i could just do `property char_img = [0, 0, 0, 0, 0, 0, 0, 0, 0]`. i was hoping the macro could copy and paste that into the class
<FromGitter> <girng> but regarding the clone way, i've never seen ` property char_img : Array(Int32) = DEFAULT_CHAR_IMG_ARRAY.clone` before. the `: Type =` part? wtf??
<FromGitter> <dscottboggs_gitlab> OH!
<FromGitter> <girng> how come we can't just do property char_img = DEFAULT_CHAR_IMG_ARRAY.dup or DEFAULT_CHAR_IMG_ARRAY.clone?
<FromGitter> <girng> it returns the array... wtf
<FromGitter> <dscottboggs_gitlab> I agree, I'm not sure why that type annotation is necessary
<FromGitter> <girng> is that what the : Type = is called?
<FromGitter> <girng> "type annotation?"
<FromGitter> <girng> i just never seen that code before lol
<FromGitter> <dscottboggs_gitlab> ...how?
<FromGitter> <girng> yours is different cause it has the : Type and =
<FromGitter> <girng> all in one!
<FromGitter> <dscottboggs_gitlab> actually this is what I was trying to point you to https://crystal-lang.org/reference/syntax_and_semantics/type_restrictions.html
<FromGitter> <dscottboggs_gitlab> `property prop_name : Type = value` is the same as saying ⏎ ⏎ ```property prop_name : Type ⏎ prop_name = value``` [https://gitter.im/crystal-lang/crystal?at=5c46977b20b78635b660f816]
<FromGitter> <girng> O_o
<FromGitter> <dscottboggs_gitlab> if the compiler fails to infer the type of a value you're using, you must inform it of the type.
<FromGitter> <girng> so wait..
<FromGitter> <dscottboggs_gitlab> All types must be known at compile time, this is the benefit and detriment of a strictly-typed statically-compiled language.
<FromGitter> <girng> so we can do property name = "" (it's a string) and works. but we don't do property name : String = "", why????
<FromGitter> <dscottboggs_gitlab> Because it's not necessary. You CAN, but you don't HAVE to.
<FromGitter> <girng> but we can't do that same with arrays? we have to explicitly type annotate it? that's where my confusion comes from i think
<FromGitter> <dscottboggs_gitlab> You can but if you move the value to a macro or a method, after a hop or two of not finding a type the compiler gives up and says "no, just tell me what you're trying to put in here"
<FromGitter> <dscottboggs_gitlab> also, no macro needed https://play.crystal-lang.org/#/r/627d
<FromGitter> <dscottboggs_gitlab> this error shows all the ways that crystal can infer the type of an instance variable https://play.crystal-lang.org/#/r/627e
<FromGitter> <girng> it's necessary for arrays is what i mean
<FromGitter> <dscottboggs_gitlab> It's necessary in all the instances not covered by the explicit rules laid out in the error message in my last link
<FromGitter> <girng> nevermind i'm confusing myself
<FromGitter> <dscottboggs_gitlab> so when using an array literal, or `property name = Array(SomeType).new` you don't need it, but if you're doing `property name = method_returning_array` you do
<FromGitter> <girng> https://play.crystal-lang.org/#/r/627g i wrote in the comments
<FromGitter> <dscottboggs_gitlab> Idk, rule 4 says it should work, but it doesn't
<FromGitter> <girng> ```thus, it becomes property char_img = [0, 0, 0, 0, 0, 0, 0, 0, 0] which does work``` ⏎ ⏎ so what does `property char_img = DEFAULT_CHAR_IMG_ARRAY.dup` become then? if .dup returns the array, it would essentially be the code above right? [https://gitter.im/crystal-lang/crystal?at=5c469a2e7a0f4d5b19e96816]
<FromGitter> <dscottboggs_gitlab> no
<FromGitter> <girng> why?
<FromGitter> <dscottboggs_gitlab> because `dup` is a function call, which is a runtime action, as opposed to dropping the literal in, which would be a compile-time action
<FromGitter> <dscottboggs_gitlab> but putting it in a macro doesn't work either, probably because of the order compilation and type inference happen in at compile time
<FromGitter> <girng> your gonna kill me, but `dup` is used here and it works though `property char_img : Array(Int32) = DEFAULT_CHAR_IMG_ARRAY.dup` ⏎ so the function call (runtime actions), can only work when you are explicitly setting a type? if i got that right?
<FromGitter> <dscottboggs_gitlab> I mean, that's what it seems be doing, although the messsage seems to indicate that as long as `dup` has a Type signiature on it it should work
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
<FromGitter> <girng> i mean am i the only one who finds this confusing? we are taught not use .dup, function calls in property macros. but then when setting a type, we are free to use a function call and it works.. so 😕
laaron has joined #crystal-lang
<FromGitter> <dscottboggs_gitlab> OH I misread rule 4
<FromGitter> <dscottboggs_gitlab> take a look here https://play.crystal-lang.org/#/r/627q
<FromGitter> <dscottboggs_gitlab> and then reread over the type inference rules
<FromGitter> <girng> why is there 2 initializers
<FromGitter> <dscottboggs_gitlab> one with an argument, one that leaves it as the default. different overloads
<FromGitter> <dscottboggs_gitlab> so you could do `Klass.new [1, 2, 3]`
<FromGitter> <girng> i see
<FromGitter> <dscottboggs_gitlab> the one with the type annotation tells the compiler what type `@ary` is supposed to be.
<FromGitter> <girng> WTF
<FromGitter> <girng> https://play.crystal-lang.org/#/r/628i here (given 0, expected 1)
<FromGitter> <girng> that's the dupe coming
<FromGitter> <girng> then, add the second initializer, boom: https://play.crystal-lang.org/#/r/628j
<FromGitter> <matthewmcgarvey> The first one, there is no `Klass.new` method that takes no arguments. There is only a `Klass.new` that takes an `Array(Int32)`. Every `Klass#initialize` generates a `Klass.new` method
<FromGitter> <matthewmcgarvey> But with your first one, you could do https://play.crystal-lang.org/#/r/628k
<FromGitter> <girng> interesting, ty
<FromGitter> <girng> and @dscottboggs_gitlab ty too. i think i'm getting it now
lvmbdv has quit [Ping timeout: 240 seconds]
lvmbdv has joined #crystal-lang
marmotini_ has joined #crystal-lang
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
laaron has joined #crystal-lang
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
laaron has joined #crystal-lang
_whitelogger has joined #crystal-lang
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
<FromGitter> <mavu> Hi, I made a more detailed forum post with my c-binding proc problem from yesterday, if anyone has some time to take a look and give me some suggestions, that would be great :) ⏎ https://forum.crystal-lang.org/t/help-c-binding-of-function-that-takes-callback/325
FromGitter has quit [Remote host closed the connection]
oprypin has quit [Quit: Bye]
FromGitter has joined #crystal-lang
<FromGitter> <bew> @mavu I've replied on the forum, let me know if it gives you sth useful :)
ashirase has quit [Ping timeout: 244 seconds]
<FromGitter> <mavu> @bew Thanks! That does get me a small step further, although I don't like the idea of checking a variable every second to see if i need to trigger something. I think I have to have a look at the ruby bindings for this function and see if that gives me some ideas.
ashirase has joined #crystal-lang
<FromGitter> <mavu> Haha :) If i read this correctly the ruby bindings neatly sidestep the issue: https://github.com/WiringPi/WiringPi-Ruby/blob/master/lib/wiringpi/event.rb ⏎ by polling :)
<FromGitter> <bew> I agree with you, polling looks wrong (either the ruby way, or checking a var change)
<FromGitter> <bew> it might be worth looking at how the signal are handled in the stdlib! Signal are kinda like interrupts as they are triggered by external event, and the handler is a C function (registered with `LibC.signal`) which doesn't take data argument
<FromGitter> <bew> @mavu ^
<FromGitter> <bew> the signal handling code is 'a bit' complex though
ua_ has joined #crystal-lang
ua has quit [Ping timeout: 244 seconds]
<FromGitter> <mavu> Thats a good idea, I'll have a look at the signals code.
<FromGitter> <mavu> on a sidenote, if I ever invent a programming language I shall name it "gmahbld", because that word yields exactly 3 hits on google and will make searching stuff much easier without constantly having esoteric articles or things about chemistry in my results.
<FromGitter> <mavu> from crystal signal.cr : ⏎ module Crystal::Signal ⏎ # The number of libc functions that can be called safely from a signal(2) ⏎ # handler is very limited. An usual safe solution is to use a pipe(2) and ⏎ # just write the signal to the file descriptor and nothing more. A loop in ... [https://gitter.im/crystal-lang/crystal?at=5c46f42f9bfa375aab3f5746]
<FromGitter> <mavu> Apparently the "loop to read variable" idea is not too far off the way signals are handled.
<FromGitter> <bew> yeah but the loop is event-ed, meaning that if there is nothing to read it'll just wait until there's something to read from the pipe (using the libevent that the crystal runtime uses for everything)
marmotini_ has quit [Ping timeout: 246 seconds]
marmotini_ has joined #crystal-lang
<FromGitter> <mavu> Ahhh
<FromGitter> <mavu> Thats a great point.
<FromGitter> <mavu> If I do the same thing, write to a pipe instead of a global variable, I can to the same and wait for IO. That sounds promising!
<FromGitter> <girng> Dir.children("./src/Data/Levels") WOW that was easy lmao noiccee!!!
<FromGitter> <girng> now just need to cut off the .txt of the file names
<FromGitter> <girng> puts file_name.chomp(".txt") 💗 me some chomp
<FromGitter> <j8r> or rchop
<FromGitter> <j8r> I find `chomp(String | Char)` confusing, this duplicated `.chomp.rchop(String | Char)`
<FromGitter> <j8r> I'm opening an issue on this
<FromGitter> <j8r> the internal code is also duplicated from rchop :/
<FromGitter> <girng> oh is rchop the same?
<FromGitter> <girng> chomp is an alias?
<FromGitter> <girng> if you use the parameter
<FromGitter> <girng> i guess it removes last character, not carriage
<FromGitter> <j8r> chomp(suffix) do a `chomp`, removing any potential \n or \r, and a `rchop` (removing the suffix)
<FromGitter> <j8r> Hum, not exactly @girng
<FromGitter> <j8r> in fact it will not remove your string if it ends with a \n
<FromGitter> <j8r> for example `puts "abc\n".chomp "c" #=> abc`
<FromGitter> <girng> ya i mean rchop
<FromGitter> <j8r> so they are not alias. I didn't know because I never use chomp :)
<FromGitter> <j8r> always lchop or rchop
<FromGitter> <j8r> sometimes rstrip and lstrip
<FromGitter> <oprypin> mavu, what do u mean that u can't access outside functions? of course you can
<FromGitter> <girng> https://play.crystal-lang.org/#/r/62a2/edit is `\n` 1 character, or is it `n`?
<FromGitter> <girng> isn't \n a carriage?
<FromGitter> <oprypin> this is one of the cases where artificially reducing your question to the minimal length is not useful. I'd start it with "i want to do x, using this library for that, want to detect when x happens and do x in response, using this function"
<FromGitter> <oprypin> @mavu something i already mentioned is that "current object" is like a local variable
<FromGitter> <oprypin> Python and C++don't conceal that fact
<FromGitter> <oprypin> and i assume you were trying to access methods on the current object but local variables are not allowed
<mps> girng: I will be surprised if the '\\n' is carriage return. it should be two chars '\' and 'n'
<FromGitter> <oprypin> wat
<FromGitter> <girng> rchop should remove just the \n then right? since n is 1 character ( the last )
<mps> '\n' should be one character
<FromGitter> <girng> from docs: `Returns a new String with the last character removed`
<mps> '\' escapes next character, so '\\' is single '\' character
<FromGitter> <girng> hmmm i see
<mps> if you have '\' as last 'visible' character in string followed by carriage return then if you want to remove it and CR you should write them as '\\\n'
oprypin has joined #crystal-lang
<FromGitter> <matthewmcgarvey> carriage returns is `\r`. `\n` is newline. I’m pretty sure you can have a newline without a carriage return but can’t have a carriage return without a newline
<FromGitter> <matthewmcgarvey> In a string`\` is an escape sequence (or atleast that’s what I think it’s called) and when used with `\n`, `\t`, etc it’s just one character
<FromGitter> <bew> @matthewmcgarvey well, you can have a carriage return without a newline, it'll just overwrite previous text on the line (in terminals at least)
<FromGitter> <matthewmcgarvey> So a string like `“This is a\nsentence”` will put sentence on the next line but a string like `”This is still a\\nsentence”` will literally have a `\n` in the string because the escape sequence escaped the escape sequence haha
<FromGitter> <matthewmcgarvey> o right 👍
<FromGitter> <matthewmcgarvey> @bew I’ve started looking at the compiler class for crystal, is there any resources that I should look into if I want to understand how crystal is written? I’m not talking crystal specific
<mps> matthewmcgarvey: of course, just didn't looked carefully what I wrote
<FromGitter> <matthewmcgarvey> Oya, we said the same thing. I’m pretty out of it
davic has quit [Ping timeout: 250 seconds]
davic has joined #crystal-lang
<mps> well, ```printf("lf: %s\\n", 'l')``` and see
<FromGitter> <bew> @matthewmcgarvey what do you want to understand? how a compiler work? how the crystal code is handled, with the parsing/semantic/codegen/etc...? or just have a specific usecass in mind you don't know how to do? ..
<FromGitter> <matthewmcgarvey> I’ve worked with antlr before so I kind of understand the lexer part of getting the tokens which is what I looked through last night. The parser and generating the ASTNodes is what I don’t understand. Then especially the interaction with the llvm
jemc has quit [Ping timeout: 246 seconds]
<FromGitter> <bmulvihill> @matthewmcgarvey The parser creates the AST Nodes from the tokens and then Crystal uses Visitor pattern to traverse the nodes to determine type information, codegen etc..
jemc has joined #crystal-lang
<FromGitter> <drum445> ORMs vs plain SQL?
<FromGitter> <drum445> I prefer the latter
blassin has quit [Quit: The Lounge - https://thelounge.chat]
blassin has joined #crystal-lang
<FromGitter> <Blacksmoke16> you crazy :p
OvermindDL1 has quit [Quit: Connection closed for inactivity]
<FromGitter> <Blacksmoke16> maybe for simpler things, ORMs make things easier tho imo
<FromGitter> <drum445> haha
<FromGitter> <drum445> I like to know what SQL is being run I think
<FromGitter> <drum445> Spent too many years working with it. I'll have to look at ORMs more, what is a lightweight one in crystal?
<FromGitter> <matthewmcgarvey> https://github.com/drum445/objectify
<FromGitter> <drum445> That's mine lol ;)
<FromGitter> <matthewmcgarvey> :trollface:
<FromGitter> <drum445> you cheeky sod
<FromGitter> <drum445> I made that so you could still write your own SQL queries though, is there a more abstracted one
marmotini_ has quit [Ping timeout: 252 seconds]
<FromGitter> <Blacksmoke16> most ORMs will show you what is being ran with DEBUG logging
<FromGitter> <Blacksmoke16> so its there if you need it
<FromGitter> <Blacksmoke16> i personally like granite
<FromGitter> <girng> problem is \ is 1 character, dame for n
<FromGitter> <Blacksmoke16> has the `JSON::Serializable` stuff built in so can do fancy stuff like `Posts.import Array(Post).from_json json_str`
sevensidedmarble has quit [Ping timeout: 245 seconds]
<FromGitter> <Blacksmoke16> and field macros support custom annotations, so CrSerializer, or other shards that use annotations would work out of the box
<FromGitter> <matthewmcgarvey> @girng check this out https://play.crystal-lang.org/#/r/62as
<FromGitter> <girng> @matthewmcgarvey why is `puts str.includes? "n"` false?
<FromGitter> <matthewmcgarvey> because `str` does not include an `n` character, only a newline character `\n`
<mps> drum445: first ORM which (from my POV) looks i couuld/would use
<FromGitter> <dscottboggs_gitlab> because when you write \n it's translated into a newline character.
<FromGitter> <girng> but the method isn't searching for a newline it searches for a character, a specific one
<FromGitter> <girng> is should return true for "n"
<FromGitter> <matthewmcgarvey> right, `abc\ndef` could be translated to
<FromGitter> <matthewmcgarvey> abc
<FromGitter> <matthewmcgarvey> def
<FromGitter> <matthewmcgarvey> and that does not contain an `n` character
<FromGitter> <girng> yeah, then the dev should check for `\n`
<FromGitter> <girng> if they want to check for a newline
<FromGitter> <dscottboggs_gitlab> A newline character is represented by byte 0xA, a backslash is byte 0x5C, and 'n' is 0x6E
<FromGitter> <matthewmcgarvey> It gets complicated if you are reading in text because if I write in a text document `abc\ndef` that `\n` will be escaped which looking for the letter n would match on
<FromGitter> <matthewmcgarvey> I don’t know what you’re referencing so I’m not sure what you’re talking about
<FromGitter> <girng> me or scott?
<FromGitter> <matthewmcgarvey> you
<FromGitter> <girng> includes is misleading
<FromGitter> <girng> should return true for "n"
<FromGitter> <matthewmcgarvey> You can see them all here https://crystal-lang.org/reference/syntax_and_semantics/literals/string.html ⏎ If you look in the chars section they are there too because these escape sequences are really just one character but represented by two
ua_ has quit [Ping timeout: 244 seconds]
<FromGitter> <AllanKlaus> Hey guys, i'm with the following error `Unhandled exception: Invalid Float64` i'm using the last release, but I donno whats the version the project was build, do u know if had any break change in Float 64?
<FromGitter> <Blacksmoke16> got a playground link?
<FromGitter> <AllanKlaus> no
<FromGitter> <Blacksmoke16> will need some code to help :p
<FromGitter> <AllanKlaus> it's a github project
<FromGitter> <AllanKlaus> this is the file
<FromGitter> <Blacksmoke16> do you have `wrk` installed?
<FromGitter> <AllanKlaus> i dont think so
<FromGitter> <Blacksmoke16> im pretty sure its trying to deserialize an empty string to a Float64
<FromGitter> <Blacksmoke16> well there you go :p
<FromGitter> <Blacksmoke16> ex
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/62ax example of one of your errors
<FromGitter> <AllanKlaus> nice
<FromGitter> <Blacksmoke16> glad you made that issue tho, i wasnt able to get it working locally either :/
<FromGitter> <AllanKlaus> I was seeing in log that there was some with with `wrk`, but i didnt notice that it was a external dependency, there was no info on README, thx
<FromGitter> <AllanKlaus> u installed the wrk and it didnt work?
sevensidedmarble has joined #crystal-lang
<FromGitter> <Blacksmoke16> is what i was getting
<FromGitter> <AllanKlaus> i'm running it again
<FromGitter> <dscottboggs_gitlab> guys
<FromGitter> <dscottboggs_gitlab> my video streaming project needs a name
<FromGitter> <AllanKlaus> @Blacksmoke16 appear that is working now ⏎ ⏎ ```Benchmark running ... ⏎ Done. <- rails ⏎ Done. <- sinatra ⏎ ``` [https://gitter.im/crystal-lang/crystal?at=5c472f94746d4a677af2f1d5]
<FromGitter> <Blacksmoke16> :0
<FromGitter> <Blacksmoke16> try running `kemal`
ua_ has joined #crystal-lang
<FromGitter> <bew> @dscottboggs_gitlab the current one is good (flix iirc?)
<FromGitter> <dscottboggs_gitlab> yes that is it
<FromGitter> <dscottboggs_gitlab> thanks
<FromGitter> <Blacksmoke16> maybe i need to update my `wrk`
<FromGitter> <Blacksmoke16> ill have to try when i get home
<FromGitter> <drum445> @mps which ORM?
<mps> drum445: https://github.com/drum445/objectify but I should write "ORM" not ORM
<FromGitter> <drum445> ah thanks mate, yeah I like using very lightweight stuff
<FromGitter> <drum445> Tried to make it similar to dapper
<FromGitter> <girng> WOW
DTZUZO_ has quit [Ping timeout: 244 seconds]
<FromGitter> <drum445> You ok there @girng lol?
<FromGitter> <girng> ```struct A ⏎ include JSON::Serializable ⏎ @a : Int32 ⏎ @b : Float64 = 1.0 ⏎ end``` [https://gitter.im/crystal-lang/crystal?at=5c47344f95e17b452590e8a6]
<FromGitter> <girng> this notation.. I LOVE
<FromGitter> <drum445> Yeah it's great, I used it quite a lot as the basis of my ORM
<FromGitter> <girng> jesus. i want to use that now instead of my JSON.parse for stuff. i'm sure there is some kindof performance improvement somewhere right
<FromGitter> <girng> it's basically statically typing my JSON instead of using JSON::Any all over
<FromGitter> <girng> and i don't need to use .to_s, .as_i shenanigans all over lol
<FromGitter> <drum445> Yeah, I did some benchmarks on my ORM which uses JSON::Serializable and there were no problems at all
<FromGitter> <drum445> Exactly, reduces the number of anonymous objects flying around your code base
<FromGitter> <girng> i was just put off by it at first several months ago because of the syntax `@[JSON::Field(key: "lat")]`
<FromGitter> <girng> looked really confusing to me, but now since i see this way in the docs.. i'm prob gonna do it
<FromGitter> <girng> @drum445 ya exactly
<FromGitter> <drum445> Yep, they've done a nice job on it
<FromGitter> <girng> might do that for my game server that is on a tick rate. struct Message, etc. cause i'm using JSON.parse on every movement incoming tick (15x a second). I'm sure if i switched to statically typed json it'd be better. plus all 30 or so game commands use .as_i, as_i64, as_s too.. which is a lot of underlying type checking ⏎ ⏎ however, i'm possibly treading the grounds of premature optimization is the root of
<FromGitter> ... all evil because i don't really notice any performance problems. however.. it's just me on the server...
<mps> drum445: also, I like lightweight packages and don't like frameworks, only use them if don't have time to write complete app
<FromGitter> <drum445> @girng Can't say I know whether you'd see a performance gain, it will make the code nicer though. Are you seeing performance issues with your current method?
<FromGitter> <drum445> @mps exactly the same for me mate
<mps> I work with SQL more than 15 years in real time production services and never tried ORM and will not, I hope
<FromGitter> <girng> @drum445 nope, so.. i'll prob think about it, but not for sure if i will do it. a lot of code needs to be changed for all the commands too. will take a while too
<FromGitter> <drum445> @mps yeah I did 2 years solid SQL at my place
<FromGitter> <drum445> It's why I'd rather write it myself
<FromGitter> <drum445> @girng haha
<FromGitter> <girng> @drum445 are i love me some SQL
<FromGitter> <drum445> It's wonderful, I'm trying to bring it back in our new product. We use Cass and ES - tragic times
<mps> also, in crystal, where I plan to move some of my systems I starting with plain crystal-db + driver
<FromGitter> <drum445> And my ORM right ;)
<FromGitter> <girng> @drum445 nice
<FromGitter> <matthewmcgarvey> I mainly do java. I hate working with Hibernate but I’ve enjoyed working with ActiveRecord in my little work in ruby so :shrug:
<FromGitter> <girng> i tried java, but went back to crystal bawhahah
<mps> drum445: I wrote, if I would/should use ORM your will be only one to consider
<FromGitter> <girng> hell, i tried elixir, golang, rust, julia... i've tried so many
<FromGitter> <girng> all roads lead back to crystal for me
<FromGitter> <drum445> @mps <3
<FromGitter> <drum445> Yeah I've used Go for a few years, wrote a few things that we use at work using it. I like it
<FromGitter> <drum445> I'm the same though, Crystal is my favourite currently
<FromGitter> <drum445> And has been for a while
<mps> also I started with go and wrote some small programs but when I saw crystal I switched that same day
<FromGitter> <girng> although, when i followd thecherno'sproject yt tutorial online about c++ that was actually really fun
DTZUZO_ has joined #crystal-lang
<mps> although I'm learning rust for system programming, it fits there better, imo
<FromGitter> <girng> would love to see more online tutorials on crystal too
<FromGitter> <drum445> Yeah it does, Go is used a lot for webapis tbh
<FromGitter> <girng> just cuz i enjoy watching them, and it's prob better instead of watching p-word at night. i can watch other stuff i'm interested in
<FromGitter> <girng> would help in the long run IMO
<FromGitter> <girng> Derek Banas or w/e has a crystal video, but he just skims through the stuff and types it out. he's not really someone well-versed in the language that is teaching it (what i like to see)
<mps> girng: I started with free Ruby books and crystal docs online, it is enough, although I bought "Progamming Crystal" less than a half month ago
<FromGitter> <matthewmcgarvey> I prefer sql wrapping libraries like rust’s http://diesel.rs/ or java’s https://www.jooq.org/
<FromGitter> <girng> @mps oh yeah i remember you telling me about the book how was it
<FromGitter> <girng> was it worth the $ in your opinion?
<mps> girng: well, it is worth these money but I think I could go without it and I think you also can ;)
<FromGitter> <girng> glorified docs in a book eh? lol
<FromGitter> <Blacksmoke16> @girng https://github.com/Blacksmoke16/CrSerializer expands upon the `JSON::Serializable` stuff with some extra featuers
<FromGitter> <matthewmcgarvey> You get the benefits of writing *almost* sql with the language tools like autocomplete and things
<mps> it is superficial but if you like to throw some money there you will have docs from the in one place, nothing more
<FromGitter> <Blacksmoke16> like reading values in from `from_json` but not displaying them in `to_json`
<mps> s/from the/from the net/
<FromGitter> <girng> i see @Blacksmoke16 i'll take a look i remember that repo
<FromGitter> <Blacksmoke16> 👍 is built on top of the stdlib stuff
<FromGitter> <Blacksmoke16> validations are pretty cool as well ;)
<FromGitter> <girng> Good lord almighty
<FromGitter> <Blacksmoke16> :p
<FromGitter> <girng> LOL
<FromGitter> <girng> i swear, even after all this time it's a new language.
<FromGitter> <Blacksmoke16> its not *that* bad once you know whats going on
<FromGitter> <girng> my gosh my brain just goes blank and i feel depressed
<FromGitter> <girng> but i find it fascinating how it all works so..
<FromGitter> <Blacksmoke16> thats basic just a copy paste from the stdlib version, with some added logic for the groups/since/until and expansion stuff
<FromGitter> <girng> but it's not inside a macro..
<FromGitter> <kinxer> Ah, this is true. I'm by no means a macro expert. I think it's related to this, though: https://crystal-lang.org/reference/syntax_and_semantics/macros/macro_methods.html
<FromGitter> <kinxer> Sorry about sending the wrong link first.
<FromGitter> <girng> it's np.. thx
<FromGitter> <girng> i think it's related to the macro in assertion.cr?
<FromGitter> <kinxer> There it is.
<FromGitter> <girng> very interesting
<FromGitter> <girng> thank you
jemc has quit [Ping timeout: 245 seconds]
<FromGitter> <girng> well TIL that hashes are not just string => value
<FromGitter> <girng> after looking at assertion.cr lol
<FromGitter> <girng> i always thought it had to be a string for the key... wow lol fail.
<FromGitter> <Blacksmoke16> yea, its for special tokens for custom messages
<FromGitter> <Blacksmoke16> so you can do like
<FromGitter> <dscottboggs_gitlab> @gring banas makes a few rookie mistakes in his video too
<FromGitter> <girng> @dscottboggs_gitlab oh really? timestamp?
Raimondi has quit [Ping timeout: 240 seconds]
<FromGitter> <dscottboggs_gitlab> I left a pretty lengthy comment on the video, and I only watched about half of it https://www.youtube.com/watch?v=DxFP-Wjqtsc&lc=Ugw-pFDlOIG0VfeU3fJ4AaABAg
<FromGitter> <dscottboggs_gitlab> The one that was super clearly a mistake was saying that you had to use `exit` to break out of a block
jemc has joined #crystal-lang
<FromGitter> <drum445> Yeah he just runs through syntax
<FromGitter> <drum445> Which can be useful if that's all you need, but it's not a tutorial
<FromGitter> <drum445> Glorified docs
<FromGitter> <girng> my word, reported
<FromGitter> <girng> im jk! 😆
<FromGitter> <girng> @dscottboggs_gitlab dang you really went all out
<FromGitter> <dscottboggs_gitlab> personally I think the Crystal Book is a great way to learn the language. I started out by reading most of it.
<FromGitter> <girng> which one? or you mean the gitbook thing?
<FromGitter> <dscottboggs_gitlab> the gitbook
<FromGitter> <girng> oh, agreed
<FromGitter> <girng> i still reference it til this day, it's super helpful
<FromGitter> <dscottboggs_gitlab> haha yeah, I was just gonna post about the first thing but then there was like worse and worse stuff so I just kept writing and only stopped when I had to go do something else
<FromGitter> <girng> semi-true though lol (https://i.gyazo.com/4d1d6e0da5e57f55b357cae4f9c8bc1e.png)
<FromGitter> <girng> that is a very rare moment
<FromGitter> <girng> will most likely never happen again
<FromGitter> <kinxer> Hey, you're officially a Crystal contributor now!
<FromGitter> <girng> 😆
marmotini_ has joined #crystal-lang
marmotini_ has quit [Ping timeout: 272 seconds]
<FromGitter> <PlayLights_twitter> Hello Folks do you know any way to print method definitions generated by macros?
<FromGitter> <PlayLights_twitter> Currently when i want to see the generated code i have to write invalid code to raise a compilation error
<FromGitter> <Blacksmoke16> {{debug}}
<FromGitter> <Blacksmoke16> also works well to do like
<FromGitter> <Blacksmoke16> ```{% begin %} ⏎ # Your macro/code stuff ⏎ {{debug}} ⏎ {% end %}``` [https://gitter.im/crystal-lang/crystal?at=5c4748f9c45b986d11a0cb55]
<FromGitter> <Blacksmoke16> @PlayLights_twitter
<FromGitter> <Blacksmoke16> @girng nice one! When you going to finish parallelism? ;)
<Yxhuvud> There is also crystal tool expand.
<FromGitter> <PlayLights_twitter> @Blacksmoke16 @yxhuvud thanks im going to try them :)
<FromGitter> <bew> @Blacksmoke16 `{% debug %}` is enough, no need to use `{{ }}`
jemc has quit [Quit: WeeChat 2.2]
<FromGitter> <girng> @Blacksmoke16 my mind gets blown when i read that word
<FromGitter> <Blacksmoke16> whoa im famous
<FromGitter> <Blacksmoke16> oh nice, never tried with the `%`
<FromGitter> <Blacksmoke16> makes sense
<FromGitter> <matthewmcgarvey> What’s the difference between `{% … %}` and `{{…}}`
<FromGitter> <girng> :D
<FromGitter> <j8r> @matthewmcgarvey they have taken this syntax from existing templating systems like jinja. {%%} are for special expressions like if, for, begin etc
<FromGitter> <matthewmcgarvey> But they have to be within a macro, correct? https://github.com/Blacksmoke16/CrSerializer/blob/master/src/CrSerializer/json/json.cr threw me off because there’s no outer `{{ }}` so I only assume that this file is loaded within a macro somewhere
<FromGitter> <Blacksmoke16> its not
<FromGitter> <Blacksmoke16> way i view it is like `{{name}}` would be a value that is adding something *from* macro land into the runtime land
<FromGitter> <Blacksmoke16> where as `{% name = "Jim" %}` *only* exists in macro land
<FromGitter> <j8r> this is a special expression to me
<FromGitter> <matthewmcgarvey> is there not also `{%= %}`
<FromGitter> <j8r> affecting a value to a macro variable
<FromGitter> <Blacksmoke16> @matthewmcgarvey that is also a thing but not related to macros t
<FromGitter> <Blacksmoke16> is more of an ECR concept
<FromGitter> <j8r> but you have a good point
<FromGitter> <j8r> is there a technical limitation to have `{% %}` replacing `{{ }}` or vise-versa?
<FromGitter> <j8r> maybe it's simpler to parse
<FromGitter> <j8r> `{{ }}` referring only to variables
<FromGitter> <Blacksmoke16> well as i said, something in `{% %}` wouldnt get dropped into the runtime code, whereas `{{ }}` would
<FromGitter> <Blacksmoke16> let me try something
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/62c2
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/62c3
<FromGitter> <Blacksmoke16> yea
<FromGitter> <Blacksmoke16> so the `%` ones are more like control/macro level expressions while `{{ }}` is inserting stuff into the runtime code
<FromGitter> <Blacksmoke16> exists purely in maco land at compile time
<FromGitter> <j8r> but macro is purely at compile time, and generates code "as text"
marmotini_ has joined #crystal-lang
<FromGitter> <j8r> I got the idea
<FromGitter> <j8r> usually `{{ }}` is mixed will real code
<FromGitter> <j8r> `{% %}` not
<FromGitter> <Blacksmoke16> exactly, which adds stuff from macro land into the program
<FromGitter> <matthewmcgarvey> lol, seems like I understood this over the weekend because my macro code is correct. Things slip so easily
<FromGitter> <Blacksmoke16> :p
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
<FromGitter> <girng> gn ii need sleep cya ya'll in 5-6 hours
ua_ has quit [Ping timeout: 252 seconds]
<FromGitter> <matthewmcgarvey> Is there any standards around setting up benchmarks as in… do they go in the spec folder or somewhere else? Anyone have any examples?
<FromGitter> <Sija> @matthewmcgarvey most common are `spec` or `examples`/`samples` but there’s nothing (I’ve seen) like a standard in that matter
ua_ has joined #crystal-lang
Raimondi has joined #crystal-lang
Creatornator has joined #crystal-lang
<FromGitter> <Blacksmoke16> been mulling over an idea i had for an "extension" for querying in ORMs
<FromGitter> <Blacksmoke16> inspired by a lib we use at work
<FromGitter> <Blacksmoke16> would be like
<FromGitter> <Blacksmoke16> ```active_users = User.match( ⏎ BelongsToCustomer.new 123, ⏎ IsActive.new ⏎ )``` [https://gitter.im/crystal-lang/crystal?at=5c476c2995e17b452592837c]
<FromGitter> <Blacksmoke16> where each "matcher" is a class that implements method to that returns requirement
<FromGitter> <Blacksmoke16> like
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5c476c981cb70a372a1e6b38]
<FromGitter> <Blacksmoke16> which each requirement would boil down to some SQL
<FromGitter> <Blacksmoke16> idea being it allows easily reusable objects to construct queries
<FromGitter> <Blacksmoke16> that can be documented and tested
<FromGitter> <Blacksmoke16> that wouldn't be based on a specific ORM
marmotini_ has quit [Ping timeout: 250 seconds]
<FromGitter> <Blacksmoke16> could also have like `match_one_or_null` or `match_single_result`
DTZUZU has quit [Quit: WeeChat 2.2]
Creatornator has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
marmotini_ has joined #crystal-lang
marmotini_ has quit [Ping timeout: 245 seconds]
Creatornator has joined #crystal-lang
DTZUZU has joined #crystal-lang
Creatornator has quit [Quit: Textual IRC Client: www.textualapp.com]
moei has quit [Quit: Leaving...]
<FromGitter> <iambudi> how to pass arg by reference?
<FromGitter> <j8r> either a class, or a pointer (not really recommended)
<FromGitter> <j8r> `pointerof(myvar)` then `mypointer.value = ...`
<FromGitter> <PlayLights_twitter> Maybe **arg?
<FromGitter> <PlayLights_twitter> Thinking in c way
<FromGitter> <iambudi> thank you. just for a var, using pointerof is simpler. Why is it not recommended btw, any side effect?
<FromGitter> <Blacksmoke16> prob could be unsafe
DTZUZO_ has quit [Ping timeout: 245 seconds]