
Why PHP Is Fun and Easy But Python Is Marriage Material - jasonlbaptiste
http://onstartups.com/tabid/3339/bid/20493/Why-PHP-Is-Fun-and-Easy-But-Python-Is-Marriage-Material.aspx
======
jacquesm
If you are comparing programming languages and marriage then here is my
advice: Stay Single.

Don't get too hung up on any one language or framework. Stay flexible and hold
the door open to something new and better if it should come along.

Even python - without a doubt a more elegant better designed language than php
- has its shortcomings.

And php, for all its shortcomings has its clever bits too (except, that it
didn't so much as go through a design phase as it went through growth out of
necessity).

~~~
cookiecaper
I don't think that the analogy has to be considered in the context of a
monogamous relationship. Marriage has not always been monogamous -- in fact,
almost exclusively in the Western Christian tradition has marriage been
considered exclusively monogamous, most other cultures have allowed polygamous
marriages.

From that context, the headline makes better sense -- you are not necessarily
considering Python as the only tool in your toolbox, but as something that is
worth taking home and making a life with, i.e., using Python as a mainstay in
your professional life.

Python, like all programming languages, has its shortcomings, you are right.
But potential wi(fe|ves) have shortcomings too -- in this mortal sphere,
nothing is perfect, but we can't let that paralyze us.

------
rick888
"The learning curve these days is not a new language (it takes a proficient
programmer just a few days to get her arms around the basics of a new
language). The learning curve is with the framework."

This is my main problem with this line of thinking. Developers aren't actually
developing anymore. They are mashing together frameworks.

I've looked into frameworks like Django. It's not good because it abstracts
away the functionality of the database. It's nice that everything is an
object, but if you want to do something more complex and go around the
framework, things get messy and start to feel hackish.

I am a PHP developer and I generally don't use a PHP framework. I have my own
set of classes that I wrote (and improve on). I have also used the smarty
template engine in the past, which works really well for keeping HTML
separated from the actual code (and it has built-in caching). Jquery is also
great for the front-end.

I started development with pascal, then moved to c/c++, and finally PHP. I
like PHP because it is a high-level enough language that makes development
easy, yet it's still powerful enough to allow for complexity and lower-level
functionality. The c-style syntax doesn't hurt either.

PHP 4 and below had many security issues (what were they thinking with
register_globals?), but 5.1+ has made some major changes.

~~~
commanda
You say you don't believe that mashing together frameworks is actual
development, yet you recommend the jQuery framework for front-end coding. Do
you draw a distinction between front-end and back-end - is front-end work not
really development?

In my experience, the time it takes to become proficient with an existing
framework is generally a lot shorter than writing a framework yourself. And,
generally, the existing one will have been vetted by thousands of people
before me.

~~~
rick888
"You say you don't believe that mashing together frameworks is actual
development, yet you recommend the jQuery framework for front-end coding. Do
you draw a distinction between front-end and back-end - is front-end work not
really development?"

I use it sparingly. Mostly because there are many quirks between the various
browsers and jquery seems to have a pretty good handle on it. As an example:
rather than using one of the many bloated pagination libraries I found based
on Jquery, I rolled my own in less code. It ended up much smaller because I
didn't have to incorporate everything in the existing libraries. Most
frameworks throw in everything, because they have to account for all
possibilities, rather than just the ones that you need. You end up with
bloated code, unless you know how it works behind the scenes (and many times
even if you do, you can't take out the parts that you don't need).

------
ryanwaggoner
_Some languages, like PHP, have very low learning curves — it’s super-easy to
get started. And, that’s awesome. It’s easy-going, fun, and you feel super-
productive (especially if you’re making a big change to something new). But,
once you get past that initial dating period, you need to think about your
future. You want to forge a relationship with a language that will be long-
lasting, rich and deep. A language that brings the best out in you — over the
long-term...Since I'm going to get into a long-term relationship with a
language, I figured Python's a pretty good bet._

I started out as a PHP programmer and have loved it over the last few years,
but after spending the last couple months playing with Python, this is exactly
how I feel.

~~~
Goladus
I think it's interesting that in the grand scheme of languages, Python has one
of the gentlest learning curves. (I'd say as a general-purpose language rather
than a web language, it's even gentler than PHP)

~~~
fiveo
I was able to learn Python in 2 weeks (lazily) using just Byte of Python. Of
course I can't build something clean and "Pythonic" with that kind of
knowledge, but I managed to build a simple CRUD selling books online app using
SQLAlchemy, CherryPy, and Genshi in 4 days (I need to build something for a
scheduled interview).

I'm not sure if I can do the same with PHP and some of the PHP libraries
(like, for an example, using Smarty, PHP, and a whatever-lightweight-ORM in
PHP).

~~~
jasonlotito
> I was able to learn Python in 2 weeks

Not to pick on you in particular, but comments like this are a pet peeve of
mine. While Python is easy to learn, and most languages are, but even if I'd
built a little application in Python as you had, and knowing what I know
already, I still wouldn't say I know Python.

Maybe I'm the exception to the rule, maybe my definition of knowing a language
is much more strict then most, but I really don't think you can learn a
language, any language, in 2 weeks.

I've done apps in Java, C, C++, Python, Perl, PHP, and even Obj-C now. Real
working apps that do things, but I'd feel very uncomfortable claiming to know
all those languages.

Oh, I know the syntax. Basic syntax is easy for any language (with my vast
knowledge of C-style syntax languages providing a good basis for this
assumption =)). But really knowing a language? Being able to create an
application from scratch? I mean, really knowing, not just hacking together
stuff you find from tutorials on line and running to SO whenever something
happens a Google search doesn't solve.

