3 ms·
I am curious to see evidence of the encouragement to cut and paste. Especially now that 5.3 has real first class functions, I can not see what paradigm/feature
by shaunxcode 17y ago
I am curious to see evidence of the encouragement to cut and paste. Especially now that 5.3 has real first class functions, I can not see what paradigm/feature (other than macro expansion) you are using in another language which can not be done in php. Well ok mixins would definitely be nice...
- neilk 17y agoI don't have evidence - I'd need a study for that. It's just one guy's experience. Ok, maybe PHP 5.3 has this now, but previously, the lack of anything lambda-ish made some refactorings just impossible. Even with Java you could make a functor that, while ugly to code, would be reasonably performant. As your comment shows, PHP spent most of its life as a procedural language and it took a few versions to get objects right. And being not-strongly-typed, refactoring tools are necessarily incomplete or primitive. I just went Googling and it seems that many PHP devs think that refactoring is the same thing as applying a regular expression search and replace to their codebase. Compared to what's possible with Java plus IDEA or Eclipse, it's no wonder PHP devs hate to refactor. Lastly: PHP encourages you NOT to separate presentation and logic. This is why big PHP sites tend to use some other templating language even on top of PHP. The barriers to refactoring when presentation and logic are commingled should be obvious.
- deleted 17y ago[deleted]
- encoderer 17y agoBlogPost blogPost = BlogPost.factory("post"); Ahhhhh, Java.
- mikepurvis 17y ago"PHP encourages you NOT to separate presentation and logic." Is this a stated policy, or are you inferring it based on the structure of PHP being embedded in HTML? There's nothing about PHP which prevents separating the two. There are even the shorter tags and braceless syntax, which are especially friendly to templating. Eg, <? foreach($pages as $page): ?> <h2><?= $page->title ?> <div class="content"> <?= paragraphs($page->content) ?> </div> <? endforeach; ?>
- bonquesha99 17y agoI've been trying to implement rubyisms in php for fun and got some pretty cool mixins functionality working. Requires php 5.3 though: http://github.com/huberry/phuby http://github.com/huberry/phuby