ChanServ changed the topic of #crystal-lang to: The Crystal programming language | | Fund Crystal's development: | GH: | Docs: | Gitter:
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> <> 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> <> I remember reading in the docs or one of the tutorials a concise way to swap two bindings...anyone know?
<FromGitter> <> Nevermind, found it
<FromGitter> <> Anyone know what this means for a method? ⏎ ⏎ ```Metrics/CyclomaticComplexity: Cyclomatic complexity too high [12/10]``` []
Nik- has joined #crystal-lang
Nik- has quit [Client Quit]
hightower2 has joined #crystal-lang
<FromGitter> <> Matrix math is tedious sometimes
<FromGitter> <> 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> and that means that a method is too complex. See
<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
<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> - wow, so much videos from conference. Look like i found what to watch on next weekends 😆
<FromGitter> <> @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> <> Interesting, though this warning didnt come from ameba
<FromGitter> <Blacksmoke16> are you sure
<FromGitter> <> 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> <> it shows up in my editor
<FromGitter> <> 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> <> 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> <> 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> <> 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> <> 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, it is unlikely any 1.0 code will break
<FromGitter> <> 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 ``, 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> 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> <> 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> <> 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> <> 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> <> Does that unit library do conversions, because domain analysis can often be difficult
<FromGitter> <> ?
<FromGitter> <> 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> <> 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:
<FromGitter> <RespiteSage> The interface I have there is pretty ugly, but ideally it would mostly be under the hood in practice.
<FromGitter> <> 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:
<FromGitter> <> 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]