Pylons and WSGI

20 06 2008

Pylons is next on my list of frameworks to look at, because I like the scalability characteristics of WSGI middleware servers.

The idea that you might have 50% of your requests using sessions, 25% using authentication, 10% some web service, 10% using some other web service (cached), and some other percentage using any of a number of other things that could involve caching, computation, instantiation, database and/or network connections, etc., and not using the mod_perl solution of loading everything into every server process, the PHP way of loading everything from scratch (or one big cache) on every request or the java solution of really big APP servers with lots of threads.

Instead of have 100 high memory and/or cpu worker processes (or threads) taking up resources so they can handle everything (except static content or database) or moving everything onto the network with webservices, splitting it up so you have just as many processes as you need for each service, saving 90 memory for each of your web service handlers, and 50 percent for your session handlers.

However, I’ve heard in practice that only a few things need offloaded, and WSGI in practice doesn’t do that much better than separating static, appserver, database, and cache, which is probably good enough for most. So the overhead of a common gateway interface isn’t that useful.

Yet I do like the idea of “feature-specific” caches or servers. Having a pool of memcached’s is really nice, but having pools of each of session caches, page caches, web service caches, business object caches, etc. seems like it would be more resource efficient, and possibly more secure.

Coming from PHP, the idea of offloading things like PDF and graphic processing from the webserver (or appserver) also appeals.





more reasons not to use RoR 2

20 06 2008

from the same slideshow

XML in, JSON out”

Why promote XML? That’s not very web 2.0. And more important, if you’re using one, why use the other. JSON is supposed to be A solution to XML, not a consumer of it. I realize you might need to consume XML, but if at any point your JS data structures look like SOAP, you’ve got problems. If ever an XML data structure that actually makes sense for the domain it is intended to be used it… well, I’ve never seen one.

Plus, there seems to be general trend towards more helper functions to write HTML snippets for you, like div_for, dom_class, dom_id, url_for, etc. It’s worse spaghetti than old school PHP. Worse than old school CGI or servlets.

I realize AJAX rendering is hard, but if this is Rails’ answer, give me JSF or ASP code behind.





real reasons not to use Rails

20 06 2008

Mostly taste, like I don’t like ActiveRecord, database naming defaults, yaml, etc.  But here is something from a What’s new in Rails 2 slideshow:

validates_numericality_of :salary, :greater_than => 49_000

Now I’m not talking about the amount.  Although I’m aware as a RoR developer, you run the risk of failing that particular validation check, something you’d never worry about in Java or C++ land.

What I mean is, if this is an example of a dynamically typed language, I don’t want any of it.  Here is the same code in Java or C:

int salary;
salary > 49_000;

Much more concise, and more better checked too.  This will catch it at compile time (unless you have a cast from a hash — but that’s an argument in favor of generics.)

Of course, Rails has a bunch of code behind the scenes that is probably doing Javascript and serverside validation and displaying a pleasant and ambiguous error message to the user and log, but you can do all that with an annotation as well.  A more realistic comparison might use an annotation to tie your salary integer to your view and/or model and require a try/catch block for type cast errors.  Or it could wrap all that up in a static function that starts with “validates” that does all that.

I’m arguing for the syntax.  And I don’t think it takes a statically typed, pre-compiled language to get that.  I hope it doesn’t take operator overloading to achieve a > comparison.  Any decent language should be able to cast, throw a runtime error on type mismatch, and return false.  How 49_000 is cast is dependent on the language, and it doesn’t really matter as long as it is consistent and documented.  So guess I’m aguing against needing to use is_numeric() style functions as well.

With enough scaffolding and inheritance, you can do anything, even in C++.  As a matter of fact, with a hypothetical C++ framework like Rails (with other goodies like boost GC) you could get pretty close to achieving the ideal conciseness above.  Maybe we should all switch to C++ web frameworks once the DHH of C++ comes along.  Then our numerical validation really would be:

salary > 49_000