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
SamantazFox has quit [Ping timeout: 240 seconds]
adam126 has joined #crystal-lang
adam12 has quit [Ping timeout: 240 seconds]
adam126 is now known as adam12
hightower3 has joined #crystal-lang
hightower3 has quit [Ping timeout: 245 seconds]
ur5us has quit [Ping timeout: 240 seconds]
ur5us has joined #crystal-lang
Guest25 has joined #crystal-lang
Guest25 has quit [Quit: Client closed]
sorcus has quit [Quit: WeeChat 3.2]
sorcus has joined #crystal-lang
ur5us has quit [Ping timeout: 240 seconds]
<FromGitter> <syeopite:matrix.org> What would be the best way to represent a bunch of constant data that is able to be inherited and have a type that can refer to all of its siblings? ⏎ ⏎ Here's what I mean: I'm trying to represent a bunch of language data (300+ in total) that'll look something along the lines of this: ⏎ ⏎ ```code paste, see link``` ... [https://gitter.im/crystal-lang/crystal?at=611caa5c9484630efa4437ee]
hightower3 has joined #crystal-lang
<frojnd> I'm testing kemal for a simple api. I have get "/:date" do |env| ... end if I enter url without param I get: `Kemal doesn't know this way.`
<frojnd> So I have to have extra endpoint in order to cover non-param url?
<frojnd> Also extra url... hm
ur5us has joined #crystal-lang
sorcus has quit [Ping timeout: 258 seconds]
sorcus has joined #crystal-lang
sorcus has quit [Ping timeout: 240 seconds]
sorcus has joined #crystal-lang
<FromGitter> <HertzDevil> so i tried to dump all the type ids in an empty source
<FromGitter> <HertzDevil> it looks interesting
<FromGitter> <HertzDevil> it contains more or less every type used in the default prelude, but it also contains what appear to be generic instances having bound type parameters
<FromGitter> <HertzDevil> look at 624-627 for example
<FromGitter> <HertzDevil> these come from `Iterator::Flatten` and `Iterator::FlatMap`
<FromGitter> <HertzDevil> i don't think there is ever a use for those formal types for runtime reflection
SamantazFox has joined #crystal-lang
ur5us has quit [Ping timeout: 240 seconds]
ur5us has joined #crystal-lang
hightower3 has quit [Remote host closed the connection]
ur5us has quit [Ping timeout: 245 seconds]
<frojnd> Can someone explains to me why kemal when param is empty adds `favicon.ico` to the param? https://carc.in/#/r/bs23
<FromGitter> <y8> Most likely it's your browser trying to fetch favicon for 127.0.0.1:3000. Try `curl http://127.0.0.1:3000/`
<frojnd> Nah, I see "Kemal doesn't know this way" message it prints html
<frojnd> From crystal console I see just: 2021-08-18 11:07:57 UTC 404 GET / 66.87µs
<frojnd> But if I enter with param like this: curl http://0.0.0.0:3000/bla I see date: bla" and 2021-08-18 11:08:58 UTC 200 GET /bla 56.54µs
repo has quit [Quit: WeeChat 3.1]
deavmi has quit [Read error: Connection reset by peer]
deavmi has joined #crystal-lang
<FromGitter> <y8> To handle `GET /`, you need separate route `get "/"`
<FromGitter> <Blacksmoke16> frojnd: https://athenaframework.org/getting_started/#route-parameters, can have default values :)
<FromGitter> <stellarpower> Are there any specific docs on how crystal manages memory? Am wondering if custom allocators would be possible.
<FromGitter> <asterite> Memory is allocated by the GC, we use boehm. You can do `LibC.malloc` and `LibC.free` if you want, but there's no support for custom allocators (Crystal is not a low-level language)
<yxhuvud> I mean, it is also definitely possible to monkeypatch `allocate`, but it is not a well threaden path and deallocation would be a problem as it would have to be manual
<yxhuvud> monkeypatching + being self hosted allows so many abilities to do horrible things :D
<FromGitter> <asterite> It's true! Also, I think you could redefine `allocate` on particular classes, and I think that would allow a custom allocator... except that this language isn't like Rust or C++ where memory is automatically deallocated when things go out of scope, so the custom memory allocator will have to be a GC
DeBot has quit [Quit: Crystal IRC]
jhass has quit [Quit: Bye]
straight-shoota has quit [Quit: ZNC 1.8.2 - https://znc.in]
DeBot has joined #crystal-lang
jhass has joined #crystal-lang
straight-shoota has joined #crystal-lang
<yxhuvud> Yes, I've played around with custom allocate on classes before. It works but it is a bit of work to get something that is useful. I could see building a slab allocator as well, where the whole slab gets deallocated at once, but that would probably be easiest by having an external allocation method rather than using the default machinery with new and initialize.
<FromGitter> <jfontan> I've been implementing a toy parallel find like command in crystal and I'm really happy with the language. Using 4 threads (8 workers) it runs slightly faster than another naive implementation I made in rust.
<FromGitter> <jfontan> Do you know if it's possible to change the number of workers from code. That is, without setting the env var
<yxhuvud> It is not, currently.
<FromGitter> <jfontan> ok, thanks
<yxhuvud> though possible is a very broad word, considering the language allows monkeypatching of basically everything. It is *possible*, but very intrusive and not recommended to redefine Crystal::Scheduler#worker_count to return something else than 4 by default.
<yxhuvud> personally I'd use https://github.com/yxhuvud/nested_scheduler instead, but I cannot really promise any api stability (or other kind of stability for that matter), at this point.
<FromGitter> <jfontan> ah, interesting
<yxhuvud> or for that matter, that the shard continue to work when the next version comes out. it monkeypatches all over the internals :)
<FromGitter> <jfontan> it works perfect, just a little bit slower than with normal threads
<FromGitter> <jfontan> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=611d700f4bfde341d9690182]
<FromGitter> <jfontan> could be the load of my machine anyway. Is a small test
<yxhuvud> could also be the overhead of the additional threads. Just be aware that it is quite likely that every version of crystal that gets released for the foreseeable future will break the shard until I fix it again :)
<FromGitter> <jfontan> right, lowering the number of threads to 5 (the same number of fibers) improves the time
jfontan has joined #crystal-lang
jfontan has left #crystal-lang [#crystal-lang]
ur5us has joined #crystal-lang
ur5us has quit [Quit: Leaving]
ur5us has joined #crystal-lang
postmodern has joined #crystal-lang