

Ask HN: Web programming for a C++ server developer? - jknupp

I've been programming low-latency, high throughput C++ systems for more than 5 years now, but I wanted to try my hand at some simple web development. Compared to 5-10 years ago (I'm 26 and haven't programmed for the web in a while), the sheer number of frameworks and add-ons to those frameworks is a bit overwhelming.<p>I've started to implement my site using Django as I'm a moderately proficient Python programmer but would be open to switching to another framework for a compelling reason. Also, where can I find resources to learn the more client facing stuff (AJAX, CSS, basic layout and design, etc)?<p>As an aside, has anyone else been through this before (i.e. much more comfortable with back end work but want to implement an idea you've had)? What did you do in that situation?
======
wheels
I went through that jump about a year back, so here are some of the things
that I've gleaned:

\- You'll be doing a lot of JS. Just use jQuery. It's the most popular of the
JS / AJAX frameworks, so even if you decide not to use it later on, it's a
good starting point.

\- I dig Ruby / Sinatra. Never really got into Rails or Django. You can learn
how to use Sinatra + Haml + Sass in a few minutes. I've also learned that,
somewhat to my surprise given my previous perception of their fan-bases that I
don't really like Python and much prefer Ruby.

\- For novelty there's Wt (<http://www.webtoolkit.eu/wt>), haven't brought
myself to actually use it for anything though.

\- CSS grid layout "frameworks" make things easier. I used
(<http://code.google.com/p/blueprintcss/>) for our new site, but can't say
that I had much love for it -- though still much better than doing all of the
layout by hand.

~~~
jknupp
What specifically about Ruby leads you to prefer it over Python? Are there
better/more modules or is the language itself more expressive or powerful in
some way?

Also, was there a specific reason you chose Sinatra over Rails? I'm not
familiar enough with either to make an informed decision so it would be
interesting to hear others opinions.

~~~
jhancock
As to ruby or python, I think its a matter of taste. Both are powerful enough.

Coming from C++, Rails might drive you nuts. I like to be certain of what my
code is doing. To achieve this with Rails, you either have to: 1 - write
_loads_ of tests or 2 - dig through Rails source to ensure the DSL does
precisely what you think it does. You don't want option 2 as Rails source is a
nightmare. Option 1 may not fit your sensibilities if you're used to writing
defensive code and writing too many tests seems a waste of time.

I can't speak for digging through Django source nor can I speak for how
clearly documented the DSL-like things are.

If you want more control over your app behavior or simply see what's going on
easier, the python world has webpy and cherrypy. The Ruby world has sinatra.
Something in between Rails and sinatra is merb.

~~~
kgrin
In general, Django is considerably more explicit about what it's doing
(particularly after the "magic-removal" branch two years ago). The implicit
trade-off is that some things that Rails does automatically you have to
declare explicitly in Django, but it hits the sweet spot for me.

My understanding is that Rails has trended that way lately, but since I don't
use it day-to-day I can't say whether that's the case.

I can't compare the Django source to Rails, having never really read the
latter, but on its own it's pretty good. Like any large-enough pile of code,
there are ups and downs, but whenever I've had to dig in and understand what's
going on, it's been fairly straightforward to follow.

~~~
jhancock
Rails has certainly become loads better. But the source is still cryptic to
anyone but a ruby master. Rails 3 is in the works which is turning into mostly
a full rewrite as near as I can tell. I expect Rails 3 code base to be much
easier to understand. But that's not out yet and when it is, I expect you'll
need to wait a year before enough of the libs and plugins are running
smoothly.

It sounds like you have enough python under your belt and like django well
enough. I'd recommend going with that. Your not missing out on some other
framework/language pair that is more powerful.

I use ruby/merb. I occasionally look around for something I like better but
nothing is worth the switching costs at this point.

------
huhtenberg
> _I've been programming low-latency, high throughput C++ systems for more
> than 5 years now_

You _will_ cringe at the web stuff then. Lots and lots of CPU cycles are
wasted to shorten the development cycle and simplify (dumb down) the life of
the developers. Layers upon layers of abstraction. Using PHP to generate a
_static_ HTML page is not a big deal. This sort of thing.

It certainly makes a lot of business sense as the hardware is cheap, and the
labor is not. But if you are used to squeezing every last drop of performance
from you code, it will be painful to look at some of the web stuff.

------
nwatson
I'm in the same situation. I've never really written a DB-backed web-based
application, so I'm starting down that road. Been working mostly on C++
distributed multi-threaded servers with lots of asynchronous network
communication.

I'm a big Perl fan and am comfortable with its object-oriented model so I've
chosen to use it. Here's the environment/tools I've settled on so far: Apache
on Linux (primary platform, might try to make sure works on Windows too);
mod_perl 2 in Apache pre-fork; PostgreSQL 8.x for back-end; Rose::DB for DB
persistence layer (apparently easy-to-use ORM, allows many-to-many relations
unlike various other Perl-based DB layers); Template-Toolkit 2 for web
template environment; going to layer on JavaScript later ... not sure which
library to use yet.

To some this may not be the ideal environment or the most current or most up-
to-date set of tools. For me though it seems the quickest way to seriously
explore and understand web issues.

I have a big hole in my software experience where several web apps should be,
and I need to fill it with something. Might try Django or some other Python
tool later. I'd actually like to try Twisted some time (asynch Python network
engine, not web-specific).

------
laurent_b
Coming from C++, if you do not want to become crazy using untyped languages
you might be interested by the haxe programming language.

A nice inference typed language which can be compiled down to neko bytecode
(much like java bytecode), JavaScript (for the client side), Flash movies
(idem), and even C++

Plus, haxe has a mod_neko for apache and lot of libraries to manipulate
databases and templates.

<http://www.haxe.org>

