Ask HN: Anyone went from PHP to Python?
11–20 of 41 posts
Re: Ask HN: Anyone went from PHP to Python?
#12I 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…
Re: Ask HN: Anyone went from PHP to Python?
#13Package 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's call_user_func_array and passing around string names of classes and functions for callbacks is just so ugly.
In terms of web framework experience I was using Symfony in PHP and switched to Django for Python. I liked both, but I've found that Django is easier to use. I'm not a big fan of Django's templating language though compared to Symfony (which was just straight PHP).
Re: Ask HN: Anyone went from PHP to Python?
#14I'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…
Django's templates aren't bad though, even if a little awkward at times.
Re: Ask HN: Anyone went from PHP to Python?
#15Re: Ask HN: Anyone went from PHP to Python?
#16In general, the Python language and tools tend to steer you in the direction of writing cleaner, better-structured code. Working with Django also gives you access to a lot of decent 3rd-party applications that you can integrate into your project, and the Python stdlib absolutely dominates PHP in terms of scope, quality, and consistency. Having the bytecode compiler and libraries that provide better data structure and algorithm in app servers also opens up the door to a whole bunch of performance optimizations that are difficult to accomplish with PHP.
That's not to say that the Pythonic way is always better, of course. PHP encourages a very iterative approach to development -- at a basic level, you're creating a static page, then incrementally adding dynamic behavior until it does what you need. Python apps tend to put the code front-and-center, and output HTML (or JSON, or XML, or whatever) as a last step in the process. In the long term, that's usually a Good Thing, but it can make the prototyping and learning processes longer for some people.
Re: Ask HN: Anyone went from PHP to Python?
#17I 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!
So I rolled my own forms, thinking at the time that it must be possible but not knowing how.
Now I hear - from someone in a HN comment - that AJAX and django don't play particularly nice.
Here is the thread, I dug it up:
Re: Ask HN: Anyone went from PHP to Python?
#18I 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…
Would you recommend Python/Django over Ruby on Rails (if you have experience with that)?
I probably should.
Re: Ask HN: Anyone went from PHP to Python?
#19Web 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 has great docs, though).
I recommend starting with Google App Engine. It basically takes care of the deployment for you, which is often a sore point in many environments. It's free and includes a basic framework that resembles web.py with bits of Django. In fact it's worth picking up Python even just for the sake of making use of GAE.
Re: Ask HN: Anyone went from PHP to Python?
#20I 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 a…
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 messages you'll get are much less than helpful.
Here is a comment from the models.py file in one of my little django applications:
# caveat, the related_name parameters of parent and thread
# should not be parent_id or thread_id, this leads to
# an 'add() argument after * must be a sequence' error
# when transforming the template. Apparently the names
# clash with the underlying field names that django
# uses for these fields.
So, effectively, what this is all about is that django names a bunch of fields in the queries as aliases, but does not check if there are real fields with those names.