Re:Show HN: I made a very simple ruby gem to make objects an...
by gonyea on Thursday February 25, 2016 @01:48AM
(#11172782)
Neat. I wouldn't use it, as I have a database :).
Some notes:
- it's not thread safe
- it's not jruby-safe
- you should generally avoid Marshal. It can have compatibility issues across Ruby versions, etc. plus yaml or json can be introspected by someone who needs to debug things.
- it looks like it saves state in your current working directory? That'll definitely burn you down the line.
- no tests. Im sure there's weird bugs hidden in there.
Edit - another observation:
- you're setting instance variables inside the class definition. Making them Class-Instance variables, rather than Instance-of-a-Class variables like you want.
You need to set them in the initialize method instead.
Re:Show HN: I made a very simple ruby gem to make objects an...
by gonyea on Thursday February 25, 2016 @03:00AM
(#11173023)
Yes. I actually mean both. Thread safety does and doesn't matter. MRI has a GIL so appending to an array across threads will "just work." JRuby doesn't and it won't end well if you're not giving it thought.
But yeah, multi-process web servers absolutely trample over each other. File access would need to be coordinated / synchronized.
Re:Show HN: I made a very simple ruby gem to make objects an...
by wingerlang on Wednesday February 24, 2016 @12:35AM
(#11164771)
Not the creator, but I can immediately see the use in, at least small projects.
Recently I made a little script that runs every now and then and I had to store the data manually (echo $val > file.txt) which is not that bad. But not having to do that little file-juggle might be the use case.
Some notes:
- it's not thread safe
- it's not jruby-safe
- you should generally avoid Marshal. It can have compatibility issues across Ruby versions, etc. plus yaml or json can be introspected by someone who needs to debug things.
- it looks like it saves state in your current working directory? That'll definitely burn you down the line.
- no tests. Im sure there's weird bugs hidden in there.
Edit - another observation:
- you're setting instance variables inside the class definition. Making them Class-Instance variables, rather than Instance-of-a-Class variables like you want.
You need to set them in the initialize method instead.
But yeah, multi-process web servers absolutely trample over each other. File access would need to be coordinated / synchronized.
Recently I made a little script that runs every now and then and I had to store the data manually (echo $val > file.txt) which is not that bad. But not having to do that little file-juggle might be the use case.