From: travis.ml-ruby-talk@... Date: 2010-07-29T03:06:56+09:00 Subject: hard drive backup program in 100% pure ruby --ON+QUYPPdli25pUV Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Just figured I'd mention that I'm working on this: http://www.subspacefield.org/security/hdb/ I think that I'll run into needing some features from the File or FileUtil classes (such as mapping from filename to inode numbers) that likely won't be present, or won't be implemented on certain file systems, OSes, and so on, so I'll end up being a contributor. This is my first ruby project, however, and I'm still learning. By the way, if you know anyone (e.g. a student) who could benefit from a case study in applying OOP/OOD to a real project, I'm writing it up here: http://www.subspacefield.org/~travis/hdb_history.html My background is python, and here were my reactions to ruby: 1) Assignment is weird. Both names point to the same object, unless it's a "small" type (fits in a register). a =3D 5 b =3D a b =3D 3 puts a # prints 5 a =3D "hello" b =3D a b['hell'] =3D 't' puts a # prints 'to' That really confused me for a bit. Fix is easy - always use dup in your initializers. It reminds me of the pass-by-value vs. pass-by-reference semantics. 2) I originally wrote some fancy set operations (like Set class but not using a hash) using array operators like -=3D. Problem is that these operates remove _the same object_ from an array, but not an equivalent (eql?) object. So when I compute metadata entries for a file based on the file, and then based on saved metadata, the same file with the same metadata is not the same object, so the -=3D operator won't actually remove it from the array. I'm considering the work it would require to implement -=3D using eql? but it seems complicated, so I'm thinking of switching to using Set. Downside of this is memory overhead for hashing and the random access I won't use much, also the fact that I build up these sets of metadata incrementally and so I'd be rehashing all the time. Building an array and then freezing it into a set seems possible, but cumbersome. 3) What's the syntax for class method constructors? I.E. I want four diffe= rent ways to create metadata entries, some of which have overlapping signatur= es, so I can't use a single initialzer method. (Yes, I know initialize is not a constructor). Currently I do this by having an empty initializer and doing something l= ike: a =3D Whatever.new().create_from_string(string_args) In general I like ruby - it's a very terse language but not overly cryptic. The documentation could be improved, but that's another list. Also, whatever MLM you're using (FML?) doesn't recognize valid RFC [2]822 addresses. travis+ml-ruby-talk@subspacefield.org IS a valid address, contrary to what it believes. This seems to be the only MLM I've encountered that doesn't do correct parsing/identification of email addresses (web apps are a different story... I wish people would RTFM...) --=20 A Weapon of Mass Construction My emails do not have attachments; it's a digital signature that your mail program doesn't understand. | http://www.subspacefield.org/~travis/=20 If you are a spammer, please email john@subspacefield.org to get blackliste= d. --ON+QUYPPdli25pUV Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (OpenBSD) iQIcBAEBAgAGBQJMUHG0AAoJEGQVZZEDJt9H62UQAIOZ8L+rWgAR0JaltgRazUht yPcybGPCsvHFjyyDiGweZM6c0qjAreA0odyTm4juPEl8OhJ0lPEXeqOKaSUoG7FX xM4cGZAh/bNZi/fNYV9QZ2MsvkB2y6Jei6spvK9ZwJ1WlUrO1vlnhvB3EUKsZ5hq JluSRq6n/zvrRUpPuF4u4WF2cXv4Z5Ss04KGDXofzkuRPf1BEH3FiYJgISbz1yef iVnPQmW0DllnuQ7gPXF3A43H6qqAM1a6QnywJynWX39+REqZytQ0ayYw0nG5PGeV Vcp9oI5Uy/DMAXoexnZv6cH8HwYeXldIWFPxcZkzZQdBNsrEcSRv8kZ6yQOAxmCG GDglni9evoUBULdMnn7MabubRN3oa/P3Osr+0pBA58yZzRAbOPj+WdlTLMoz5N/U XIPBZVyJCqCPsBJubWewM6KSmp6W+KRe3JEZCjLgxUScMX6Cz95h9453MoVksgKg 1BA5CA5yzPUQUGProHpaaQGWkt7Km+lfBheAqcGxKskzXv90Jm+iThtIyaz5kf+j xxH7x/uiybiJIJbxT4o50WnZ8ij/RVDjEPiP8A7voBYRn5PEFO0VHCxC1rEdT9Nq ZVWud1c9OV5FvXiSH/YvhLeDjEWU72GS3+WIG+Uj9TXxnOrU47bIYMnw12jH9M8W e9cmcIaGn2jeWl39XFva =CLdi -----END PGP SIGNATURE----- --ON+QUYPPdli25pUV--