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
<FromGitter> <dscottboggs_gitlab> And actually, rkeene, I don't think `select` actually uses `select(2)` -- fibers have their own implementation with an internal event loop that's compiled into every crystal program (whether it `spawn`s or not)
<FromGitter> <Blacksmoke16> main program prob spawns under the hood?
<FromGitter> <Blacksmoke16> since its a fiber too
<FromGitter> <dscottboggs_gitlab> mebbew
<FromGitter> <dscottboggs_gitlab> just was a bit of a shock the first time I tried to `objdump` a Crystal `puts "hello world"`
<FromGitter> <Blacksmoke16> oh?
<FromGitter> <dscottboggs_gitlab> I think it was 5x or 10x as long as the C equivalent. Which, tbf a `puts("hello world");` program isn't really helpful for more than academic purposes, but the more I look into the language internals the more I feel like over time they will slim down a lot
<FromGitter> <dscottboggs_gitlab> hah `puts("whatever");` is both valid C and Crystal
<FromGitter> <dscottboggs_gitlab> well...sort of...nevermind haha
laaron has quit [Remote host closed the connection]
<FromGitter> <Blacksmoke16> :S fair enough
<FromGitter> <Blacksmoke16> i dont think C is that simple
<FromGitter> <dscottboggs_gitlab> C is *simple* but it's not safe and it doesn't provide good ways to build shortcuts on top of it. I think it's a lot more fair to compare Crystal to C++ -- Crystal just has a lot more shortcuts, safety, and better macros :p
laaron has joined #crystal-lang
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d1015cdd1aaa16964fc0b55]
<FromGitter> <Blacksmoke16> seems like a lot of code for what its doing
<FromGitter> <Blacksmoke16> WTB `STDIN.empty?`
<FromGitter> <dscottboggs_gitlab> `undefined method 'empty?' for IO::FileDescriptor`?
<FromGitter> <Blacksmoke16> sorry `WTB` meaning i want to buy that method :P
<FromGitter> <Blacksmoke16> i.e. i want it
<FromGitter> <dscottboggs_gitlab> hahaha
alex`` has quit [Read error: Connection reset by peer]
alex`` has joined #crystal-lang
alex``` has joined #crystal-lang
alex`` has quit [Ping timeout: 245 seconds]
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
<FromGitter> <PlayLights_twitter> Do you really think that c++ is similar to ruby?
<FromGitter> <PlayLights_twitter> I was about thinking about practicing some c++
alex``` has quit [Ping timeout: 268 seconds]
alex``` has joined #crystal-lang
teardown has quit [Ping timeout: 268 seconds]
<FromGitter> <robacarp> c++ can be pretty high level, if you work with it. The syntax isn’t as high level, but a properly compartmentalized class system it pretty programmer friendly.
<rkeene> I'd go with Tcl over C++ :-D
<FromGitter> <watzon> I'd go with almost anything over C++
<FromGitter> <watzon> But C++ and I have a long history of hatred
<rkeene> https://www.youtube.com/watch?v=D3T-ihMy6vc I compare some Tcl and C++ work
<FromGitter> <watzon> It's unfortunate that they always suck at recording at those conferences
<rkeene> Yeah
<rkeene> The Tcl conference is pretty small and doesn't get a lot of funding
<FromGitter> <robacarp> I have never had the opportunity to use TCL
<rkeene> It's pretty awesome -- AOT compilable, supports multiple threads, supports every platform, stable ABI, ...
<wmoxam> I think I should learn Tcl/Tk
<wmoxam> I find myself wanting to write some GUI *nix apps, and Tcl/Tk seems like the most sane way
blassin2 has joined #crystal-lang
blassin has quit [Ping timeout: 245 seconds]
<vegai_> racket's gui libs seem to get some love from people too
ZombieByte has joined #crystal-lang
<FromGitter> <girng> nice, yet another language that is more confusing crystal. just what i want to learn!
laaron has quit [*.net *.split]
yxhuvud has quit [*.net *.split]
<FromGitter> <watzon> @girng that's most of them haha
<FromGitter> <sirbroadwell> Hello ⏎ I would like to create a scripting language for video games (https://xercle.netlify.com) ⏎ I'm looking for an implementation language, I'm thinking of Haskell but I would have liked to see what might be interesting if I chose Crystal
<FromGitter> <j8r> How will it compare to Lua?
<FromGitter> <sirbroadwell> As a viable alternative
<FromGitter> <j8r> IMO Lua is already quite good, you'll have to work hard to compete with it
<FromGitter> <sirbroadwell> Lua is good but Xercle will be too ;p ⏎ The goal is to promote the functional paradigm for game scripting
devil_tux has quit [Ping timeout: 246 seconds]
devil_tux has joined #crystal-lang
devil_tux has quit [Ping timeout: 272 seconds]
devil_tux has joined #crystal-lang
devil_tux has quit [Ping timeout: 246 seconds]
<jokke> lua is a terrible language :D
devil_tux has joined #crystal-lang
<FromGitter> <bajro17> I have a question about http://shards.info this site so often show me 500 error or sometimes won't to show me results
<FromGitter> <bajro17> my question is: Is that happen because: 1. Kemal or 2. Github api or something else
<FromGitter> <bajro17> because I want use Kemal for my next big project I want be sure
mjblack has quit [Ping timeout: 245 seconds]
mjblack has joined #crystal-lang
<FromGitter> <yxhuvud> jokke: no, lua is a perfectly fine language.
alex``` has quit [Ping timeout: 246 seconds]
alex``` has joined #crystal-lang
<FromGitter> <sirbroadwell> The goal is not to denigrate lua but to show that functional programming can work for video game scripting
<jokke> oh functional programming
<jokke> but why crystal then?
<jokke> for a similarily simple functional language as lua you could try some lisp dialect. :)
<jokke> lisp is dead simple
<jokke> yet quite elegant
<jokke> if you can look past all the parentheses
<FromGitter> <j8r> or OCaml
<FromGitter> <Blacksmoke16> @dscottboggs_gitlab is that `select` thing documented anywhere?
<FromGitter> <dscottboggs_gitlab> I dunno... I learned that from go. I was searching the docs last night and didn't see anything
<FromGitter> <Blacksmoke16> gotcha
<FromGitter> <Blacksmoke16> ```code paste, see link``` ⏎ ⏎ managed to cut it down a bit, so that works for me [https://gitter.im/crystal-lang/crystal?at=5d10c04c30cc05479fb6cf72]
<FromGitter> <Blacksmoke16> `STDIN.empty?` would still be nice tho :/
<FromGitter> <Blacksmoke16> or an IO for that matter
<FromGitter> <dscottboggs_gitlab> couldn't you wrap STDIN in an IO::Buffered?
<FromGitter> <Blacksmoke16> isnt that just a module tho?
<FromGitter> <Blacksmoke16> lol fml
<FromGitter> <Blacksmoke16> isnt that what i want/
<FromGitter> <Blacksmoke16> i mean the `read_timeout` part
<FromGitter> <Blacksmoke16> ah no, its only in socket
<FromGitter> <Blacksmoke16> actually works for STDIN tho. be nice if you could just return nil or something, raising/catching the exception is prob less performant than your `select` thing id imagine?
lucasb has joined #crystal-lang
<FromGitter> <dscottboggs_gitlab> Oh cool
duane has joined #crystal-lang
sagax has quit [Ping timeout: 272 seconds]
<FromGitter> <girng> LOL
<FromGitter> <girng> functional programming language for video games?
sagax has joined #crystal-lang
<FromGitter> <girng> imagine going to hell n back, then still having to worry about your game
<FromGitter> <girng> can another dev chime in and help this guy out https://forum.crystal-lang.org/t/how-to-make-crystal-app-scriptable/878/3
<FromGitter> <girng> I'm pretty sure he's talking about embedding Crystal into another app and using it like how you would LuA
<FromGitter> <j8r> that's very basic, with https://github.com/j8r/crystal-object-send string expressions can be evaluated at runtime
<FromGitter> <j8r> Lua is a good option
<rkeene> Tcl > Lua :-D
<FromGitter> <sirbroadwell> re ⏎ As I think functional programming can work very well for video game scripting! ⏎ Xercle will be there to prove it ⏎ I'm looking for a programming language to create my compiler, I've seen parsers combinator in crystal but I'd like to know what you think of the language and if you think it's enough for my task [https://gitter.im/crystal-lang/crystal?at=5d10d177aafbc32629770d5e]
<FromGitter> <bew> @sirbroadwell well, Crystal's compiler is written in Crystal, so it's definitely enough for the task
<FromGitter> <sirbroadwell> Okay, thanks to you! ⏎ are there any game engines for crystal? ⏎ ⏎ Crystal is orienting herself towards which domain? Web system? Go? [https://gitter.im/crystal-lang/crystal?at=5d10d29080f91e2d3e822e6b]
<FromGitter> <girng> @sirbroadwell not really an engine, but there are SFML bindings: https://github.com/oprypin/crsfml
<FromGitter> <sirbroadwell> I don't really like bindings to the C version of the sfml
<FromGitter> <girng> me neither, i use Godot Engine for the client side, and Crystal for the backend. I think Crystal shines in game backend server development, and good old web servers (Kemal)
<FromGitter> <sirbroadwell> Do you have any examples of crystal game servers you've made?
<FromGitter> <girng> That's just my opinion from using the language for a year+. Everyone is different though you'll prob get diff responses from everyone lol
<FromGitter> <j8r> @girng Crystal shines for API servers too :)
<FromGitter> <girng> Nope, but I made a small example script to show how easy it is: https://forum.crystal-lang.org/t/simple-godot-crystal-tcp-script/45/7
<FromGitter> <sirbroadwell> Okay, thanks :)
<FromGitter> <girng> That's basically my foundation for my gameserver, which now has evolved into a monstrosity of code
<FromGitter> <girng> In terms of me writing too much and not commenting enough lol
<FromGitter> <girng> But that would have happened if I were writing in any language, it's just so damn easy to write with Crystal I did it so much
<FromGitter> <girng> I need to learn not to have every single damn function in one file, that would help :D
<FromGitter> <girng> @j8r yeah :D
<FromGitter> <sirbroadwell> a plan for crystal godot bindings?
<FromGitter> <girng> not worth the time invested, godot's gdscript is so simple already i found. just my opinion and there has only been like 3 people who are interested that i've seen in the past year LOL
<FromGitter> <girng> here is a great example of crystal's real-world usage for backend gameservers. i have an item that when it's used, it rolls for min/max values dependent on an item's item level: https://play.crystal-lang.org/#/r/7471 ⏎ ⏎ `tiers` can be imported from json/csv storage, etc.
<FromGitter> <girng> i was contemplating on whether or not, higher tiers should have weighted RNG, but figured.. if the player is lucky enough to roll on that tier, they deserve to get those values
<FromGitter> <Blacksmoke16> A static binary built in alpine doesnt work on a mac?
<FromGitter> <girng> rip
<FromGitter> <Blacksmoke16> i know it doesnt support static binaries, but i thought that was just when building them on the mac, or is that in general?
hightower2 has joined #crystal-lang
<hightower2> Why for FileUtils#cp the argument is "dest", while for FileUtils#cp_r the argument is named "dest_path"?
<FromGitter> <Blacksmoke16> but i guess it makes sense
<FromGitter> <Blacksmoke16> re/ alpine not working on mac
laaron has joined #crystal-lang
<rkeene> I made a little HTTP-based file browser for AppFS: http://browser.appfs.rkeene.org/rkeene.org/crystal/
<jokke> what the shit... i'm amazed how convoluted the use of TCPServer in ruby is
<jokke> there seems to be no way to set SO_REUSEPORT before it already tries to bind (and fails due to EADDRINUSE)
<jokke> the only way is to use Socket
<jokke> but this doesn't have most of the method TCPServer does
<jokke> *methods
<jokke> guhh
<jokke> it amazes me how something so simple in crystal can be so complicated in ruby
<hightower2> Uhm, help me out a little bit here. I have a class (representing a file on disk) with @path containing its path. I want to create a method (or macro), which when called, calls Kilt.render(@path), or Kilt.render(file's content) if that exists.
<hightower2> The issue seems to be that Kilt.render(), being a macro, only accepts a literal filename, not a variable of any sort
<hightower2> any pointers?
<FromGitter> <tenebrousedge> I mean, macros can take arguments, but it doesn't sound necessary to use a macro
<hightower2> tenebrousedge: can't do it without a macro, the way Kilt works. But in any case, asking if someone did it already and knows a solution offhand
<FromGitter> <tenebrousedge> so you want the variable to be evaluated at runtime?
<hightower2> yes, I want Kilt.render(), or any of Kilt's calls, to render a template using a filename or content that I pass to it in runtime
<FromGitter> <tenebrousedge> macros are expanded at compile time, so that's going to complicate matters. Can you post some code that you're working with?
<FromGitter> <tenebrousedge> https://play.crystal-lang.org/#/cr
<hightower2> There's no code. An example (which doesn't work) can be as simple as: file = 'myfile.ecr'; Kilt.render(file)
<hightower2> I just have a mental block here. I'm not sure if this just isn't possible, or I was out of Crystal long enough that I now have no idea how to do it
<FromGitter> <tenebrousedge> macros are generally for code generation
<FromGitter> <tenebrousedge> I think that it's not impossible to create a macro that would create a function that would read a variable at runtime and render the template
<FromGitter> <tenebrousedge> but if you want to render a template and not generate a function to render a template, then a macro is the wrong tool
vegai_ has left #crystal-lang [#crystal-lang]
devil_tux has quit [Ping timeout: 258 seconds]
yxhuvud has joined #crystal-lang
<hightower2> damnit I don't get it
<hightower2> All I want to do is run some file find function in runtime, then call Kilt.render() on all found filenames
<FromGitter> <tenebrousedge> `Dir.glob("./**/*.ext", &->Kilt.render(String))`
<hightower2> Dude, I appreciate your help, but you're not getting what the problem is
<hightower2> Kilt.render, embed, etc., as well as all 'render' methods from all individual languages it supports (liquid, ecr, temel, crikey, ...) are macros
<FromGitter> <tenebrousedge> so those are going to be expanded at compile time
<hightower2> yes. And list of files that will be found in the directory are not known at compile time
<FromGitter> <tenebrousedge> you can either use a macro to generate a function that will read that directory
<FromGitter> <tenebrousedge> or you can give up on the idea of doing this with a macro
<hightower2> Yes, I know. I am not trying to do it with a macro. I am trying to do it in any way that would work, in runtime
<hightower2> but anyway
hightower2 has left #crystal-lang ["Leaving"]
<FromGitter> <tenebrousedge> `Dir.glob` is a good way to find files in a directory
<FromGitter> <tenebrousedge> there are other options if you want to find by e.g. `mtime`
laaron has quit [Remote host closed the connection]
<FromGitter> <girng> If anyone has some spare time, please take a glance at https://forum.crystal-lang.org/t/statically-parse-csv-to-hash/882
<FromGitter> <tenebrousedge> @girng I think I'd usually prefer a `Struct` to a `Hash` for CSV files
<FromGitter> <girng> Yeah i added a comment about that, was jsut thinking about that
<FromGitter> <girng> I have a csv_to_dict method but it's buggy as shit
<FromGitter> <girng> doesn't work if the keys are not an Int32, doesn't support a row of `,`'s, etc
<FromGitter> <girng> I just wish the CSV class could add support for this...
<FromGitter> <tenebrousedge> well, it has `Row#to_a` and `Row#to_h` it looks like
<FromGitter> <girng> https://crystal-lang.org/api/0.29.0/CSV.html#parse%28string_or_io%3AString%7CIO%2Cseparator%3AChar%3DDEFAULT_SEPARATOR%2Cquote_char%3AChar%3DDEFAULT_QUOTE_CHAR%29%3AArray%28Array%28String%29%29-class-method
<FromGitter> <girng> i'm gonna fiddle around
<FromGitter> <girng> wtf is csv.next
<FromGitter> <girng> to access another row, i'd have to call `csv.next`?
<FromGitter> <girng> LOOOOOOOOOOL
<FromGitter> <tenebrousedge> no, there's an `each_rows`
<FromGitter> <tenebrousedge> so like, `csv.each_row { |row| csv.headers.zip(row).to_h }`
<FromGitter> <girng> looks like there is no way to get that data in a structure
<FromGitter> <girng> so i can just access it by a key, globally
<FromGitter> <girng> ty, i'll try
<FromGitter> <tenebrousedge> @girng you might also want to try implementing `CSV#dig`
<FromGitter> <tenebrousedge> actually
<FromGitter> <girng> how to get that into a Hash or Struct?
<FromGitter> <girng> with key access []
alex``` has quit [Ping timeout: 258 seconds]
<FromGitter> <girng> no way to statically type them to their type'
alex``` has joined #crystal-lang
<FromGitter> <girng> this has to be possible, crystal is a statically typed language
<FromGitter> <tenebrousedge> ugh, this is ugly
<FromGitter> <kinxer> I do think there should be an easier way to get that into a struct, though.
laaron has joined #crystal-lang
<FromGitter> <girng> @kinxer thx https://play.crystal-lang.org/#/r/74d9/edit
<FromGitter> <girng> now, how to statically type them to their types instead of String?
<FromGitter> <girng> actually, since it was parsed from string, there is no way to do it right?
<FromGitter> <tenebrousedge> I mean, you could use `scanf` if it existed in Crystal
<FromGitter> <girng> if i need a statically typed hash/struct, i need to literally generate the struct/hash when exporting the csv
<FromGitter> <girng> to conform to crystal code, so it's statically typed, correct?
<FromGitter> <r00ster91> well it does, bind the C function but it surely isn't the best solution
<FromGitter> <tenebrousedge> hmm, I should figure out how to do that though
<FromGitter> <kinxer> @girng In order to have static typing, you need to know the types when you compile, so you'd at least have to write a `struct` manually to read the CSV into.
<FromGitter> <girng> WATTT
<FromGitter> <girng> We need this FOR CSV
<FromGitter> <girng> it's statically typed! with the json mapping macro
<FromGitter> <tenebrousedge> I mean, is not using CSV a viable option?
<FromGitter> <girng> but wait, they use classes
<FromGitter> <girng> so if that json changes, the class's properties need to be updated as well
<FromGitter> <girng> nvm
<FromGitter> <girng> omg...........
<FromGitter> <girng> So.. it's either.. when exporting CSV or JSON, you must generate a class/struct a long with it, if you want your structure to be statically typed within Crystal. ⏎ OR, you can do something like this `https://play.crystal-lang.org/#/r/74dx/edit` or use `JSON.parse`, but you would need to invoke method calls (.to_i)
<FromGitter> <girng> Do I got that correct?
<FromGitter> <girng> There is no way for a string to become statically typed? There has to be a way lol
<FromGitter> <girng> Can't you convert a type or something
<FromGitter> <watzon> What do you mean make a string statically typed? @girng
<FromGitter> <watzon> Example?
<FromGitter> <girng> 1 sec
alex``` has quit [Ping timeout: 258 seconds]
<FromGitter> <girng> Example, here: https://play.crystal-lang.org/#/r/74e6 ⏎ I have to do method invocation all over whenever I access ["min_value"] (.to_i)
<FromGitter> <girng> Can't I just change it permanently to a Int32... lol
<FromGitter> <watzon> If you wan't the same functionality you'd get out of `JSON.mapping` or `JSON::Serializable` you'd have to create such a thing for CSV
alex``` has joined #crystal-lang
<FromGitter> <watzon> It would be an interesting challenge
<FromGitter> <girng> Well, even then you'd still need to update the Class's properties if the JSON structure is changed, etc. Which is kinda nnoying. ⏎ All I want is for Crystal to know what kind of keys I want typed for a data structure (Hash or Struct), and then I want to access that data statically
<FromGitter> <girng> I mean, I export my csv with adminer.php from my db table. I could make it so it doesn't export a CSV, but a crystal file with a class and all it's statically typed properties...
<FromGitter> <girng> Writing Crystal code in PHP LOOOOOOL
<FromGitter> <Blacksmoke16> why not just export JSON and use the .from_json
<FromGitter> <Blacksmoke16> if thats an option
<FromGitter> <girng> first sentence ^^
<FromGitter> <Blacksmoke16> ah
<FromGitter> <Blacksmoke16> still, how often does it change? would only be like adding 1 property
<FromGitter> <girng> true, is there a from_json like option for CSV though
<FromGitter> <girng> that would be amazeballs
<FromGitter> <Blacksmoke16> ☝️ June 24, 2019 1:11 PM (https://gitter.im/crystal-lang/crystal?at=5d11045030cc05479fb962af)
<FromGitter> <watzon> That is the downside of using untyped data structures with a typed language. You will always have to maintain a schema of what the data should look like.
<FromGitter> <watzon> If something changes you have to update it
<FromGitter> <Blacksmoke16> which isnt a big deal imo
<FromGitter> <watzon> Not really
<FromGitter> <Blacksmoke16> `property new_field : String` done
<FromGitter> <watzon> The structure shouldn't change that often
<FromGitter> <Blacksmoke16> > All I want is for Crystal to know what kind of keys I want typed for a data structure (Hash or Struct), and then I want to access that data statically
<FromGitter> <Blacksmoke16> i feel like we're back to the issue you had on the forum :P
<FromGitter> <girng> yeah I think I just went full circle here
<FromGitter> <girng> FML
<FromGitter> <Blacksmoke16> it would be cool but i just dont know how it would know what type everything should be without you telling it
<FromGitter> <girng> basically what Chris Watson said at the 1:11 comment above
<FromGitter> <girng> from_csv or something would be cool, with csv mappings
<FromGitter> <girng> however, at this point. i'm going to just use https://play.crystal-lang.org/#/r/74e6/edit
<FromGitter> <girng> and do .to_i
<FromGitter> <girng> for now
<FromGitter> <girng> but FFS it just doesn't feel right LOL
<FromGitter> <Blacksmoke16> well you could do something like
<FromGitter> <Blacksmoke16> sec
<FromGitter> <dscottboggs_gitlab> well, you could read in the CSV header at compile time and generate a class or struct based on that in macros
<FromGitter> <girng> Statically typed language, but I'm calling `.to_i` all over hahahahahah
<FromGitter> <girng> STRING TO INT BOYS
<FromGitter> <girng> AND BACK
<FromGitter> <girng> 😆
<FromGitter> <girng> Probably not even good for performance, but I'm not even going to go into that lol
<oprypin> sirbroadwell, what do u mean bindings to the C version of sfml, this is bindings to the C++ version
<FromGitter> <girng> can a class be used as a schema?
<oprypin> i mean, that's literally what json mapping does
<FromGitter> <girng> hi oprypin long time no see
<oprypin> hi
<oprypin> {%{%}%}%{}%{}%{}%%
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/74f0
<FromGitter> <girng> good god almighty
<FromGitter> <watzon> Yup
<FromGitter> <watzon> Lol
<FromGitter> <Blacksmoke16> cant you do something like that @girng ?
<FromGitter> <watzon> Macro hell
<oprypin> the good news is that csv is much easier than json
<oprypin> aanyway, why would anyone use csv??
<FromGitter> <tenebrousedge> ^
<FromGitter> <Blacksmoke16> its girng 🚎
<FromGitter> <girng> less redundant keys than json
<FromGitter> <girng> much faster to parse with godot
<FromGitter> <girng> i keep same structure client/server
<oprypin> lol
<oprypin> after all these conversations months ago csv cant be the conclusion :(
<FromGitter> <girng> i use both but for large data (items) for example, i use csv
<FromGitter> <girng> other stuff json is fine
<FromGitter> <tenebrousedge> why not pull from the db directly?
<FromGitter> <Blacksmoke16> `much faster to parse with godot` like how much faster?
<FromGitter> <girng> 300-500ms on load time differences
<FromGitter> <girng> i've tested it
<FromGitter> <Blacksmoke16> is it worth it
<FromGitter> <girng> oh hell yeah
<FromGitter> <Blacksmoke16> are you sure?
<FromGitter> <girng> yeah lol, game feels snappier loading up. there is a noticable delay with large json data parsing in godot
<FromGitter> <girng> it's night n day faaster when i tested it with csv, file size is way less too. no redundant keys
<FromGitter> <Blacksmoke16> loading just once or?
<FromGitter> <girng> initial game load, ye
<FromGitter> <Blacksmoke16> so is 500ms worth a good amount more effort dev work
<FromGitter> <girng> wat is that
<oprypin> that is the thing with no redundant *anything*
<FromGitter> <girng> i export to json / csv, not gonna export to godobuf, unless it's faster than csv load times
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d110a27260d3b498154fb16]
<oprypin> well of course its faster, csv is still slow af
<FromGitter> <Blacksmoke16> speed isnt really everything, maintainability is also quite important imo
<FromGitter> <girng> if there is protobuf addon for adminer.php
<FromGitter> <girng> i'll try it out, thanks
<FromGitter> <tenebrousedge> @Blacksmoke16 that's quite nice
<oprypin> isn't that just the basic usage of JSON::Mapping
<FromGitter> <Blacksmoke16> similar, but bases properties off your ivars vs what you define manually
<oprypin> oh sorry, i meant json serializable anyway
<FromGitter> <Blacksmoke16> ah, yea but its combined with a record
<oprypin> thats pretty good
<FromGitter> <Blacksmoke16> bit cleaner if you're not going to change anything
<FromGitter> <Blacksmoke16> i.e. its immutable by default
<FromGitter> <girng> wait.. in your example @Blacksmoke16 how did you convert that string to a statically typed int32
<FromGitter> <girng> i thought this was impossible
<FromGitter> <Blacksmoke16> i defined a `from_csv` on the record that parses your csv row into an instance of that struct
<FromGitter> <Blacksmoke16> vs just a hash
<oprypin> Blacksmoke16, no but that doesn't eliminate `to_i`, it just hides it
<FromGitter> <Blacksmoke16> true, just have to do it once now tho
<oprypin> i suppose these simple examples are exactly what's needed in this situation. good job
<FromGitter> <girng> yeah that's hwat i wanted
<FromGitter> <Blacksmoke16> obs if you had `CSV::Serializable` that's pretty much what it would be doing
<FromGitter> <Blacksmoke16> but wouldnt have to be manually defined
<oprypin> it could theoretically parse without storing the string first, but no big deal
<FromGitter> <Blacksmoke16> might be able to optimize it a bit
<FromGitter> <Blacksmoke16> i didnt spend too much time on it
<FromGitter> <girng> so record is a hidden struct?
<FromGitter> <Blacksmoke16> a record is just a macro that defines a struct with getters for the given ivars, and an initializer for them as well
<FromGitter> <girng> in your example blacksmoke, you call to_i once and now we don't need to do .to_i again. ⏎ ⏎ is there a reason why the language doesn't do that already? why do we need to continue to use .to_i everywhere when it can be parsed statically in a macro
<FromGitter> <girng> it would be create way cleaner code and readability
<FromGitter> <Blacksmoke16> because the value is a string when it comes from the csv row
<FromGitter> <Blacksmoke16> and its still a string when its in the hash
<FromGitter> <Blacksmoke16> how would it know what to do it on, given a hash with values of various types?
<FromGitter> <watzon> You could always do `to_i` in a rescue block
<FromGitter> <watzon> On every item
<FromGitter> <girng> yeah but you don't use a schema
<FromGitter> <girng> so i don't understand how this is working statically
<FromGitter> <watzon> I think anyway
<FromGitter> <Blacksmoke16> i kinda do tho
<FromGitter> <Blacksmoke16> the record
<FromGitter> <girng> i thought for statically typed, we need to have a schema with properties and their typed values
<FromGitter> <Blacksmoke16> its going csv_row => Hash => obj
<oprypin> im coming to the rescue, hold on
<FromGitter> <girng> `new(row["name"], row["min_value"].to_i, row["max_value"].to_i, row["mod_type"])`
<FromGitter> <girng> has no macro usage
<FromGitter> <Blacksmoke16> exactly
<FromGitter> <girng> how the hell is this working
<FromGitter> <Blacksmoke16> im just newing up a struct
<FromGitter> <Blacksmoke16> which returns a new instance of that struct with the given values
<FromGitter> <girng> @oprypin is that an expanded version of blacksmoke's code?
<FromGitter> <Blacksmoke16> yes
<FromGitter> <Blacksmoke16> just a shortcut to defining a struct with an initializer/getters for the provided ivars
<FromGitter> <watzon> Oh that's cool. `crystal tool expand` expands macros?
<FromGitter> <Blacksmoke16> thats what it does yes ;P
<FromGitter> <watzon> That's pretty nifty
<FromGitter> <girng> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d110dcbf5b00456dfd4619a]
<FromGitter> <girng> where the hell isthis coming from
<FromGitter> <Blacksmoke16> struct
<FromGitter> <girng> being generated from*
<FromGitter> <girng> what's with the clone and copy
<FromGitter> <Blacksmoke16> clone creates a new independent instance, and looks like copy_with allows creating a new instance, that defaults to current values but allows overriding specific ones
<FromGitter> <girng> `new(row["name"], row["min_value"].to_i, row["max_value"].to_i, row["mod_type"])` where is this
<FromGitter> <girng> in opyrpin's expanded link
<FromGitter> <Blacksmoke16> its not included, it would look exactly like that tho
<FromGitter> <girng> i want to know where the .to_i gets hidden
<oprypin> welp Blacksmoke16 youve gone too far
<FromGitter> <Blacksmoke16> i've blown his mind apparently :P
<FromGitter> <girng> oprypin said the string is still hidden
<FromGitter> <girng> i want to know where
<FromGitter> <Blacksmoke16> alright let me explain this
<FromGitter> <Blacksmoke16> you know how you can do like `MyClass.new 1, "foo"`?
<FromGitter> <girng> how the hell can a struct turn a string to a permanent int, when .new(row part doesn't have any macro syntax
<oprypin> girng, there are 2 or even 3 things going here. Blacksmoke16 decided to also mix `record` into this mess but it's completely irrelevant and separate; thats what my example explains though
<FromGitter> <Blacksmoke16> im doing that manually by doing `row["max_value"].to_i`
<oprypin> yea thats it
<FromGitter> <girng> yes but that's after it's parsed
<FromGitter> <girng> so how does it become a int32 where we don't need to use .to_i any longer
<FromGitter> <Blacksmoke16> because its becoming an object
<FromGitter> <Blacksmoke16> its used in the initializer of the struct
<FromGitter> <girng> yoou basically converted a string to an int32 in a statically typedlanguage
<FromGitter> <girng> oh so when it's passed
<FromGitter> <Blacksmoke16> let me make a simpler example
<oprypin> cuz `@min_value : Int32`
<FromGitter> <girng> it's an int32?
<oprypin> u have an instance variable thats int32, is that so hard to comprehend
<FromGitter> <girng> i know but it was originally a string lol
<FromGitter> <girng> how does it "magically" convert to a Int32
<oprypin> theres no magic omg
<oprypin> if u write `a = "5"` that doesn't mean u have to refer to it as `a.to_i` `a.to_i` `a.to_i` `a.to_i` `a.to_i` until the end of time
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/74fs
<oprypin> u just write `b = a.to_i` and omg now u can just write `b` `b` `b` `b` `b`
<oprypin> good example
<FromGitter> <girng> WHAT
<FromGitter> <Blacksmoke16> you have a tendency to not use objects i noticed
<FromGitter> <Blacksmoke16> always using hashes/tuples
<oprypin> php damage
<FromGitter> <girng> wait, so
<FromGitter> <girng> the class'
<FromGitter> <girng> the class's initialize took that int32 and now it's part of `MyClass` permanently as a statically typed Int32?
<FromGitter> <Blacksmoke16> yes
<FromGitter> <girng> what happens to `hash`'s string?
<FromGitter> <Blacksmoke16> its still a string
<FromGitter> <girng> oh shit
<FromGitter> <girng> this opens a lot of ideas for me I think
<FromGitter> <Blacksmoke16> im just creating an object from the hash's values
<FromGitter> <tenebrousedge> ^
<FromGitter> <Blacksmoke16> casting each value to the proper type to pass to the initializer of the class
<FromGitter> <girng> so basically hashed died for me, so i don't have to .to_i eveywhere
<oprypin> 😂
<FromGitter> <girng> what's up with all this runtime and compile time stuff issues i had 6+months ago
<FromGitter> <girng> just gonna do this
<FromGitter> <girng> LMAOO
<oprypin> i mean, people did tell you like a 1000 times not to use hash but w/e
<FromGitter> <girng> it's just so easy cause [] access
<FromGitter> <girng> i like to access by keys
<FromGitter> <kinxer> @oprypin Lay off a bit, please. It's not helping him learn.
<FromGitter> <girng> with classes, i need custom overload [], i am not sure how to do that lol
<FromGitter> <Blacksmoke16> just doing do that and use dot notation
<FromGitter> <girng> but i remember opyprin showing me a custom overload [] method sometime
<FromGitter> <girng> so.. my fault for not remembering
<FromGitter> <girng> wtf this feel so weird knowing this now though
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/6k7d
<FromGitter> <kinxer> @Blacksmoke16 Is right. It's much easier to write and read `ModSuffixWeapons.name` as opposed to `ModSuffixWeapons["name"]`.
<FromGitter> <Blacksmoke16> we went over this a while ago :P
<FromGitter> <girng> Yeah that [] macro part
<FromGitter> <Blacksmoke16> returns a union tho
<FromGitter> <Blacksmoke16> just use `.value`
<FromGitter> <Blacksmoke16> and dont make things more complicated
<FromGitter> <girng> i like ["key"]?
<FromGitter> <girng> i use it all over already
<FromGitter> <girng> not gonna change :P
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/6k6v like this is what you would have if you just used json everywhere
<FromGitter> <Blacksmoke16> everything just works
<FromGitter> <kinxer> @girng I promise you that `object["key"]` is much slower than `object.key`.
<FromGitter> <girng> problem is, sometimes i need to `key` to be a mutable variable and check against it
<FromGitter> <girng> make sure that key exists, and if it does, access that property
<FromGitter> <girng> can't really do that with `object.key`
<FromGitter> <kinxer> That's absolutely doable.
<FromGitter> <tenebrousedge> `&.try` is a thing
<FromGitter> <Blacksmoke16> thats what `property key : String? ` is for
<FromGitter> <Blacksmoke16> nilable makes it optional, similar to if the key wasnt there
<FromGitter> <girng> for example, users = Hash(Int32, Client).new ⏎ ⏎ users[2] = Client.new ⏎ ⏎ if users[incoming_id]? ... [https://gitter.im/crystal-lang/crystal?at=5d111245ae76db56e03c49e1]
<FromGitter> <girng> users.2 exists?
<FromGitter> <girng> that doesn't work
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/74fv
<FromGitter> <Blacksmoke16> sec
<FromGitter> <girng> it's so much nicer to just do if users[incoming_id]? they exist
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/74fx
<FromGitter> <Blacksmoke16> you're using an OO lang but not using OO
<FromGitter> <Blacksmoke16> losing out on a lot of the type safety and features objects give you
<FromGitter> <girng> hash lookup is not OOP?
<FromGitter> <girng> my type safety is if user = users[incoming_id]?
<FromGitter> <Blacksmoke16> i mean hash is still an object, but in the perfect world you would have your own custom classes for your program
<FromGitter> <girng> now I know for 100% certainty, user exists :D
<FromGitter> <Blacksmoke16> then you could do stuff like this
<FromGitter> <girng> And is type `Client`
<FromGitter> <girng> Local variables!!!
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/74fy
<FromGitter> <girng> eh
<FromGitter> <Blacksmoke16> `return unless user.exists?`
<FromGitter> <Blacksmoke16> `raise "User doesnt exist" unless user.exists?`
<FromGitter> <Blacksmoke16> et
<FromGitter> <girng> im gonna fiddle around with that class initializer thing though i got an idea
<FromGitter> <girng> with .to_i and statically casting types
<FromGitter> <Blacksmoke16> could also do the same thing with your tuples
<FromGitter> <girng> can't touch tuples atm
<FromGitter> <girng> too much code is usiung them
<FromGitter> <Blacksmoke16> ```def self.from_tuple(tuple) ⏎ new(tuple[0], tuple[1]) ⏎ end``` [https://gitter.im/crystal-lang/crystal?at=5d1113b1260d3b4981555721]
<FromGitter> <girng> oh initialize them nvm
<FromGitter> <girng> yah i like that
<FromGitter> <Blacksmoke16> then you get objects you can interact with
<FromGitter> <Blacksmoke16> which you could add method to, which could be used everywhere, vs doing the same checks all the time
<FromGitter> <girng> oh god
<FromGitter> <girng> adding methods to tuples is what you're saying?
<FromGitter> <Blacksmoke16> want an example?
<FromGitter> <girng> i don't know, might blow my mind lmao
<FromGitter> <tenebrousedge> I think the primary benefit is in being able to add methods
<FromGitter> <girng> i'm def eccentric i do everything so different it seems like
<FromGitter> <girng> i'm a real hopeless dev
<FromGitter> <tenebrousedge> naw
<FromGitter> <kinxer> @girng I think it's because of your background in PHP.
<FromGitter> <kinxer> It seems like you're approaching Crystal the same way, which isn't how Crystal (or most programming languages, for that matter) is designed.
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/74g9
<FromGitter> <Blacksmoke16> news up a `User` object from the tuple, then allows adding method, such as getting their full name, vs manually doing that everywhere
<FromGitter> <girng> interesting
<FromGitter> <girng> @kinxer i grew up more with js tbh but yeah i've used php a lot
<FromGitter> <tenebrousedge> PHP's native methods for working with arrays are problematic enough that Laravel borrowed a lot of Ruby's `Enumerable` methods in the form of their `Collections` library
<FromGitter> <kinxer> Yeah, but Javascript and PHP are both *very* dynamic and (unless I'm mistaken) not very Object-Oriented.
<FromGitter> <Blacksmoke16> typescript helps with the JS side of things
<FromGitter> <Blacksmoke16> PHP kinda is, but ofc it doesnt force you to use it
<FromGitter> <girng> @Blacksmoke16 so you don't even need to use a macro to get that string to permanent int32
<FromGitter> <Blacksmoke16> i.e. could use associative arrays everywhere if you wanted i guess
<FromGitter> <girng> it can happen by just using the initialize of a class
<FromGitter> <Blacksmoke16> well you still do it manually
<FromGitter> <Blacksmoke16> but then since its now an object, that ivar is typed to Int32, so you know thats what its going to be
<FromGitter> <girng> i got a great idea
<FromGitter> <girng> give me a few mins
<FromGitter> <Blacksmoke16> if you didnt do the .to_i in the `new(...)` it wouldnt compile
<FromGitter> <PlayLights_twitter> Hello, sorry for interrupting the conversation, does anybody know if I can disable "Connection: keep-alive" on http on crystal?
<FromGitter> <Blacksmoke16> since you would be passing a string to a argument that is typed to int32
<FromGitter> <Blacksmoke16> pass a `Connection: close` request header?
rohitpaulk has joined #crystal-lang
<FromGitter> <kinxer> @girng If Blacksmoke16 wanted to expand that example, the fact that he's using objects would let him, for example https://play.crystal-lang.org/#/r/74gh
<FromGitter> <PlayLights_twitter> is that a default header? I have never set it
<FromGitter> <Blacksmoke16> prob defaults to keep-alive if you dont tell it otherwise by default?
<FromGitter> <PlayLights_twitter> Maybe is default, similar to "Content-Length"
<FromGitter> <Blacksmoke16> prob
<FromGitter> <girng> HAHAHA
<FromGitter> <girng> I DID IT
<FromGitter> <girng> OMG
<FromGitter> <girng> @Blacksmoke16 I LOVE U TY
<FromGitter> <girng> Statically TYPED BABY let's go, no more .to_i's :D
<FromGitter> <Blacksmoke16> do you really need to give your properties defaults?
<FromGitter> <Blacksmoke16> giving them defaults for sake of having defaults isnt the best idea
<FromGitter> <girng> what do you mean defaults
<FromGitter> <Blacksmoke16> ``` property min_value = 0 ⏎ property max_value = 0 ⏎ property mod_type = ""``` [https://gitter.im/crystal-lang/crystal?at=5d11189bf5b00456dfd4d48f]
<FromGitter> <girng> i just put them like that so i don't use : Type
<FromGitter> <girng> it defaults to the type right
<FromGitter> <girng> 0 = Int32
<FromGitter> <girng> "" = String?
<FromGitter> <Blacksmoke16> ` property min_value, max_value, mod_type`
<FromGitter> <Blacksmoke16> can just do that, are already typing them in your initializer
<FromGitter> <girng> ty
<FromGitter> <Blacksmoke16> but just know you're using a struct, might lead to undesired results if you dont know how a struct works
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
<FromGitter> <girng> yeah we'll c, i think i'll be fine
<FromGitter> <girng> hey @Blacksmoke16
<FromGitter> <girng> just curious, what happens to the data in the `csv_data`, since now it's in the Suffixes struct
<FromGitter> <girng> is it free'd from memory
ZombieByte has quit [Ping timeout: 246 seconds]
<FromGitter> <girng> since we basically just used it as a dummy to statically type
salvor has left #crystal-lang ["bye"]
<FromGitter> <watzon> Struggling with how to implement a plugin system for a cli
<FromGitter> <Blacksmoke16> uhh, not super familiar with how all that works
<FromGitter> <Blacksmoke16> id imagine eventually it would?
<FromGitter> <girng> which cli?
<FromGitter> <girng> the new windows one?
<FromGitter> <watzon> No, I'm building a cli that I want to be pluggable
<FromGitter> <girng> oh really?
<FromGitter> <girng> you're making your own cli?
<FromGitter> <girng> interesting
<FromGitter> <watzon> Yup, and making it pluggable is going to be interesting. Super simple in a dynamic language like Ruby, but with Crystal any plugin would have to be compiled.
<FromGitter> <girng> got any teaser screenshots
<FromGitter> <watzon> Unless I included a scripting language
<FromGitter> <watzon> And nope, still very early development
<FromGitter> <girng> yeah too advanced for me to help but wish you the best of luck
<FromGitter> <girng> @Blacksmoke16 see here (https://i.gyazo.com/7dada885f9bcf552e3b03d3ef867e96d.png) all the method invocations. now, once i statically type these structures it will enhance readability
<FromGitter> <girng> now ya see how annoying the to_i's are for me lol
rohitpaulk has quit [Remote host closed the connection]
<FromGitter> <watzon> I guess the best way to implement plugins would be to list them in a config file and then have the cli fetch them, compile them together with the cli code, and then run the compiled program
<FromGitter> <girng> @watzon is there a way to protect against unwanted code tho, what if they make a plugin that does something bad lol
<FromGitter> <watzon> That's always the problem with plugins
<FromGitter> <watzon> Users have to pay attention to what they're installing
<rkeene> If you're really into pushing the plugin into a sandbox it's probably best to make it its own process then, which is isolated and you talk to over an IPC mechanism such as a file descriptor
<rkeene> I let people run arbitrary code on my system, in a sandbox :-D
<FromGitter> <watzon> Yeah that's not a bad idea
<rkeene> https://rkeene.dev/js-repl/ if you want to run arbitrary code on my system
<oprypin> we have http://carc.in for that :)
<oprypin> i wanted to set up my own several times but boy is it a lot of work just to read about the available options for that
<FromGitter> <watzon> If anyone's interested in SushiChain (the blockchain being developed in Crystal) https://www.reddit.com/r/SushiChain/comments/c4tnnj/interview_with_kingsley_hendrickse/
<FromGitter> <girng> https://play.crystal-lang.org/#/r/74hx/edit how can i get `jj` to work?
<FromGitter> <girng> i have to do |k, v| if i'm selecting from a hash's value?
devil_tux has joined #crystal-lang
<FromGitter> <girng> WTF LOL
<FromGitter> <girng> it works!!
rohitpaulk has joined #crystal-lang
<FromGitter> <watzon> Lol there you go
<FromGitter> <girng> `&.[2]` is the same as ⏎ ⏎ ```do |k, v| ⏎ v == 2 ⏎ end``` [https://gitter.im/crystal-lang/crystal?at=5d11241ad010383639c81263]
<FromGitter> <girng> TIL
<FromGitter> <girng> now that i think of it. `&.` is confusing as balls
<FromGitter> <girng> do |k, v| is so much more explicit
<FromGitter> <girng> i like that better
<FromGitter> <watzon> Or you could shorten it to be `{ |k, v| v == 2 }`
<FromGitter> <girng> oooo
<FromGitter> <girng> i like that, ty
<FromGitter> <watzon> No problem
<FromGitter> <watzon> It's just a shorter syntax for blocks
<FromGitter> <girng> i totally forgot about the {'s lol
<FromGitter> <tenebrousedge> `{ |_, v| v == 2 }`
<FromGitter> <watzon> Ahh yeah, forgot about that
<FromGitter> <watzon> No need to make an unused variable
<FromGitter> <girng> what's the differnce
<FromGitter> <girng> what is `_` compared to `k`?
<FromGitter> <tenebrousedge> it's mostly a naming convention
<FromGitter> <girng> ohhhh so it seems like k isn't used
<FromGitter> <tenebrousedge> signifying that the variable is unused
<FromGitter> <girng> = easier to read?
<FromGitter> <watzon> Yeah, with `_` it's not creating a variable
<FromGitter> <watzon> And yes
<FromGitter> <girng> wait really
<FromGitter> <girng> awww ic, okay i like that then
<FromGitter> <girng> cause `k` does seem a bit odd ther lol
<FromGitter> <watzon> Does ameba warn on unused variables?
<FromGitter> <watzon> I can't remember
<FromGitter> <tenebrousedge> I think that `_` does get populated, but if I am remembering right, you can use `_` repeatedly in a block
<FromGitter> <watzon> You can
<FromGitter> <girng> oh yea, looks much better
<FromGitter> <tenebrousedge> exactly
<FromGitter> <girng> gosh i love it when everything is statically typed
<FromGitter> <watzon> Same
<FromGitter> <girng> that thing blacksmoke came up with is awesome lmao
<FromGitter> <girng> basically making a string into a permanent int32 so no need to use to_i all over
<FromGitter> <girng> i bet lead devs are prob like wtf is girng getting himself into LOOOOOL
rohitpaulk has quit [Ping timeout: 246 seconds]
duane has quit [Ping timeout: 246 seconds]
<FromGitter> <bajro17> @bajro17 ⏎ I have a question about http://shards.info this site so often show me 500 error or sometimes won't to show me results ⏎ my question is: Is that happen because: 1. Kemal or 2. Github api or something else ⏎ because I want use Kemal for my next big project I want be sure [https://gitter.im/crystal-lang/crystal?at=5d11283ef5b00456dfd571f8]
devil_tux has quit [Ping timeout: 245 seconds]
<FromGitter> <watzon> As always it's probably because of the implementation, not the framework
<FromGitter> <watzon> Kemal is pretty stable itself
<FromGitter> <watzon> But if you don't catch errors...
<FromGitter> <girng> how i feel about my gameserver. that's why i rescue everything lol
<FromGitter> <girng> although, i do like how the outer functions catch the raises of the inner functions. and if it's in a fiber, it won't crash crystal, you can just disconnect the player. another underrated feature of fibers that are awesome
<FromGitter> <watzon> @icyleaf seriously has some of the best projects
<FromGitter> <watzon> I see him everywhere when I'm searching for crystal libs
<FromGitter> <bajro17> @watzon Thank you so much
<FromGitter> <watzon> No problem
rohitpaulk has joined #crystal-lang
<FromGitter> <girng> https://play.crystal-lang.org/#/r/74jd .select is powerful love it
rohitpaulk has quit [Ping timeout: 252 seconds]
<FromGitter> <Blacksmoke16> @girng two things, just catching up
<FromGitter> <Blacksmoke16> this kinda relates to the benefit of having object, as then you could do like
<FromGitter> <Blacksmoke16> ```def deallocate_items(client, item : Item) ⏎ ...``` [https://gitter.im/crystal-lang/crystal?at=5d112f7f154d273638d51300]
<FromGitter> <girng> yeah that's what i get for using item as a Tuple
<FromGitter> <Blacksmoke16> then even where you get the master item you could have a method on you `Item` class that returns it
<FromGitter> <Blacksmoke16> second
<FromGitter> <Blacksmoke16> `v.max_value >= item_i_atk_speed && v.min_value <= item_i_atk_speed` is this actually a thing you need to do, or just example you did for the playground link?
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
<FromGitter> <girng> not sure yet, might need to use it on the server to check an item's suffix status, but will use it for sure on client to append suffix name to item
<FromGitter> <girng> need to find the suffix name for the item's atk speed roll
laaron has joined #crystal-lang
<FromGitter> <girng> based on the item's atk speed roll
<FromGitter> <Blacksmoke16> mainly was thinking you could do something like
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/74jo
<FromGitter> <Blacksmoke16> 1) using an enum for your `mod_type` to simplify the first select ⏎ 2) add a method to the struct to centralize common logic
<FromGitter> <girng> interesting, thanks
<FromGitter> <Blacksmoke16> which again the benefit of this is if you need to change that logic its just the one place
<FromGitter> <watzon> Ok what do you think of this plugin flow for a `cli`? ⏎ ⏎ 1) Plugins are listed in `_config.yml` ⏎ 2) User runs `hyde plugins install` ⏎ 3) The cli checks the plugin list against the registered plugin list ... [https://gitter.im/crystal-lang/crystal?at=5d11408b54a9d54980fffc10]
<FromGitter> <Blacksmoke16> whats an example of a plugin
<FromGitter> <watzon> Could be anything. This is for static site generation, so anything from a different templating engine to a asset pipeline
<FromGitter> <watzon> Or even simpler shit like just registering a liquid pipe
<FromGitter> <Blacksmoke16> gotcha
<FromGitter> <watzon> This is the best idea I could come up with that doesn't require using a scripting language for plugins
<FromGitter> <watzon> I mean what's the point of a static site generator written in Crystal if you can't use Crystal for plugins?
<FromGitter> <Blacksmoke16> what would a plugin look like?
<FromGitter> <Blacksmoke16> like a shard on github?
<FromGitter> <watzon> Basically. It would just be a shard who's main class extends the `Hyde::Core::Plugin` abstract class, maybe with some extra metadata in `shard.yml`. Idk yet. I'm working on the structure right now.
<FromGitter> <Blacksmoke16> could you make them self installing?
<FromGitter> <watzon> The idea being that a plugin would be allowed to hook into various parts of the compilation pipeline
<FromGitter> <Blacksmoke16> using some `postinstall` hook
<FromGitter> <Blacksmoke16> when doing `shards install`
<FromGitter> <watzon> Well there wouldn't be a `shards install` in this case. I mean, `hyde` itself is going to mainly be a `cli` and the idea is for sites to not be shards. I'm trying to keep crystal out of the site itself.
<FromGitter> <watzon> Very similar to the way jekyll does things
<FromGitter> <Blacksmoke16> right so its not installed like a shrad
<FromGitter> <watzon> Exactly
<FromGitter> <Blacksmoke16> more like grab the binary off github release and there you go
<FromGitter> <Blacksmoke16> gotcha
<FromGitter> <watzon> Yup, that's the idea
<FromGitter> <watzon> Makes the plugin system a more complicated concept
<FromGitter> <watzon> But I'm all about making life complicated
ashirase has joined #crystal-lang
duane has joined #crystal-lang
<FromGitter> <watzon> Second thought, registering plugins may not even be necessary. If I just expose the entire core then they can monkey patch whatever they want. All I'd have to do then is generate a crystal file that imports each of the plugins after importing the cli.
<FromGitter> <watzon> Then I don't have to worry about hooks
<FromGitter> <watzon> And it would allow for a lot more customization
<FromGitter> <kinxer> I don't know about a plugin system based on monkey-patching.
<rkeene> What about plugins that are loaded at runtime ?
<FromGitter> <kinxer> @rkeene How would they integrate into the CLI? Inter-process communication?
mps has quit [Ping timeout: 248 seconds]
mps has joined #crystal-lang
<rkeene> kinxer, It depends -- you could just dlopen(), dlsym() if you have a stable ABI
<FromGitter> <watzon> Yeah loading plugins at runtime won't work very well
<FromGitter> <watzon> That means that for each individual plugin you have to spawn a new process and then they have to talk to each other. That has two issues, one is speed and two is that it limits what they can do.
<FromGitter> <PlayLights_twitter> Is there any way to splat an array?
<FromGitter> <PlayLights_twitter> `argument to double splat must be a named tuple, not Array(String)`
<FromGitter> <dscottboggs_gitlab> no sir
<FromGitter> <watzon> Unfortunately not
<FromGitter> <dscottboggs_gitlab> Arrays are of a dynamic size and you can't splat their values at runtime
<FromGitter> <dscottboggs_gitlab> because like... the compiler doesn't know how many values will be in the array so it can't know which values will be present or not.
<FromGitter> <PlayLights_twitter> Have sense, ok I thought I was possible now I have to think how to solve it._., thanks guys
hightower2 has joined #crystal-lang