Pstore: Ruby Built-In Hash Persistence(github.com) |
Pstore: Ruby Built-In Hash Persistence(github.com) |
Ruby itself is just such an enabler.
https://ankane.org/new-ml-gems
Any thoughts on what the Ruby community would need to build in order for it to become an attractive tool for AI work?
Something would need to happen that makes Ruby far more attractive. Say performance parity with Crystal or Nim.
Or maybe it would be a hard task that didn't justify the effort.
The main thing is that it's part of the standard library. If you import a gem anyway, often you'd be well off with sqlite.
As for storage format, there's also:
https://ruby-doc.org/stdlib-3.1.2/libdoc/yaml/rdoc/YAML/Stor...
I even created a little gem when I was starting with Ruby, 10 years ago, that was a very thin wrapper around it so that I could play around using an ActiveRecord like syntax (https://github.com/brunnogomes/active_yaml). I used in some pet projects so I could do stuff like:
p = Post.new
p.title = "Great post!"
p.body = "Lorem ipsum..."
p.save
Post.all # => [#<Post:0x895bb38 @title="Great post!", @body="Lorem ipsum...", @id=1>]
Post.find(1) # => #<Post:0x954bc69 @title="Great post!", @body="Lorem ipsum...", @id=1>
Post.where(author: 'Brunno', visibility: 'public')
# => [#<Post:0x895bb38 @author="Brunno", @visibility="public", @id=1>, #<Post:0x457pa36 @author="Brunno", @visibility="public", @id=2>]
And have access to the data directly in the YAML files.Good times!
Such as?
This is bad enough on its own, but it also makes pivoting a file read/write primitive into code execution much easier.
Maybe that's why Ruby is best known for Ruby on Rails.
It's now no longer technically stdlib, but a "default gem", a gem that is installed by default with ruby, see: https://stdgems.org/
Since a few years every version remove one or two rarely used default gems. The Ruby core team just doesn't like big breaking changes.
Sure there are many things that "should" have been fixed above - but just having any old ruby version on hand was enough to help check for a memory leak and mitigate it - while taking the time to figure out if the leak could be plugged.
And offline support (a server in dmz/locked down wrt new software) is big too!
...
The problem with JSON is that the keys take up too much space because they are duplicated. I don't love BSON, but there's a reason why I recommend bson-ruby.
And I could keep going... ;)
The benefit of using YAML is precisely that there's meaningful whitespace. Different strokes for different folks.
The answer is that we have serialization techniques that are as good on all the dimensions that matter (speed, serialized size, etc.) and better in terms of security. Pickle and Marshal are, at best, footguns in otherwise very safe language ecosystems.
I'd look at that sentence with great skepticism. What could possibly surpass a conversion to raw object representation? Do you mean libraries which require you to use protocol languages like protobuf or inheritance?
I'm honestly not sure, though, how much I should be worried about the fact that someone who has write access to my database can maybe escalate that to an arbitrary code execution if I use pstore. Literally not sure. Write access to my DB seems pretty disastrous already...