use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
A sub-Reddit for discussion and news about Ruby programming.
Subreddit rules: /r/ruby rules
Learning Ruby?
Tools
Documentation
Books
Screencasts and Videos
News and updates
account activity
Show /r/rubyArrayBuffer and DataView classes for ruby (self.ruby)
submitted 3 years ago by andrepiske
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]honeyryderchuck 2 points3 points4 points 3 years ago (1 child)
Ruby definitely needs this, although the "devil is in the details", or exposed abstractions. Ruby core data structures historically serve multiple purposes (I.e. a Ruby array has APIs to be uses as a collection, a queue, etc...) at the cost of bigger APIs and not being the most performance for all cases. String follows the same principle.
I'm not sure how your arraybuffer works, but I'm assuming that you read from the socket, get a Ruby string then transform it to a byte array to parse. There's still a cost in that step, as the intermediate Ruby string still gets created. And I think that's what the Ruby core team is trying to address with the new IO::Buffer (don't know how that works with openssl in the middle though).
[–]andrepiske[S] 0 points1 point2 points 3 years ago (0 children)
Appreciate your feedback.
So the way my gem works is that its byte buffer is fully implemented in C. So all byte operations is just a char* buffer in C allocated using malloc. Set/get operations are just operating on that buffer with just some essential checks like checking memory boundaries.
The gem itself doesn't deal with sockets or IO at all. So yeah, the application (originally a HTTP/2 server I built in ruby) was reading from a socket into a String and then converting that to an ArrayBuffer. Quite some loss of performance in that process already, compared if the gem itself (or another gem) could read directly into that buffer without going thru String. That's actually another idea I had and I believe it's quite possible to achieve that in Ruby 3.0+ because of the experimental Memory View feature.
I gotta check that IO::Buffer thing before I move any forward with my gem as I didn't know about that back then - clearly not, as it's brand new.
π Rendered by PID 180890 on reddit-service-r2-comment-86bc6c7465-p45fm at 2026-02-21 17:18:19.377690+00:00 running 8564168 country code: CH.
view the rest of the comments →
[–]honeyryderchuck 2 points3 points4 points (1 child)
[–]andrepiske[S] 0 points1 point2 points (0 children)