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
taupiqueur has quit [Remote host closed the connection]
taupiqueur_ has joined #crystal-lang
taupiqueur has joined #crystal-lang
taupiqueur_ has quit [Ping timeout: 240 seconds]
taupiqueur has quit [Read error: Connection reset by peer]
taupiqueur has joined #crystal-lang
taupiqueur has quit [Read error: Connection reset by peer]
taupiqueur has joined #crystal-lang
taupiqueur has quit [Read error: Connection reset by peer]
taupiqueur has joined #crystal-lang
taupiqueur has quit [Read error: Connection reset by peer]
taupiqueur has joined #crystal-lang
taupiqueur has quit [Read error: Connection reset by peer]
taupiqueur has joined #crystal-lang
taupiqueur has quit [Read error: Connection reset by peer]
taupiqueur has joined #crystal-lang
taupiqueur_ has joined #crystal-lang
taupiqueur has quit [Ping timeout: 240 seconds]
ejjfunky has joined #crystal-lang
taupiqueur_ has quit [Ping timeout: 240 seconds]
taupiqueur has joined #crystal-lang
taupiqueur_ has joined #crystal-lang
taupiqueur has quit [Ping timeout: 272 seconds]
waleee has quit [Ping timeout: 260 seconds]
ejjfunky has quit [Quit: Leaving]
ejjfunky has joined #crystal-lang
taupiqueur_ has quit [Read error: Connection reset by peer]
taupiqueur has joined #crystal-lang
taupiqueur has quit [Read error: Connection reset by peer]
taupiqueur has joined #crystal-lang
taupiqueur_ has joined #crystal-lang
taupiqueur has quit [Ping timeout: 240 seconds]
taupiqueur_ has quit [Ping timeout: 272 seconds]
taupiqueur has joined #crystal-lang
taupiqueur_ has joined #crystal-lang
taupiqueur has quit [Read error: Connection reset by peer]
notzmv has quit [Remote host closed the connection]
notzmv has joined #crystal-lang
taupiqueur has joined #crystal-lang
taupiqueur_ has quit [Read error: Connection reset by peer]
taupiqueur has quit [Ping timeout: 272 seconds]
taupiqueur has joined #crystal-lang
taupiqueur_ has joined #crystal-lang
taupiqueur has quit [Read error: Connection reset by peer]
taupiqueur has joined #crystal-lang
taupiqueur_ has quit [Ping timeout: 272 seconds]
taupiqueur has quit [Ping timeout: 240 seconds]
taupiqueur has joined #crystal-lang
taupiqueur has quit [Ping timeout: 256 seconds]
taupiqueur has joined #crystal-lang
taupiqueur has quit [Read error: Connection reset by peer]
taupiqueur has joined #crystal-lang
taupiqueur has quit [Ping timeout: 250 seconds]
taupiqueur has joined #crystal-lang
taupiqueur_ has joined #crystal-lang
taupiqueur has quit [Ping timeout: 256 seconds]
taupiqueur_ has quit [Remote host closed the connection]
taupiqueur has joined #crystal-lang
fifr has quit [Ping timeout: 256 seconds]
taupiqueur has quit [Read error: Connection reset by peer]
taupiqueur has joined #crystal-lang
taupiqueur_ has joined #crystal-lang
taupiqueur has quit [Ping timeout: 240 seconds]
taupiqueur_ has quit [Read error: Connection reset by peer]
fifr has joined #crystal-lang
taupiqueur has joined #crystal-lang
taupiqueur has quit [Ping timeout: 272 seconds]
taupiqueur has joined #crystal-lang
<SamantazFox> asterite: I saw your forum post about messages for to_json/to_xml error messages. Thanks you for posting it :)
notzmv has quit [Ping timeout: 260 seconds]
taupiqueur has quit [Quit: taupiqueur]
<holst> In the boilerplate code that is generated with `crystal init app` everything is put into a Module. To what benefit do I want to wrap my code with a Module like that? Can't I just put it as-is without the wrapper?
<SamantazFox> holst: When you put things in modules, you avoid conflicts with top-level crystal functions and classes.
<holst> I am writing a small tool that uploads a set of files (I will put it as open source, UNLICENSE ;-)). I want to make sure that my worker fibers have completed before the program exists. What pattern should I use to yield execution until all fibers have finished?
<holst> The files are read from STDIN until a nil token is read
<holst> on the "main" fiber
<holst> Basically, I want to do Fiber.yield
<holst> until there is nothing left to yield to :)
<holst> but how do I know that?
notzmv has joined #crystal-lang
<SamantazFox> holst: Err, sorry, I'm not very familiar with fibers yet
<FromGitter> <oprypin:matrix.org> holst, say you have 10 fibers. each fiber can send a `nil` to a `Channel(Nil)`. then on the main you can just `10.times` receive the nils
<holst> opry not a bad idea. that would resolve the "How would I know" without resorting to implementation detail inspection of running fibers
<holst> there is another basic concept I am strugling with right now though, and I want to remember this was done automatically before
<holst> if x is a String? then if I did a if x != nil then within that context the type of x would be just String
<holst> that doesnt seem to be happening now, did something change the last year or did I just misremember how this type reduction works?
<yxhuvud> domgetter: You can improve the linking time at least, by not using ld, but instead switching to lld.
<yxhuvud> won't matter for release mode, but could help out dev mode a little.
<holst> .nil? condition is required, == nil will not do
<holst> (answering my own question)
<holst> is HTTP::Client not "fiber safe"?
<holst> I got some nasty SSL stackframes using several concurrent #post commands using the same Client
<holst> and one of those guys...
<holst> malloc(): unsorted double linked list corrupted
<FromGitter> <oprypin:matrix.org> holst, wow well even if something is not fiber safe, there's no way that that can interfere with malloc
<holst> Its failing a bit too hard on me this is naive code, is there something fundamentally wrong with the approach? :)
<holst> I think I potentially should not use "10 workers" as the pattern but rather fiber fork the job after the file has been read from stdin
<holst> but that would be an improvement, not a bugfix?? :)
<holst> In any effect, since I do not know how to potentially expose HTTP/2 and pipelineing (which is part of 1.1 too) it is anyway faster to create 10 separate HTTPS clients and just hammer those
<holst> 100 files / second. pretty happy about that
<holst> Pretty fancy with my fibers now. Anyone care to crique if its idiomatic CR?
<FromGitter> <Blacksmoke16> Could use a pool of connections
<holst> "It should be as easy as running curl"
<holst> LOL. Curl is a monster
<holst> thats why I am writing my own app to do it
<holst> curl just made it *very hard* to efficiently "upload a bunch of files" to a specific endpoint
<holst> Blacksmoke16: re. how I am creating loops and breaking out, is there a tighter syntax that would acheive the same thing? like while stmt; cond; body like syntax in C for loops
<FromGitter> <Blacksmoke16> https://github.com/j8r/pool.cr
waleee has joined #crystal-lang
ejjfunky has quit [Remote host closed the connection]
<holst> hmm, pretty cool. I might look into that later, as part of deprecating the "workers" pattern which feels kind of weird in an event loop
<holst> what I really neeed was the multiple HTTP::Clients
<holst> and to make sure I am only using one of them at the same time
<holst> i.e., not calling client.post before the previous post call completed
<FromGitter> <devsrealmguy:matrix.org> Hi guys, Is this the right place to ask a random question about the crystal-lang?
<FromGitter> <Blacksmoke16> yes
<FromGitter> <devsrealmguy:matrix.org> Thanks, appreciate the quick response.
<FromGitter> <devsrealmguy:matrix.org> I am trying to settle with a language for my computer vision project, and for future projects. I have checked some newer languages like nim and zig, but they lack one thing; better support for OOP. I have also wanted to go with the modern fortran which is really cool, the thing is I want a newer language, with OOP characteristics, which should also be super fast (nicer syntax is a plus too),
<FromGitter> ... crystal is the only language that ticks those boxes for me, so, I appreciate the work that went into this awesome language. ⏎ ⏎ I am done with the specifications of my projects, and the following are the things that would make my life easier while writing the implementation: ⏎ ⏎ 1) Is there a way I can do a dynamic functio ... [https://gitter.im/crystal-lang/crystal?at=6223bf3e9bd1c71eca8b81c8]
<FromGitter> <devsrealmguy:matrix.org> I tried the number on the website playgroud, but no joy.
<FromGitter> <Blacksmoke16> 1) yea there is no `#send` like in Ruby, are some shards that implement it with a macro + case statement, but its not the same as it results in a large union of all possible return types
<FromGitter> <Blacksmoke16> 2) probably want to take a look at https://crystal-lang.org/reference/1.3/guides/concurrency.html
<FromGitter> <Blacksmoke16> 4) maybe via a shard? would have to look around
<FromGitter> <Blacksmoke16> 5) there are https://crystal-lang.org/reference/1.3/syntax_and_semantics/literals/proc.html which could be used as callbacks if thats what you mean?
<FromGitter> <devsrealmguy:matrix.org> Okay, how come I couldn't find this in the homepage, that aside, looks like it supports most of what I needed, that number one would be a huge drawback for me, I'll look at the shards (don't know what that means for now, lol) and see if it would keep me going
<FromGitter> <Blacksmoke16> the homepage of the crystal site you mean? pretty sure thats mainly for news/marketing, clicking on the `LEARN` button below the logo takes you to the language reference material
<FromGitter> <Blacksmoke16> shards are libraries, similar to like Ruby gems, or packages you could say
<FromGitter> <devsrealmguy:matrix.org> Okay, gotcha.
<FromGitter> <Blacksmoke16> but yes, you'll have to go to plan b for number 1
<FromGitter> <Blacksmoke16> related: https://github.com/crystal-lang/crystal/issues/49
<FromGitter> <devsrealmguy:matrix.org> Hmm, interesting read, and understandable reason for not having that functionality. I'll see if I can come up with another design pattern that won't give me headache too much.
<FromGitter> <Blacksmoke16> 👍
<FromGitter> <devsrealmguy:matrix.org> The more I think about this, the more it wouldn't work, maybe you can borrow me an idea, let's say you have a list of event handlers that you want to pass an event to when an event is raised. For example if a new user registers, and some of the event handlers are registered to onNewUserRegisterEvent, how would you call the event handlers in turn while passing the event object to each one of
<FromGitter> ... them. I need two things to make this work, storing the eventHandler functions/callback in an array, dict, list, whatever. and the ability to pass an object to its param.
<holst> devsrealmguy should probably throw his "not invented here" hat and just use Python :)
<holst> its the defacto language these days for ML/vision/anything data science
<holst> I think Crystal lang is way cool, but there is zero support for it in the computer vision community
<holst> If you want to develop all tooling yourself and you do not need to involve other devs nor any need to share the code with anyone. It would still be a questinoable choice, but without larger consequences
<FromGitter> <devsrealmguy:matrix.org> Haha, Python would be too slow for my use case. You know what, most of the stuff I'll be implementing would be from scratch, so, Python wouldn't help much
<holst> numpy is mostly C/Fortran kernels. Yes, python helps
<holst> it makes it reasonable easy to glue in your compute kernels in a high level language
<holst> and most of the work is already done by the community
<FromGitter> <Blacksmoke16> https://athenaframework.org/EventDispatcher/ might be helpful then?
<FromGitter> <devsrealmguy:matrix.org> Thanks, that is what I am talking about
<FromGitter> <devsrealmguy:matrix.org> @FromIRC: Wouldn't it be cool if we have something as such in the crystal-lang eco-system too?
<FromGitter> <devsrealmguy:matrix.org> Ha, sorry
<FromGitter> <moe:busyloop.net> maybe a bit more idiomatic/approachable when new to crystal
<FromGitter> <devsrealmguy:matrix.org> Thanks
<FromGitter> <moe:busyloop.net> eek https://crystalshards.org/ is down
<FromGitter> <devsrealmguy:matrix.org> Yh, I checked too, and I had the same issue
<FromGitter> <moe:busyloop.net> well there's https://shards.info/ as an alternative
<FromGitter> <moe:busyloop.net> crystalshards.org is far better tho. hopefully back soon.
<FromGitter> <moe:busyloop.net> actually shards.info is alright, too. if only it would show the readme by default instead of that silly info-tab.
<holst> Is it possible to build a static binary with crystal 1.13?
<holst> this is what i am getting when I run the code outside the crystal lang docker container
<holst> even if I use --static
<holst> ldd says its static but I think it might be some parts of it that still uses dynamic linking
<FromGitter> <Blacksmoke16> Probably need to build in alpine Linux. Is the easiest way to get fully statically linked. Is a blog post on how to do it with docker on the crystal site
<holst> Yes, now I remember. thank you
<holst> I havn't used crlang in some time. Fully embedded in cloud stuff. :)
<holst> compiling the app in the alpine container generated a static binary that also works on Fedora 35 host
<holst> Thanks blacksmoke16 you're been a real gem helping, many times. :)
waleee has quit [Ping timeout: 245 seconds]
waleee has joined #crystal-lang
wolfshappen has quit [Ping timeout: 268 seconds]