I have seen zen and it is flask

The more I look at Flask the more I get a hard on.

because you have to write everything from scratch to do anything useful with it?


200px-Trollface.svg.png
 


All this talk about smaller, micro type frameworks has me looking into something to build more restful apps with.

I took a look at a few across python, ruby, and php and came up with this short list:

1. Slim, MicroMVC, Laravel - PHP
2. Merb, Sinatra, Camping - Ruby
3. Flask, Bottle, CherryPy - Python

I am going to try to make a simple rest api out of each ( mainly to learn ruby and python more ) and see which one I end up liking.
 
All this talk about smaller, micro type frameworks has me looking into something to build more restful apps with.

I took a look at a few across python, ruby, and php and came up with this short list:

1. Slim, MicroMVC, Laravel - PHP
2. Merb, Sinatra, Camping - Ruby
3. Flask, Bottle, CherryPy - Python

I am going to try to make a simple rest api out of each ( mainly to learn ruby and python more ) and see which one I end up liking.

pretty sure sinatra is the only ruby one still under active development.
 
because you have to write everything from scratch to do anything useful with it?

I know you be trolling but, no you don't. There are lots of useful plugins AND it gives you the ability to write anything from scratch or integrate something without getting in your way. That's the way it should be.

SQLAlchemy actually looks useful vs Djangos ORM (which I'm not very fond of).

I was able to get a small example app up in running in like an hour or two from 0 knowledge. Can't say I've had the same experience with Django.

28308841.jpg
 
( for dchuk ) ^^ yeah, I havent gotten knee deep into anything yet.. just culling my options. Some of these might not even be good choices for rest ( I noticed at least 2 that didnt have built in GET POST DELETE differences built in.
 
I know you be trolling but, no you don't. There are lots of useful plugins AND it gives you the ability to write anything from scratch or integrate something without getting in your way. That's the way it should be.

SQLAlchemy actually looks useful vs Djangos ORM (which I'm not very fond of).

I was able to get a small example app up in running in like an hour or two from 0 knowledge. Can't say I've had the same experience with Django.

28308841.jpg

so now you're using frameworks AND ORMs???

What strongly-argued-yet-incorrect programming opinion are you going to go back on next? My guess is using deployment automation instead of FTP.
 
so now you're using frameworks AND ORMs???

What strongly-argued-yet-incorrect programming opinion are you going to go back on next? My guess is using deployment automation instead of FTP.

I know shocking. Pretty sure I've made the thread that said I started using frameworks. I still don't think most frameworks are the "bees knees" per say, but they can be useful. I'm really not convinced that I create stuff really much or any faster. Although I guess that depends on the framework and how it's set up. If anything though, I feel like they keep more organized which is a good thing.

Flask actually seems like something that I can use to actually produce something easier and faster without getting bogged down in the finer sides of the framework documentation, while still allowing a lot of flexibility. How many frameworks give you that?

I don't regret my former views or take them back. I still think beginner programmers shouldn't use frameworks and I think they'll come out a better programmer because of it. I think you should learn what is going on under the framework magic. I work with other programmers on various projects and you can tell when they are using the framework as a crutch.
 
I think the most important thing a new programmer can do is to build awesome things because that is very motivating. That's why I recommend starting with frameworks, as they speed up development and help you build awesome stuff.

As you progress, you can start peeling back the layers and learning how everything works. I don't program for fun, fun for me is building products and cool shit, and programming is what allows me to do that.
 
I think the most important thing a new programmer can do is to build awesome things because that is very motivating. That's why I recommend starting with frameworks, as they speed up development and help you build awesome stuff.

As you progress, you can start peeling back the layers and learning how everything works. I don't program for fun, fun for me is building products and cool shit, and programming is what allows me to do that.

Yeah I donno, I see where you're going with that. To me, you can't really build something that cool if you don't understand what is going on underneath, instead you're locked in to what the framework makes easy for you.

Yeah it may seem like it's really cool at the time simply because it's new to you, but it'll probably be something relatively not cool and worthless. Rather than being forced to learn the material you're more likely to just tread water. I normally find in life doing things the hard and proper way are not only more rewarding, but prepare you more for the hard stuff. To each their own though.
 
The framework first plan didn't work for me. Didn't matter if I could hook up with a db and have a working crud in minutes. I didn't have the basics down in the beginning to peel back the layers. I'm the exact opposite on the reason for it all. The end product is anti climatic for me. Learning on the way is the reason I do it. Good thing I don't code for a living.

I just didn't get it and wasted time starting off with a framework. I back tracked to the basics of procedural then a better grasp of oop. It was only then that frameworks helped. A lot.
 
narrowed it down to:

Slim for PHP
Sinatra for Ruby
Flask for Python ( although bottle looks really simple ).

Here's some Sinatra + Active Record (ORM) + SQLite3 (DB) boilerplate.

Code:
Our initial file hierarchy
-- app/
   +-- Gemfile
   +-- Rakefile 
   +-- app.rb
   +-- config.ru

config.ru

Code:
require "./app"
run Sinatra::Application

Gemfile:

Code:
source :rubygems
gem "sinatra"
gem "sqlite3"
gem "activerecord"
gem "sinatra-activerecord"
group :development do
  gem "shotgun" # Development server that auto-reloads our environment
  gem "tux"       # Sinatra dev console
end

Rakefile:

Code:
# Rakefile
require "./app"
require "sinatra/activerecord/rake"

app.rb

Code:
require "sinatra"
require "sinatra/activerecord"
set :database, "sqlite3:///articles.db"

class Article < ActiveRecord::Base
end

get "/" do
  @articles = Article.all
  erb :index
end

__END__

@@ layout
<!DOCTYPE html>
<title>Gay Webmaster Forum</title>
<%= yield %>

@@ index
<h1>Articles</h1>
<ul>
<% @articles.each do |article| %>
  <li><%= article.title %></li>
<% end %>
</ul>

Bootstrap it:

Code:
$ bundle install
Gemfile locked

Let's see our rake tasks:
$ rake -T
rake db:migrate
rake db:rollback
rake db:create_migration NAME=some_name

Start the shotgun server:
$ shotgun
Listening on localhost:9393

Create Articles table:

Code:
$ rake db:create_migration NAME=create_articles
Generated file: db/migrate/201210201150_create_articles.rb

Fill in the migration:

Code:
class CreateArticles < ActiveRecord::Migration
  def change
    create_table :articles do |t|
      t.string :title
      t.text :body
      t.timestamps
    end
  end
end

Run it:

Code:
$ rake db:migrate
Articles table created

Verify in tux console:

Code:
$ tux

>> Article
Article(id: integer, title: string, body: text, created_at: datetime, updated_at: datetime)

>> 10.times { Article.create(title: "Testing", body: "Testing") }
>> Article.count
10

Oh, and here's all of the above except if you were using Rails:

$ rails new myapp
$ rails generate resource Article title body:text
$ rake db:migrate
$ echo "root to: 'articles#index'" > config/routes.rb
$ rails server
$ rails console