Concept overloading madness

May 09, 2007 14:30

I recently had cause to go delving into the documentation for Ruby's open() method. While I found the information I needed fairly quickly, I was appalled to discover that open() will happily open a pipe to a subprocess (if the path parameter starts with "|") and even fork your app (if the path parameter is ( Read more... )

programming

Leave a comment

Comments 8

kazriko May 9 2007, 15:54:23 UTC
The fact that Ruby is heavily reliant on Perl for many of its idioms is something that always irks me when I go to use it.

Reply

jerith May 9 2007, 15:58:59 UTC
Part of what precipitated this post was an unconfirmed rumour (when I was ranting about it on IM) that Python might be heading in the same direction with open(). I'd like to think it isn't ("explicit is better than implicit") but I've been out on the fringes of the Python community for too long to know where to look for confirmation.

Reply

kazriko May 9 2007, 17:25:05 UTC
*ugh*

I can see one place where it would be useful. When you go to open a file in a GUI app, it'd be nice to be able to put in a URL or some other thing. It'd be better, though, if instead of a open() handling all of them, they provided you with a function that would give you the appropriate object to call .open() on to handle that path. That would let the user explicitly support arbitrary special paths like that without a huge amount of code, but leave the unsuspecting from inadvertently creating a huge security hole in their system because they used open() and someone sent them a |- from a web page.

filetype.gethandler(path).open(path)

Reply

jerith May 9 2007, 17:33:47 UTC
I'd be fairly happy with open_anything() translating behind the scenes and giving me a file-like. I don't believe it should popen() (which lets you run arbitrary code) or fork() (which confuses the hell out of everything) though. I see the current Ruby (and, I suppose, Perl) behaviour as dangerous and not quite sane.

Reply


southernmyst May 9 2007, 17:16:03 UTC
*hugs*

Of course, you know what this means. You need to make your own programming language and then get with the marketers at MicroSoft to make sure it's almost the only one used. ;)

Reply

jerith May 9 2007, 17:36:38 UTC
Nah, I haven't had nearly enough exposure to different programming paradigms to be able to do that. Besides, it sounds too much like hard work...

Reply

southernmyst May 9 2007, 18:06:17 UTC
Silly jerith. You hire cheap Elbonian labor to do the hard work while you occupy yourself with ravishings from me all day ;P

Reply

jerith May 10 2007, 07:13:38 UTC
Ooh, I like that idea. Got any spare Elbonians?

Reply


Leave a comment

Up