ChanServ changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.32.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
_whitelogger has joined #crystal-lang
watzon has joined #crystal-lang
watzon has quit [Quit: WeeChat 2.7]
watzon has joined #crystal-lang
watzon has quit [Quit: WeeChat 2.7]
watzon has joined #crystal-lang
watzon has quit [Quit: WeeChat 2.7]
watzon has joined #crystal-lang
watzon has quit [Quit: WeeChat 2.7]
watzon has joined #crystal-lang
watzon has quit [Client Quit]
watzon has joined #crystal-lang
f1refly has joined #crystal-lang
chachasmooth_ has quit [Ping timeout: 250 seconds]
chachasmooth has joined #crystal-lang
f1reflyylmao has quit [Ping timeout: 248 seconds]
ur5us_ has quit [Ping timeout: 248 seconds]
ht_ has joined #crystal-lang
return0e has joined #crystal-lang
return0__ has quit [Ping timeout: 268 seconds]
ur5us_ has joined #crystal-lang
ht_ has quit [Quit: ht_]
return0e_ has joined #crystal-lang
return0e has quit [Read error: Connection reset by peer]
Human_G33k has quit [Ping timeout: 248 seconds]
HumanG33k has joined #crystal-lang
HumanG33k has quit [Remote host closed the connection]
HumanG33k has joined #crystal-lang
HumanG33k has quit [Remote host closed the connection]
HumanG33k has joined #crystal-lang
ur5us_ has quit [Ping timeout: 248 seconds]
bougyman has quit [Ping timeout: 248 seconds]
bougyman has joined #crystal-lang
bougyman has quit [Ping timeout: 245 seconds]
bougyman has joined #crystal-lang
beepdog has quit [Ping timeout: 240 seconds]
erdnaxeli has quit [Ping timeout: 246 seconds]
olbat[m] has quit [Ping timeout: 252 seconds]
ternarysolo has quit [Ping timeout: 246 seconds]
Human_G33k has joined #crystal-lang
HumanG33k has quit [Ping timeout: 245 seconds]
<FromGitter> <absolutejam_gitlab> Does Crystal have anything analogous to https://medium.com/learning-the-go-programming-language/writing-modular-go-programs-with-plugins-ec46381ee1a9?
<FromGitter> <tenebrousedge> what are you trying to do?
<FromGitter> <tenebrousedge> you can `build --emit obj` if you need to
return0e_ has quit [Read error: Connection reset by peer]
<FromGitter> <tenebrousedge> you can't dynamically change code at runtime, if that's what you're after
return0e_ has joined #crystal-lang
<FromGitter> <nsuchy> This isn’t JavaScript L0L this language has actual rules πŸ€ͺ
<FromGitter> <Blacksmoke16> PHP lets you call class methods on a class from a string that represents the path of the class
<FromGitter> <Blacksmoke16> πŸ˜•
<FromGitter> <tenebrousedge> the path? like the filename or the namespace?
<FromGitter> <Blacksmoke16> `\MyApp\Bundle\SyndicationBundle\Controller\SyndicationReviewController`
<FromGitter> <Blacksmoke16> like namespace + class name
<FromGitter> <tenebrousedge> I've written a lot of PHP at various times. I'll never love it. Psy and Laravel aren't bad though
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5dfa36bec5a23938b43f8425]
<FromGitter> <tenebrousedge> I mean, I don't think that's unusual
<FromGitter> <tenebrousedge> PHP has pretty limited metaprogramming
<FromGitter> <Blacksmoke16> i mean i get why/how it works, is just a bit strange, esp when you have your vars typed to `string`
<FromGitter> <Blacksmoke16> IDE will complain that `myStaticMethod` doesnt exist on `string`
<FromGitter> <tenebrousedge> I forget, does PHP even allow you to pass around a `Class` object?
<FromGitter> <Blacksmoke16> cant say i ever tried
<FromGitter> <Blacksmoke16> i know you can call methods of a class based on a string
<FromGitter> <Blacksmoke16> ```$method = 'foo'; ⏎ ⏎ $obj->$method();``` [https://gitter.im/crystal-lang/crystal?at=5dfa37a5e0131f50c9660388]
<FromGitter> <tenebrousedge> like ⏎ ⏎ ```if (condition) { $var = String } else { $var = Integer }``` ⏎ ⏎ Because I don't remember being able to do that [https://gitter.im/crystal-lang/crystal?at=5dfa37adc62fdf33f712ade7]
<FromGitter> <tenebrousedge> my recollection was that all metaprogramming was based on strings, like your examples
<FromGitter> <Blacksmoke16> what is `String` tho, i get an undefined constant
duane has joined #crystal-lang
<FromGitter> <tenebrousedge> well exactly
<FromGitter> <Blacksmoke16> You can do like `MyClass::class` which is similar to crystal's `MyClass.class` however in PHP it just returns the FQN of the class vs a diff type
<FromGitter> <tenebrousedge> right, it's all string-based
<FromGitter> <Blacksmoke16> ``````
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5dfa387ae0131f50c9660a47]
<FromGitter> <tenebrousedge> you can also do something like ⏎ ⏎ ```$obj->{"foo" + $bar}();``` ⏎ ⏎ Although I don't recall if that's the exact syntax. I have used that before [https://gitter.im/crystal-lang/crystal?at=5dfa387ec0c8ef301bd36266]
<FromGitter> <Blacksmoke16> this also kinda blows my mind
<FromGitter> <Blacksmoke16> yea, have to admit while it all seems wrong and super hacky it can be pretty slick
<FromGitter> <tenebrousedge> I mean, it works, but I can't say it's slick, compared to Ruby
<FromGitter> <Blacksmoke16> `it works` about best you going to get in php ha
<Yxhuvud> AoC days like this make me wish for a nice Heap in stdlib.
sorcus has quit [Quit: WeeChat 2.6]
alexherbo2 has joined #crystal-lang
<FromGitter> <alehander92> its very similar to `send` in ruby right
<FromGitter> <Blacksmoke16> yea
<FromGitter> <alehander92> and getattr in python, yeah, its cool that many idioms are
<FromGitter> <alehander92> easily mappable between them
<FromGitter> <tenebrousedge> with the caveat that `send` is wired deeply into Ruby
<FromGitter> <christopherzimmerman> Does Crystal have something similar to Rust's enum functionality? Where you can do something like: ⏎ ⏎ ```enum Foo { ⏎ Bar(usize) ⏎ Baz(usize) ⏎ }``` [https://gitter.im/crystal-lang/crystal?at=5dfa40da090f1379680f943e]
<FromGitter> <Blacksmoke16> what does `usize` mean?
<FromGitter> <christopherzimmerman> Just an integer, you can pass arguments to enum flags to provide additional information.
<FromGitter> <alehander92> ADT-s ?
<FromGitter> <tenebrousedge> @christopherzimmerman
<FromGitter> <alehander92> no rust enums
<FromGitter> <alehander92> are basically algebraic types iirc
<FromGitter> <alehander92> which is confusing, as c/crystal/nim etc enums seems lot more minimal
<FromGitter> <tenebrousedge> there's some discussion of that on the exclusive case github issue, but yes, the intent is not to do full ADTs
ternarysolo has joined #crystal-lang
erdnaxeli has joined #crystal-lang
olbat[m] has joined #crystal-lang
beepdog has joined #crystal-lang
<FromGitter> <j8r> generally, you can use modules/structs in place of Rust enums
<FromGitter> <j8r> with composition/inheritance
<FromGitter> <firejox> use union type. ⏎ they would work as Rust enums.
ternarysolo has quit [Remote host closed the connection]
olbat[m] has quit [Remote host closed the connection]
beepdog has quit [Remote host closed the connection]
erdnaxeli has quit [Remote host closed the connection]
<FromGitter> <j8r> not really, because I think he want a relation between this types
<FromGitter> <j8r> maybe an alias of unions
DTZUZO has quit [Ping timeout: 252 seconds]
DTZUZO has joined #crystal-lang
<FromGitter> <christopherzimmerman> I ended up with something like this: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5dfa4cec0cb24d1d44dff66e]
sorcus has joined #crystal-lang
<FromGitter> <tenebrousedge> why not ⏎ ⏎ ```enum Foo ⏎ Bar = 1 ⏎ Baz = 2 ⏎ end``` [https://gitter.im/crystal-lang/crystal?at=5dfa4d238897197969bae9a0]
<FromGitter> <christopherzimmerman> Because the value doesn't have any relation to the enum.
<FromGitter> <tenebrousedge> k
commavir has joined #crystal-lang
ternarysolo has joined #crystal-lang
erdnaxeli has joined #crystal-lang
beepdog has joined #crystal-lang
olbat[m] has joined #crystal-lang
snapcase_ has quit [Quit: Reconnecting]
snapcase has joined #crystal-lang
<FromGitter> <daya> Is there any built in library for SAML2.0 support
ht_ has joined #crystal-lang
<watzon> I think someone was working on a SAML library, but I don't think it's maintained
<watzon> Hmm maybe not, I can't find it
alexherbo26 has joined #crystal-lang
alexherbo2 has quit [Ping timeout: 252 seconds]
alexherbo266 has joined #crystal-lang
alexherbo26 has quit [Ping timeout: 258 seconds]
alexherbo266 has quit [Read error: Connection reset by peer]
alexherbo2 has joined #crystal-lang
ht_ has quit [Ping timeout: 246 seconds]
ht_ has joined #crystal-lang
<FromGitter> <Blacksmoke16> what are your guy's thoughts on how to handle configuration? ⏎ ⏎ 1) A yaml file ⏎ 2) in code configuration [https://gitter.im/crystal-lang/crystal?at=5dfa83358dfce538b5ccfce7]
<FromGitter> <tenebrousedge> YAML or JSON
<FromGitter> <Blacksmoke16> current idea is to have a base struct that other components can reopen to add their own config types
<FromGitter> <Blacksmoke16> where the base struct is used with `from_yaml`
<FromGitter> <Blacksmoke16> required properties would be not nilable without a default, so they would fail when trying to parse the config
<FromGitter> <Blacksmoke16> plan would also be to have some pre processing step to replace placeholders with ENV vars/parameters
<FromGitter> <tenebrousedge> okay
<FromGitter> <Blacksmoke16> sounds fine?
<FromGitter> <tenebrousedge> it doesn't sound crazy
<FromGitter> <Blacksmoke16> might look into adding custom yaml tag support to crystal
<FromGitter> <Blacksmoke16> i feel like that would be pretty slick
<FromGitter> <Blacksmoke16> `env: !crystal/env APP_ENV`
<FromGitter> <tenebrousedge> There are a number of people who dislike YAML and consider it hard to parse
<FromGitter> <Blacksmoke16> parse as in read?
<FromGitter> <Blacksmoke16> or for a computer to parse
<FromGitter> <tenebrousedge> probably the latter
<FromGitter> <tenebrousedge> there are a fair amount of articles to that effect
duane has quit [Ping timeout: 252 seconds]
ur5us_ has joined #crystal-lang
bcardiff has joined #crystal-lang
ChanServ changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.32.1 | 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
bcardiff has quit [Client Quit]
duane has joined #crystal-lang
<FromGitter> <watzon> I like YAML personally. It's concise and supports a lot of things that JSON doesn't, like multiline strings for instance
<FromGitter> <Blacksmoke16> same
<FromGitter> <absolutejam_gitlab> I like yaml for the right use cases
<FromGitter> <absolutejam_gitlab> big k8s manifests really stretch that
<FromGitter> <absolutejam_gitlab> and it's a superset so you're not constrained
<FromGitter> <absolutejam_gitlab> although yaml has some weirdness, like 'null' values
<FromGitter> <absolutejam_gitlab> saw your messages about PHP earlier @Blacksmoke16
<FromGitter> <absolutejam_gitlab> the weirdest part of PHP has to be https://www.php.net/manual/en/language.variables.variable.php
<FromGitter> <absolutejam_gitlab> @tenebrousedge I wasn't trying to do anything, I just discovered go's `buildmode=plugin` and I was thinking about this kind of thing before as a way of extending Crystal apps without recompiling the world
<FromGitter> <absolutejam_gitlab> just curious
<FromGitter> <absolutejam_gitlab> haven't written any Crystal or been active here in forever, just want a reason to write some Crystal :[
<FromGitter> <absolutejam_gitlab> @Blacksmoke16 I'm a fan of code configuration if it's appropriate
<FromGitter> <absolutejam_gitlab> like, if you're configuring the app, why not utilise the app to configure itself
<FromGitter> <absolutejam_gitlab> or laravel uses config PHP files, etc.
<FromGitter> <absolutejam_gitlab> But then on the flip side, I think something like Wordpress shouldn't use `wp-config.php`, but should use yaml
<FromGitter> <absolutejam_gitlab> or just be incinerated altogether
<FromGitter> <Blacksmoke16> yea for sure
<FromGitter> <Blacksmoke16> main usage would be for like CORs
<FromGitter> <Blacksmoke16> or like global app settings, like `logs_dir`, default charset etc
<FromGitter> <absolutejam_gitlab> if you're doing for a framework, then in-app
<FromGitter> <Blacksmoke16> eventually want to get to the point where you define parameters, then use the parameters in the config as well
<FromGitter> <absolutejam_gitlab> if it's a binary that you just consume, then yaml
<FromGitter> <Blacksmoke16> hmm good point
<FromGitter> <Blacksmoke16> it would be kinda annoying to have to ship your binary with a yaml file...
<FromGitter> <absolutejam_gitlab> just dump out a default one or use defaults and make it optional
<FromGitter> <Blacksmoke16> at that point whats the point of having the file?
<FromGitter> <absolutejam_gitlab> well you ship it with sane defaults
<FromGitter> <absolutejam_gitlab> and let people override
<FromGitter> <Blacksmoke16> i guess what im trying to get at is, is it bad to have to ship a yaml file with your binary
<FromGitter> <Blacksmoke16> that controls those overridden settings
<FromGitter> <Blacksmoke16> vs having that in the binary and it configures itself
<FromGitter> <Blacksmoke16> based on ENV vars or what have you
<FromGitter> <absolutejam_gitlab> it depends whether your app is something highly reusable or if it's going to be configured at build
<FromGitter> <absolutejam_gitlab> like, if it's your business app that gets deployed with highly specific business config, I'd say you manage it in-app/talk to services like consul
<FromGitter> <Blacksmoke16> use case would be for athena ofc
<FromGitter> <Blacksmoke16> which i cant imagine people changing the settings once its running
<FromGitter> <absolutejam_gitlab> or if it's something highly generic like hugo, consul, etc. that you configure with the CLI, env, etc. then I'd say config file(s)
<FromGitter> <absolutejam_gitlab> Yeah, I'd say in-app
<FromGitter> <Blacksmoke16> that makes things a lot easier as well...
<FromGitter> <Blacksmoke16> still going to make a PR for custom yaml tags, think that would be cool :P
<FromGitter> <absolutejam_gitlab> like our production Laravel app, we have 20+ config files that all call out to env (and in prod we use Consul-template), and eventhough you can change things on the fly, we ship it as a docker image so it's essentially a 'binary'
<FromGitter> <absolutejam_gitlab> whereas if I use something off the shelf like Consul, Influxdb, whatever, then I'd often supply a config file and env vars to configure it
<FromGitter> <absolutejam_gitlab> because I'm just consuming it, not using it as a framework
<FromGitter> <absolutejam_gitlab> and our production Laravel app is our website, it's not something like Snipe-IT where people will build upon it/consume it
<FromGitter> <Blacksmoke16> gotcha
<FromGitter> <Blacksmoke16> in-app deff seems the way to go for this case
<FromGitter> <Blacksmoke16> ``````
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5dfa99b2c62fdf33f7156af7]
<FromGitter> <Blacksmoke16> neat
<FromGitter> <Blacksmoke16> going to make an issue about it first tho
<FromGitter> <kinxer> Have you already implemented it?
<FromGitter> <Blacksmoke16> a proof of concept at least
<FromGitter> <kinxer> Nice. That was pretty quick.
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5dfa9a41c0c8ef301bd60280]
<FromGitter> <Blacksmoke16> was imaging something like that, diff nameing and stuff id imagine tho
<FromGitter> <kinxer> How would you integrate that with `YAML::Serializable`?
<FromGitter> <Blacksmoke16> 😬
<FromGitter> <Blacksmoke16> sec
duane has quit [Ping timeout: 246 seconds]
<FromGitter> <Blacksmoke16> would have to include it somewhere in that logic
duane has joined #crystal-lang
<FromGitter> <Blacksmoke16> should be doable tho
<FromGitter> <kinxer> I think the issue would benefit from your example usage code above.
<FromGitter> <Blacksmoke16> done
<FromGitter> <j8r> INI for configuration, if possible
ht_ has quit [Remote host closed the connection]
duane has quit [Ping timeout: 248 seconds]
<FromGitter> <j8r> I love INI - simple, readable - but that's also a downside - limited. ⏎ In a way, it forces us to keep things simple
<FromGitter> <absolutejam_gitlab> does ini have data types?
<FromGitter> <j8r> Only strings
<FromGitter> <j8r> JSON and YAML have more, but are also limited. For example, no time type
<FromGitter> <absolutejam_gitlab> that seems out of their domain though
<FromGitter> <j8r> not really, it's quite common to store dates in JSON
<FromGitter> <j8r> But it's not really a big limitation to have to integer types, php-pfm.conf handle it.
<FromGitter> <j8r> The biggest one is the nesting limitation: only 2 levels
<FromGitter> <absolutejam_gitlab> store it as an ISO8601 string
<FromGitter> <j8r> ok, so it's not a problem to store integers as strings then
<FromGitter> <absolutejam_gitlab> Maybe I just don't see dates as a primitive
<FromGitter> <absolutejam_gitlab> because they vary from languages
<FromGitter> <j8r> It's more important when transferring the data between services
<FromGitter> <absolutejam_gitlab> although json has no int
<FromGitter> <j8r> it has? https://www.json.org/json-en.html
<FromGitter> <absolutejam_gitlab> I thought they were all floats? πŸ’­
duane has joined #crystal-lang
ur5us_ has quit [Remote host closed the connection]
ur5us_ has joined #crystal-lang
alexherbo2 has quit [Ping timeout: 248 seconds]