Live data from Hacker News

Python web micro-framework battle

slideshare.net

21–30 of 59 posts

Re: Python web micro-framework battle

#21

Where does one draw the distinction between micro- and megaframeworks? Or, for that reference, just a "framework"?

> Where does one draw the distinction between micro- and megaframeworks? Or, for that reference, just a "framework"?

Here is how we (Flask developers) define microframework: http://flask.pocoo.org/docs/foreword/#what-does-micro-mean

Re: Python web micro-framework battle

#22

I have no idea how the LOC numbers of Flask come together though. Flask itself is 1.4KLOC, Jinja2 is 6.5KLOC and Werkzeug is 10KLOC (all measured without tests). Even if you add them up you don't end up with 32KLOC.

The author probably did something like this:

    sudo pip install -u flask
    cd /usr/local/lib/python2.6/dist-packages
    find flask/ werkzeug/ jinja2/ -name '*.py' | xargs wc
    ...
      34936  127298 1658380 total
Werkzeug alone has 18KLOC and does not ship with tests.

Re: Python web micro-framework battle

#23

Where does one draw the distinction between micro- and megaframeworks? Or, for that reference, just a "framework"?

The difference between a library and a framework is simply that you call the library whereas the framework calls you. The framework provides a frame into which you put your code as opposed to a library which you use as part of your code.

Generally I would consider any framework which requires (almost) no setup requirements to be a microframework. This is opposed to frameworks which require a basic configuration, directory layout or certain files to be present.

However there are a lot of other people with other definitions regarding this, the distinction is not at all very clear for example there are people that consider being written in a single file to be a distinguishing feature of microframeworks.

Re: Python web micro-framework battle

#24
post #22

I have no idea how the LOC numbers of Flask come together though. Flask itself is 1.4KLOC, Jinja2 is 6.5KLOC and Werkzeug is 10KLOC (all measured without tests). Even if you add them up you don't end up with 32KLOC.

The author probably did something like this: sudo pip install -u flask cd /usr/local/lib/python2.6/dist-packages find flask/ werkzeug/ jinja2/ -name '*.py' | xargs wc ... 34936 127298 1658380 total Werkzeug alone has 18KLOC and does not ship with tests.

Those are not lines of code. That includes docstrings which all of Pocoo code is full of. If you want to measure lines of code you at least have to skip comments, docstrings and empty lines. And for that there is sloccount. This also includes the testsuites btw.

With this little script (http://paste.pocoo.org/show/465885/) I get the following results:

    Flask      1467 LOC
    Jinja2     6560 LOC
    Werkzeug   9923 LOC
    Bottle     1910 LOC
(FWIW)

Re: Python web micro-framework battle

#25
I used web.py for a few years before switching over to mostly coding in Rails for the last few months.

Is this for real? Do people find the difference between the style of these micro-frameworks substantial? Maybe I've been out of Python-land for too long, but 70% of these look almost identical (raising exceptions for redirects, a combination of lists and naming conventions or decorators for routes/methods, etc.) and the other 30% look awful.

Furthermore, when all of the frameworks are basically the same, isn't a much more important question what scenario they were designed for, or what extra features they have, or performance, or how big a community they have? (Even where the author seems to have reasonable criteria, like WSGI, he doesn't seem able to look up that web.py is WSGI-based.) And seriously, does anyone care about Python 3 and/or PyPy support in 2011?

Another way of putting this: do the criteria that the author lists match anyone's criteria who is currently writing Python web applications in the real world?

Re: Python web micro-framework battle

#26
post #22

Earlier quoted context omitted.

The author probably did something like this: sudo pip install -u flask cd /usr/local/lib/python2.6/dist-packages find flask/ werkzeug/ jinja2/ -name '*.py' | xargs wc ... 34936 127298 1658380 total Werkzeug alone has 18KLOC and does not ship with tests.

Those are not lines of code. That includes docstrings which all of Pocoo code is full of. If you want to measure lines of code you at least have to skip comments, docstrings and empty lines. And for that there is sloccount. This also includes the testsuites btw. With this little script ( http://paste.pocoo.org/show/465885/ ) I get the following results: Flask 1467 LOC Jinja2 6560 LOC Werkzeug 9923 LOC Bottle 1910 LOC…

There are better ways to count LOC, I agree. But the idea is the same: Bottle does what it does with 1/10 of the code that runs flask.

Re: Python web micro-framework battle

#27
This seems like an illogical conclusion. I didn't see API Design mentioned once in any of these slides.

Aside from Python3 Support (which is a bit irrelevant at this point), what does Bottle actually offer that Flask does not?

Nothing, that I can see. Flask has a thriving community, first-class extensions, extremely high quality documentation, and an elegant API. It even lets you dip down into the lower-level werkzeug when you want.

Is Bottle being chosen because of LOC? Again, completely irrelevant.

Re: Python web micro-framework battle

#28
post #26

Earlier quoted context omitted.

Those are not lines of code. That includes docstrings which all of Pocoo code is full of. If you want to measure lines of code you at least have to skip comments, docstrings and empty lines. And for that there is sloccount. This also includes the testsuites btw. With this little script ( http://paste.pocoo.org/show/465885/ ) I get the following results: Flask 1467 LOC Jinja2 6560 LOC Werkzeug 9923 LOC Bottle 1910 LOC…

There are better ways to count LOC, I agree. But the idea is the same: Bottle does what it does with 1/10 of the code that runs flask.

> Bottle does what it does with 1/10 of the code that runs flask.

Not all of the code that is in Jinja2 or Werkzeug is used by the average Flask application. Also Flask does a lot more than Bottle, even for the same things. The routing system behind Werkzeug itself already comes close to 1KLOC (and for good reasons). Which is why I think that any comparison between Bottle and Flask is pretty pointless, it's not really a fair fight for either.

For Flask it was never a goal to have less code than another framework, in fact, from our perspective that's quite a pointless goal.

Re: Python web micro-framework battle

#29
post #17

Where does one draw the distinction between micro- and megaframeworks? Or, for that reference, just a "framework"?

Things a company will ask you to know is a megaframeworks. Else, it's a micro or simply framework. Obviously, I'm not serious here; but there's some truth in it. I.e. You'll see some companies ask for django or rails developers; not for flask python hacker right ;-)

Your point is interesting, but I would look at it from a different angle: If you need a highly paid specialist with many years of experience to fully master a framework, call it mega-framework. If it fits your brain and can be learned over the weekend, its a micro framework. Everything in between is just a framework :)
Post reply on HN