<FromGitter>
<bew> @stronny not sure if you got tge answer after all, but iirc you can do `"a=".split "=", remove_empty: true` to only get `["a"]` (note: i'm writing from memory on my phone, so i might be wrong on the exact argument)
<FromGitter>
<stronny> yes, I've read why how and what. and Ary even said that personally once again
<FromGitter>
<bew> Nevermind, you got the answer already
return0e has quit [Ping timeout: 240 seconds]
return0e has joined #crystal-lang
dwdv has left #crystal-lang ["leave"]
postmodern has joined #crystal-lang
_whitelogger has joined #crystal-lang
ur5us has quit [Ping timeout: 240 seconds]
ur5us has joined #crystal-lang
ur5us has quit [Ping timeout: 256 seconds]
_ht has joined #crystal-lang
_ht has quit [Quit: _ht]
FromGitter has quit [Remote host closed the connection]
FromGitter has joined #crystal-lang
<FromGitter>
<oren> is there a way to exist a function? not the entire program?
<FromGitter>
<oren> i guess 'return' does that.
alexherbo2 has joined #crystal-lang
<FromGitter>
<Daniel-Worrall> breaking flow keywords you should know are `next`, `break`, `return`, `raise`
<FromGitter>
<Daniel-Worrall> I feel like I missed one
<FromGitter>
<nothratal> Hello
<FromGitter>
<nothratal> can someone explain to me why the compiler enforces a space after an argument in methods? There is probably a good reason for it, I just didn't find it yet
<FromGitter>
<j8r> @Daniel-Worrall `exit`
<FromGitter>
<j8r> I will break the whole program :)
<FromGitter>
<stronny> @nothratal I guess that has something to do with named tuples?
gangstacat has quit [Ping timeout: 272 seconds]
<FromGitter>
<j8r> Optimization question: I would like to make path parsing as fast as possible, with as fewer allocations as possible. ⏎ Transform `aa/bb/cc` into `"aa"` `"bb"` and `"cc"`
<FromGitter>
<stronny> do you need parts as separate variables?
<FromGitter>
<j8r> Obviously there is `String#split`, but I was also digging in the unsafe land
<FromGitter>
<stronny> hey, you know what
<FromGitter>
<stronny> you can have Slices pointing to a first byte of a part
<FromGitter>
<j8r> I tried with Slices, but I didn't see any meaningful gain
<FromGitter>
<j8r> In fact, it would be like consuming the string - if possible
<FromGitter>
<stronny> the problem here is UTF8
<FromGitter>
<stronny> I think you can have a single loop iterating over string's characters and making slices upon encountering "/"
<FromGitter>
<j8r> It won't be a problem, since URL path are ASCII only
<FromGitter>
<stronny> then it should be as fast as it can be
<FromGitter>
<j8r> I did try it by keeping an `offset`, and using `Slice#index`
<FromGitter>
<j8r> I have to try it again and do a proper benchmark
<FromGitter>
<stronny> what do you mean consuming the string?
<FromGitter>
<j8r> Like an Array of chars, shift
<FromGitter>
<stronny> still don't understand
<FromGitter>
<j8r> I would like to avoid allocations
<FromGitter>
<stronny> you already have a string allocated
<FromGitter>
<j8r> Using `#split` or `#partition` will use `malloc`
<FromGitter>
<stronny> slices don't allocate
<FromGitter>
<j8r> But I need each time to create a new one, not sure it would be more efficient?
<FromGitter>
<stronny> each time create a new String?
<FromGitter>
<stronny> where does it come from?
<FromGitter>
<j8r> `String#split` will create a new string on each iteration
<FromGitter>
<stronny> worse, it will create Array(String)
<FromGitter>
<j8r> `Slice# (start : Int, count : Int) ` is what I used to create new slices
<FromGitter>
<j8r> @stronny I meant `String#split(&)`
<FromGitter>
<stronny> I would go with smth like this
<FromGitter>
<j8r> Or, maybe the perf was negligible because the bottleneck was elsewhere...
<FromGitter>
<j8r> Ok thanks, I will try again with slices then
ua has quit [Read error: Connection reset by peer]
ua has joined #crystal-lang
<FromGitter>
<stronny> my tip would be moving from socket layer keepalives to application layer. idk whether icp proto has any pings/nops etc, but if it does, I'd go that way
alexherbo2 has quit [Remote host closed the connection]
<Welog>
Yes IRC has ping / pong mechanism and it is implemented in the code. And it works well a few days (19-20 days) but after that it seems the connection is timeout (IRC server tell "lost connection" and socket rescue after 5 minutes ERROR Errno: connect: Connection timed out)
<FromGitter>
<stronny> well maybe there's something wrong with the connection at the network level
<FromGitter>
<kinxer> I don't suppose there's a good way of inspecting what kind of constants those are (beside assuming that pascal-case means classes)?
<FromGitter>
<Blacksmoke16> @j8r right, but those changes were made 3 days ago
<FromGitter>
<Blacksmoke16> results on master dont include it, hence why i thought it wasnt updated yet
<FromGitter>
<j8r> Sure, I really need to run the project to see how fast my router/framework is :D
<FromGitter>
<kinxer> I'm just contemplating how difficult it would be to create a dependency sandboxing shard in Crystal. I'm assuming it'll be very difficult, but it may not be feasible at all...
<FromGitter>
<Blacksmoke16> oh interesting
<FromGitter>
<stronny> plz explain?
<FromGitter>
<Blacksmoke16> dependency sandboxing? like a service container?
<FromGitter>
<kinxer> It would be nice not to have to trust shard X not to read my filesystem and send that off somewhere. Containerization helps with that issue, but it doesn't really solve the base problem (and has its own difficulties).
<FromGitter>
<stronny> I don't think that's possible and/or practical or even a good idea
<FromGitter>
<kinxer> Why not a good idea?
<FromGitter>
<stronny> permissions are hard
_ht has joined #crystal-lang
<FromGitter>
<kinxer> That's not a compelling argument. That's just why we need a good reason to do it, which we have.
<FromGitter>
<stronny> this is not a new problem, how was it solved before?
<FromGitter>
<kinxer> At the OS level?
<FromGitter>
<kinxer> I admit I don't have much experience with this topic. I know that browsers use sandboxing as a way of running untrusted code (e.g. plugins); I'd guess that experience with that is why WASM comes with solutions to this built-in.
<FromGitter>
<kinxer> Also, how old is this problem, really? Wide software dependency ecosystems have only been around for what, 15 years at most? Software has been around for much longer, but industrial software dependencies have a point of contact (a company) who you can sue if they bake in malicious code. Open source software seems to rely really heavily on having a large number of eyes on the code, which usually works (since it's
<FromGitter>
... unlikely that they would all benefit from malicious code). But in many software ecosystems (such as our Crystal shard ecosystem), lots of packages that are useful have a single developer. I tend to trust those people, but I shouldn't *have to* trust those people not to insert malicious code. It's only been a year and a ha ... [https://gitter.im/crystal-lang/crystal?at=5e667ecfd17593652b721897]
<FromGitter>
<stronny> C libs were around since forever
<FromGitter>
<kinxer> And was there a technical solution to this problem in C or its ecosystem? Or was it a sociological solution?
<FromGitter>
<j8r> ... they use postgres, omg...
<FromGitter>
<stronny> I don't think a technical solution is possible
<FromGitter>
<kinxer> In Crystal or at all?
<FromGitter>
<stronny> at all
<FromGitter>
<kinxer> Why is that?
<FromGitter>
<stronny> I can't see a way to solve the problem is all
<FromGitter>
<Blacksmoke16> @j8r yea :/ used to be sqlite
<FromGitter>
<Blacksmoke16> i added a docker-compose file that should make things easier tho
<FromGitter>
<stronny> a philosophical solution would be revisiting our current ethos around development
<FromGitter>
<kinxer> Ah... In WASM, the way they're solving it is by building module separation into the language. Obviously, most language ecosystems can't do that. However, I'd expect that you should be able to enforce certain constraints in compiled languages at compile-time.
<FromGitter>
<kinxer> I'm curious what you mean by that.
<FromGitter>
<stronny> I don't consider wasm approach to be a *solution*
<FromGitter>
<kinxer> Why is that?
<FromGitter>
<stronny> it doesn't solve the problem?
<FromGitter>
<kinxer> Could you explain why you think that?
<FromGitter>
<stronny> first let's define the problem then
<FromGitter>
<stronny> you know what: maybe a way forward would be in FP pure functions
<FromGitter>
<kinxer> Those are just deterministic functions?
<FromGitter>
<kinxer> (A legitimate question)
<FromGitter>
<stronny> no side-effects, no access to grobal state
<FromGitter>
<kinxer> Right. How do you do I/O in that scheme?
<FromGitter>
<stronny> you don't
<FromGitter>
<stronny> you use FP for the *libraries*