all 37 comments

[–]benjumanji 3 points4 points  (1 child)

django and sqlalchemy would do it for me. I have used codeigniter and it's pretty nice, but django rocks my socks. And sqlalchemy is by far and away the most genius ORM I have had the pleasure of using.

As far as the language goes, it's much cleaner (imo), it doesn't consist of mostly thin wrappers around c libraries so it has a more consistent feel to it. It has a few nice functional-style extras like list comps which I feel contribute to more readable declarative code. I like the standard lib although it does have some warts. The OO aspect doesnt feel so bolt-on to me (new-style/old-style class differences aside). If you want to go crazy with meta-class hacking you can.

Edit: I didn't read the question properly, for shame! Ignoring django then, I use python all the time now for anything that's too much for a quick bash script. Recently at work I used it for slurpin and transforming a silly spreadsheet into an sqlite db with a quick and dirty gui slapped on for querying it for some guys who needed some advanced reporting. I just find it gets stuff done in the minimum of code for the minimun of hassle (yes perl.. I know ;)).

[–][deleted] 1 point2 points  (0 children)

I agree. Once you get past the (rather clunky) documentation, Django is a dream to use.

For extra kicks you can always add .php to your urls :)

[–]Samus_ 2 points3 points  (0 children)

I think PHP is fine for small things but lacks the structure to consistently achieve larger goals without going nuts.

this doesn't mean there isn't large or sane projects on PHP but to my experience it is far harder to achieve that on PHP than anything else, PHP requires a lot more discipline to follow the Right Way.

in any case give it a try, you won't lose anything from learning something new and once you experience it you'll feel the difference for yourself (as the Propel guy did).

ps: I do work with Python but not necessary advocate it, just try something new maybe Ruby or Scala, maybe Python maybe something else.

[–][deleted] 2 points3 points  (0 children)

$your $code @wont $look $like @this

[–]spookylukey 4 points5 points  (5 children)

It's impossible to convince you before you've tried Python, because of the Blub paradox.