I fully realise that my standards might be a bit to high. I just don't know by
how much? Am I really just not giving myself enough credit, or am I reading
too much into this?

Edit: fiveo, I'm _not_ focusing this at you, obviously. This is merely a
general observation. =)

~~~
fiveo
I agree with you Jason. It doesn't mean I know Python. Perhaps I should use
the phrase "basic Python" instead of just Python.

But the point that I'm trying to make is that it's so much easier to learn and
build something using Python, even if it's not top notch or following best-
practice/patterns or trying to be Pythonic all the way.

Of course this is not sufficient knowledge in the long term.

~~~
jasonlotito
Yep, that's fine. =) Like I said, I didn't mean to address you specifically. I
realise the context of your comment is more than the single phrase I quoted,
and context changes things.

------
wenbert
I think PHP's strength is coming from the large amount of web hosting
companies offering it. It seems to be the "default" they offer, along with
MySQL. Also, those hosting providers are so cheap that for some it is the only
choice that they have (including myself).

While I have been learning Python for over a month now, I still do not have a
server to run my stuff on. I run it on my local machine but it feels different
when you have it "out there".

After a month of looking at and learning Python, I fell in love with it.
Bottom line, if web hosting companies offer Python as one their "default"
installations, then I would directly jump right in.

Python is nice because it has great web frameworks available - and at the same
time, I can use it as tools to parse my huge CSV files (and other tasks) while
I'm offline.

Python is a very "comfortable" language to learn - I never had that feeling
when I tried to learn Ruby.

~~~
Yaggo
There are plenty of Django-friendly hosts available with easy deployment
options:

<http://code.djangoproject.com/wiki/DjangoFriendlyWebHosts>

If your needs are more exotic, you can buy a VPS for $20 per month.

~~~
wenbert
I still can't afford $20/month. :-| That is almost the same amount I pay for
my hosting for the whole year.

FYI, I live in the Philippines. If get a Linode, I will not be able to afford
to pay for my internet connection hehe

I am however planning to get a VPS though. I'll find a way :P

~~~
Yaggo
I see, no doubt that's lot of money in Philippines. Even the typical smallest
VPS (eg. from Linode) has so much power, that you can easily run multiple
instances of various services on it (if we are speaking of hobby / small scale
projects). Maybe you can share the costs with some friends?

Or deploy your apps on Google App Engine! It's free (within the free quota),
supports WSGI apps, so you can run Django-nonrel, Tornado, Flask, Pylon,
Tipfy, or whatever your favorite Python web stack is.

~~~
wenbert
Me and my friends thought about sharing a VPS, but it did not work out.

Google App Engine sounds good. I will give it a spin as soon as I can...
Appreciate the response :)

------
jpeterson
_In Python land, the clear web framework winner is Django._

Is this really true? Personally, I prefer Pylons by a large margin.

~~~
cookiecaper
I have used Pylons extensively, but not Django. I really prefer Pylons's
packaging and methodology. Django seems more like a "classical" web framework
where everything is included and much has been reinvented. Since my
exploration in programming is often a matter of personal taste (i.e., not
forced by employer to learn something very often), I have not really spent
much time with Django as that style of framework does not mesh with my
preferences.

That said, I have recently been tinkering with a Satchmo cart. I am under the
impression that Django apps that utilize the Django backends can be converted
into plugins for other Django apps with trivial or near-trivial effort, and
that gives Django-based applications a lot of power, because if both Satchmo
and some Django-based forum use the Django admin and user database, I can plug
in or replace forums really easily without creating a bunch of extra overhead
for my users. That is very appealing to me, and the first reasonable use of a
"big" framework (like Django, Rails, or Cake) as far as I am concerned. It has
encouraged me to explore Django/Pinax more thoroughly.

~~~
zeemonkee
I find Django slightly unusual compared to other frameworks in that it has
many CMS like qualities, such as predefined user/permission models and the
admin (not surprising, given its origins). Rails, Pylons, CodeIgniter, etc.
provide you with an ORM, but it's up to you to define your schemas.

Not that this is necessarily a bad thing - it can save a lot of time in
certain projects. Sometimes though it's overkill for projects that don't need
these features.

So I'm glad that Django isn't the one and only framework in Python, as it's
good to have a choice. Multiple frameworks also mean competition and more
ideas and approaches, which benefit everyone.

------
avdempsey
I liked this line: "Though Ruby/Rails would likely have been fine too, there’s
something about it that I just found unnatural. If I had a dog, the dog would
bark at the Ruby code."

