4 ms·
This may come off in a pejorative way but thats definitely not my intention... Is the intention here to make PHP more Ruby like? If so why?
by TamDenholm 16y ago
This may come off in a pejorative way but thats definitely not my intention...
Is the intention here to make PHP more Ruby like? If so why?
- leftnode 16y agoI'm not the author, but it could be. As an 11 year PHP programmer, why not? Ruby certainly has some nice language features, is well respected, and has gained a lot of ground recently. Why not borrow some ideas?
- TamDenholm 16y agoYeah i agree, which was one of the reasons for asking. I'm a PHP guy myself, i've not taken the time to properly learn Ruby but i am aware of some of its features and i remember thinking at the time "thats very cool, i wish PHP did that", so yeah, totally with you.
- raganwald 16y agoUpmodded for asking an interesting question, namely "why?" Perhaps there is some sort of ideal that Ruby's author Matz and the author are both striving for. If Ruby is closer to the ideal than PHP, an observer who examines the two languages and this work may wonder if the intention is to make PHP programming more like Ruby programming, where is actuality the author is seeking the ideal. This trick of perspective probably explains why so many people seem to reinvent Lisp over the years. They aren't trying to turn their languages into Lisp, they're seeking what Lisp's authors have sought over the years but haven't found another path towards the ideal. As to why... PHP and Javascript are both very interesting because they are so widely deployed by default and have a very large "market penetration" amongst programmers. Once you get past the "uncool factor," reaching PHP programmers is probably one of the highest value activities a toolsmith can pursue. JM2C.
- dhotson 16y agoThanks for taking a look Reg. Would you mind if I ran an idea past you? The other idea I'm toying with is something similar, but having immutable classes. So basically every time you add a new method, instead of modifying the class you would return a brand new class. Crazy? :-)
- jerf 16y agoRunning through that in my head, that's basically equivalent to subclassing. At least, I can't find a difference. (In fact if you do it the naive way you'll end up with something less functional than subclassing for no good reason, so you might as well just treat it as a subclass.) It also blocks monkey patching the original class, which I observe neutrally.
- deleted 16y ago[deleted]
- raganwald 16y agoI think it call comes down to class resolution. So whether you call it subclassing, versioning, whatever, the interesting thing is when you say that this bird is a "Blackbird," how do we figure out which version of the class to use? Sometimes we want to take the existing Blackbird, add or change something, let's call it Blackbird2 internally. If we are creating and owning an object, it's a Blackbird2 in our scope obviously. But if we get handed a Blackbird from someone else, can we treat it as a Blackbird2 in our scope but it is still a Blackbird outside of our scope? That mechanism is really scoped class resolution or scoped behaviour resolution or something. It completely solves the clashing monkey patch problem. Anyhow, I guess what I'm saying is that the implementation of versions of classes is one thing, and the resolution of names or references to classes is another (and very interesting) thing.
- dhotson 16y agoNot at all. Thanks for taking a look. :-) Yep, the intention was to implement classes in a more dynamic and hackable way. Ruby was certainly an inspiration, but I'm not really trying to copy it if that's what you mean. Ruby is pretty good in this regard, except that classes are global. This means that any change you make to a class is permanent (it's not scoped).