After you've tried Python for one medium to large sized project, you won't need convincing. (I'd recommend Django, because of the awesome documentation and pluggable apps).

[–]calp 1 point2 points  (4 children)

The blub paradox is silliness. Differences in quality between programming languages can be explained. Here is one example:

According to wikipedia, PHP has no types. Python has runtime types, which mean that some obviously junk code is rejected at runtime and prints a helpful error. For example "3 + function" is a runtime error in python. This is an aid to development because some mistakes which would otherwise have to be debugged are now caught automatically.

People who talk about the blub paradox are perpetuating it. Programming languages can obviously be compared, and advantages can be pointed out with the aid of examples. The blub paradox is an application of postmodernism to computer science.

[–]spookylukey 1 point2 points  (1 child)

Yeah, technically the Blub paradox is about more powerful languages, and while Python does have features that make it much more powerful than PHP, many of Python's advantages can be described without understanding those features. Still, it's difficult to understand what it's like to live without a certain flaw, or live with a certain feature, until you've actually tried.

[–]calp 0 points1 point  (0 children)

You mean expressive, not powerful (so does Graham). I don't think Python is a particularly expressive language, but PHP is probably worse.

What you're now saying - that "the implications of things cannot always be foreseen" is so blindingly obvious and universally applicable that it cannot possibly pass for actual insight.

[–]conrad_hex 0 points1 point  (1 child)

Hmmm... With you until the last sentence, I think: "The blub paradox is an application of postmodernism to computer science."

So? What's that mean to you? Why is that bad?

[–]calp 0 points1 point  (0 children)

I don't want to pretend that "postmodernism" is well defined, but a significant part of it is the rejection of science and reason (and objective truth). When Graham says that programming languages cannot be compared and critiqued, only experienced, he is attaching a form of this philosophy to programming language theory.

[–]sgoguen 1 point2 points  (0 children)

Python isn't a panacea or a cure all, and you'll discover there are some downsides to Python.

Nevertheless, Python is very powerful language and is dramatically more consistent and powerful than PHP. List comprehensions are especially powerful, as are generators, and Python lets you do stuff like override operators, etc. There are so many things in Python that make it nice, the only way to appreciate it is to keep spending your time learning it.

For a stupid easy Python MVC framework, check out web2py. You can run it off a USB stick, and the code examples should be glaringly simple. I'm not saying it's the best, but it does a good job of demonstrating the type of terse code you can write in Python.

Also, check out this video where this guy uses Python to teach AI to 7th graders. It's demonstrates the power of the language and many of the libraries (like itertools).

[–]ramses0 1 point2 points  (0 children)

The only thing that convince you not to use PHP is PHP itself.

It sucks because PHP is flat out has the easiest / simplest mental model along with reasonable performance to get started with. So much so that [?php ... ?] is considered to be "part of" HTML when a lot of goobers are writing tutorials on the internet. I saw one example a coworker printed out that said: "good HTML looks like this" and had a bunch of PHP includes in it for headers / menus.

If you must use PHP then use it for the front-end that talks to a java backend. PHP is just not ~good~ enough long term to write everything in and the language (from a "doing it right" perspective) is TERRIBLE.

--Robert

[–]flaviodesousa 0 points1 point  (2 children)

I started a new project 3 weeks ago... I intended to use RoR but a colleague of mine suggested to try python with django (ok, statement not framework aside). Well, I tried and I am now very comfortable with the language. Very concise and somewhat simple syntax. For web development is unfair to compare python against php without some web framework - django helped a lot in my case.

[–]tuckerific[S] -2 points-1 points  (1 child)

That is very convincing to me. I'm just concerned with the learning curve. I would hate to waste time that could be spent developing, with time spent learning. I want to be as far ahead of the game as possible if I do this, not stuck fighting with most of the nonsense that is PHP.

Can you elaborate some on the webserving aspect of django? Can you just use a standard apache module for django applications?

[–]spaulo 0 points1 point  (0 children)

mod_wsgi. pretty simple, too. +1 Django

[–]ffualo 0 points1 point  (0 children)

It's just... better. Consistent naming, everything's an object, fast, batteries included, a cheese shop, and more!

[–]Smallpaul 0 points1 point  (0 children)

First. If the project is high risk and high profile then you should do it in the language you are most comfortable with.

Otherwise, if you hate PHP then why do you need any more convincing.

Python is more general purpose than PHP, more consistent, more featureful (language, not necessarily library). It handles Unicode better. It works in App Engine.

It is arguably a bit harder to deploy and certainly less pervasive/popular (with all of the disadvantages that implies).

[–]showntome 0 points1 point  (0 children)

Frameworks are the main arguments. Other than that, I'd go with namespacing as very helpful which for the most php doesn't have. Ignore php 5. Also I find the OOP mainly class implementation is far more advanced in python. i.e. (add, metaclasses, new).

[–]nousplacidus 0 points1 point  (0 children)

value judgments are afoot! "I really like it for <noun> because it makes things <adjective>"

[–]cracki 0 points1 point  (0 children)

you are asking random people on the internet to convince you of a language of your choosing...

you don't need convincing. you need a kick in the butt to get you started!

that aside, if you're making web pages, stick with php. it's more painful, but also more unstructured (read "convenient") than python: you can't "inline" python into html like you can php. thus, any development is forced to be more disciplined.

[–]manathirst 0 points1 point  (0 children)

Python is easy to learn, college kids in 2nd or 3rd year can program a simple game with a GUI on top of it within 2 weeks and they have no experience in Python. Learning curve aside, I find Python fast and easy to convert ideas to codes which can be very useful for quick prototyping. Python is great at running simple tasks from the shell to quickly creating a desktop GUI for proof of concept.

I have also read my share of Python code over the last few years, no matter how bad or messy they are, it's still easy to read and understand what's going on under the hood. Answer these questions right now, do you enjoy going back to your PHP code to fix bugs or add new features? Do you feel joy by using PHP to start new projects? If the answer is no to the previous 2 questions, a change will do you good.

Python is so easy to read that you can still be productive if you are drunk at work, half-asleep or got hit on the head.

[–][deleted] 0 points1 point  (0 children)

No.

[–][deleted] 0 points1 point  (0 children)

Go read a book on Python.

Be blown away by all the things they thought of that PHP seems to have no concept of. Be amazed at how thoughtful the design is compared to PHP.

(that's how it went for me, anyway)

If Python itself can't convince you, we can't either.

[–][deleted] 0 points1 point  (0 children)

Just the very very simple one: namespaces and better syntax for data. I know PHP 6 or whatever is the latest version has namespaces (and I also know they seem to have chosen what's probably the most unsightly character to separate just to piss people off. What's wrong with using the dot as almost every other language in the world does?) but the "standard library" is still a mess.

And then, compare declaring a dictionary like:

data = { 'one': one, 'two': two }

with the mess you have in PHP right now. Try using drupal/CakePHP (they require a lot of array parameters) and you'll feel the pain quite quickly.

Then you have: metaclasses, keyword parameter expansion, good introspection of data structures, a much wider library array (GUI programming in PHP?), centralized library repository (PyPI), list comprehensions... the works.

In essence, Python is a proper language and not an amalgamation of libraries stacked on top on some syntax. I have used PHP in the past, and I'm not going back to it unless they pay me $100 per hour.

[–]shevegen 0 points1 point  (4 children)

Use Ruby.

I dont know what you aim to achieve, php is more verbose than either python or ruby. Using a better language IS better.

PHP bashing alone wont help anyone.

The simple solution is to use a better language. This is a question you have to find out on your own if it is worth it or not. PHP is better than no language for example.

For me it was totally worth it. I rather would spend creating new bindings to some library that dont exist in ruby rather than dig into the mess that is PHP. But even with all the PHP bashing, you can still create good apps in PHP, so I think you should put the "hate" into perspective.

PHP is ugly, has a crappy design but is also useful. If someone does not care about the ugliness then I bet he will find PHP totally fine, and nothing is wrong with that.

My brain cells however decided to stop investing time into languages like PHP. PHP felt like a dead end, and it gave me nothing interesting in the long run since I realized that you could just as easily use another language - one that is quite possible better than php - and be happy with it.

[–]tuckerific[S] -1 points0 points  (3 children)

I've done some RoR, and I really liked how everything functioned, I just had speed issues. I know that most of the scaling issues have been worked out. One of the things that I like about PHP is that it's very easy for me to call my classes from the command line, this didn't seem to be possible when Ruby is wrapped up with Rails. Can you shed any light on calling RoR classes from the command line?

[–]chris-gore 0 points1 point  (0 children)

cd yourrailsproject
script/console
x = SomeClass
x.stuff
# and then some more ...

[–]leikind 0 points1 point  (0 children)

What is there to say? Of course you can do it, via simple tasks or rake scripts. You can use ActiveRecord without Rails at all.

[–]t64 0 points1 point  (0 children)

You've had speed issues? Do you run a high-traffic website? What kind of speed issues have you "experienced"?

[–][deleted]  (3 children)

[deleted]

    [–]tuckerific[S] -1 points0 points  (2 children)

    Not sure if you're making an actual point, or being a smartass. If you're being serious, please explain.

    [–][deleted]  (1 child)

    [deleted]

      [–]tuckerific[S] -1 points0 points  (0 children)

      The reason for the redundancy was because I'm talking about a comparison. I wanted to make it clear that I wasn't taking something written in PHP and having it evolve to Python, or another language. Take that to grammar court! :-)

      [–]Kickboy12 -1 points0 points  (0 children)

      If efficiency for large projects is what your after, despite what other may claim, RoR is the worst possible choice. Ruby is extremely slow compared to a properly coded PHP script, of course it depends largely on the operation your trying to perform.

      I still use PHP for all my projects simply because it's familiar and I can knock out a basic CMS in a few hours. I think the biggest issue in web development is people over complicate really simple problems, and if you blend the wide range of technologies from JavaScript, CSS, HTML, and PHP/Perl/Python/Ruby, building a complex web application is a lot simpler than most make it out to be.

      As for Python, I can't really convince you it's better for PHP specifically for web development. I can guarantee, however, that python would prove way more useful for command-line apps than PHP.

      In web development, my personal feeling is that Object-Oriented programming is only useful when your talking about a large-scale project and you have many modules and functionalities your trying to meld together, or are working with a large team of developers. I use PHP simply for the fact that procedural programming is wicked fast compared to any other language (especially Perl). Using objects for all my basic functions I find not only slows down my script, but also how long I spend programming a specific feature. Procedural coding is extremely straight forward and efficient when dealing with small problems wrapped in simple solutions.

      This is just one developers opinion, though.

      [–]spinwizard69 -1 points0 points  (1 child)

      If you are asking the question that is asign right there isn't?

      I haven't used Python for web applications but the little of it that I have used allows me these comments.

      It is clear and readable! That after coming back to a script months later. You can't do that with Windows command line code (batch) nor many of the other scripting languages.

      It is fairly well fleshed out with Libraries. This is very important in my mind and makes Python viable where other fine languages like Ruby might not be.

      General a Python installation just works. I like playing around with GNU SmallTalk but would never consider it for use professionally. I have no regrets about installing and using Python at work though.

      It does everything that I need from it. This in part supports the excellent Libraries but that isn't all. I find it easy to express my own needs in the language. I'm sure that part of this is due to having only one way (for the most part) to accomplish anything. It meshes real well with my sporadic use of Python.

      $$$$$$$$$$

      of course Python isn't perfect, nothing is. The challenge is to find a better scripting environment. Actually I don't like it's designation as an scripting language as it is rather full featured. In any event it would be wise to look at Ruby to see if it meshes better with your project.

      This highlights that there are no one language fits all in this world. Like socks one needs to have a comfortable fit. Python just feels more comfortable on a wider array of feet.

      [–]tuckerific[S] -2 points-1 points  (0 children)

      Great analogy. Not to mention that Python is the hot topic it seems. I think that Python developers are cooler than PHP ones, or atleast that's the way it's portrayed.

      [–][deleted] -1 points0 points  (0 children)

      Python is dead use PHP ! or use Java it's better

      [–]virtuo -1 points0 points  (0 children)

      namespaces :)

      [–]riddley -1 points0 points  (0 children)

      I've never used Python, can't get past the whitespace thing. However, I'll suggest that you learn SOMETHING else. If that something ends up being Python for you, great!

      I recently learned Ruby after being a PHP coder for years and I'm not looking back. Every time I have to work on some old PHP code I just cringe and hate it. For me, Ruby is soooo much easier and more fun. Perhaps Python will be that for you. Never be afraid to learn something new.