Hacker News new | ask | show | jobs
by memla 4677 days ago
That really depends on what you're writing and how you are doing it. How is this php[1] code uglier than this python[2] code?

[1]: https://github.com/laravel/framework/blob/master/src/Illumin... [2]: https://github.com/reddit/reddit/blob/master/r2/r2/controlle...

5 comments

Is that really a good comparison?

The PHP code you linked to is basically a class with a bunch of getters and setters.

The Python code, on the other hand, handles numerous real-world HTTP requests that do actual work.

So it's not unexpected that the PHP code is lighter; it doesn't really do anything useful!

Although it helps implement a wiki system, the Python code is still very readable and comprehensible with minimal effort.

I think I know the point that you're trying to make, but those examples surely don't back it up in any way.

Well, wherever you look you'll find the same thing as the whole framework is written in the same way: specific classes with small methods. And you can't say that the framework as a whole does nothing.

I agree about the python code that it is reasonably readabale, but i still think it's ugly. Those two things are not the same.

I'm not saying it really matters, but the PHP just looks ugly to me. I think it's all the dollar signs and braces.
That's a mirror image of 'Lisp just looks ugly to me. I think it's all the parentheses.'.

There is a lot more to a language than its syntax.

Syntax is highly important, however. A poor syntax can make an otherwise decent language quite unbearable. A nice syntax doesn't make an otherwise poor language good, either.
That's extremely shortsighted.

Special chars, like PHP $, Rust's ~, Ruby's @, help the programmer tell things apart easily.

Vastly better than having to keep the information in your mind after the declaration -- and much lighter and better than full-on hungarian notation madness.

As for the braces, they never went out of style. In fact, with the exception of Python, the languages that don't use them are not that popular, compared to the ones that do. Coffescript, for example, is insignificant compared to the plain Javascript use.

I'm afraid you picked a pretty terrible example. That PHP code is 414 lines of getters and setters - the code does nothing of actual value. It's a mess of design patterns and OOP verboseness, which mainly suggests that the PHP community are determined to copy the worst aspects of the Java ecosystem.

The Python code, while a little heavy on decorators for my personal taste, spends the same number of lines of code implementing a whole swathe of useful application functionality.

I'm not saying your particular example proves anything about PHP vs Python, I just think you chose an apples-to-oranges comparison to illustrate your point. It would be much more interesting to see some PHP code that implements business logic similar to that Python.

I already answered this below. Anywhere you look in the framework you'll find that it is written in the same manner, so i couldn't possibly find any code that is comparable in style to the python codebase. Yet, it is a full-stack framework, so you can't say it doesn't have any "useful application functionality".

Since the point was to show what kind of code you'll be looking at depending on the choice of your language/framework i think that the examples are appropriate. Which application implements better design patterns is a discussion that goes a little beyond the point of this thread.

It is uglier, very easy. How? The dollar signs, curly brackets and angle brackets.
seem php shorter without comment. while see the python.. quite nasty import from.. i tough python is simple .