Live data from Hacker News

Ask HN: Anyone went from PHP to Python?

news.ycombinator.com

1–10 of 41 posts

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

#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 list a whole series of problems with just about any development stack out there at the moment, at least the ones that I've used.

For quick and dirty stuff (throwaway sites or quick tests or prototypes) I still prefer PHP, but mostly because I can rely on a framework that I wrote years ago that makes it very easy to throw something together. It's far from perfect but it's the devil that I know best.

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).

I wished there was a clear winner amongst all these technologies, everybody seems to have built just enough to satisfy their particular itch.

Next on the list of stuff to try is werkzeug, another python framework.

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

#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.

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

#4
I've had some previous exposure to python, but nothing mission critical. I just switched from php to python about 3 weeks ago in order to deploy apps on the Google App Engine. My deepest language experience is in frontend Actionscript 3, so Python feels very similar to that in that you have imports, packages, and modules. I do still find myself typing ";" on rare occasions to end lines.

Here are a few things that I got tripped up by:

- I was searching for a substr? function. there is none; instead you do things like str[0:1]

- Dont Count on autocompletion (at least not in eclipse). I was hoping I could duck type things like i had done in php Eclipse and get object info autocompleted. This is not possible, so you have to keep a lot more info about objects in your head. Perhaps one way around this is to try keep all your classes in one module.

- Test with IDLE. I was used to testing php code by whipping up a single page and browsing to localhost. With appengine, and possibly your web server, this isn't justifiable when Python ships with a pretty cool cmd IDE.

hth!

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

#5
I started using Python about 5 years ago, but still used PHP for my main dev for a couple of years. PHP gradually got more and more painful to go back to, though, the more Python I wrote, and eventually I ditched PHP for all but mostly-static 3-page sites. I'm a fulltime web programmer, and we now do all our work in Django.

(That said, I'm using more and more Clojure for my personal stuff.)

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

#6
post #4

I've had some previous exposure to python, but nothing mission critical. I just switched from php to python about 3 weeks ago in order to deploy apps on the Google App Engine. My deepest language experience is in frontend Actionscript 3, so Python feels very similar to that in that you have imports, packages, and modules. I do still find myself typing ";" on rare occasions to end lines. Here are a few things that I g…

> - Dont Count on autocompletion (at least not in eclipse)

Tbh, PyDev for Eclipse is pretty darn good. Doesn't fail me on autocompletion, function arguments etc, except for places where objects are created dynamically. Also, I find it very handy being able to navigate to any one places in my $PYTHONPATH with one keystroke on F3 and get the documentation + the implementation to read through. Keeps me away from most documentation sites and inside the IDE.

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

#7
It'll take a couple of weeks to get very comfortable in the language itself, and a little longer to get used to a web framework like Django.

Once you do this, you'll be very annoyed every time you need to go back to using php. This change will be practical and eye opening for you. Enjoy.

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

#8
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…

> 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 at all. Very occasionally we step out of the ORM (usually in places we should be stepping out of RDMS in general, anyway, like tracking ad-clicks). (The ORM does now support aggregation, too - SUM(), AVG(), ad-hoc calculations etc.)

And the Forms lib is great if you're happy with default html-generation (it can do paras or tables); things get kinda fiddly when you're trying to customise layout and appearance, but it's still nice having validation, saving to the db etc. all in one place.

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

#9
More of a story than anything. I'm not sure if this is typical for someone going from PHP to Python, but it might give you an idea of what to expect if you end up becoming a Python convert.

I went from PHP-Nuke, to pure PHP, to Python, to handwritten Python site engines, to Google App Engine, and now finally hunkering down and getting Django under my belt, for real this time.

And that's my first tip: GAE makes a great stepping stone to Django (and even includes a sizable chunk of Django).

I have a very bad taste in my mouth from prior experience with Joomla, but I found Drupal to be very easy to use. But once I made the decision to finally learn a real framework, Python and Django made the work... almost trivial. Looking at the code for Drupal modules now makes me wonder why I let myself do all of that extra work that Django doesn't require.

I'm with jacquesm, I still use PHP from time to time for minor things, simply because there are a good amount of hosting providers that don't offer Django. But I think my experience with Python has made me a better PHP programmer. However that works. However I've never really had issues with forms, at least not with GAE, but it IS a little wonky.

    self.request.get('form_field_name')

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

#10
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…

> I keep hearing that forms are hell (but I rolled my own forms, so that wasn't a big deal).

You should try it for yourself and form your own opinion. I've found the declarative nature of the forms in Django to be extremely pleasant. My biggest complaint is the need for writing forms at all!

Post reply on HN