Whenever I see Flask code, it just reminds me how unbelievably succinct Sinatra is.
I imagine it's a limitation of Ruby vs Python for creating DSLs, but a basic Flask app just seems so verbose. It's like seeing "Hello World" in Java vs "Hello World" in a dynamic language like python or ruby.
The intention wasn't to diss Flask. It is a very concise and useful framework. All the comments apply to my original comparison.
public static void main(..){
System.out.println("Hello World");
}
really isn't much more verbose than
print "Hello World"
yet every tutorial on a new language points out how frustrating it is for someone learning the language to type "public" "static" "void" "System" and other keywords/objects/modules without having any idea what they mean just to do something simple.
In Flask I need to instantiate the Flask app, define a function to run and decorate it with a route. That raises all sorts of questions about what a decorator is (which for a casual pythonist may or may not be something they understand - I know my understanding of decorators is sketchy at best). Then I need to explicitly call app.run() somewhere.
In Sinatra, the DSL makes it much simpler. If I receive a "get '/'" request, then "do" the following stuff. "end".
Flask is very concise. No doubt about it. It's stripped down to it's very minimum. Yet Sinatra manages to be even simpler, which is impressive to me.
>Whenever I see Flask code, it just reminds me how unbelievably succinct Sinatra is.
I hereby dub this the programmer equivalent of "sharp knees".
Explanation from the ever inimitable Urban Dictionary:
"A judgment leveled against an otherwise perfectly proportioned, if not slightly trim, and pleasant looking woman. Generally uttered by a male who is way below her class."
This comment is otherwise beneath a reasoned response.
Rather than quibbling over syntax, I'd like to comment on a real concern I have about blogs, particularly ones that engage in hagiographies on things they don't appear to rightly understand.
Nota bene: I am a user of Flask and have been one for quite some time. I am incredibly fond of it and it has replaced Django for most things I do in web dev. I am very familiar with it and its limitations/ugly corners. Familiarity breeding contempt and all that. That said, little contempt has arisen from my familiarity with Flask. It's that good.
Do we upvote these blog posts because we think they're constructive? This is somewhere on the order of a press release in depth. The farthest this post gets is in describing an app that uses hard-coded credentials to log an administrator in.
This doesn't demonstrate the strengths of Flask, nor the weaknesses, nor why it's necessarily better than Sinatra, Bottle, or any other micro web-framework.
Since this post has failed to do so, I'll fill in that gap as quickly as I can.
Flask is great because it scales to your needs. It starts as painlessly as any other micro web-framework, but what makes it nice is that it's so easy and clean to graft disparate ways of doing a web-app.
In my particular case, I'm in the process of building a service on Flask and MongoDB. I'm in the process of making Flask, WTForms, and MongoEngine all play nice together and Flask has done a wonderful job of making this painless because it doesn't make any bizarre assumptions and it doesn't force any strange contortions in my code like Sinatra or raw Rack apps do.
Having hacked on some Rack and Sinatra code, I can tell you right now that the moment you want to make a "real" app with the typical complexity of a mature service, even the bare basics get painful really fast.
Flask hasn't done this to me yet, it's already breezed well past where I've taken raw Rack and Sinatra+Rack apps before.
This blog post, however, does not come from experience. It does not attempt to explain why Flask is better than the alternatives, it doesn't even demonstrate any interesting aspects of Flask.
This is blogspam.
Please reconsider your upvotes, please reconsider promoting content like this again.
Popularity for popularity's sake in the absence of knowledge, experience, and data is simply "pop culture". (cf. Node.js)
Edit: Worse, the author even explicitly appeals to the quality of Flask on the basis of "branding".
Engineering decisions shouldn't be made on the basis of pop culture.
Choose Flask because you know it suits the problem you're solving well, or because you know it suits your style of programming.
Don't choose it because somebody showed you a "hello, world!" example.
I think this is a very valid point, and it comes up quite frequently in comparison of frameworks and libraries.
One example that was annoying me recently was in trying to select a Javascript client-side MVC (MVVM, etc.) framework for a single-page application.
The internet is full of people busily comparing, contrasting, arguing about, and recommending JS frameworks. Problem: 95% of them are doing so based on a < 100 line demo app, usually implementing a todo list, often which makes implausible simplifying assumptions. "Hm, that's nice, but check out the demo todo list app for MagicJS! It's 57 characters shorter, and the code forms the shape of a flower, and it would be quite easy to extend it to let you create new items!""
No real world app is going to be solved in < 100 lines[1], and while it's awesome to know that you've chosen a framework which can be used to create incredibly elegant < 100 line demo apps, what I really care about is how the framework works for large apps. Scale (in the sense of scaling up from the example code on the frameworks homepage to a real app that actually handles all the corner cases) matters HUGELY. And I don't think that gets nearly enough recognition.
(In fact, on this very thread, I see someone comparing a "hello world" app in Flask and Sinatra, and complaining about Flask's relative "verbosity". This is utter nonsense of the precise kind you've identified. Implement a calendar app in both that syncs with Google Calendar, and THEN compare line counts, and NOW you have a some feel for verbosity. Sinatra might win handily, but you can't tell that from a hello world app. Then again, off the top of my head, I can't think of one actually useful thing a hello world app can tell you about a framework.)
[1]: I'm speaking figuratively, obviously. Some of my proudest moments as a programmer have involved solving problems in just a couple. Sadly, this does not happen often. :)
phamilton|14 years ago
I imagine it's a limitation of Ruby vs Python for creating DSLs, but a basic Flask app just seems so verbose. It's like seeing "Hello World" in Java vs "Hello World" in a dynamic language like python or ruby.
psyklic|14 years ago
phamilton|14 years ago
The intention wasn't to diss Flask. It is a very concise and useful framework. All the comments apply to my original comparison.
really isn't much more verbose than yet every tutorial on a new language points out how frustrating it is for someone learning the language to type "public" "static" "void" "System" and other keywords/objects/modules without having any idea what they mean just to do something simple.In Flask I need to instantiate the Flask app, define a function to run and decorate it with a route. That raises all sorts of questions about what a decorator is (which for a casual pythonist may or may not be something they understand - I know my understanding of decorators is sketchy at best). Then I need to explicitly call app.run() somewhere.
In Sinatra, the DSL makes it much simpler. If I receive a "get '/'" request, then "do" the following stuff. "end".
Flask is very concise. No doubt about it. It's stripped down to it's very minimum. Yet Sinatra manages to be even simpler, which is impressive to me.
heretohelp|14 years ago
I hereby dub this the programmer equivalent of "sharp knees".
Explanation from the ever inimitable Urban Dictionary:
"A judgment leveled against an otherwise perfectly proportioned, if not slightly trim, and pleasant looking woman. Generally uttered by a male who is way below her class."
This comment is otherwise beneath a reasoned response.
heretohelp|14 years ago
Nota bene: I am a user of Flask and have been one for quite some time. I am incredibly fond of it and it has replaced Django for most things I do in web dev. I am very familiar with it and its limitations/ugly corners. Familiarity breeding contempt and all that. That said, little contempt has arisen from my familiarity with Flask. It's that good.
Do we upvote these blog posts because we think they're constructive? This is somewhere on the order of a press release in depth. The farthest this post gets is in describing an app that uses hard-coded credentials to log an administrator in.
This doesn't demonstrate the strengths of Flask, nor the weaknesses, nor why it's necessarily better than Sinatra, Bottle, or any other micro web-framework.
Since this post has failed to do so, I'll fill in that gap as quickly as I can.
Flask is great because it scales to your needs. It starts as painlessly as any other micro web-framework, but what makes it nice is that it's so easy and clean to graft disparate ways of doing a web-app.
In my particular case, I'm in the process of building a service on Flask and MongoDB. I'm in the process of making Flask, WTForms, and MongoEngine all play nice together and Flask has done a wonderful job of making this painless because it doesn't make any bizarre assumptions and it doesn't force any strange contortions in my code like Sinatra or raw Rack apps do.
Having hacked on some Rack and Sinatra code, I can tell you right now that the moment you want to make a "real" app with the typical complexity of a mature service, even the bare basics get painful really fast.
Flask hasn't done this to me yet, it's already breezed well past where I've taken raw Rack and Sinatra+Rack apps before.
This blog post, however, does not come from experience. It does not attempt to explain why Flask is better than the alternatives, it doesn't even demonstrate any interesting aspects of Flask.
This is blogspam.
Please reconsider your upvotes, please reconsider promoting content like this again.
Popularity for popularity's sake in the absence of knowledge, experience, and data is simply "pop culture". (cf. Node.js)
Edit: Worse, the author even explicitly appeals to the quality of Flask on the basis of "branding".
Engineering decisions shouldn't be made on the basis of pop culture.
Choose Flask because you know it suits the problem you're solving well, or because you know it suits your style of programming.
Don't choose it because somebody showed you a "hello, world!" example.
Lazare|14 years ago
One example that was annoying me recently was in trying to select a Javascript client-side MVC (MVVM, etc.) framework for a single-page application.
The internet is full of people busily comparing, contrasting, arguing about, and recommending JS frameworks. Problem: 95% of them are doing so based on a < 100 line demo app, usually implementing a todo list, often which makes implausible simplifying assumptions. "Hm, that's nice, but check out the demo todo list app for MagicJS! It's 57 characters shorter, and the code forms the shape of a flower, and it would be quite easy to extend it to let you create new items!""
No real world app is going to be solved in < 100 lines[1], and while it's awesome to know that you've chosen a framework which can be used to create incredibly elegant < 100 line demo apps, what I really care about is how the framework works for large apps. Scale (in the sense of scaling up from the example code on the frameworks homepage to a real app that actually handles all the corner cases) matters HUGELY. And I don't think that gets nearly enough recognition.
(In fact, on this very thread, I see someone comparing a "hello world" app in Flask and Sinatra, and complaining about Flask's relative "verbosity". This is utter nonsense of the precise kind you've identified. Implement a calendar app in both that syncs with Google Calendar, and THEN compare line counts, and NOW you have a some feel for verbosity. Sinatra might win handily, but you can't tell that from a hello world app. Then again, off the top of my head, I can't think of one actually useful thing a hello world app can tell you about a framework.)
[1]: I'm speaking figuratively, obviously. Some of my proudest moments as a programmer have involved solving problems in just a couple. Sadly, this does not happen often. :)
irrationalidiom|14 years ago
We are developing a web service with it, and as our project has grown we have had no problems moving from decorated functions to class based views.
We looked at Django but quickly realised that our service didnt need to be that heavy.
And because of its Flasks clear modularity, unit and functional testing things has been fairly easy.