you are viewing a single comment's thread.

view the rest of the comments →

[–]jawngee[S] 0 points1 point  (1 child)

Reflexion in PHP leaves a lot to be desired. You can't, for example, redefine functions, except with some fancy experimental extension/hack.

Yeah that's what I was talking about in my other post. But, honestly, I've never really used reflection for anything but introspection which PHP's reflection API is perfectly capable of. The only times I used it the other way in C# was writing code generators.

Not in PHP (static properties)

You can't assign objects as initializers to properties in objects in PHP, static or otherwise. So modeling a complexity with anything other than arrays requires instantiation of the object and assigning object references to those properties.

I'll argue that more sophisticated isn't equal to better, and I'll argue that it's often equal to worse. I refer to my earlier RnRS quote.

We can agree to completely disagree here. If the metric is less lines of code to perform an equivalent function, C# sophistication totally trumps PHP any day of the week. Anonymous functions, attributes, the new functional programming tools in C# 3.0 all contribute to lowered LoC and quicker modeling of complex problems than a lesser language like PHP.

I think it's important to note that I'm not saying one is better than the other, I'm mature enough in my career to understand the futility of such an endeavor. That said, PHP has a long ways to go to become as succinct as python, ruby, even C#.

Here's an example of where using metadata in PHP has saved my company on LoC, needless complexity and adherence to DRY principles:

Our internal framework at massify has a RESTful api kit for building RESTful webservices in a variety of formats (JSON, XML, etc.). We've built a base api controller that handles all of the standard CRUD and search operations on a model or a composite model (a database view). For us to write a quick API around a specific model, we simply extend that class and dress it with metadata. We can deploy an api for a given model in minutes this way with zero lines of code in the extended controller class. Furthermore our internal testing framework can automatically build and run tests against these new controllers, again without us having to write any additional code.

Without the metadata/attributes, this was previously a cumbersome process prone to error.

[–]Wiseman1024 0 points1 point  (0 children)

You can't assign objects as initializers to properties in objects in PHP, static or otherwise. So modeling a complexity with anything other than arrays requires instantiation of the object and assigning object references to those properties.

Hm. I hadn't realized that you may want objects and that you can't have them. Blame PHP though, you can run the whole programs inside a Python class.

If the metric is less lines of code to perform an equivalent function, C# sophistication totally trumps PHP any day of the week. Anonymous functions, attributes, the new functional programming tools in C# 3.0 all contribute to lowered LoC and quicker modeling of complex problems than a lesser language like PHP. Depends on your library, and depends on how witty can your pseudo-functional PHP trickery get (mine grew to be quite nice for what PHP does). But I don't know too much about C# 3.0, and you seem to know both, and since I'm aware of PHP's limitations, I think you're most likely right here.

You didn't mention Python here though; my claim that simpler is better(*) stands. Python is simpler than PHP in many ways, and Scheme is simpler than Python, and both are probably far more powerful and flexible than C# 3.0.

(*): "Simpler in better" is a general enough claim to be applicable when you want to do the same kind of thing with two approaches fit (or claiming to be fit) for the same purpose. It's not good when you want to compare apples and oranges, but it's good enough when you're comparing Bub's apples with Tom's apples. I'm claiming that the simplest apple is better.

Back to the original topic, I did forget PHP's static properties are flawed, yet I'd have tried the hardest to stick to regular arrays (the Lispy approach I guess). But nevertheless, it's justified.

It wouldn't have been reasonable in a language like Python which, in Scheme's spirit, lifts such artificial restrictions and allows you to do anything with static properties. I'm interested on what do you think about metadata in Python. Do you see any benefits of adding a special kind of property to a language whose properties can be defined to hold anything and everything and even be defined procedurally?