tags:

views:

894

answers:

7

Hello,

I am familiar with both Python and C++ as a programmer. I was thinking of writing my own simple web application and I wanted to know which language would be more appropriate for server-side web development.

Some things I'm looking for:

  • It has to be intuitive. I recognize that Wt exists and it follows the model of Qt. The one thing I hate about Qt is that they encourage strange syntax through obfuscated means (e.g. the "public slots:" idiom). If I'm going to write C++, I need it to be standard, recognizable, clean code. No fancy shmancy silliness that Qt provides.
  • The less non-C++ or Python code I have to write, the better. The thing about Django (Python web framework) is that it requires you pretty much write the HTML by hand. I think it would be great if HTML forms took more of a wxWidgets approach. Wt is close to this but follows the Qt model instead of wxWidgets.

I'm typically writing video games with C++ and I have no experience in web development. I want to write a nice web site for many reasons. I want it to be a learning experience, I want it to be fun, and I want to easily be able to concentrate on "fun stuff" (e.g. less boilerplate, more meat of the app).

Any tips for a newbie web developer? I'm guessing web app frameworks are the way to go, but it's just a matter of picking one.

+6  A: 

If you'd like to avoid writing HTML, you could try GWT. However, in my experience, using an intermediate framework to generate HTML and ECMAScript never works anywhere near as well as hand-writing the pages.

[edit] nikow mentions in the comments that Pyjamas is a port of GWT to Python.

Regarding the language, if given the choice between C++ and Python I would pick Python 100% of the time. Even ignoring the obvious difference in abstraction between those languages, Python simply has more useful libraries than C++. You don't have to write your own development-oriented web server -- Django comes with one. You don't need to write a custom template library -- Python has Genshi. Django comes with a capable ORM layer, or for even more control you can use SQLAlchemy. It's barely a contest.

John Millikin
Note the Pyjamas project, which allows you to use Python instead of Java for GWT.
nikow
If this wasn't already the selected answer, I'd encourage posting Pyjamas as its own answer.
quark
A: 

The only reason you might want to use C++ over Python is when speed is paramount.

If this is going to be your first web-app, you'll probably be ok with just Python, and your development speed will be orders of magnitude better than with CPP.

Django's templating language is far from powerless, to me it actually seems very pythonic. You actually can write pure python in a template(although this is generally not recommended).

Even better, it's possible to replace Django's templating system with the one you like. My personal favourite language for this is HAML.

Here's some data on this: http://stackoverflow.com/questions/519671/is-there-a-haml-implementation-for-use-with-python-and-django

x10
You can't write pure Python code in Django's (default) templating language. (I don't see this as a limitation, though.)
mipadi
"The only reason you might want to use C++ over Python is when speed is paramount." *Another reason*: avoiding to create the situation in which every small project in your company is implemented in a different programming language, which in turn comes with a different IDE, standard library, custom written libraries, programming language quirks and limitations, library quirks, profilers, etc...
Dimitri C.
+2  A: 
  • Django is good point to start web development it is great framework
  • If you look for C++ take a look on CppCMS, it is much more close to Django, it is not like Wt that mimics Qt.

In any case, it is really depends on your needs. C++ can be used for embedded or high performance web applications, but for medium range web sites Django would be better. (and I'm developer of CppCMS)

Artyom
+1: Also, Django forms do not force you to write HTML. The page as a whole must be in HTML, but input form HTML is specifically taken away from you.
S.Lott
A: 

I have almost zero experience in this area, but maybe the Nagare project would be more to your liking. It has some kind of programmatic HTML generation. Note that it requires Stackless Python.

nikow
+1  A: 

I think you better go firt python in your case, meanwhile you can extend cppCMS functionalities and write your own framework arround it.

wt was a good idea design, but somehow not that suitable.

ZeroCool
+1  A: 

If you are exploring Python frameworks (based on the excepted answer I think you are) I think you really owe it to yourself to check out CherryPy. When you write CherryPy apps, you really are just writing Python apps. The framework gets out of your way in a real hurry. Your free to choose your own templating, ORM (if you choose to use ORM), etc. Seriously, take 10 or 20 minutes and give it a look.

Shaun
A: 

Having looked several ones, like django, pylos, web2py, wt. My recommendation is web2py. It's a python version of "ruby on rails" and easy to learn.