Live data from Hacker News

Ask HN: Anyone went from PHP to Python?

news.ycombinator.com

21–30 of 41 posts

Re: Ask HN: Anyone went from PHP to Python?

#21
post #19

As far as syntax, it's about as easy to pick up as it gets. ( http://diveintopython.org/ ) Web dev wise, it helps if you had some experience with PHP frameworks (though most of them are modeled more on Rails rather than Django or other Python frameworks). Also, the libraries aren't built in as in PHP and documentation isn't as good as PHP's (I'm not aware of any language that has online docs as good as PHP's. Django…

> in fact, I don't know if any language has online docs that come close to PHP's

MSDN and MSDN Social has some decent doc and comments.

Re: Ask HN: Anyone went from PHP to Python?

#22

I've made the switch from PHP to Python and don't really want to look back. Python is generally much better thought out from an object oriented perspective. Package and module imports are a lot saner in Python. I'm glad I'm no longer messing with require_once, autoloaders, and all sorts of functions polluting the global namespace. Python having first class functions and classes makes a whole lot more sense to me. PHP…

There are some very neat fixes to the more glaring issues with Djangos templating language, for instance the if statement.

edit: more digging:

http://www.djangosnippets.org/snippets/1350/

Re: Ask HN: Anyone went from PHP to Python?

#24
post #19

As far as syntax, it's about as easy to pick up as it gets. ( http://diveintopython.org/ ) Web dev wise, it helps if you had some experience with PHP frameworks (though most of them are modeled more on Rails rather than Django or other Python frameworks). Also, the libraries aren't built in as in PHP and documentation isn't as good as PHP's (I'm not aware of any language that has online docs as good as PHP's. Django…

From my experience, going from .NET to Django/Python, the documentation on MSDN was superior.

I hate to say it, but that was what I encountered. The paucity of the documentation on Django is one of my primary irritations with it.

I still strongly recommend checking out Python and Django. Excellent and productive environments.

Re: Ask HN: Anyone went from PHP to Python?

#25

I've made the switch from PHP to Python and don't really want to look back. Python is generally much better thought out from an object oriented perspective. Package and module imports are a lot saner in Python. I'm glad I'm no longer messing with require_once, autoloaders, and all sorts of functions polluting the global namespace. Python having first class functions and classes makes a whole lot more sense to me. PHP…

There are some very neat fixes to the more glaring issues with Djangos templating language, for instance the if statement. edit: more digging: http://www.djangosnippets.org/snippets/1350/

if's been upgraded in 1.2 to be significantly more useful:

http://docs.djangoproject.com/en/dev/releases/1.2-alpha-1/#s...

Re: Ask HN: Anyone went from PHP to Python?

#26
post #8

Earlier quoted context omitted.

> I've made three sites in python/django, it works but the ORM is very limiting and I keep hearing that forms are hell (but I rolled my own forms, so that wasn't a big deal). Huh. That's not been my experience at all. I guess if you're trying to build full-strength webapps that might be the case, but we've built a decent number of fairly complex user-content-managed type sites, and Django has not caused any trouble a…

A complex query is one that hits several tables in several databases on more than one server. You can simply forget that using django, you'll have to export all the stuff you want to query in a format that exactly matches Djangos field name magic. And better not get any of that wrong or you'll be tearing your hair out, an underscore in the wrong spot and it will look just fine but it will never work and the error mes…

Okay, I see. In that case, you're being tripped up by the fact that `parent = ForeignKey(OtherModel)` actually creates a database field `parent_id`; parent just becomes a synthetic property. AFAIK foreign keys and "_id" is the only place that happens. On the whole though, I think you're exaggerating the "field name magic". Double-underscores in field names would be a bigger problem, but python considers those special anyhow.

And sure, cross-database and cross-server are weak points for Django. I guess it depends on the scale and complexity of what you're building… I build reasonably conventional websites for a living, and haven't hit too much pain with Django.

Re: Ask HN: Anyone went from PHP to Python?

#27
I made the jump from PHP to Python a few years ago and am very glad I did. As far as frameworks are concerned, I started with Django, web.py and cherry.py and landed on on Tornado. I love the include what you need, non-kitchen sink aspect of Python development and have found my apps to have much smaller CPU and memory footprints. In addition, I believe Python development has made me a better developer in general.

I can honestly say I'd be surprised if you didn't thank yourself for jumping over to Python. Just make sure to give yourself the time and resources required for the shift in process and thinking.

Re: Ask HN: Anyone went from PHP to Python?

#28

I've made the switch from PHP to Python and don't really want to look back. Python is generally much better thought out from an object oriented perspective. Package and module imports are a lot saner in Python. I'm glad I'm no longer messing with require_once, autoloaders, and all sorts of functions polluting the global namespace. Python having first class functions and classes makes a whole lot more sense to me. PHP…

PHP is, essentially, a souped up templating language, so I'm really not surprised you prefer it. Django's templates aren't bad though, even if a little awkward at times.

Indeed. It just seemed a little restrictive not to be able to use some basic Python operators from within a template. Why invent a separate awkward syntax when Python itself is perfectly suitable?

Re: Ask HN: Anyone went from PHP to Python?

#29

Earlier quoted context omitted.

PHP is, essentially, a souped up templating language, so I'm really not surprised you prefer it. Django's templates aren't bad though, even if a little awkward at times.

Indeed. It just seemed a little restrictive not to be able to use some basic Python operators from within a template. Why invent a separate awkward syntax when Python itself is perfectly suitable?

The idea was so that a web designer who didn't know any programming could easily edit it.

Re: Ask HN: Anyone went from PHP to Python?

#30
post #3
post #2

I did. Python is a great little language but even after multiple thousands of lines it still looks like the guardrails on the highway are missing, I never knew I was so addicted to curly braces. I also find it very hard to switch from the one to the other and back again after sticking to one of the two for a while. My 'preferred' language/framework for more complicated stuff actually does not seem to exist. I can lis…

Thanks for this honest response. By the way, forms are also hell with the Zend Framework IMHO.

It's surprising how hard forms seem to be to get right. Forms in Pylons were terrible too... I've not used other declarative form systems besides this but it seems like a terrible idea in general.

Do anything even slightly complicated (say validations dependent on other field values) and you end up having to extend the framework in truely monstrous ways just to get it to happen. (On a side note, using the validate decorator in Pylons is NEVER the great idea it initially seems to be).

In the end I replaced the form system with my own that let me work procedurally instead of declaratively (without the need to memorise the multi-tiered internal form handling API) but I could still plug into the existing declarative system (no need to re-invent the wheel).

In that regard Rails form handling is a pleasure to work with. Validation is just as easy for simple and complex scenarios. Integration with the ORM is fantastic removing a tonne of manual pain when constructing forms.

Post reply on HN