ChanServ changed the topic of #crystal-lang to: The Crystal programming language | https://crystal-lang.org | Fund Crystal's development: https://crystal-lang.org/sponsors | GH: https://github.com/crystal-lang/crystal | Docs: https://crystal-lang.org/docs | Gitter: https://gitter.im/crystal-lang/crystal
ua_ has quit [Ping timeout: 265 seconds]
ua_ has joined #crystal-lang
<raz> hmm, scala 3 looks quite tempting
<raz> just that java baggage.. ugh
<FromGitter> <mjfiano:matrix.org> It's a nice language, though not very usable for my domain
ur5us has quit [Ping timeout: 240 seconds]
Guest4325 has joined #crystal-lang
Guest4325 has quit [Quit: Client closed]
ua_ has quit [Ping timeout: 268 seconds]
ua_ has joined #crystal-lang
ua_ has quit [Ping timeout: 245 seconds]
ua_ has joined #crystal-lang
ur5us has joined #crystal-lang
ua_ has quit [Ping timeout: 252 seconds]
ua_ has joined #crystal-lang
raz has quit [Ping timeout: 240 seconds]
raz has joined #crystal-lang
raz has joined #crystal-lang
raz has quit [Changing host]
ua_ has quit [Ping timeout: 276 seconds]
ua_ has joined #crystal-lang
ua_ has quit [Ping timeout: 268 seconds]
ua_ has joined #crystal-lang
ur5us has quit [Ping timeout: 245 seconds]
<FromGitter> <mjfiano:matrix.org> I remember reading in the docs or one of the tutorials a concise way to swap two bindings...anyone know?
<FromGitter> <mjfiano:matrix.org> Nevermind, found it
<FromGitter> <mjfiano:matrix.org> Anyone know what this means for a method? ⏎ ⏎ ```Metrics/CyclomaticComplexity: Cyclomatic complexity too high [12/10]``` [https://gitter.im/crystal-lang/crystal?at=6100f37ff4d1dc69f30ba78f]
Nik- has joined #crystal-lang
Nik- has quit [Client Quit]
hightower2 has joined #crystal-lang
<FromGitter> <mjfiano:matrix.org> Matrix math is tedious sometimes https://gist.github.com/mfiano/3ca4b4417cf8e818b68e14200e4e8742
<FromGitter> <mjfiano:matrix.org> insert @Blacksmoke16 emoji here
hightower2 has quit [Ping timeout: 240 seconds]
<yxhuvud> I'm .. fairly certain someone has implemented matrix math in some shard.
Guest23 has joined #crystal-lang
Guest23 has quit [Client Quit]
hightower2 has joined #crystal-lang
<FromGitter> <Blacksmoke16> Oof, i feel like there's a better way
<FromGitter> <Blacksmoke16> @mjfiano:matrix.org and that means that a method is too complex. See https://www.rubydoc.info/gems/rubocop/RuboCop/Cop/Metrics/CyclomaticComplexity
<FromGitter> <Blacksmoke16> is usually a sign that a method may need broken up into multiple methods, but some cases it's unavoidable so can manually disable that rule on the specific method
<FromGitter> <Blacksmoke16> wew, gotta love a kemal controller :P
<FromGitter> <RespiteSage> @raz Where you asking why I'm restricting the generic type of `Saline::Saturating(T)` to `T < Number`?
<FromGitter> <RespiteSage> *were
<raz> already forgot what that was about, n/m
<riza> I did some fun matrix stuff in my experiments with qr codes a few years back https://github.com/tumblerlock/crystal_qr/tree/master/src/qr
<riza> not handy for arithmetic though
<riza> it allows you to do maxtrix[rowN..rowM][colA..colB] and get a reference matrix which can be iterated in a few different ways
<riza> the map for how data is injected into a qr code is a bit strange, but this allowed me to build a nice concise language to fill the matrix
<riza> oh I forgot you could also do matrix[rowN..rowM, rowQ..rowR] too
delucks has quit [Ping timeout: 252 seconds]
delucks has joined #crystal-lang
Guest1291 has joined #crystal-lang
Guest1291 has quit [Quit: Client closed]
otoburb has joined #crystal-lang
<FromGitter> <MrSorcus> https://crystal-lang.org/conference/ - wow, so much videos from conference. Look like i found what to watch on next weekends 😆
<FromGitter> <mjfiano:matrix.org> @Blacksmoke16: How to manually disable that rule? Also, believe it or not, that warning is not for the method I linked, but a much less complex one
<FromGitter> <Blacksmoke16> something like `# ameba:disable Metrics/CyclomaticComplexity`
<FromGitter> <mjfiano:matrix.org> Interesting, though this warning didnt come from ameba
<FromGitter> <Blacksmoke16> are you sure
<FromGitter> <mjfiano:matrix.org> No, but it came from crystalline
<FromGitter> <Blacksmoke16> because thats deff an ameba warning
<FromGitter> <Blacksmoke16> sure its just not running ameba on change or something?
<FromGitter> <mjfiano:matrix.org> it shows up in my editor
<FromGitter> <mjfiano:matrix.org> not sure how it would call ameba unless it is built in to crystalline
<FromGitter> <Blacksmoke16> :shrug: i never used it
<FromGitter> <Blacksmoke16> but im pretty certain thats an ameba thing
ur5us has joined #crystal-lang
ur5us has quit [Ping timeout: 240 seconds]
<FromGitter> <HertzDevil> random thought: if some 1.0.0 code defines a type called `::Steppable`, wouldn't its addition in the stdlib be a breaking change
<FromGitter> <mjfiano:matrix.org> I wouldn't say so.
<FromGitter> <HertzDevil> from which it follows we cannot add *any* top-level type to the stdlib (if they reside in a namespace we could call them monkeypatching)
<straight-shoota> It's definitely a breaking change because it can break code that previously worked.
<FromGitter> <HertzDevil> starting to think this is why languages like c++ put everything under std
<FromGitter> <mjfiano:matrix.org> I think of breaking changes as API changes, not any monkey patching the user might do. Putting your own types in your own namespaces should be considered the good practice, if at all possible.
<FromGitter> <mjfiano:matrix.org> But it does break existing code
<FromGitter> <HertzDevil> "your own namespaces" still have a chance to conflict with crystal stdlib's top-level types
<straight-shoota> mjfiano: If you have a shard called `steppable`, it's not monkey patching. You would actually be a good citizen by putting everything in the `Steppable` namespace.
<FromGitter> <mjfiano:matrix.org> I do agree, and I found it odd that Crystal didn't have a stdlib namespace.
<FromGitter> <HertzDevil> more specifically, stdlib types defined in the default prelude
<straight-shoota> Yeah, that's an inheritance from Ruby
<straight-shoota> It's not just Ruby though. Many languages have stdlib types defined in the default namespace
ur5us has joined #crystal-lang
<FromGitter> <HertzDevil> like if we add `::Quaternion` in the stdlib but don't require it in prelude.cr, it is unlikely any 1.0 code will break
<FromGitter> <mjfiano:matrix.org> Such as where I come from, Common Lisp, where it is (usually, depending on the implementation) a compile-time error for the user to use any toplevel symbols defined in that namespace in a user definition.
<straight-shoota> @HertzDevil: It's only safe if it's not related to any existing stdlib code. If it's required by `http.cr`, code that has `require "http"` could still break.
<straight-shoota> It might be easier to work around than if it's in the prelude. But not if `require "http"` is in a dependency.
<FromGitter> <RespiteSage> @mjfiano:matrix.org The problem with doing that in Crystal is that we can reopen classes and modify them (usually just to add methods). It's just really nice and convenient sometimes. One of the Crystal libraries I use most (currently internal to my company, unfortunately) lets you define physical quantities without having to keep track of the units, and I really love being able to define `length =
<FromGitter> ... 50.meters`.
<FromGitter> <mjfiano:matrix.org> Yes, I understand. CL can get away with it because it uses multiple dispatch : methods don't belong to types/classes.
<FromGitter> <RespiteSage> But there's definitely the tradeoff, because you (or any upstream or downstream dependencies) can really mess stuff up or (in the worst case) inject malicious logic into standard library calls.
<FromGitter> <mjfiano:matrix.org> That is a nice API though (units)
<FromGitter> <RespiteSage> Yeah, it is. A long-term goal I have is convincing my company to open-source it or writing my own version of it myself (since there are some quality-of-life features that I think would be nice for users in general but aren't necessary for our use cases).
<FromGitter> <RespiteSage> And it's *so* much better than using a naming scheme (e.g. `length_nm = 50`).
<FromGitter> <mjfiano:matrix.org> Scala iirc has a way to seal classes, though not sure how that might tie into a language like Crystal.
<FromGitter> <RespiteSage> I think there's an RFC about adding that to Crystal.
rem has quit [Quit: WeeChat 3.2]
<FromGitter> <RespiteSage> I think there's some optimization or type inference benefit that was brought up.
<FromGitter> <mjfiano:matrix.org> Does that unit library do conversions, because domain analysis can often be difficult
<FromGitter> <mjfiano:matrix.org> ?
<FromGitter> <mjfiano:matrix.org> So many times I messed up distance/time conversions, like angular velocity
<FromGitter> <HertzDevil> if a user defines `Number#meters`, that's definitely considered monkeypatching by stdlib so the stdlib defining it would not be a breaking change
<FromGitter> <RespiteSage> Yeah. Currently we just define our own conversions (e.g. `Length#/(value : Timespan) : Velocity`), but eventually I'd like to support arbitrary derived units, since some values can have the same unit derivation but different meanings (e.g. `m**2/s` is identified as "Kinematic Viscosity" on Wikipedia, but that would also be the SI base unit for how fast someone painting a wall is working).
<FromGitter> <RespiteSage> @HertzDevil Yeah, I know. I was just using it as an example of why Crystal wouldn't want to suddenly disallow redefinition of standard library types.
<FromGitter> <RespiteSage> I.e. monkey patching isn't encouraged in general, but it's a useful feature in specific circumstances, so even apart from it being a huge breaking change we (or at least I) wouldn't want to disallow it on stdlib types.
<FromGitter> <mjfiano:matrix.org> I look forward to the open-sourcing/rewrite. Sounds like a nice tool
<FromGitter> <RespiteSage> Re the arbitrary derived units, that's just hard because it's important to me that the conversions between arbitrary derived units and specific derived units be type-safe, and that means doing some wacky stuff with generic types.
<FromGitter> <RespiteSage> If you're interested, this is as far as I got with the derived units a while back: https://carc.in/#/r/bnri
<FromGitter> <RespiteSage> The interface I have there is pretty ugly, but ideally it would mostly be under the hood in practice.
<FromGitter> <mjfiano:matrix.org> Yeah, I really wish that methods in macroland issue was resolved. Even if it is under the hood, code is read much more often than written, and it would make it a lot easier to understand imo.
<FromGitter> <RespiteSage> Also, here's that rfc I was talking about for sealed types: https://github.com/crystal-lang/crystal/issues/9116
<FromGitter> <mjfiano:matrix.org> In CL, it is considered bad practice to have large macros, since macros can call arbitrary methods at macro expansion time.
hightower2 has quit [Ping timeout: 250 seconds]