ChanServ changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.34.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
straight-shoota has quit [Ping timeout: 264 seconds]
deavmi has quit [Read error: Connection reset by peer]
deavmi has joined #crystal-lang
rocx has quit [Ping timeout: 260 seconds]
ryanprior has joined #crystal-lang
<FromGitter> <ryanprior> Can I bootstrap the Crystal compiler without installing a binary Crystal compiler? I ask because I'm interested in building a bootstrap package.
<oprypin> ryanprior: https://github.com/crystal-lang/bootstrap-script is the *simplest* way
Human_G33k has joined #crystal-lang
HumanGeek has quit [*.net *.split]
deavmi has quit [*.net *.split]
return0e has quit [*.net *.split]
f1refly has quit [*.net *.split]
deavmi has joined #crystal-lang
return0e has joined #crystal-lang
f1refly has joined #crystal-lang
_ht has joined #crystal-lang
<repo> hey
<repo> i'm running the master version of shards and get the following error: v0.1.0+git.commit.205752dcdbe05e2494d3e8b09ca280fc710c2476
<repo> "master version"... shards built from master branch i mean
<oprypin> wait whats the erorr
<repo> ah sorry
<repo> cp mistake
<repo> Invalid version for git resolver: v0.1.0+git.commit.205752dcdbe05e2494d3e8b09ca280fc710c2476
_ht has quit [Remote host closed the connection]
_ht has joined #crystal-lang
<oprypin> repo, please show your shard.yml file
<FromGitter> <bestwebua> I have stuck with class vars, could somebody describe me how I can call instance method on instance that was saved in class var? Thanks! ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5eb12fa822f9c45c2a6e2316]
<oprypin> bestwebua, the error is compile-time. crystal doesn't let you call `(DummyClass | Nil).some_method` because indeed, Nil doesn't have such a method. what if you forgot to call `set_class_var`? does the error make sense then?
<FromGitter> <naqvis> @bestwebua you have told compiler that `class_var` might be `Nil` or it might reference to instance of `OtherDummyClass`. So you will have to handle for cases where this class var is nil. Quick and simple way could be to use `try` like ⏎ ⏎ ```p DummyClass.class_var.try &.some_method``` ⏎ ⏎ above code will work when `class_var` is not nil [https://gitter.im/crystal
<FromGitter> ... -lang/crystal?at=5eb13439b6dd230697a7d165]
<oprypin> that link shows you the explicit way. `if (temp = DummyClass.class_var); temp.some_method; end` - will work
<oprypin> crude way to move the error away from compiletime would be `def self.class_var; @@class_var.not_nil!; end`. and i think this is equivalent: `class_getter! class_var`
<oprypin> yes.
<oprypin> and a nice debugging tool would be to `p typeof(DummyClass.class_var)` - it's the compile-time type rather than just `p DummyClass.class_var.class`
<FromGitter> <bestwebua> Thanks guys, now everything fell into place) 🍻
<FromGitter> <naqvis> 👍
<FromGitter> <bestwebua> 👍
straight-shoota has joined #crystal-lang
Flipez2 has joined #crystal-lang
Nekka has quit [Ping timeout: 264 seconds]
Nekka has joined #crystal-lang
Flipez2 is now known as Flipez
Flipez has quit [Ping timeout: 246 seconds]
Stephie has quit [Ping timeout: 246 seconds]
Stephanie has joined #crystal-lang
<FromGitter> <chosenhood> Guys, is it possible to use some variables inside a macro iteration to handle some conditioning properly? ⏎ dummy example of my case: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5eb14b3d7975db7ebfe5e56f]
<FromGitter> <tenebrousedge> there is a read file macro
<FromGitter> <tenebrousedge> https://crystal-lang.org/api/0.34.0/Crystal/Macros.html#read_file(filename):StringLiteral-instance-method
<FromGitter> <chosenhood> Okay that's great, but how would it be done if I had something like this? ⏎ MyCustomParser returns a custom object type. The issue I have is that the compiler says it can be MyObjectType | Nil. ⏎ I only want to add objects of MyObjectType, no nils. ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5eb14c8b97338850a2eaac1f]
<FromGitter> <tenebrousedge> this is an x y problem
<FromGitter> <tenebrousedge> you don't need a macro to get rid of `Nil`
<FromGitter> <tenebrousedge> and you can't create a variable at compile time using runtime methods
<FromGitter> <tenebrousedge> if you know the return value from `MyCustomParser.parse` will never be nil, use `not_nil!`
<jhass> kingsleyh: I guess you want to embed the files at compile time?
<FromGitter> <chosenhood> Yeah that's what I want
<jhass> whoops, chosenhood^, sorry for the wrong highlight
<jhass> so, do they also neeed to be parsed at compile time or is that okay at runtime?
<FromGitter> <chosenhood> I have a custom parser which builds an object based on the json files. ⏎ I need them parsed in compile time.
<jhass> I would question that need. But anyways. Then you want to come up with a serialization format for the parsed object, something you can store in a literal (hash, string, array, tuple, named tuple, integer, float, combination thereof)
<jhass> then write a run macro (see the docs linked above, same page) that reads the file, parses it and outputs crystal code that builds up this literal
<FromGitter> <chosenhood> Before that I had a runtime variation of this code which did the same logic like in the macro but I also checked if my object is truthy or not before adding it to the hash
<jhass> then you can reinstantiate the object at runtime from the literal
<jhass> your run macro also could output code that builds up your custom objects with literals as arguments
<jhass> but as you can see this gets quite complex, so I would suggest to reevaluate if the probably fairly minor gains in runtime speed/application boot time is worth the development and code commplexity
<jhass> also if it's any substantial data this approach will likely negatively affect compilation speed and binary size
<jhass> compared to a pure runtime approach or a hybrid approach where you just store the file contents as string literals and parse those at runtime
<FromGitter> <chosenhood> Your idea with literals seems interesting.
<jhass> so a first step is to develop a crystal program that outputs crystal code that builds up the structures you want. Basically something that compiles if you do crystal run generator.cr | crystal run
<FromGitter> <chosenhood> Those jsons are basically big config files and there is many of them. It's kinda better if it's included in compile time and later there is no dealing with reading those files, relative paths etc. Had big problems when my code is run in docker and so on as it is a shard.
<jhass> then you can use that program to either just pregenerate files in your library or hook it up to the run macro
<jhass> if that's your only concern I would strongly argue in favor of just storing them as stringliterals with the read_file macro and parsing them at runtime
<jhass> much simpler to maintain
<jhass> and reason about
<FromGitter> <chosenhood> Yup. I like that approach with literals.
<FromGitter> <chosenhood> My main concern is avoiding dealing with reading files in runtime
rocx has joined #crystal-lang
<raz> might be a middleground
<straight-shoota> I'd rather recommend https://github.com/schovi/baked_file_system
<straight-shoota> it's more robust than rucksack
<straight-shoota> rucksack might probably has an advantage when packing huge payloads, though
<FromGitter> <Uzay-G> this is pretty noob but how do we get the length of an array in crystal?
<FromGitter> <Uzay-G> I tried `.length` but I guess not
<FromGitter> <tenebrousedge> `size`
<FromGitter> <Uzay-G> thanks
<FromGitter> <Uzay-G> oh also my problem yesterday was because for some reason postgres was connecting on ipv6. Thanks for your help :)
<FromGitter> <tenebrousedge> np glad you got it working
<FromGitter> <3n-k1> does specifying a branch other than master in shard.yml even work? i've never been able to get it working, even though the branch absolutely exists on the remote
<FromGitter> <Uzay-G> try deleting `lib/`and then running `shards update`
<FromGitter> <Uzay-G> it worked for me
<FromGitter> <3n-k1> that did it, thanks!
<FromGitter> <Uzay-G> is there a way to like have multi-line strings?
sorcus has quit [Quit: WeeChat 2.8]
<jhass> yes, press enter :D
<raz> want to make $$$ fast? easy, press shift-4 three times in a row!
<jhass> if you were thinking of not introducing the newline into the string: https://carc.in/#/r/90hb
sorcus has joined #crystal-lang
<raz> scnr :p
Stephanie is now known as Stephie
<ryanprior> Woah amazing bootstrap script, 160 stages.
v2px__ has quit [Ping timeout: 260 seconds]
baweaver has joined #crystal-lang
<FromGitter> <bararchy> Hi everyone, if there are among you those who are interested in Application Security and infosec in general, starting tomorrow we will do a two days push of changes and improvements to https://github.com/NeuraLegion/broken_crystals, this project is meant to help Crystal devs improve application security and avoid common pit-falls, If you have any idea on cool situations, scenarios or security issues you wish
<FromGitter> ... to add to the project let us know either in twitter (@neuralegion) or over at the Github issues. Happy and secured development!
<sorcus> bararchy: :thumbs_up:
<FromGitter> <bararchy> Thanks sorcus
_ht has quit [Quit: _ht]
sagax has quit [Ping timeout: 260 seconds]
<FromGitter> <Uzay-G> Hey, what do you guys think is the most mature and efficient web framework in crystal?
<FromGitter> <Uzay-G> I'm planning on building something with it and wanted to know your opinions
<FromGitter> <Blacksmoke16> depends on what your needs/requirements are
<FromGitter> <Blacksmoke16> you have a few choices :p
<FromGitter> <Uzay-G> like what?
<FromGitter> <Uzay-G> which one have you used that are good?
<robacarp> all of them
<FromGitter> <Uzay-G> all of them are good? 😆
<robacarp> but really, it depends on how complex your application is going to be
<FromGitter> <watzon> It's really between Lucky and Amber if you're looking for a full framework
<FromGitter> <watzon> Athena too if you just want an API
<FromGitter> <Blacksmoke16> API or server rendered? Looking for something simple or full stack? etc
<FromGitter> <watzon> Personally I prefer Lucky
<FromGitter> <Uzay-G> full stack I guess with server rendering and an api
<FromGitter> <Uzay-G> but more backend focused
<FromGitter> <Uzay-G> I might use lucky yeah
<FromGitter> <watzon> Lucky is nicely integrated with laravel mix too
<FromGitter> <watzon> It's got you covered on both ends pretty well
<FromGitter> <Blacksmoke16> Athena's the way to go 😉
<FromGitter> <Blacksmoke16> takes a diff approach compared to other frameworks, so has some unique stuff at least work checking out
<FromGitter> <Blacksmoke16> worth*
go|dfish has joined #crystal-lang
<FromGitter> <Blacksmoke16> id be happy to answer any questions etc as well
<FromGitter> <watzon> What happened to gring? Did he disappear again?
<FromGitter> <Blacksmoke16> (PS im biased, Athena is mine :S)
<FromGitter> <Blacksmoke16> he comes around every so often, says `goodmorning`, or `crystal time` then disappears again :P
<FromGitter> <Blacksmoke16> so id imagine he's up to something haha
<FromGitter> <watzon> Trying to mention him doesn't show his new username anymore haha
<FromGitter> <watzon> I need to chat with a game dev though
<FromGitter> <Blacksmoke16> @ImAHopelessDev_gitlab @watzon needs you
<FromGitter> <watzon> Weird, his name wouldn't come up for me haha
<FromGitter> <Blacksmoke16> had to scroll up to find it
<FromGitter> <Uzay-G> nice i will check things out
<FromGitter> <Uzay-G> my first crystal project: https://github.com/Uzay-G/onyx. It's not much and the code isn't perfect but I am happy about it
<FromGitter> <watzon> Haha onyx seems to be a popular name
<FromGitter> <watzon> There's a web framework and a language with that name now
<FromGitter> <Uzay-G> argh
<FromGitter> <Blacksmoke16> no longer maintained tho afaik
<FromGitter> <Blacksmoke16> https://crystal-lang.org/api/master/OptionParser.html might be helpful @Uzay-G
<FromGitter> <Uzay-G> this bot is for discord
<FromGitter> <Uzay-G> not command line
<FromGitter> <Blacksmoke16> ah, i missed the `client.on_message_create do |message|`
<FromGitter> <Blacksmoke16> well fwiw `OptionParser` can be used for any arg array
<FromGitter> <Uzay-G> oh nice
<FromGitter> <Uzay-G> what does fwiw mean lol
<FromGitter> <Blacksmoke16> default is just `ARGV`
<FromGitter> <Blacksmoke16> for whatever its worth
<FromGitter> <Blacksmoke16> ah nvm, would require `-` based args like for a cli
<FromGitter> <straight-shoota> @Uzay-G If you're not too strongly attached to the name, I'd recommend to change to an uncontested name while it's still fresh
<FromGitter> <Uzay-G> well idt there are any discord bots named `onyx`
<FromGitter> <straight-shoota> No, but crystal shards =)
<FromGitter> <kinxer> Sure, but it's not gonna help people find your thing if there are other, unrelated things with the same name. Like, I probably shouldn't start a self-hosted digital journal project named "Markdown"; that name is already decidedly taken, even if it's something totally different.
<FromGitter> <watzon> Yeah it's best to be unique in as many aspects as possible to set your project apart from others
<FromGitter> <Blacksmoke16> i dont see an `IO#[]=` anywhere
xyhuvud has quit [Read error: Connection reset by peer]
yxhuvud has joined #crystal-lang
<FromGitter> <Blacksmoke16> ohhh nvm, its `String.new` now `String.build`
<FromGitter> <Blacksmoke16> nvm
<oprypin> ok now i officially hate exhaustive case errors https://github.com/crystal-lang/crystal/issues/9235
<rocx> but it's for your safety™
<straight-shoota> Maybe start a club? =)
<straight-shoota> I'm not decided yet if I would join. Exhaustive case has some real issues, but it's also proven to be useful :/
<FromGitter> <Blacksmoke16> scoped to enums might be a good start
<straight-shoota> Maybe...
<straight-shoota> But for long enums it doesn't make sense
<FromGitter> <Blacksmoke16> or a diff syntax* i know that was proposed before
<straight-shoota> And I find it particularly useful when destructing union types
<straight-shoota> A different keyword might be a good solution actually.
<FromGitter> <Blacksmoke16> `case!`
<FromGitter> <Blacksmoke16> was an issue/pr about it before iirc
<straight-shoota> Yes, there were different alternatives in the discussion