That's how I felt when I started learning Ruby after years and years of
Python. Ruby has method names with question marks in them...my dog would bark
at that.

~~~
seiji
I prefer free form function names when when parenthesis aren't required after
the function name. Hyphens in function names are great too.

    
    
      (member? 'a some_list)
      member?('a', some_list)  <-- ugly
      member? :a, some_list
    
      (check-user-credentials session user)
      (is-user-authorized? page user)

~~~
avdempsey
True, not having parens on the end of the function call makes this look better
(and those parens are optional in Ruby). Extra kudos to lisp flavors because
you could argue they have even "purer" syntax than Python.

Mostly, I'm just tickled by the idea of "would my dog bark at it?" as a mental
test.

------
citricsquid
So a few people said that PHP will die in the next few years because of things
like Ruby and Python becoming better and better, does anyone here feel the
same? I argued that PHP has such a low barrier to entry and is so accessible
that I don't think it'll happen -- at least not to Ruby/Python -- anyone
agree/disagree?

~~~
michaelchisari
Not when there's so many major open source projects written in PHP (Joomla,
Drupal, Wordpress, etc), and PHP support comes standard in every shared
hosting environment out there.

The install density is way too high, the language has been improved to the
point where most of the issues people have with it are aesthetic, and there
are a good amount of solid development frameworks out there to fill in any
gaps.

I think anyone who says PHP will die anytime soon is engaging in simple
wishful thinking.

~~~
mechanical_fish
_the language has been improved to the point where most of the issues people
have with it are aesthetic_

Now, let's not go too far.

~~~
michaelchisari
What would you say is missing?

~~~
mechanical_fish
This margin is too big to contain the answer.

But I'll try to sum up: PHP was designed as a minimalist, procedural language
designed to help occasional programmers write interpreted scripts that run in
brief, efficient bursts to generate responses to HTTP requests in a classic
CRUD-app context. It's designed to be the perfect language for someone who
wants to embed code in a set of HTML templates, upload them to the server, and
test them by clicking around and making sure the pages look right.

These are PHP's great strengths, and the reason why it isn't going anywhere.
But they are also its weaknesses. Attempts to drag PHP too far out of its
sweet spot get gradually more painful until you start to cry and switch to
something else.

Today PHP makes me cry because Ruby is so, so much easier to test. Tomorrow
there will be a different reason to cry.

~~~
michaelchisari
That's more of a general (if colorful) perspective on the language's origins
and your experiences with it, but I'm wondering what specific features of the
language you feel are missing?

I have experience with both PHP and Ruby, by the way, and am lead developer
for a very large open source application built in PHP, used mostly for
pragmatic reasons, but I am interested in hearing what language features
people feel PHP is missing.

------
forgotAgain
While I agree with the conclusion that the design of Python will over time
make it the more productive language for development I don't agree with the
importance given to Django.

I find that more view effort is being placed in browser code (JavaScript) and
the back end is becoming less presentation oriented. Therefore the need for a
framework like Django is diminishing.

~~~
SoftwareMaven
I disagree, though my use has changed. I recently worked on an app that only
had a couple of views; almost everything else was handled by exposing APIs via
Piston (which were consumed via jquery). Still, the value of the other
features of the framework made it work using in the project.

------
billybob
Point #5 did a good job of addressing a debate we see here sometimes:
"Language X serves our company well, but picky developers don't want to work
for us because we use it" vs "I want to work in a job that uses Language Y
because it's better." I think it's worth quoting:

 _Lets say you’re something like me: You’ve learned PHP and used it to build
and launch “real world” apps. For you, the cost of change is high (maybe even
prohibitively high). Really hard to justify the change, because though you
might grudgingly admit that Python is better, it’s not better enough to
warrant switching. You’ve got a startup to grow, you can’t be bothered with
trying to join the cool kids._

 _But, I’m to advocate for some empathy here. Lets say you were on the outside
looking in (i.e. you’re a gifted developer looking to join a cool new
startup). Since you’re really good, and demand for great developers always
exceeds supply, you essentially get to pick where you want to work. All things
being equal, you’re going to pick the place that is doing Python vs. PHP. Of
course, not all things are equal, and you might actually pick the startup
whose business you think has the best chances of success or whose founders you
like and respect. But, often, it’s hard to know that stuff upfront, so you
focus on what you do know — that developing in Python’s a better “bet”. I
wouldn’t fault people for solving for their self-interest and preference.
They’re not trying to talk you into switching, they’re just saying that it
matters to them._

------
bergie
The biggest issue with PHP doesn't really have anything to do with the
language itself: there is a serious lack of ecosystem. Instead of sharing
modules and libraries, every project seems to form an isolated environment
where code from any other project is shunned. I've been thinking about ways to
solve this, as the PEAR effort never really took off.

------
pmarin
You have it doble posted: <http://news.ycombinator.com/item?id=1840444>

<http://news.ycombinator.com/item?id=1840442>

~~~
jasonlbaptiste
WHOA, how'd that happen? pg ?

------
udfalkso
Great title.

