<ryanprior>
That should make its way to Gitter within a year if you believe their timeline
tsujp has quit [Ping timeout: 265 seconds]
tsujp has joined #crystal-lang
Seich has quit [Quit: Gone fishing.]
Seich has joined #crystal-lang
<jhass>
fwiw we can moderate the IRC side of things, me, RX14, oprypin, asterite and bcardiff are ops. Though the latter two are not active in IRC and we others are all in european timezones I believe :/
<jhass>
cerulean was a network wide spam bot, those usually get K-lined sooner or later
HumanG33k has joined #crystal-lang
HumanG33k has quit [Remote host closed the connection]
HumanG33k has joined #crystal-lang
<oprypin>
oh i'm op? i totally forgot π¬
<jhass>
unless you made a new nickserv account :D
yukai has quit [Ping timeout: 240 seconds]
andrzejku has joined #crystal-lang
deavmi_ has joined #crystal-lang
deavmi has quit [Read error: Connection reset by peer]
HumanG33k has quit [Remote host closed the connection]
<FromGitter>
<Blacksmoke16> would have to do `Foo.new [1, 2, 3] of Int32?`
<FromGitter>
<naqvis> `Foo.new([1,2,3,nil])` will work
<FromGitter>
<Blacksmoke16> right
<FromGitter>
<Blacksmoke16> because the type is inferred to be `Int32?`, but if you just give it `[1, 2, 3]` its `Array(Int32)`, which cant have `nil`, thus not matching the type restriction of `val`
<FromGitter>
<naqvis> true, but thing is compiler is being told that it could be either A or B
<FromGitter>
<naqvis> so shouldn't it respect the contract?
<FromGitter>
<Blacksmoke16> is it not by rejecting `Array(Int32)`?
<FromGitter>
<naqvis> but isn't the value fulfilling the contract?
<FromGitter>
<naqvis> optional mean it may or may not
<FromGitter>
<Dan-Do> but the `array of A` is not equal to `array of either A or B`, I guess :)
<FromGitter>
<Blacksmoke16> `[1, 2, 3]` is not a `Array(Int32?)`, so no it doesn't match
<FromGitter>
<Blacksmoke16> right
<FromGitter>
<naqvis> but that defeats the intention of optionals
<FromGitter>
<naqvis> doesn't it?
<FromGitter>
<Blacksmoke16> i mean to be clear what you're trying to do it totally possible, you just have to tell the compiler that array can also contain `nil`, via `Foo.new [1, 2, 3] of Int32?`
<FromGitter>
<Blacksmoke16> otherwise it cant know that that array should be allowed to contain `nil`
<FromGitter>
<naqvis> method declaration is the contract and there its told that its an array of optionals
<FromGitter>
<naqvis> so passing an array with no null, shouldn't violate that condition
<FromGitter>
<naqvis> vice versa case is different
<FromGitter>
<Blacksmoke16> its also a bit more strict because this is the type of an ivar, not just a method type restriction
alexherbo2 has quit [Ping timeout: 240 seconds]
<FromGitter>
<Blacksmoke16> if it was the latter it would most likely be fine
<FromGitter>
<naqvis> i mean, declaration not allowing accepting of optional, then passing an optional should be an error
<FromGitter>
<Blacksmoke16> im pretty sure it would
<FromGitter>
<naqvis> yeah
<FromGitter>
<naqvis> it should and it does
<FromGitter>
<asterite> if you don't assign if to `@val` it unfortunately
<FromGitter>
<asterite> one of the inconsistencies of the language
<FromGitter>
<naqvis> yeah, but isn't the latter behavior correct?
<FromGitter>
<asterite> It depends
<FromGitter>
<naqvis> i mean in this scenario
<FromGitter>
<asterite> When `Array(Int32 | Nil)` is used as a type restriction, it's asking "is each element an int or a nil? if so, then let the argument pass"
<FromGitter>
<asterite> but when you assign `Array(Int32)` to an instance variable of type `Array(Int32 | Nil)` then that doesn't compile
<FromGitter>
<asterite> the reason is that you would later be able to push a `nil` inside it, which would be wrong
<FromGitter>
<asterite> I think ideally `Array(Int32?)` would only match exactly `Array(Int32?)`, never `Array(Int32)`
<FromGitter>
<naqvis> type coercion will happen?
<FromGitter>
<asterite> and we'd need a syntax like `def foo(x : Array(T)) where T < Int32?`
<FromGitter>
<asterite> there's no way to do type coercion for an array
alexherbo2 has joined #crystal-lang
<FromGitter>
<christopherzimmerman> Is there to catch any missing method that has an argument of a certain type? β I know you can't use `typeof` in macros but I can't figure any way to identify this case. β β ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5f84719324a20801a8e1255e]
<FromGitter>
<Blacksmoke16> did you try `.is_a?`
<FromGitter>
<Blacksmoke16> or `<= Half`
<FromGitter>
<christopherzimmerman> Yea, `call.args[0]` is a `MacroID`, so it never picks up on the type I want.
<FromGitter>
<Blacksmoke16> ofc wouldnt handle sub types or if there are two of that class in diff namespaces...
alexherbo2 has quit [Read error: Connection reset by peer]
<FromGitter>
<christopherzimmerman> I think that just produces `_arg0` or whatever. I will never need to handle different subtypes or namespaces luckily, It's supposed to mimic a primitive.
<FromGitter>
<Blacksmoke16> yea i dunno, i never used `method_missing`. iirc its kinda a hack
<FromGitter>
<Dan-Do> `Error: alias Number is already defined`
<FromGitter>
<Blacksmoke16> guess not
<FromGitter>
<Dan-Do> :sad:
<FromGitter>
<asterite> macros receive ast nodes and they don't have types (the only things that have types are instance variables of types, in macros)
<FromGitter>
<Blacksmoke16> methods can as well, via arg/return type restrictions
<FromGitter>
<Dan-Do> > guess not β It's strange, since we can overwrite the methods/vars
<FromGitter>
<asterite> I thought you couldn't pass a closure to C
<oprypin>
so I'm using Box and then i can
<oprypin>
it's not even about C though. just asking, is it possible to use closures without using heap
<FromGitter>
<asterite> nope
<oprypin>
:(
Human_G33k has joined #crystal-lang
HumanG33k has quit [Ping timeout: 258 seconds]
Human_G33k has quit [Excess Flood]
Human_G33k has joined #crystal-lang
HumanG33k has joined #crystal-lang
Human_G33k has quit [Ping timeout: 240 seconds]
Human_G33k has joined #crystal-lang
Human_G33k has quit [Read error: Connection reset by peer]
Human_G33k has joined #crystal-lang
HumanG33k has quit [Ping timeout: 240 seconds]
Human_G33k has quit [Ping timeout: 272 seconds]
<FromGitter>
<vinyll> Hey all! β When running a basic script, it takes like 10 seconds to compile/run (Macbook i5, 8Gram). β That's pretty long for a reloading process. Any recommandation?
<FromGitter>
<Blacksmoke16> built a binary and run that instead
<FromGitter>
<Blacksmoke16> would be your best bet assuming you're not actively devving on it
<FromGitter>
<vinyll> Well, would that update when I update the code?
<FromGitter>
<Blacksmoke16> no
<FromGitter>
<vinyll> Oh right, that's the case, need to update a typo and see the result in a web page
<FromGitter>
<vinyll> Does it take that long for you too?
<FromGitter>
<Blacksmoke16> are you running it in release mode?
<FromGitter>
<Blacksmoke16> depends on the program, but most things are quite fast
<raz>
yup 10s seems long for a basic script, unless it has a bazillion deps
<FromGitter>
<Blacksmoke16> or just low single core perf
<raz>
yeh, i5 is slow, but that slow? hm
<FromGitter>
<Blacksmoke16> just tried on work laptop, was 3.2s for hello world on first compile, then .75s on additional runs
<raz>
blacksmoke: mine goes down to 0.8 after a few runs :P
<raz>
i also tried vinyl's code now. `time crystal build src/server.cr` gives me 4.2s
<raz>
still not zippy, but that seems about realistic
<FromGitter>
<Blacksmoke16> id have to try with desktop, work laptop has more cores but slower single core speed since its a laptop
<raz>
yeh i'm on the mbp 16"
<FromGitter>
<vinyll> 1) 2s would be decent enough for me
<raz>
for me compile times are right at the "ok, can work with this" threshold. my real app is in the 8-10s range (but that's fully fleshed out, ORM and all)
<FromGitter>
<vinyll> Strangly I get 6 sec the first time
<raz>
i'd take it as an excuse to buy that bigger macbook ;)
<raz>
would be great if the compiler got faster, but that's prob not gonna happen very soon
<raz>
or, the old school route: buy/rent a cheap buildbox and compile there
<raz>
i've worked that way for years, takes a bit of setup - but for purely cli/web stuff it's not much different from compiling locally
<FromGitter>
<vinyll> I tried Grip vs Athena (@Blacksmoke16 π) using Crinja. β And figured it actually comes from VSCodium! β It must be a Crystal extension, or even more probably Cristallineβ¦
<FromGitter>
<wyhaines> That's Ubuntu 20.04 on WSL 1 on a Dell XPS 15" from last year.
<FromGitter>
<vinyll> yes, a `puts "Hey!"` is less than a second as well for me :)
<FromGitter>
<Blacksmoke16> @vinyll ah nice, went with grip eh? π
<FromGitter>
<vinyll> 5 seconds when running a web homepage with Grip or Athena + Crinja
<FromGitter>
<Blacksmoke16> not too bad
<FromGitter>
<vinyll> I'm still trying frameworks actually. β I'm even still wondering wether to go with Crystal or not (Elixir might be an option because of the ecosystem, though Crystal seems more straightforward)
psydroid has quit [Quit: killed]
return0e[m] has quit [Quit: killed]
ryanprior has quit [Quit: killed]
<FromGitter>
<Blacksmoke16> π fair enough. Happy to answer any questions/etc in regards to Athena.
psydroid has joined #crystal-lang
<raz>
i wanted to like elixir, tried it a few times. but the whole "one language stacked on top of another" just breaks the deal for me every time
return0e[m] has joined #crystal-lang
<raz>
same with the JVM languages. it just always feels messy, stuff leaks in from the underlying language, you end up needing to know the quirks of both
<raz>
crystal may not be as wrinkly and mature yet, but at least when there's a crystal bug, it's a crystal bug. not some obscure "oh btw" from two decades ago that pokes through 2 layers of "we never liked this but gotta carry it on cause now everything depends on it"
<riffraff169>
jruby bothers because of that too...what is the problem, ruby? java? jvm? who knows?
<raz>
yea, i actually used jruby for a production rails app for a while (before MRI performance became tolerable)
<riffraff169>
on the other hand, some could argue same thing with most languages and c....is that an X bug, or a C bug...well, until the language becomes self-hosted
<raz>
fun times... swapping out gems for others that may hopefully work
<raz>
yea, but C and LLVM don't really count for me. at that layer it's not my problem, it's the language-makers problem.
<raz>
whereas with elixir-on-erlang or anything-on-jvm it is my problem. constantly
<riffraff169>
that is true
<FromGitter>
<dscottboggs> idk there are a bunch of things I've run into about Crystal that are just "it has to be this way because C is this way" when interoperating with C libraries. And it's not like you're gonna get away from C libraries unless you run lillith (https://github.com/ffwff/lilith) as your daily driver, and even then....
<FromGitter>
<dscottboggs> I've also heard that there are performance constraints on our hardware imposed by the C memory and processing model, but my understanding isn't advanced yet to understand or have encountered those yet.
<FromGitter>
<dscottboggs> the biggest thing that comes to mind is Crystal closures being unable to be passed as C function pointers. Totally destroyed a really awesome library idea I had
<FromGitter>
<vinyll> I find this confusing: β β ```require "athena" β class ExampleController < ART::Controller``` β β `ART` exists in `athena`, but how can you figure where it comes from when requiring muliple files? ... [https://gitter.im/crystal-lang/crystal?at=5f84b9543775d02b5a075a0c]
<FromGitter>
<Blacksmoke16> `ART` is an alias `Athena::Routing`
<FromGitter>
<vinyll> How would you know that `ART` is declared in `athena`
<FromGitter>
<Blacksmoke16> less typing
<FromGitter>
<dscottboggs> the docs
<FromGitter>
<Blacksmoke16> read the API docs?
<FromGitter>
<Blacksmoke16> yea
<FromGitter>
<Blacksmoke16> thats kinda a problem with any shard, you wouldnt know the types that are exposed from that shard w/o looking at api or source
<FromGitter>
<vinyll> I mean in Python one would do `from athena import ART` and the code would be explicit. β Here, readiing the code, it seems like it comes out of nowhere. β Changing language is changing paradigms; so I'm learning to adapt ;)
<FromGitter>
<Blacksmoke16> i would love to have something like that, but alas it doesnt exist
<FromGitter>
<dscottboggs> name collision is not an error in Crystal -- if you, do β β ```code paste, see link``` β β Both `#b` *and* `#b` will be defined as members of `Ex`, rather than an error being thrown [https://gitter.im/crystal-lang/crystal?at=5f84ba3a78d7f20c9fa66a07]
<FromGitter>
<dscottboggs> this is a big change if you're used to python
<FromGitter>
<dscottboggs> (even though it's technically possible to do at least the latter example in python, the way to do it isn't obvious)
<raz>
unlearning python is such a pleasant experience, wish i could do it again
<raz>
that language is so broken on so many levels :<
<FromGitter>
<vinyll> Right, I see the confusion and collision. β Is there a benefit, flexibility or other interest with this paradigm?
<FromGitter>
<Blacksmoke16> i have thought about using private aliases to avoid large namespace names in code
<FromGitter>
<Blacksmoke16> like a pseudo import system, but :shrug:
<FromGitter>
<Blacksmoke16> prob just is what Ruby does :shrug:
<FromGitter>
<Blacksmoke16> is how it came to be
<FromGitter>
<dscottboggs> yes exactly, firstly it was how ruby did it
<FromGitter>
<rishavs> tried both `version: ~> 0.21.1` and `version: ~> 0.22.0` β had no effect
<FromGitter>
<rishavs> Anyway, I have added a bug in crystal-pg repo. Hope a fix comes soon. Thanks for al the help raz and blacksmoke. Much appreciated
<raz>
np. bugs like that suck. :(
<FromGitter>
<Blacksmoke16> id best its WSL issue tbh
<FromGitter>
<j8r> @rishavs can you try running `git archive --format=tar --prefix= refs/tags/v0.10.0 | tar -x -f - -C '/mnt/c/Users/Mockingbird/Documents/GitHub/kaipi/lib/db` ?
<raz>
yea that would also be my guess. does it something weird with the filesystem?