Friday, February 27, 2015

Netbeans 8 on 4k displays

Running Windows 8 (or 8.1) on a 4k display is pretty sweet once you get your settings right. Even the Metro apps run good on a 4k display.

The problem here is the 3rd party apps like Netbeans 8. They don't show right because of scaling issues. Fortunately is can be easily fixed by doing a bit of editing a text file.

In order for Netbeans 8 to display right in 4k resolution displays on Windows 8 you have to:

  1. Open for edit netbeans.conf file. It should be located at c:\Program Files\Netbeans 8.0\etc folder 
  2. Change -J-Dsun.java2d.dpiaware=true to -J-Dsun.java2d.dpiaware=false
And we should be set.

Monday, February 9, 2015

Stop asking me which one: Flask vs Web.py

I'm writing this entry because I've been asked the same question at events and on the internet too many times: "Which one to use, flask vs web.py?" I'm also doing this to clarify my reasons on why I like Flask better than web.py.

Disclaimer: this is more of an personal opinion rather than a more true technical comparison.

Flask and Web.py are these Python micro-architectures for building web sites and applications. Django is also a Python framework for building websites but it's whale huge so Django is out.

Age
The age of the framework matters because it helps you "find stuff" for it; find stuff, I mean like StackOverflow pages, blog entries, github projects and such. Also it makes for a good chance that someone already has solved your problem and was good enough to post it somewhere on the web.

Web.py is older and Flask is a bit more recent.

I like new.

Code-wise
Programmers and coders eventually develop a particular "taste" on how to write or organize code. This is another bias of mine because I prefer how Flask's code looks vs Web.py's.

Let's take both framework's "hello world" examples.

This is Flask's way:

from flask import Flask
app = Flask(__name__)

@app.route("/")
def hello():
    return "Hello World!"

if __name__ == "__main__":
    app.run()

This is Web.py's way:

import web
        
urls = (
    '/(.*)', 'hello'
)
app = web.application(urls, globals())

class hello:        
    def GET(self, name):
        if not name: 
            name = 'World'
        return 'Hello, ' + name + '!'

if __name__ == "__main__":
    app.run()

I like annotations better than route lists but that's just me.

Use cases
I have a pretty simple use case because I only run these things in a Google app engine instance. Both flask and web.py are supported by GAE.

Here's a flask starter for GAE and here's the web.py cook book page for GAE.

I still like Flask.

In the end
Personally, I think the question is relatively moot since both micro-frameworks do roughly the same thing. Although, web.py is older it is still actively developed and it's community is still ticking. Flask is newer but it's still a bit rough around the edges.

I'm a Flask kind of guy.