Nando Florestan http://dev.nando.audio/ Python, javascript, HTML5, classical music etc. en-us Sat, 12 Jul 2014 00:00:00 +0000 http://dev.nando.audio/2014/07/12/i_am_creating_a_music_score_editor_in_python.html http://dev.nando.audio/2014/07/12/i_am_creating_a_music_score_editor_in_python.html <![CDATA[I am developing a music score editor in Python]]>

I am developing a music score editor in Python

In January 2014 I started a formidable project: I am writing sheet music editing software. I feel I am very qualified to do so because I am a musician, a composer who knows a lot about music notation, a good software developer, I always put myself in the user’s shoes and I have been using music software for 24 years, having accumulated a little list of wishes that have never been granted by Finale, Encore, Overture, Sibelius, Notion etc.

In fact, the project grew out of my dissatisfaction with all these existing programs. As a composer, I feel using their software is frequently uncomfortable. Even Sibelius, the most user-friendly of them all. Maybe the result of my efforts will be a little more comfortable to use.

Each of these programs has their own set of problems...

  • Finale is powerful but unfriendly, it couldn’t be used for composition.
  • Encore had the best GUI during the 90s but today it is seriously outdated; its (re)positioning bugs have never been fixed and the user interface is still based on toolbars.
  • Overture, which was once the successor of Encore (same author), hasn’t seen a release in years.
  • Sibelius is powerful and user-friendly but in July 2012 Avid fired the original development team, so it might be dying too.
  • Notion is the new kid on the block, it has the best playback features but also the worst notation abilities, you can’t change the keyboard shortcuts and anything you do requires a mouse click.
  • The only open source solution worth mentioning, MuseScore, has quite a few bugs, very basic playback features and bad spacing problems (collisions happen between staves and the user is required to insert a “spacer” item, this is such a bad idea)...

All these programs were written in C++. I am creating mine in the Python language, such that the result will be hackable by its users. They will be more able to scratch their itches.

But the problem is that the scope of the project is so daunting. I have a huge backlog of features I need to implement before my solution can compete. I estimate the entire project will take 2 man-years before it can be useful to anyone. It is July already and I have been able to work on this project for only 2 man-months, so there are 22 to go. When I think about this, I feel I am a little crazy for even having started it. If I give up, I will have wasted X months of my life and nobody will ever have had any use for any of it.

After 2 man-months of work, what do I have? My program reads scores created in other programs in the MusicXML interchange format and puts the score in memory. (Representing music in the computer memory poses intimidating problems by itself.) It also shows a subset of the music symbols on the screen. You can zoom in and out, you can cycle through a few color themes and you can change the title of the piece. Undo and redo have been implemented and there’s a neat framework that will be used for every user command. Many keyboard shortcuts have been planned and placed in a configuration file so the user can change any of them if she wishes to. A music cursor already exists that travels through all notes in the piece. But you still cannot add, change or delete a single note. And there is so much still not shown on the screen... There are no beams, no slurs, no articulations, no dynamic markings etc.

Alpha version of my music editor

Screenshot of an alpha version of my music editor showing a test of clusters

This is because music notation is very complex. Simply displaying it on screen is very hard. If you are a musician, can you articulate the rules to display clusters of notes? Questions of spacing have to be faced... In my software, from day zero, the collisions (between music signs) that plagued this kind of software for years and years, making users drag symbols all the time... these placement problems are considered bugs with the greatest priority. Nobody wants to be fixing these manually, the program must get this right without any human help!

If this project is so hard even today, I can imagine what the Finale developers accomplished back in 1988 ― such software did not yet exist. Respect goes out to them, deep respect. Today I have open music fonts that I can use, the Python language and the Qt framework which do so much of the work for me, especially concerning graphics. Even creating PDF files probably won’t be much different than showing the stuff on the screen, thanks to Qt.

Obviously I should not be doing this alone. This post is a sort of call for help, as there are some kinds of help I could use:

  • Help making the project financially viable. I haven’t found an investor. Here in Brazil, crowdfunding websites such as catarse.me exist but are less successful than in, say, the U. S. Kickstarter itself is not available here. Also, I am a very technical person, I don’t like my business abilities.
  • Help programming. The software is being written in the high-level Python 3.4 language, which is proving to be a very good choice because it is so expressive and easy to read. Performance is fine so far even without any optimization. For the GUI I am using Qt through Pyside. Playback features are deferred to the end of the backlog, but it wouldn’t hurt to have someone get started on them. I have ideas (to do things differently from the competition) in many subjects, including playback.
  • When the time comes, help testing the application will be very appreciated.

I have dreamed of writing this software for decades. In my dreams it would always be open source. But right now I don’t see how open source could ever repay such an effort. I need to be adequately compensated for this work. This will probably be cheap software, but not (immediately) open source ― even though I like free software so much.

Can you help? Any messages about the project are very welcome!

]]>
Sat, 12 Jul 2014 00:00:00 +0000
http://dev.nando.audio/2014/04/04/why_i_sort_of_dislike_django.html http://dev.nando.audio/2014/04/04/why_i_sort_of_dislike_django.html <![CDATA[Why I sort of dislike Django]]>

Why I sort of dislike Django

Here is my opinion on Python web frameworks.

Pyramid is currently the best choice because:

  • It is full-featured, with a very well-defined scope as a web framework and a really careful implementation of all the right choices, organized by this little genius called Chris McDonough over literally years of dedicated development.
  • Routes are decoupled from request handlers, while offering both URL dispatch and tree traversal.
  • Because template rendering is a separate step, view handlers can be easily unit tested. The test case can see the dictionary that a view handler returns. In other frameworks you have to inspect the returned HTML :(
  • You can use whatever templating languages you want, including Genshi, Kajiki, Chameleon, Mako, Jinja2 etc.
  • You can use whatever you want as a database, including SQLAlchemy, the most powerful Python ORM.
  • It has a great authentication and authorization framework which is independent of your choices for data persistence.
  • It makes your project an independent Python package, teaching you to use standard Python packaging tools for your benefit.
  • It has the best scheme for reusing existing projects, since you can overload templates and views as you integrate another Pyramid site into yours. For an example, see horus, a Pyramid pluggable authentication app using SQLAlchemy.
  • It avoids the global variables and threadlocal variables that other web frameworks, such as Flask, like to use, thinking they will be convenient, until they make some things impossible.
  • It is thoroughly documented and has a great community with a great IRC channel and a great mailing list.

The only drawbacks of Pyramid might be:

  • Because you can choose everything (templating language, ORM etc.), it might take longer to get a project started than if you pick, say, Django. (But the advantages of choosing your libraries, such as deform, compensate for this.)
  • Pyramid takes time to learn properly. You have to read the documentation and practise for a while.

Let’s compare this to Django. The advantages of using Django today might be:

  • It is old and well-established.
  • It has by far the largest community of all web frameworks in Python.
  • Very quick to get started because everything has been chosen for you, including templating language and an ORM (even if you don’t want or need an ORM).
  • Therefore, there are many existing reusable applications developed in it. These apps tend to work well together because they use the same stack.
  • Its web form stuff is really good. (Although not so powerful as deform.)
  • Great documentation.

The disadvantages of Django are:

  • It is old and needs to maintain backwards compatibility, so it evolves slowly.
  • Its daft templating language is severely and deliberately handicapped. It goes to great lengths to prevent you, the developer, from putting logic in a template ― it even forbids you from calling a Python function from the template. Then, in order to remedy this, it allows you to implement a filter, which is nothing more than a way to call a function. What could be more retarded? The syntax of this templating language is also too verbose. On the plus side, many people use Jinja2 instead, which has the same bad syntax, but lets you call functions and works very well.
  • People are impressed by the admin, but it really isn’t important at all for development. Other frameworks, being less tightly integrated, cannot offer an admin that would work for everybody. Again, this is of no consequence for real world development.
  • Its ORM, created before SQLAlchemy existed, is now much inferior to SQLAlchemy. It is less flexible, its API is less well thought out, and it is based on the Active Record pattern which is worse than the Unit of Work pattern adopted by SQLAlchemy. This means, in Django, models can “save” themselves and transactions are off by default, they are an afterthought. In SQLAlchemy, one thinks in transactional terms from the start. This talk explains this better.
  • Model relationships have ON DELETE CASCADE by default, which is a poor choice because it is not safe ― one might lose data because of this. The default should be safe, and the programmer would declare the cascade when applicable. To avoid cascading, one needs to write on_delete=models.PROTECT in each ForeignKey.
  • Models can have no mixins ― only simple inheritance. Less powerful than SQLAlchemy.
  • Many projects don’t access a database, but there is no way to turn off the ORM, you even have to configure it.
  • Django enthusiasts sometimes boast that Django is a single package. Don’t they realize this is actually a bad thing? Django is a tangled monolithic piece of software. The fewer dependencies you have, the more code you have to write yourself. Django is in fact a bad case of Not Invented Here syndrome. Django by itself does not encourage anyone to learn and use standard Python packaging tools.
  • Django solved the problem of route definition by using regular expressions; now they have 2 problems. This is jurassic next to the sophisticated dispatch in Pyramid...
  • Class-based views. Oh, Django devs have really shot themselves in the foot here, soon they are going to be very sorry. Why? Well, please read Pylons creator Ben Bangert’s blog post titled Why Extending Through Subclassing (a framework’s classes) is a Bad Idea. Looks like Django devs weren’t paying attention to Pylons’ mistakes when they came up with their own class-based views! These are extended through inheritance, which will make everyone’s life complicated in subsequent versions. No separation between the framework’s API and implementation has been indicated. (This separation, by the way, is always in the mind of the Pyramid developers.)
  • Class-based views, again, for a different reason. If you ever want to subclass one of them, to change their behaviour slightly, you will be in pain. This is because they themselves are a deep hierarchy of subclasses. Too deep. So you read about 10 classes trying to figure out where you should interfere. This is such a big problem for every Django user who likes class-based views, that an entire website was created to help understand them: http://ccbv.co.uk ― the very existence of which should be seen as a red flag.

Advantages of Flask:

  • Gets you started quickly, if the job is simple.

Disadvantages of Flask:

  • Suffers from thread local variables everywhere.
  • Severely incomplete documentation that seems to only explain something to someone who already knows it.
  • Blueprints are simple overengineering.
  • Plugin greed: Flask enthusiasts may want everything in the system to be a Flask plugin, which is just plain bad software architecture.

What advantages do I see in Google App Engine?

  • Only one: Auto-scaling.

Disadvantages?

  • First off, the web framework of Google App Engine is very poorly organized. Some libraries are offered by default, you turn them on via configuration. Then you have to provide other libraries alongside your own project. There is no clean separation, no safe place to put them. You cannot use standand Python packaging tools. Let’s just say this: Guido, I expected more of you...
  • The documentation is laughable. Very unhelpful.
  • Google folks don’t seem to value an appengine-enabled Python interpreter for the developer to try things out. In order to obtain an ipython shell you have to resort to a tremendous hack that includes adding several directories to sys.path.
  • Often, interesting subprojects appear, then their bugs are never ironed out and the projects are discontinued by Google because nobody uses them.
  • Lock-in. Develop for the Google App Engine and you can only deploy there.

What advantages do I see in web2py?

  • Not one.

Disadvantages?

  • Its pypi description starts thus: “Everything in one package with no dependencies.” An even more extreme case of Not Invented Here than Django! At least Django was one of the very first web frameworks developed in Python. web2py is much newer. When it was created, SQLAlchemy already existed, along with many libraries that could have been reused...
  • web2py does not offer an ORM (object-relational mapper), only a DAL (data access layer). It boasts this as a great advantage (it’s not a bug, it’s a feature?). By the way, SQLAlchemy has 2 layers: its ORM is based on its DAL, and you can use the one you prefer.
  • I didn’t familiarize myself with web2py after seeing this, but I don’t suppose I am missing much.
]]>
Fri, 04 Apr 2014 00:00:00 +0000
http://dev.nando.audio/2014/04/01/large_apps_with_sqlalchemy__architecture.html http://dev.nando.audio/2014/04/01/large_apps_with_sqlalchemy__architecture.html <![CDATA[Large web apps in Python: A good architecture]]>

Large web apps in Python: A good architecture

If you are setting out to write a large application in Python using a relational database, this long post is for you. Herein I share some experience acquired over 6 months while writing large applications that use SQLAlchemy (the most advanced ORM available for the Python language) in a large team.

To be honest, I think this post might be too convoluted, trying to teach too many things at once. But it is really trying to show how multiple aspects converge to fail together.

The dangers ahead

It would be near impossible to explain all the reasons for the bad software I have seen, but it is safe to say they result from the interplay of some forces:

  • haste
  • suboptimal technological choices
  • the fact that SQLAlchemy requires a few weeks of study before a developer can use it wisely
  • lack of a better overall architecture than MVC
  • inconsistent understanding of MVC among developers
  • developers who don’t yet realize that test automation should inform the way the main code is factored
  • the need to practice TDD (Test Driven Development), which means, write your unit test first
  • the deleterious effect that a relational database can have on the speed of one’s test suite
  • the need to learn what unit tests really are: some devs write integration tests thinking they are unit tests

I will talk about all of these forces, their relationships and some solutions.

Haste is bad... Don’t hurry... Mkay?

Unless the software is to be extremely short-lived, it never pays off to write it in a hurry. Creating software takes time, research, learning, experimentation, refactoring and testing. Every concession you make to haste will have nasty repercussions for sure. But don’t believe me; suffer these yourself ― everyone does.

Carefully pick your frameworks

The recommendations contained in this section stand as of April 2014.

When writing large applications, one should choose tools more carefully. Don’t just go the quickest path. For instance, it pays off to choose a more complex web framework such as the full-featured, beautifully designed and thoroughly documented Pyramid, which shows a better defined scope and superior decoupling, than something like Flask, which gets small jobs done more quickly, but suffers from thread local variables everywhere, incomplete documentation that seems to only explain something to someone who already knows it, and plugin greed (Flask enthusiasts may want everything in the system to be a Flask plugin).

You will be tempted to choose Django. Its single advantage is its community size. But it suffers from age and the need for backwards compatibility. Django had to create its own ORM (SQLAlchemy didn’t exist then) which is much worse than SQLAlchemy. Also, if you only know Django, you are likely to have a misconception of the importance of SQLAlchemy. You see, the Django ORM follows the Active Record pattern, while SQLAlchemy adheres to the completely different Unit of Work pattern. It might take you some time to understand the session and the lack of a save() method on your models. This talk helps with that. Finally, Django’s templating engine is severely (and deliberately) handicapped; Genshi, for instance, is much, much richer in features.

Django is also monolithic (as in Not Invented Here syndrome) ― a design trait that flies in the face of everything I say below ― and you see people boasting that Django is a single package, as if this were a good thing. Often they avoid using the package management tools in Python and that is just silly. Many things in Django are just silly...

Now, SQLAlchemy is so advanced in comparison to all the other ORMs in the Python world that it is safe to say, if you are accessing a relational database through anything else, you are missing out. This is why you should not choose the web2py web framework, either. It does not have an ORM, just a simple DAL to generate SQL.

(Since I have already recommended Pyramid and SQLAlchemy, why not a word about form validation toolkits? Since the ancient FormEncode, many libraries have been created for this purpose, such as WTForms and ToscaWidgets. I will just say that you owe it to yourself to try out the Deform and Colander combination – they have unique features, such as the conversion of data to a Python structure, and the separation of schema (Colander) from widgets (Deform), that really get it right. This architectural clarity results in a much more powerful package than the competition. But again, it will be necessary to spend a little more time learning how to use these tools. The learning curve of the competition might be less steep, but you can suffer more later on.)

MVC is not enough for a large project

You probably know the MVC (model, view, controller) architecture as applied to web development. (If you don’t, you are not ready to create a large application yet: go make a small one first, using an MVC framework, and come back to this post in a few months. Or years.)

Strictly speaking, MVC is an ancient concept, from early Smalltalk days, that doesn’t really apply to web development. The Django folks have correctly understood that in Python we actually practise MTV (model, template, view):

  • The template contains HTML content and presentation logic. It is written in a templating language such as Kajiki. It gets data from the view and outputs a web page.
  • The view (also sometimes called “controller”), written in Python, is just glue code. It uses the web framework to put everything together. It can see all the other layers. It defines URLs, maps them to functions which receive data from the web framework and use the other layers to finally answer back to the web framework. It should be kept small, because the code in it is not very reusable. Even if you keep it lean, web forms tend to make it complex.
  • The model layer is essentially a persistence layer: its most important dependency is SQLAlchemy. The model knows how to save the data, constituting the most reusable code in the entire project. It certainly does not know anything about HTTP or your web framework. It represents the essence of your system without the details of a user interface.

But wait. Where? In the view or in the model? Where should you put the soul of your project: the business rules? The template layer is automatically out because it is not written in Python. So 3 possible answers remain:

  • The view. This is the worst choice. The view should contain only glue code, should be kept thin, and should isolate the web framework from the rest of your system, so the system can be reached independently of the web framework, in usage and in unit testing. Also, business logic should reside in a more reusable place. The view layer is considered a part of the presentation logic, so business logic is out of there. Indeed, to create a desktop UI in addition to the web UI, one would ignore views and HTTP and need business rules to be reusable ― therefore, out of the view layer.
  • The model. This is slightly preferrable, because at least the model is a reusable layer. But the model should focus on persistence, it should depend on little more than SQLAlchemy (which is already a complex beast).
  • A new layer. This is the correct answer. Let us understand this better through an example below.

MTV certainly is all you need to create a blog. But for more complex projects, there is at least one layer missing there. I mean, you need to remove the business logic from where it stands and put it in a new, reusable layer, which most people call a “Service” layer, but I like to call “Action” layer.

Why do you need that?

In larger applications, it is common for a single user action to cause multiple activities. Suppose, for instance, the user successfully signs up for your service. Your business rules might want to trigger many processes as a consequence:

  • Create data in multiple tables of the relational database, using the models.
  • Enqueue a task that will send an email to the user.
  • Enqueue a task that will send an SMS to the user’s phone.
  • Enqueue a task that will create space and other resources in preparation for actual use of the service.
  • Enqueue a task that will update user statistics.
  • ...

This is a good example of what we understand by a “business rule”: Given a user action (e. g. sign up), these are the activities the system must perform. This business rule had better be captured in a single function; in which layer should this function go?

If all this were implemented in a model, can you imagine how complex it would be? Models are hard enough when they focus only on persistence. Now imagine a model doing all that stuff, too. How many external services does it have to consume? How many imports are there at the top of the file? Don’t some of those modules, in turn, want to import this model, too, creating a cyclic dependency that crashes the system before it starts?

A circular dependency alone is a clear sign that you aren’t seeing your architecture properly.

It simply isn’t clean for a model to depend on Celery, to know how to send emails and SMS and consume external services etc. Persistence is a complex enough subject for the model to handle. You need to capture many of these business rules outside of the model – in a layer that stands between the model and the view. So let’s call it the “Action” layer.

Also remember that a model usually maps to a single table in the relational database. If you are at once inserting a User and a Subscription, which of these 2 models should contain the above logic? It is almost impossible to decide. This is because the set of activities being performed is much larger than either the User’s concerns or the Subscription’s concerns. Therefore, this business rule should be defined outside of either model.

When a dev is performing maintenance, sometimes she wants to run each of these steps manually; other times she will execute the whole action. It helps her to have these activities implemented separately and called from a single Action function.

You might wonder if what I am proposing isn’t really an instance of an antipattern called Anemic Domain Model. Models without behaviour are just contrary to object-oriented design! I am not saying “remove all methods from your models”, but I am saying “move away methods that need external services”. A method that finds in a model all the data that it needs... really wants to belong to that model. A method that looks out to the world, consumes external services and barely looks into self... has been misplaced in the model.

Another reason that makes this a successful architecture is testing. TDD teaches a programmer to keep things decoupled and it always results in better software. If you have to set up a Celery application and who knows what other external services before you can test your model, you are going to be frequently in pain.

There is a final reason to keep business rules outside the view layer. In the future, when you finally decide it’s time to switch from Flask to Pyramid, you will be glad that your views are as thin as possible. If all your view does is deal with the web framework and call a couple methods on your Action layer, it is doing one job (as should be) and code is properly isolated. Web frameworks can be greedy; don’t let them have their way with your system.

So here are the layers I propose for a typical large application in Python:

  • Model is the lowest, most reusable, most visible layer. It focuses solely on persistence. It is all right for a model to contain behaviour, as long as this behaviour pertains only to this model and not to other things. Models can be returned by each layer, all the way to the template at the end of a request.
  • External services. Make one of these for each service such as sending email.
  • Action. This layer is the core of your system. It contains business rules and workflows. It uses the external services to achieve certain goals and uses the models to persist data. With the above layers, it constitutes the whole system, including configuration, except for the user interface.
  • Template. This layer only contains presentation logic such as looping through a list to output an HTML table.
  • View. It is the highest, least reusable, layer. It depends on (and isolates from the rest of the system) the web framework. It depends on (and isolates from the rest of the system) the form validation library. It can see the Template and Action layers. It cannot call a Model directly ― it must go through an Action. But when an Action returns models, these can be passed on to the template. (A Celery task is analogous to a web view.)

This architecture helps avoid heroic debugging sessions insofar as it clearly defines responsibilities. It is also eminently testable because it is more decoupled, thus requiring less test setup and fewer test mocks and stubs.

Good architecture is all about decoupling things. If you ever catch yourself trying to resolve a cyclic dependency, rest assured you haven’t thought well about the responsibilities of your layers. When you see yourself giving up and importing something inside a function, know that your architecture has failed.

It also goes without saying that your web app should be kept separate from your Celery (tasks) app. There can be code reuse between them ― especially models ― but there is no reason for a Celery app to ever import the web framework! Obtaining configuration is no exception. Reading configuration is easy in Python.

Automated testing is a mighty challenge, too

Python is a very flexible, expressive, reflexive language. A down side of its dynamism is that it catches fewer errors at “compile time”. One wouldn’t create large systems in Java without automated testing today; even less so in Python.

You start writing tests as soon as you realize their importance towards your confidence in the software. You understand this and you start writing them. The first tests you write have enormous value. They give you an incredible boost in confidence in your system. You are having fun.

However, soon your tests start feeling more like a burden. You now have hundreds of tests and the test suite takes forever to run ― minutes, even. In this sense, each new test you write makes your life worse. At this point, some might become disenchanted and conclude testing isn’t worth it. A premature conclusion.

You thought you knew how to write tests. But in your naiveté, you have been writing all integration tests. You call them unit tests, but they really aren’t. Each test goes through almost the whole stack in your system. You put your mocks at the most remote points possible. You thought this was good (it was testing more this way). Now you start to see this isn’t good.

A unit test is the opposite. A real unit test is focused like a laser. It executes only one function of one layer, it uses mocks to prevent descent into other layers, it never accesses external resources, it asserts only one condition, and it is lightning fast.

To add insult to injury, when your tests do their job ― showing you that you messed up ― they are a nuisance. Instead of a single focused failed unit test showing you exactly where you did something wrong, you have dozens of integration tests failing (all of them for the same reason, because they all go through the same code) but it takes you a long time to figure out where the bug really is. You still need some heroic debugging. You need to learn to write better tests!

Experts recommend you write 99% of real, focused, mocked, sniper, unit tests. And only 1% of all-layers-encompassing integration tests. If you had done so from the start, your unit test suite would still be running in only a couple seconds, which is required for TDD to be feasible. If a unit test is not instantaneous (less than 10 milliseconds for sure), it’s really some other kind of test, but not a unit test.

If this were a small application, you could still get away with your sluggish integration tests. But we are talking about large applications, remember? In this context, the reality is, you either optimize your tests performance, or you cannot practise TDD!

Also, as you can remember, some tests have been difficult to write. They required too much work to set up. (Integration tests tend to.) Someone explains this is because your tests aren’t really unit tests and you aren’t doing Test First – you are writing tests to existing code that wasn’t written with sufficient decoupling that it would be easily testable. Here you start to see how TDD really changes not only the tests, but your actual system, for the better.

Watch these talks about test writing.

To find out which are your 2 slowest tests, run this command:

py.test -s --tb=native -x --durations 2

SQLAlchemy and testing

But the system uses SQLAlchemy! Data travels between layers in the form of model instances. A database query is performed and boom, you are already over the 10ms limit. This forces you to conclude: if it hits the database, it is not a unit test. (It is instantaneous to instantiate a SQLAlchemy model, but it is expensive to talk to SQLite, even if it is in memory.) Yeah, TDD will force you to keep queries, session.flush() and session.commit() outside of a function suitable for unit testing!

You still need to write a few integration tests anyway. They test the contracts between the layers and catch bugs that unit tests don’t catch. For integration tests, John Anderson has a good approach: Use SQLAlchemy, but never allow the transaction to be committed. At the end of each test, do a session.rollback() so the next test can run without the database having been changed. This way you don’t need to recreate tables for each test you run.

To make that possible, you can’t be committing the session all over the place. It is probably best to stipulate a rule: the system can only call session.commit() in the outermost layer possible. This means the web view or the Celery task. Don’t commit in the Model layer! Don’t commit in the Action layer!

This creates a final problem: How do I write a unit test for a task, if the task commits the transaction? I need a way for the test to call the task saying: exceptionally, just this once (because this is a test), please don’t commit. Otherwise the unit test would hit the database server and exceed the maximum of 10 milliseconds.

I finally came up with a mechanism to give an external function (e. g. a test case) control over whether the transaction is to be committed or not. With this scheme, a task commits the transaction by default, but allows a test to tell it not to commit. You are welcome to the following code:

from functools import wraps

def transaction(fn):
    '''Decorator that encloses the decorated function in a DB transaction.
    The decorated function does not need to session.commit(). Usage::

        @transaction
        def my_function():  # (...)

    If any exception is raised from this function, the session is rewinded.

    But if you pass ``persist=None`` when calling your decorated function,
    the session is neither committed nor rewinded. This is great for tests
    because you are still in the transaction when asserting the result.

    If you pass ``persist=False``, the session is always rewinded.

    The default is ``persist=True``, meaning yes, commit the transaction.
    '''
    @wraps(fn)
    def wrapper(*a, **kw):
        persist = kw.pop('persist', True)
        try:
            fn(*a, **kw)
        except:
            db.session.rollback()
            raise
        else:
            if persist is False:
                db.session.rollback()
            elif persist is True:
                db.session.commit()
    return wrapper

This post is dedicated to my friend Luiz Honda who taught me most of it all.

]]>
Tue, 01 Apr 2014 00:00:00 +0000
http://dev.nando.audio/2012/11/26/o_monstro.html http://dev.nando.audio/2012/11/26/o_monstro.html <![CDATA[O Monstro]]>

O Monstro

― Acho que hoje ele não vem. Já está tarde ― disse vovô, esperançoso.

Olhei para trás: os olhinhos castanhos de meu priminho Vit ostentavam sua diversão. Como gostávamos de brincar de espião! Fiz sinal de silêncio com a maior veemência.

― Ele sempre vem no início do mês. Pode tardar, mas não tem misericórdia ― soluçou vovó.

― Arre, mulher! É por isso que nada de bom acontece nesta casa! ― bufou vovô roucamente.

Estiquei a cabeça para além da quina do armário. Suas feições graves não me encontraram.

Titia surgiu do quintal limpando as mãos. Escondi-me de novo. ― Mas ela tem razão ― contemporizou. ― Ficando aqui, estamos sujeitos a essa desgraça!

― O que não tem remédio... ― grunhiu vovô, aproximando-se. ― Isso não tem remédio!

Disparamos na direção da entrada da casa com estardalhaço. Vit continuou brincando como se não tivesse escutado nada. Eu era maior e não sei se entendia mais, mas a conversa me deixara um pouco preocupado.

― Crianças, não saiam! ― gritou vovó, lá da cozinha.

Esgueirando-nos pelos cantos, chegamos à janela da frente. Olhamos para fora com cuidado para não sermos detectados, pois restava uma pitada de crepúsculo. Ventava muito: a árvore do outro lado da rua parecia tentar desprender-se do chão. Meus pensamentos foram interrompidos por um estalo medonho, seguido de um trovão, que arregalou os olhinhos do meu primo de susto ― e eu mesmo tive um arrepio, que o raio deve ter caído bem ao lado da casa. Em seguida desabou uma chuva de granizo, a qual assistimos da janela.

Um carro ― lembro que era grande e escuro ― parou em frente à nossa casa. Um minuto depois, desceu uma enorme figura oculta numa capa de chuva bege. Enquanto fechava a porta, pensei ter avistado... o quê? Pelo?

Vit riu baixinho e me puxou para baixo. Empurrei-o ― tinha que olhar ― algo não estava certo.

O vulto dirigiu-se à casa da frente. Segundos depois, abriram e ele entrou.

― É um mon ― começou Vit, mas tapei sua boca, pois nesse momento pude discernir gritos vindo da casa da frente, mesmo sob a chuva. O alarido durou alguns segundos, o que era? Consternação? Pavor? Meu mal-estar só aumentava.

A chuva agora estava mais fraca. A porta se abriu e o vulto veio direto para a nossa casa. A cada passo, um pesado estalido. Vit apertou meu braço com aflição. Arrependi-me de fitá-lo, pois ele detectou o medo nos meus olhos. A campainha soou dura: de um pulo, puxei meu primo para trás da cortina, de onde assistimos o resto da hedionda cena.

Vovô veio da cozinha com um olhar de profundo desgosto. ― Não abra ― instou vovó, mas ele a ignorou e escancarou a porta de uma vez só. E junto com a chuva, aquela voz odiosa entrou na casa:

― O aluguel atrasado, senhores.

]]>
Mon, 26 Nov 2012 00:00:00 +0000
http://dev.nando.audio/2012/09/14/organizing_a_classical_music_collection.html http://dev.nando.audio/2012/09/14/organizing_a_classical_music_collection.html <![CDATA[Organizing a classical music collection: the Composer tag]]>

Organizing a classical music collection: the Composer tag

If you are into classical music, you know how hard it is to organize your audio files.

The most important problem is lack of support for the “Composer” tag in music player software. For a while, this led me to the idea of reusing the mainstream “artist” tag to contain composer information. But then performer information must go into other tags such as “Album” or “Comment”.

The advantage of this approach is that it works with any and all music players.

But it has many disadvantages. First of all, tagging your music becomes an endless nightmare: no tagging software I have encountered out there does it this way, so basically you would have to make corrections manually. Forever. Remember that your are files always coming from many different sources, so you would have to keep track of which files have already been converted to your system.

Also, this kind of reasoning is just conceptually wrong. Though the idea of the “artist” in music is a wrong concept by itself, what it really means in practice is “performer”. If you start abusing concepts you end up with nightmares as repulsive as this system:

http://musicbrainz.org/doc/ClassicalStyleGuide

No solution could be less correct in data normalization terms...

Finally I found it easier to just use the correct tags. Use the “Composer” tag for the composer. The disadvantage is, you have to work harder to find software that supports it. But it is not impossible. Apple products support the “composer” tag. On a PC (Windows or Linux) one can use powerful music players such as Amarok which fully supports the “composer” tag. (On Ubuntu Linux, you just type sudo apt-get install amarok.)

What about my phone? I’ve been unable to find an Android music player with support for the “composer” field. I did find hints on the web and tried a few players, but the tips were written years ago and apparently the newer versions do not support the “composer” tag anymore.

Since phones are unable to carry that much music anyway, I intend to just use any directory-based player. What’s important is that my collection will be correct and give me less of a headache.

Summing up, I have 2 pieces of advice:

  • Use the “composer” field: use the correct tags and spend some time to find software that supports them. Such software deserves to be preferred.
  • Regardless of tagging, keep your collection well organized in terms of directories.
]]>
Fri, 14 Sep 2012 00:00:00 +0000
http://dev.nando.audio/2012/08/18/war_horse.html http://dev.nando.audio/2012/08/18/war_horse.html <![CDATA[So you are going to watch "War Horse"]]>

So you are going to watch “War Horse”

So you are going to watch War Horse, Spielberg’s movie of 2011. Here is what you need to know. (No spoilers here, this is safe to read.)

This is a traditional movie in many ways. But which traditions? Well, you are going to see a (non-satirical) picaresque fictional story about a horse in First World War times, derived from a book for children.

So the foremost tradition is that of the horse movie. You get everything you would expect: themes of friendship between a youngen and a special horse who is one of the most important characters, stunning visuals that only nature and animals can provide, gallops, adventure etc.

Because the horse is perhaps the main character, he is going to suffer. Be prepared for this. However, it’s all in good taste.

Now remember the story has something of a picaresque quality, without really belonging to this genre. To me this means the hero goes through adventures in different places during his life, and whether characters reappear later is anyone’s guess. These episodes may sometimes seem a bit disconnected from each other, however this is part of the wonder, you would exclaim: “what an interesting life”! And I have to say, this falls quite nicely upon a traditional horse movie character who would like his freedom.

So if the plot is sometimes stretched, well, in my opinion this is just part of the genre. There is no satire though.

The First World War is the circumstance that keeps these episodes together. But this is only a war movie to the extent of old, traditional war movies. I mean, this isn’t a remake of Private Ryan, gore isn’t the focus. This isn’t an ultra-realistic movie in any way and Spielberg has been able to mix these 2 genres (war and horse) in a tasteful way.

I guess I mean to say, there is war in the movie, but it isn’t exactly a war movie, it isn’t focused in showing the raw horrors of war, and if it were, you might care that much less about the horse. You gotta like the horse, otherwise the movie won’t make sense! And I understand this is true, that horses did indeed suffer in that war.

The fact that the Germans speak English put some people off; they wanted to see subtitles. I guess they were expecting a contemporary war movie. But remember that children are to be included in this audience... I, for one, felt it refreshing to see raw realism – which would be pointless here anyway – give way to a more direct way to tell the story. This looks back to old war movies, in which foreign characters might speak their own languages a bit for effect, but not when you really had to understand what they were saying. In many ways, that was a better way to just tell a story.

Some people complain that the first part was slow. Another complaint is that there wasn’t enough friendship established between the horse and the boy. I thought the balance was perfect between these two opposing forces.

Finally, you get traditional John Williams music, not so memorable but perfectly adequate. And Spielberg is the perfect director to manipulate your heart, which makes many people mad at him. How dare he?!

Now you are prepared to be entertained by a pretty good film, knowing that it won’t change your life.

]]>
Sat, 18 Aug 2012 00:00:00 +0000
http://dev.nando.audio/2012/04/26/reasons_not_to_use_windows.html http://dev.nando.audio/2012/04/26/reasons_not_to_use_windows.html <![CDATA[Reasons not to use Windows]]>

Reasons not to use Windows

When people buy a new computer, it tends to come with Windows preinstalled. Because of this, most people just use it – unaware that it would be much better for them to install Linux instead. Further, Linux is free.

Here is my list of the most important reasons to avoid Windows:

1. Windows is insecure.

There is a whole industry built on the paranoia, the fear of catching viruses, trojan horses and other exploits. Ask yourself this: How is it possible that the other operating systems (Linux and Mac OS X, as well as others) are much more secure, their users don’t worry, no antivirus software is needed, and things work well with rare exceptions? Antivirus software is constantly slowing down any Windows computer, checking every operation. It is just a very unfortunate thing to worry about...

And they want your money. Antivirus software is always intruding, showing to you that it is working for you, this way you will always remember it is useful, and you are more likely to pay for protection every year.

What is this like on Linux? No worries, no antivirus software is needed.

2. Windows is simply slower.

Because of the antivirus software constantly running in the background, there is no way a Windows system can compete with secure systems in terms of performance.

3. No unified update system

The user is constantly being bothered by one or another program (Windows itself, Java, antivirus software, web browsers etc. etc.) which wants to be updated. This could easily be so different!

What is this like on Linux? There is a single packaging system to install and update software programs. This means when you are informed of available updates, the information is comprehensive of all the software you have. On Linux you get interrupted much less.

Further, the software that comes with a Linux distribution is much more comprehensive than that which comes with Windows. For instance, on Linux it is very easy to get all the multimedia codecs installed, while on Windows there are many options for this, all of which feel unsafe.

4. Windows hardly respects our right to turn off the computer.

Windows thinks disconnection time is appropriate for installing software updates. (The process continues when the computer starts up again.) There is a way to turn off the computer without installing anything, but if you click on the OTHER way, then you can’t cancel it. This is absurd. Further, it takes forever – sometimes a whole hour – to install updates. No control over this is offered to the user.

What if I really have to go away, turn the computer off, catch my bus and go home? There is no option like “Stop after the current update no. 22 and leave the other 15 updates for later”... Instead, the screen prominently shows “Do not turn your computer off”. Excuse me, Microsoft...

What is this like on Linux? You are notified of new available updates. You choose when to download and install them. Most updates are applied quickly and take effect immediately. Only a few updates require a boot to take effect, and you are never really required to boot right now.

5. The desktop is extremely polluted in practice.

A new notebook tipically comes with at least 5 mostly useless icons in the system tray, in addition to the 3 necessary icons for sound level, network status and battery status. The 5 icons I am looking at now are:

  • one for configuring the touchpad,
  • one for configuring hardware graphic acceleration,
  • one for the antivirus,
  • one for “HP ProtectTools”,
  • one for “HP Quick Launch”.

The last two are certainly pointless and I would have them disabled. Actually as I wrote this, avast antivirus created a second icon (as if one weren’t enough to show off its work) and Windows created yet another to say it is downloading more updates... Total icons: 10.

Further, many applications we install under Windows like to add their own toolbars (unrelated to the reason you’re installing the app for) to web browsers, stealing screen space, confusing the user, who most likely never uses the toolbar... Applications add their own icons to the Start menu, to the desktop and to the Quick Launch buttons. The Start menu has its own selection of the most used apps. What a mess!

What is this like on Linux? Since applications are mostly free software – not proprietary –, and because the most important applications are part of the operating system as packaged by an organization, there is no conflict of interest leading to desktop pollution. In practice, the desktop feels simpler and better organized.

6. Too many difficult questions are asked.

Too many applications, and even Windows itself, are constantly demanding the user’s attention, as if saying “I need maintenance”... Countless misfeatures work this way; for instance, Windows offers to clean the desktop for you, hiding icons because you rarely use them. Of course this kind of thing steals your attention from the work you are actually doing, they are annoyances.

Windows users have developed a default reaction to difficult questions that pop up: without even thinking, they click on the X to close the window with the question. Needless to say, this is a pathological reaction to a sick situation. The question could be important, just closing the window could be like hiding a problem from yourself...

The simple fact is user’s aren’t bothered quite so much in other operating systems, these just don’t need any maintenance.

What is this like on Linux? No weird questions pop up, you just work without being interrupted, save from the software update question, which can have its periodicity configured (daily or weekly). Linux should not be installed by people who don’t know what they are doing – but once installed, using it is a breeze. For my grandmother, I installed Ubuntu Linux.

7. Did you initiate this action?

Windows Vista introduced a security misfeature that occurs when you are doing some simple change to the system configuration. A window pops up asking for your confirmation, after all, someone else (or a malicious program) could be trying to execute the configuration, and Windows cannot tell if it is the user...

The effect of this is that the user experience under Windows, as of 2012, is one of clicking much more to do the same configurations, than any of the other operating systems. I wonder, how do these manage to be much more secure, yet bother the user much less?

What is this like on Linux? This problem does not exist, it is just the result of Microsoft incompetence on Windows.

8. Windows does not make economic sense

Unless you really need to use software that is only available on the Windows platform – i.e. AutoCAD –, it makes no sense to pay for it. Linux comes with much more functionality and costs nothing.

For Adobe design software you have the option of using an Apple computer, which is not cheap, but does not suffer from insecurity or excess of difficult questions...

9. Microsoft is an immoral company

Microsoft does not deserve that you honor it with your preference, since it is known for immoral and illegal actions in the computer market, both against competitors and against consumers. I shall mention only one immoral practice against consumers which should be enough to convince you: the Starter Edition – a severely crippled operating system that prevents the user from opening more than 3 applications simultaneously, or storing more than 120 GB on their hard drive, or using more than 512 MB RAM... This is pure evil because in Brazil computers with this system preinstalled have been sold to unsuspecting customers, who then had to replace it.

10. Microsoft has been detrimental to the advancement of the web

After winning the browser wars, effectively driving Netscape Navigator out of the market, Microsoft didn’t work on its browser, Internet Explorer, for years and years, ignoring the cries of web developers against its hundreds of bugs. Microsoft only started improving this situation after a better browser, Mozilla Firefox, finally appeared to endanger IE.

Now Chrome is the most popular browser but IE still holds the web back to an extent, since it is still popular but lagging behind the other browsers in support for the newest web standards.

When you use Internet Explorer you help drive the statistics to its favour, which influences decisions that hold back the web. So don’t use it. This is a product that does not deserve your preference.

]]>
Thu, 26 Apr 2012 00:00:00 +0000
http://dev.nando.audio/2012/04/04/teste_de_elenco.html http://dev.nando.audio/2012/04/04/teste_de_elenco.html <![CDATA[Como se comportar em um teste de elenco sem cachê teste]]>

Como se comportar em um teste de elenco sem cachê teste

http://vimeo.com/38818639

]]>
Wed, 04 Apr 2012 00:00:00 +0000
http://dev.nando.audio/2012/03/29/inventing_on_principle.html http://dev.nando.audio/2012/03/29/inventing_on_principle.html <![CDATA[Inventing on principle]]>

Inventing on principle

If you are at all interested in computing or invention or creativity, you shall now watch this talk by Bret Victor.

]]>
Thu, 29 Mar 2012 00:00:00 +0000
http://dev.nando.audio/2012/03/27/tinkering.html http://dev.nando.audio/2012/03/27/tinkering.html <![CDATA[I am now tinkering.]]>

I am now tinkering.

In June 2004 I started a blog using a full-featured CMS written in PHP. The first post was titled Nando Florestan’s site is now interactive. I was very excited...

Today I am starting a new blog ― and I am also excited because I can finally get rid of the old thing, using something much simpler: Tinkerer, a static blog generator written in Python.

There is a powerful text markup language that Python developers have traditionally used for documentation. It is called reStructuredText. Nowadays, with everybody using Sphinx, reStructuredText is even more popular. So Python developers needed a blog system that supported reStructuredText. Blogging is easier without mental context switching between markup languages.

So when famous programmer Ben Bangert mentioned Tinkerer in a chat, I immediately knew it would be eagerly adopted by Python developers. Ben has just migrated from Tumblr to Tinkerer.

For common people who want a new blog, I still recommend Tumblr though.

]]>
Tue, 27 Mar 2012 00:00:00 +0000
http://dev.nando.audio/2009/04/28/what_oracle_should_do_to_mysql.html http://dev.nando.audio/2009/04/28/what_oracle_should_do_to_mysql.html <![CDATA[What Oracle should do to MySQL]]>

What Oracle should do to MySQL

What is probably going to happen now that Sun and MySQL belong to Oracle is:

1) They are going to get a world-class boring buzzword-compliant website.

2) All this.

]]>
Tue, 28 Apr 2009 00:00:00 +0000
http://dev.nando.audio/2009/04/27/javas_opinion_of_python.html http://dev.nando.audio/2009/04/27/javas_opinion_of_python.html <![CDATA[Java's opinion of Python]]>

Java’s opinion of Python

I read some guy talking about Java, “the greatest language in the world”, just like an ugly American might say “the greatest country in the world”. He has motivated me to become an ugly Pythonista.

A Javer and a Cee-Sharper meet a Pythonista and consider Python for a brief moment.

Oracle Certified Java Programmer: ― I guess writing code in Python is quicker, but it might create maintenance nightmares later. Python is optimized for productivity and Java for maintainability.

Microsoft Certified Professional: ― Actually, the absence of great IDEs for Python, such as Visual Studio, might slow down the production of code.

Oracle Certified Java Programmer: ― “Rigid” languages such as Java make you write more code, but that code stays legible till the end of the project lifecycle.

Python apologist guy: ― You are wrong. I chose Python exactly because it is the most readable language available...

Microsoft Certified Professional: ― Nah, creating properties is very hard without an IDE. Another problem in Python is the lack of Generics. I am proud of writing in a language that has LINQ. Python is also missing a nice Reflection library such as the ones in C# and Java! That shows how much more powerful these languages are.

Oracle Certified Java Programmer: ― Yeah, I like Java because I get to program in XML. Hey, in Python you never know the type of a variable or parameter. Java is more explicit, therefore Java code is more readable.

Python apologist guy realizes the hopelessness of it: ― You are right, of course, but you can always use Hungarian Notation: s_name = ‘Nando’; i_age = 33;

Microsoft Certified Professional: ― I don’t like Python or Java. I prefer the C family of languages, invented by Microsoft, that includes C, C++ and C#.

Python apologist guy: ― Wait, in Python you can continue to type a semicolon at the end of every line.

Oracle Certified Java Programmer: ― Hmm, it must have copied Groovy. But that makes Python better than I figured...

Python apologist guy tries to ignore him: ― You can have strongly typed variables too. And braces. See this example:

# MyClass.py
# Proud author: nosklo (Clovis Fabricio)
class MyClass(object):#{
    def __init__(self, s_name, i_age):#{
        assert isinstance(s_name, str);
        assert isinstance(i_age, int);
        if (i_age > 20):#{
            print s_name;
        #}
    #}
#}

Microsoft Certified Professional: ― Hmm, the eye sees the #{ combination easily. OK, this code is readable. But I like .net because it is extremely multi-language.

Python apologist guy: ― Don’t worry, you can even have goto if you wish. Here is a VB-like alternative:

# MyClass.py. Proud author: nosklo (Clovis Fabricio)
class MyClass(object):
    def __init__(self, s_name, i_age):
        assert isinstance(s_name, str)
        assert isinstance(i_age, int)
        if (i_age > 20):
            print s_name
        #end if
    #end function
#end class

Microsoft Certified Professional: ― You can’t convince me because Python is an interpreted language, and I only like compiled languages, like C#. Furthermore, I like when enterprise libraries are ready so I don’t have to write them myself. ― Goes away.

OCJP waits until MCP is far enough. ― Never mind him, he never even understood the importance of Checked Exceptions. Hey, I see there are 2 classes in this file. This must be a maintenance nightmare! The only true way is one class per file.

Python apologist guy: ― Yeah, namespaces are one honking great idea ― let’s do more of those!

Oracle Certified Java Programmer: ― As much as I might like your language, I could never give up world-class enterprise-ready buzzword compliance and a BIG company backing us up.

Python apologist guy: ― Good for you!

Ruby developer: ― Excuse me, I couldn’t help but hear your conversation. I just wanted to say that if you ever need a dynamic language, consider Ruby ― it is more powerful.

Python apologist guy turns his back to OCJP and attacks Ruby developer:Die, heretic scum!

]]>
Mon, 27 Apr 2009 00:00:00 +0000
http://dev.nando.audio/2009/04/24/schemaless_python_databases.html http://dev.nando.audio/2009/04/24/schemaless_python_databases.html <![CDATA[Schemaless Python databases]]>

Schemaless Python databases

3 new persistence options for Python

As I struggle to create an object-oriented database for Python on top of Tokyo Cabinet – Pykesto – I have found two other nice persistence mechanisms:

Kineta is a dynamic, schemaless, relational database written in Python on top of Berkeley DB. It is almost done, I have tested it a bit and was impressed. It is full of different ideas, sometimes I felt it was too different from what I am used to, but if you really think about them and try to be fair, you realize these are all good ideas. Really, take a look at Kineta.

The last one – Copycat – is a Prevayler for Python. For those unfamiliar with the Prevayler concept, this is an extremely fast, transparent, ACID persistence mechanism for small databases that fit in memory. In such a case you can be free of all the overhead of traditional databases and just use your objects in the most natural way. Behind the scenes, the framework writes a log of all the operations you do. Every night or so a checkpoint is created, too (allowing the log to be reset). When the system is turned off and on again, the checkpoint is loaded and the log is applied so your objects come back to the state they were before. This might take a lot of RAM, but RAM can be much cheaper than developing with traditional databases.

Copycat is in an alpha state, but is already functional.

EDIT: One more! buzhug is a pure-Python database engine.

And there exists a B-plus Tree implemented in Python.

]]>
Fri, 24 Apr 2009 00:00:00 +0000
http://dev.nando.audio/2009/04/07/corel.html http://dev.nando.audio/2009/04/07/corel.html <![CDATA[Corel]]>

Corel

Comece devagar a gradualmente aproximar-se de uma situação em que raramente você precise contrariar uma convicção absoluta de NUNCA usar software cujo nome comece com Corel.

― Mas qual a alternativa?

Inkscape é bem mais barato. Senão, tem sempre o Adobe Illustrator.

]]>
Tue, 07 Apr 2009 00:00:00 +0000
http://dev.nando.audio/2009/04/03/installing_tokyo_cabinet.html http://dev.nando.audio/2009/04/03/installing_tokyo_cabinet.html <![CDATA[Installing Tokyo Cabinet and its Python driver]]>

Installing Tokyo Cabinet and its Python driver

Tokyo Cabinet is the fastest database available, and it comes in several flavors. Here is how to install it in Ubuntu and use it with Python.

After realizing that CouchDB is not appropriate when you know you will need ad hoc queries (which doesn’t mean CouchDB isn’t very cool), I am trying out Tokyo Cabinet.

Here is a post about it, using Ruby.

Tokyo Cabinet offers several types of database, but the version that comes in Ubuntu 8.10 is missing the fixed-length and the table database, so I had to compile it:

sudo apt-get install checkinstall build-essential libbz2-dev
# Dependencies installed; now compile:
./configure --prefix=/usr
make clean
make
# checkinstall -R    # would create an RPM package
sudo checkinstall -D # creates and installs a Debian package
# Now you have a package that you can install AND uninstall, instead of
# sudo make install

Now the library, programs and headers are available, so we can install the Python driver. The most well-known is the old pytc which also doesn’t offer all kinds of databases. tc is the Python driver we need. Here is the author’s blog.

I download the latest code from github, uncompress it, enter its directory, then:

./setup.py install

That will succeed in Ubuntu 8.10 as long as the header files are found.

Unfortunately this driver is only nearly complete. As of 2008-04-03, the table database lacks a close() method, and the query API is being finished (you cannot execute queries yet).

Anyway, what software are we going to write using Tokyo Cabinet? How about an ambitious object-oriented database for Python apps? Something to replace ZODB? I am talking about pykesto and I wish you would help me write it.

However, it will take time to get there, and we might have to start by creating a higher-level interface to Tokyo Cabinet, because right now instantiating, for instance, the table database involves passing ugly flags like this:

import tc
t = tc.TDB('test.tdb', tc.TDBOWRITER | tc.TDBOCREAT)
# The above means open the file 'test.tdb' for writing and
# create it if it does not exist.
t.put('row id', {'col id':'value'})
t.get('row id')
# Out: {'col id': 'value'}
t.close()

Another reason to create a higher-level API is that the query API for the table database also involves lots of flags. I am sure this can easily be made Pythonic. I will put the code at pykesto as soon as I have it.

]]>
Fri, 03 Apr 2009 00:00:00 +0000
http://dev.nando.audio/2009/03/28/running_kurso_de_esperanto.html http://dev.nando.audio/2009/03/28/running_kurso_de_esperanto.html <![CDATA[Running Kurso de Esperanto on Ubuntu 8.10]]>

Running Kurso de Esperanto on Ubuntu 8.10

Today I decided to learn Esperanto. Best way to start seems to be Kurso, a gratis program. So...

...I downloaded Kurso3.0.deb and installed it. You might have 3 issues running this program in Ubuntu:

  1. No way to start the program

Installing the program does not add a menu entry for it. So click the Gnome Panel, pick “Add to panel...”, then “Custom Application Launcher”, then type:

Name: Kurso
Command: kurso

You may also click the button at the left to choose a nice icon. That’s it, now you can easily launch the program.

  1. /usr/share/kurso/tradukoj

The second problem that might happen is a message about lacking write access to the directory /usr/share/kurso/tradukoj. Another symptom is, clicking on the Settings button does not display the configuration screen.

A solution would be to type the following in a console:

cd /usr/share/kurso/
ls -l # prints out the contents of the kurso directory
sudo chmod 666 tradukoj
ls -l

This sets write permissions on that directory. Now you can restart the program, the message is gone and you can open the Settings screen.

  1. Sounds problem

You might get no sound for playback or recording. The solution is:

  1. Install mpg321:
sudo apt-get install mpg321

b) Open the Settings screen, switch to the Sound/Internet tab, and leave it like this:

MP3 player:    mpg321
WAV recorder:  aplay
WAV player:    arecord --duration=3 --rate=44100
Browser:       firefox
e-mail client: thunderbird

If you are really paying attention, you might notice that it doesn’t make sense to pick “aplay” to record and “arecord” to play. This is not my mistake; in this version (3.0) of Kurso, they messed up the 2 labels.

There you go, fully functional Kurso.

]]>
Sat, 28 Mar 2009 00:00:00 +0000
http://dev.nando.audio/2009/03/11/web_dev_in_python_must_read.html http://dev.nando.audio/2009/03/11/web_dev_in_python_must_read.html <![CDATA[Web dev in Python: must read]]>

Web dev in Python: must read

If you are a Python web developer, here is some stuff you absolutely cannot miss.

]]>
Wed, 11 Mar 2009 00:00:00 +0000
http://dev.nando.audio/2009/02/15/easily_start_the_screensaver.html http://dev.nando.audio/2009/02/15/easily_start_the_screensaver.html <![CDATA[Easily start the screensaver in Ubuntu Linux]]>

Easily start the screensaver in Ubuntu Linux

How to start the Gnome screen saver immediately

The command to start the Gnome screensaver is:

gnome-screensaver-command -a

I tried to make this happen using keyboard shortcuts first, but couldn’t find a way. So I went with the next best thing: a launcher in the Gnome panel.

Right click the Gnome panel and click “Add to panel...”. Pick “Custom Application Launcher”. Another window appears. Fill it like this:

Type: Application
Name: Screensaver
Command: gnome-screensaver-command -a
Icon: <pick any icon...>

Hit OK and now you can start the screensaver by clicking the new icon.

]]>
Sun, 15 Feb 2009 00:00:00 +0000
http://dev.nando.audio/2009/01/08/tuples_lists_dicts_and_objects.html http://dev.nando.audio/2009/01/08/tuples_lists_dicts_and_objects.html <![CDATA[Tuples, lists, dicts and objects: how fast?]]>

Tuples, lists, dicts and objects: how fast?

Comparison of tuple, list, dict and object instantiation performance in Python.

It is well-known that in Python tuples are faster than lists, and dicts are faster than objects. I wondered how much so. After some tests, the conclusions are:

1. Use a tuple when you need a tuple and a list when you need a list. A list can have items appended or removed, while a tuple is immutable. If you won’t be adding or removing items, use a tuple and your code will run a little faster.

On the other hand, if you make a tuple with the intention of being fast, and then some code has to create another tuple out of your tuple, when it could have added or removed an item from a list instead, then you are actually being slower.

2. Dicts can be twice as fast as objects (but they do much less). Object oriented programming is based on the fact that uniting data and behaviour in a single place leads to better factored, more reusable code. So go on and make classes and objects, it is the only civilized thing to do! However, note that dicts are quite faster than objects (to instantiate).

Needless to say, premature optimization is the root of all evil, so keep these facts in mind only when you are optimizing some code, not when you are writing something new.

Here is a little module, and the tests are in its docstring if you want to reproduce them:

#!/usr/bin/env python
# -*- coding: utf-8 -*-

'''speed_test.py

Comparison of tuple, list, dict and object instantiation performance.

Usage: (results are from Python 2.5.2 in Ubuntu)


python -m timeit -s 'from speed_test import *' 'a = {}'
10000000 loops, best of 3: 0.0792 usec per loop

python -m timeit -s 'from speed_test import *' 'a = []'
10000000 loops, best of 3: 0.081 usec per loop

python -m timeit -s 'from speed_test import *' 'a = object()'
1000000 loops, best of 3: 0.231 usec per loop

This object() instantiation is almost useless, done only to get a rough idea.

Conclusion:
For empty containers, lists and dicts are equivalent.


python -m timeit -s 'from speed_test import *' 'a = (x, x)'
10000000 loops, best of 3: 0.184 usec per loop

python -m timeit -s 'from speed_test import *' 'a = [x, x]'
1000000 loops, best of 3: 0.271 usec per loop

python -m timeit -s 'from speed_test import *' 'a = {x:x, y:x}'
1000000 loops, best of 3: 0.474 usec per loop

python -m timeit -s 'from speed_test import *' 'a = TestObj(x, x)'
1000000 loops, best of 3: 1.17 usec per loop

Conclusion:
For storing 2 values, tuples are 50% faster than lists.
Lists are twice as fast as dicts, but not fair: dicts also store keys.
Dicts are 250% faster than objects.


python -m timeit -s 'from speed_test import *' 'a = (x, x, x, x)'
1000000 loops, best of 3: 0.268 usec per loop

python -m timeit -s 'from speed_test import *' 'a = [x, x, x, x]'
1000000 loops, best of 3: 0.357 usec per loop

python -m timeit -s 'from speed_test import *' 'a = {x:x, y:x, z:x, v:x}'
1000000 loops, best of 3: 0.79 usec per loop

python -m timeit -s 'from speed_test import *' 'a = TestFour(x, x, x, x)'
1000000 loops, best of 3: 1.81 usec per loop

Conclusion:
When storing 4 values, tuples are 33% faster than lists.
And dicts are 2 times faster than objects.

The difference diminishes as you store more and more values.
'''

__author__ = 'Nando Florestan'

x = 42 # we use variables because constants would be much faster.
y = 43 # you don't use so many constants in the real world.
z = 44
v = 45


class TestObj(object):
    def __init__(self, a, b):
        self.a = a
        self.b = b


class TestFour(object):
    def __init__(self, a, b, c, d):
        self.a = a
        self.b = b
        self.c = c
        self.d = d
]]>
Thu, 08 Jan 2009 00:00:00 +0000
http://dev.nando.audio/2009/01/08/i_dream_of_a_db4o_for_python.html http://dev.nando.audio/2009/01/08/i_dream_of_a_db4o_for_python.html <![CDATA[I dream of a db4o for Python]]>

I dream of a db4o for Python

I wish Python would have an object database that wouldn’t eat up all the RAM.

Such a project could also be defined as “Durus with queries that don’t have to first instantiate objects”.

It would need a custom file format, without using Python’s pickles, to be able to query without instantiating. And I wouldn’t mind losing some dynamic-language-like flexibility if I could have this.

I have been using the SQLAlchemy ORM because it uses very little memory, it is very powerful and very fast. It does everything you need and more. However...

For some projects, I feel the difficulties in defining SQLALchemy models (and dealing with the relational database behind it). I want to use Python types, not relational database types. I would switch to an object database, if only it would query and use little RAM.

(In Python, making a tuple is faster than making a list is faster than making a dict is MUCH faster than instantiating an object.)

If I were to start such a db4o-like project (maybe 2010?) I would have to wrap my head around pointers to objects and their activation. So at first I might use SQLAlchemy as a backend. A table of properties... belongs to a table of objects... which know their Python type. This would probably enable one to make those queries without first instantiating.

About this scheme, ronny tells me to take a look at RDF – neat for dealing with not clearly defined object graphs.

(This is not my area of expertise...)

If you are a real good, but real good Python developer, go ahead and do it! But heads up, you’re gonna face DAMN tricky stuff about reference cycles and efficient collections.

This project is for the future. Python 3.0 on it!

]]>
Thu, 08 Jan 2009 00:00:00 +0000
http://dev.nando.audio/2008/12/29/backalaika.html http://dev.nando.audio/2008/12/29/backalaika.html <![CDATA[Backalaika, an easy backup solution]]>

Backalaika, an easy backup solution

Here is another open source creation of mine!

Backalaika is not a Russian musical instrument. It is a backup solution for small offices, available at SourceForge.

Written in Python, it lets you define backup profiles, filter filenames, compress to zip, tar.gzip or tar.bz2, perform differential, incremental or full backups etc.

You can download it here.

And here is the Python package.

]]>
Mon, 29 Dec 2008 00:00:00 +0000
http://dev.nando.audio/2008/12/13/reembolso_windows.html http://dev.nando.audio/2008/12/13/reembolso_windows.html <![CDATA[Conseguindo o reembolso da licença do Windows]]>

Conseguindo o reembolso da licença do Windows

Se você comprar um computador que vem com Windows, mas for usar outro sistema operacional, pode se reembolsar da licença do Windows. (Eu ainda não fiz isso, mas achei interessante haver gente fazendo.)

]]>
Sat, 13 Dec 2008 00:00:00 +0000
http://dev.nando.audio/2008/12/07/inventando_nomes_para_as_notas.html http://dev.nando.audio/2008/12/07/inventando_nomes_para_as_notas.html <![CDATA[Inventando nomes para as notas "pretas"]]>

Inventando nomes para as notas “pretas”

Solfejar cantando os nomes das notas tem uma utilidade da qual você não está consciente: Cultivar o ouvido. Mas as notas pretas não têm nome próprio... ou melhor, não tinham.

O que é ouvido absoluto

Ouvido absoluto é a capacidade de ouvir uma nota e saber seu nome tão instantaneamente quanto podemos dizer “laranja” ao ver a cor correspondente. (Uma ou mais notas.) Também expressa a habilidade de pensar e cantar uma nota sem nenhuma referência anterior (principalmente ao acordar de manhã).

A maioria dos humanos não tem ouvido absoluto – mesmo entre os músicos. Em última análise, ele não é necessário. Mas os poucos que o possuem podem ser mais rápidos em certas atividades, por exemplo a improvisação ou o “tocar de ouvido”.

Dentre os grandes compositores, é certo que Mozart tinha ouvido absoluto (por várias anedotas de sua infância). Também é provável que Beethoven o tivesse, primeiro porque falava muito nas peculiaridades das tonalidades, e se pensarmos no caso, foi capaz de compor certas harmonias inovadoras da Nona Sinfonia totalmente surdo. Quanto aos outros grandes compositores, não acho que o caso de nenhum deles seja comprovado.

Você também poderia ter ouvido absoluto?

Acredita-se que o ouvido absoluto seja inato, ou determinado na tenra infância ao se exercer atividade musical. Por isso fiquei curioso ao ver que um americano, David Lucas Burge, vende um curso de Perfect Pitch. Segundo ele, o ouvido absoluto pode ser adquirido treinando as técnicas ensinadas no curso...

Consultada, uma amiga pianista que possui ouvido absoluto contou-me que o dela certamente foi aprendido. Mas como assim? Simples. A professora dela solfejava tudo cantando os nomes das notas. A memória musical dela associou as alturas diretamente aos nomes.

Às vezes entram em jogo no ouvido absoluto certos tipos de sinestesia. A pessoa pode ver, por exemplo, cores nas notas (não com os olhos, nem com o ouvido, mas com a mente). Mas não existe a “cor certa” para o mi bemol. Cada um tem a sua, ninguém concorda. É tudo muito arbitrário.

Não é o caso da minha amiga pianista. Ela não usa muito esse papo de cores.

Você que tanto pratica o seu instrumento, nas raras vezes em que solfeja, tem preguiça de cantar os nomes das notas. Talvez você cante “lá lá lá”. Talvez você nem cante, só fale os nomes das notas no ritmo... Fique sabendo que você pode estar perdendo a oportunidade de adquirir ouvido absoluto. Assim fui levado a crer.

A necessidade de nomes para as notas com acidente

Cantar os nomes das notas é fácil enquanto estivermos estritamente em dó maior. Sol, dó, lá, fá, mi, dó, ré, segundo a Noviça Rebelde, tudo muito fácil. Sabe por quê?

Porque ela deixou os acidentes para a sequência.

Cantar “siii... si bemoool...” simplesmente não funciona: o “si bemoool” soa como 3 notas seguidas e toma muito tempo. Um professor nosso mandava estalar os dedos ao cantar as notas com acidente (ou seja, dizer somente “si” e estalar o dedo). Isso também não é prático, os nossos dedos devem ficar livres para outros fins musicais! O que precisamos é, finalmente, de direitos civis. Nomes para as pretas, em igualdade com as brancas.

Também precisamos reconhecer que vivemos num mundo temperado e enarmônico. A distinção entre fá sustenido e sol bemol, no contexto de um solfejo rotineiro da música ocidental tradicional, é especialmente irrelevante para o nosso propósito específico.

Tentemos agora inventar os melhores nomes monossílabos para as cinco notas “anônimas” que estão no meio de dó, ré, mi, fá, sol, lá e si. (Até onde eu sei, ninguém fez isso antes.)

De onde vêm dó, ré, mi e sua turma

Neste momento é interessante lembrar que esses nomes foram inventados na Idade Média pelo monge Guido d’Arezzo, pai da notação musical tradicional. E originalmente as notas se chamavam ut, re, mi, fa, sol, la, si. De onde vieram? Havia um hino em que o 1º verso começava no dó, o 2º no ré e assim por diante. Então na verdade as notas é que tomaram os seus nomes da 1ª sílaba de cada verso:

Ut queant laxis
    resonare fibris,
Mira gestorum
    famuli tuorum,
Solve polluti
    labii reatum,
Sancte Ioannes.

Essa escala que herdamos tem as seguintes características interessantes:

  • Dó substituiu Ut por ser mais fácil de solfejar. Ut tinha duas desvantagens: a vogal U e a consoante no final. As vogais abertas são mais fáceis de cantar. E todos os outros monossílabos têm uma consoante para o ataque e uma vogal.
  • Si é substituída por Ti em algumas culturas. Ti tem a vantagem de não repetir a consoante S (já usada na nota Sol) e começar com uma consoante mais curta.
  • Assim nenhuma consoante é repetida.
  • A vogal “a”, talvez a melhor para soltar a voz, já é representada 2 vezes: e .
  • A vogal “i”, boa para colocar a voz no lugar (cante “ni ni”), é usada em mi e si.
  • A vogal aberta “ó” está presente em dó e sol, mas não temos a vogal fechada ô.
  • A vogal aberta “é” só existe no ré e não temos a vogal fechada ê.
  • A vogal “u” não aparece.

Ao inventar nossos monossílabos, fizemos as seguintes presunções (que não estão cientificamente confirmadas):

  • O solfejo resultará mais rico se tivermos a máxima variedade de consoantes e vogais.
  • Vogais abertas são mais cantáveis que as fechadas.
  • Mesmo assim, é injustiça ainda não termos nenhum U.
../../../_images/bupagukexo.gif

O batismo

Destarte proponho os seguintes novos monossílabos:

  • Dó# = BU (“boo”)
  • Ré# = PA (“pah”)
  • Fá# = GU (“goo”)
  • Sol# = KÊ (“kay”)
  • Lá# = XÔ (“show”)

Advirto entretanto que esses nomes não estão testados...

Update

Depois de escrever isto, descobri no artigo “Solfège” da Wikipedia que na Inglaterra já existe um sistema em que as pretas ascendentes são di ri fi si li, e descendentes são ra me se le te. Mas não sei até que ponto não é utilizado... todo mundo diz “B flat”. Parece-me que um sistema enarmônico seria mais útil para solfejar (embora pior para ensinar harmonia). Também acredito ainda que esse sistema bretão repita consoantes e vogais demais para soar bem.

Também descobri que não sou o primeiro a inventar um sistema enarmônico e chamá-lo assim. “The important thing is to pick a system and learn it thoroughly. (I use my own enharmonic system in which the chromatic scale is ‘do gu ri bu mi fa ka so ja la pa ti do.’)”, diz Benjamin Crowell na página 54 de “Eyes and Ears”.

]]>
Sun, 07 Dec 2008 00:00:00 +0000
http://dev.nando.audio/2008/11/28/comecando_a_usar_ipython.html http://dev.nando.audio/2008/11/28/comecando_a_usar_ipython.html <![CDATA[Começando a usar ipython]]>

Começando a usar ipython

(UPDATE de 2011: Estou gostando mais ainda do bpython...)


Dei umas dicas hoje no canal IRC #python-br do Freenode. Colei a conversa aqui para ajudar outras pessoas também.

<NandoFlorestan> pode abrir o interpretador e testar

<NandoFlorestan> já tens ipython?

<marmadeoli> não

<marmadeoli> tinha baixado o Idle

<NandoFlorestan> easy_install ipython

<NandoFlorestan> o ipython não compete com o idle

<NandoFlorestan> ele é um interpretador

<NandoFlorestan> melhor que o python ;)

<marmadeoli> mas o python já não é o interpretdor?

<NandoFlorestan> sim

<NandoFlorestan> mas no ipython por exemplo tem tab completion

<NandoFlorestan> tem histórico dos comandos (usando as setas)

<NandoFlorestan> e uma pá de outros recursos

<marmadeoli> vou baixá-lo... easy_install -U ipython

<marmadeoli> NandoFlorestan: cara, mil desculpas, desde ontem que te encho o saco. Mas... Como eu rodo esse programa?

<marmadeoli> ele é somente no console?

<NandoFlorestan> sim

<NandoFlorestan> digita ipython

<marmadeoli> tá, mas dai ele é só um interpretador. Ou seja, se eu quiser escrever arquivos não rola nele!

<marmadeoli> é como o interpretador do python no console

<NandoFlorestan> isso mesmo

<NandoFlorestan> mas é muito útil

<NandoFlorestan> pra testar coisas, ler docstrings etc.

<marmadeoli> sim..

<NandoFlorestan> tipo

<NandoFlorestan> import cherrypy

<NandoFlorestan> cherrypy?

<NandoFlorestan> põe o ponto de interrogação

<NandoFlorestan> ...e ele mostra a documentação

<NandoFlorestan> cherrypy.request?

<NandoFlorestan> mais documentação

<NandoFlorestan> E se vc quiser ver os fontes?

<NandoFlorestan> Usa 2 pontos de interrogação:

<NandoFlorestan> cherrypy??

<marmadeoli> ahhh bacana

<marmadeoli> bacana mesmo

<NandoFlorestan> Se precisar rodar um comando do shell, usa ponto de exclamação antes do comando. Por exemplo:

<NandoFlorestan> !top

<NandoFlorestan> Resumindo, quem tem ipython não precisa de nenhuma IDE. Só precisa de um editor de textos que mostre o código colorido.

<NandoFlorestan> Mas eu uso a IDE Geany mesmo assim ;)

<marmadeoli> ninguém usa aqui o python com o Eclipse?

<NandoFlorestan> Eu tento de vez em quando, mas quando trava eu fico furibundo :P

]]>
Fri, 28 Nov 2008 00:00:00 +0000
http://dev.nando.audio/2008/10/28/pablo_francisco.html http://dev.nando.audio/2008/10/28/pablo_francisco.html <![CDATA[Pablo Francisco is hilarious...]]>

Pablo Francisco is hilarious...

Pablo Francisco is an awesome stand-up comedian. But first, you have to know who Don LaFontaine was.

Well, Pablo Francisco made a carrer out of impressions of Don LaFontaine.

But Pablo has other funny material too.

And of course, imitating Arnold is always their preferred sport.

]]>
Tue, 28 Oct 2008 00:00:00 +0000
http://dev.nando.audio/2008/10/28/music_links.html http://dev.nando.audio/2008/10/28/music_links.html <![CDATA[A couple of music links]]>

A couple of music links

]]>
Tue, 28 Oct 2008 00:00:00 +0000
http://dev.nando.audio/2008/09/17/wireless_network_is_down.html http://dev.nando.audio/2008/09/17/wireless_network_is_down.html <![CDATA[Wireless network is down on Ubuntu startup/boot]]>

Wireless network is down on Ubuntu startup/boot

A quick tip for Hardy users.

After finally finding and buying a PCI wireless card that has a little penguin logo on the package, I found out that it worked, but I had to do “sudo ifdown wlan0; ifup wlan0” on every boot.

The solution for this is:

sudo nano /etc/network/interfaces

...and add a line to your interface definition that reads:

pre-up sleep 7

...this way the network will start 7 seconds later, but with success. (Some systems might need more than 7 seconds, just increase the value.)

Linux on Frankenstein PC hardware still has too many of these annoyances and I don’t see them going away at all. Using free software instead of a Mac that just works does have a cost, we have to admit it.

For more information on the interfaces file:

man interfaces
]]>
Wed, 17 Sep 2008 00:00:00 +0000
http://dev.nando.audio/2008/05/22/falsa_democracia.html http://dev.nando.audio/2008/05/22/falsa_democracia.html <![CDATA[José Saramago: falsa democracia]]>

José Saramago: falsa democracia

http://www.youtube.com/watch?v=m1nePkQAM4w

]]>
Thu, 22 May 2008 00:00:00 +0000
http://dev.nando.audio/2008/04/23/MuseScore.html http://dev.nando.audio/2008/04/23/MuseScore.html <![CDATA[MuseScore, open source music score editor]]>

MuseScore, open source music score editor

MuseScore is the most promising free-software music score editor I have ever seen. It is similar to Sibelius in many ways. And it is probably in your Linux distro’s packages already.

]]>
Wed, 23 Apr 2008 00:00:00 +0000
http://dev.nando.audio/2008/04/12/entendendo_mal_debussy.html http://dev.nando.audio/2008/04/12/entendendo_mal_debussy.html <![CDATA[Entendendo mal Debussy]]>

Entendendo mal Debussy

Se a “Pequenas Empresas Grandes Negócios” não sabe o que é software livre (vide post anterior), vejamos então a Folha de São Paulo, será que sabe dizer alguma coisa sobre música?

Acabo de ler a maior sandice que já encontrei num artigo que tenta falar de música séria:

“As obras de Debussy não chegaram a revolucionar a história da música, mas influenciaram muitos artistas renomados como Ravel, Satie e Bartók, marcando o fim da era wagneriana.”

Ocioso reclamar: dizer que Debussy não revolucionou a música é não saber absolutamente nada sobre composição. A anta que escreveu isso na Folha de São Paulo parece achar Debussy inferior (e “menos renomado”) a Ravel, Satie e Bartók. Estamos falando do pai da música moderna... Até o ponto em que essas coisas podem ser “medidas” (foi a Folha quem começou, hein?), a obra de Debussy é freqüentemente mais complexa, abstrata, original e influente que a dos outros gigantes mencionados — especialmente Satie, que pode ser considerado basicamente um humorista musical.

O erro só é grave para quem ainda acha que jornal e revista são fonte de informação. Mas precisa ser muito inocente para ainda estar nessa fase, a essa altura do campeonato...

Não adianta, quem trabalha para a indústria cultural vai direto para o inferno!

Que Debussy ele mesmo fale, e que depois disso nenhum animal de orelhas grandes zurre.

]]>
Sat, 12 Apr 2008 00:00:00 +0000
http://dev.nando.audio/2008/04/08/wymeditor.html http://dev.nando.audio/2008/04/08/wymeditor.html <![CDATA[WYMeditor]]>

WYMeditor

WYMeditor: finally a javascript wysiwyg editor that shouldn’t generate buggy XHTML.

]]>
Tue, 08 Apr 2008 00:00:00 +0000
http://dev.nando.audio/2008/03/30/deathnote.html http://dev.nando.audio/2008/03/30/deathnote.html <![CDATA[Our daily nazism — parents beware]]>

Our daily nazism — parents beware

What are our children being prepared for? *Death Note, seen by millions, is nazi. The story was a huge opportunity for moral thought, but only nazi ethos has a chance to appear.*

Death Note

I am talking about Death Note, anime series. The manga series has been read by millions in Japan alone. There is also a Japanese film and a few other franchises.

I wouldn’t normally lose any of my time with nonsense such as anime series, but my 14-year-old daughter likes it and I decided to accompany her, plus in the first few episodes I was curious myself. Why?

Light is a popular, good-looking student who only gets A grades. A genius, really. One day he finds a weapon, thrown unto this world by a Shinigami (a God of Death) for his amusement. The weapon basically lets Light kill anyone he wants, without even meeting the victim. Light decides that he will use this weapon to kill every criminal that appears on the news. This way, he thinks, he will be the unknown creator of a new world, without crime.

Crime rates drop quickly and crowds thank the mysteryous Kira (“killer”) for it.

Is it nazi enough for you? But there is more.

The premise of the story seems a golden opportunity to talk about ethics. It would have been easy to discuss (and, in the process, teach children) about:

  • how wrong it is to take justice in one’s own hands;
  • how wrong it is to be accuser and judge at the same time;
  • why we need the due process of law;
  • how deceiving the news (and the rest of the culture industry) can be;
  • how anybody can end up committing a crime (nobody is immune);
  • how the law is not always right and may define crimes that shouldn’t be;
  • how the law may not define some actions as crimes when they should be;
  • the principle that punishment should be proportional to the crime;
  • etc. etc.

Instead what happens?

  • The mass murderer, who thinks of himself as a god, is indeed called Light;
  • He just kills everybody, he is not interested in finding out whether the news are even true;
  • He is Japan’s best student (!!!) but somehow has no idea that his concept of justice is barbaric, absolutely uncivilized;
  • The series carefully avoids any moral evaluation, except Kira’s own reasoning to do as he does;
  • Nobody else has high dreams;
  • Kira is the main character, no other character comes close;
  • Eventually other people find a way to follow the mass murderer’s example;
  • The Gods of Death don’t ever interfere for moral reasons. They interfere either for fun or because they are in love with a female character. They don’t really think there is an enormous mess going on. In the end the plot just forgets about the Shinigami, they almost disappear.
  • The whole series becomes just a thriller alla Sherlock Holmes versus Moryarty. Except that the killer is more competent than the cops.
  • When the blockbusterish thriller ends, the series ends. There was nothing else to say.
  • Due process of law is never mentioned.
  • What is a crime? This is never questioned.
  • How should punishment be done? This is never asked.
  • etc. etc.

Do you think I am exaggerating? Do you think nobody would really identify with Kira? Think again.

Many people already think like Kira and would do the same. I have witnessed bad taste television shows in Brazil in which the angry host talked about a criminal (not a convicted criminal, but one that had just been arrested by the police), showing sensationalist disgust to what the criminal had done, saying things like “when he was doing it, he didn’t think about human rights, so why should he have human rights now?”

This is how many people think. We are surrounded, outnumbered by the stupid.

I was curious enough to go to IMDb. I know most of the posts there are noise; there is no place to find idiots as the IMDb forums. But I have also found extremely intelligent comments there before. Maybe it depends on the film.

In this case, I could find next to nobody interested in any moral issues raised by Death Note. Most people just talked about the cat/mouse game. When they did talk about ethics, they were always examples of what I am saying:

Example 1

I have a hunch as to why Light may not have ultimately succeeded in wiping out criminals. Rather why he ended up getting caught. It’s because he never got creative with his killings. He killed solely by heart attacks.

Example 2

“The real problem started when Light decided to kill an innocent. IE Lind “L”. For starters, he’s no longer got moral authority. Before that you could make a philosophical argument that although he wasn’t legally supposed to kill criminals with the Death Note, from a moral standpoint he was the only one with the power to protect the world and humanity from it’s own evil elements, and therefore he had to act. But the moment he kills “Lind” (who as far as Light knew was only doing his job), he’s just another killer who takes pleasure in the act.”

Example 3

YEah you shouldn’t feel sorry for Misa b/c she even states that she doesn’t care if Light only uses her and she’s happy w/ just that.

Example 4

death note is not about good vs. evil L died because Light is better than him and Light died because the death note is bad luck.

in my opinion Light is a good person that happened to pick up the death note and use it to make the world a better place (he can be seen as a supper hero who’s only power is to kill people just by knowing their face and name, some evil guy who wants to take over the world, or a victim). I didn’t really see treat misa bad he just got mad at her when she did something stupid (it was her fault why they got cot by L besides she wanted to help light. Also I thank he fell in love with her when they lost their memory. If he didn’t like her would have killed her or break up with her near the end of the series in stead of going to marry her.

L might seem like the good guy but he’s not really a good person. he’s just a detective for fun, he doesn’t care if what he’s doing is bad or good, he will do any thing just to solve a case like lie, stalling, killing, letting good people die, takes advantage of people, breaks the law, forces people to do bad thing (forcing light to take advantage of misa) siding with criminals. He also hinted he is/was a pervert. You see his evil side and love of sweets in mello and his thinking, logic, loner side in near.

If it was about good vs. evil it would have been more black and white about it.

If any thing the most good person is light dad and the most bad person is the mob boss

Conclusion

See what I mean? People can watch this obscenity and not even be aware that they are becoming nazis.

In the last (bloody) episode, the good cops prevail. OK. But notice how this is done. Kira, surrounded, wounded, once again explains at length what he thinks (more nazi propaganda). Now the good cops are going to respond. I expect some education, finally, would anyone pleeease explain to Kira his mistake? Nobody does. The cop just says “you are wrong, you are just another serial killer and that is all”.

But I have already shown that the moral question is not understood by the target audience. I don’t feel it is understood by the author either.

Artistically, this shit isn’t. It is just another anime. Economically animated (this means many, many stills), silly story, unidimensional characters (who never change), everything you can expect from the culture industry. No investigator appears smoking — but most of them are children (because children is the target audience of this crap and they like to see children), so they have children’s vices such as eating too much chocolate. When a female character finally appears, of course she is a model, blonde, subservient, dumb, and her voice sounds like a woodpecker with a toothache. Intelligent characters are always socially inept, even Light (who starts out popular) becomes lonesome; the detective who finally defeats Kira is a 10-year-old genius who only plays alone with his toys. In other words, all significant people must always be alone. If there ever was a serial killer generator, this is it.

Trash that only children would take; however it is rated TV-14. Much of the music (which always sounds stupid and is repeated in every episode) is stolen from “Carmina Burana” by Carl Orff, himself possibly a Nazi and in any case a favourite composer of the original Nazis. (“Carmina Burana” is a very simple score by 20th century standards; nazis don’t take complexity well, as “Death Note” helps to show.) Some of the credits music is heavy metal, which is known to always be Nazi anyway.

Some cultural references are thrown in without any real significance or effect:

  • Plainchant in the music is in the wrong places and leads to nothing.
  • The main Shinigami character likes to eat apples and Kira provides apples to him. Everybody knows what apples mean, but like I said, this has no significance or effect. It is like an afterthought: “wow, I finally finished writing this damn script — oh wait, I forgot to drop a couple of biblical references in it”.

Anyhow, now that Death Note contains apples, people are saying it is cult.

Desu nôto is one of the most irresponsible things I have ever seen. My advice is: take care of your children and never be afraid to say “no TV”!

]]>
Sun, 30 Mar 2008 00:00:00 +0000
http://dev.nando.audio/2008/03/28/entendendo_mal.html http://dev.nando.audio/2008/03/28/entendendo_mal.html <![CDATA[Entendendo mal o software livre]]>

Entendendo mal o software livre

Será que os jornalistas da Globo sabem o que é software livre? Mas é claro que não!

Um amigo me envia esta notícia no portal Globo.com e fica esperando minha reação. Eu sabia que levaria horas para escrever a seguinte diatribe. Mas decepcioná-lo nunca!

O texto tem duas partes. A primeira noticia o resultado de uma pesquisa. A segunda vira ainda mais um artigo do gênero “Quem tem medo do open source?”. Esse trecho final, para começar, me parece desnecessário. Hoje acho que nem Eric S. Raymond evangeliza mais. Além disso, há erros grosseiros nesses últimos parágrafos. Vou tentar não me preocupar com as asneiras de português e falar só do conteúdo.

A besteira mais ululante e que tanta gente comete é a confusão entre software livre e software grátis. Por exemplo: “Marcelo Okano, confere inúmeras vantagens aos softwares livres frente aos aplicativos pagos.” (A vírgula é do original.)

Vamos combinar uma coisa. Software livre não é o mesmo que software grátis. Essas duas questões são ortogonais. “Livre” opõe-se a “proprietário”. O primeiro pode ser modificado e redistribuído sem dar satisfação a ninguém. O outro não.

O artigo diz: A forma de licenciamento dos softwares livres é gratuita. Isso é freqüente, mas nem sempre. Nada impede uma empresa que produz software livre de cobrar por ele e muitas o fazem. Exemplos: Red Hat, Mandriva, MySQL, db4o etc. O licenciamento é uma questão cheia de firulas; existem muitas maneiras de fazê-lo e uma pessoa comum levará semanas para entender o que está acontecendo.

Nessa esteira, o segundo parágrafo sugere que a “crença geral” é a de que software livre é software para pobre. Verdade? Crença de quem, essa? Da Globo? Pergunto porque já faz anos que o open source é a maneira de trabalhar preferida das maiores empresas de tecnologia (com poucas exceções). Por exemplo, as empresas gostam de fazer tudo em Java e neste universo quase todos os componentes são de código aberto.

Quem fala do open source como se ainda fosse minoria o faz por conhecer somente o monopólio do desktop.

Dito isto, na prática o preço do software livre tende a ser muito competitivo porque o cliente pode mudar de fornecedor sem trocar de software. Por exemplo, se uma empresa fornecedora de suporte ao banco de dados Postgres cometer muitos erros ou cobrar caro demais, o cliente pode mudar de fornecedora e continuar usando o mesmo software.

A liberdade de redistribuir o software também reprime preços altos. O argumento da empresa que vende o software acaba sendo o suporte — pois o mesmo software pode geralmente ser obtido de outra fonte.

Os trechos sobre confiabilidade e segurança são mais ou menos verdadeiros. É que são expressos de maneira tão desajeitada que ficam sujeitos à fácil impugnação pelos adversários. “Há um firewall feito para Linux.” Um? UM firewall? Haja paciência com quem ouviu o galo cantar mas não sabe onde...

O parágrafo seguinte sugere que o Samba é um novo avanço. Como se nossos computadores não conversassem com a rede do Windows há mais de uma década.

“O Linux, por exemplo, é um sistema operacional, sendo o único livre.” Quem disse isso esqueceu-se de FreeBSD, OpenBSD, OpenSolaris... Eu estou me esquecendo de outros. Em números absolutos, existem mais sistemas operacionais livres do que proprietários.

“Pessoas que desenvolvem softwares livres não entendem como uma empresa pode cobrar muito mais pelos programas do que gastou para desenvolvê-los. Como eram contra essa filosofia, lançaram os aplicativos gratuitos”, analisa.

Capitalistas bonzinhos? Isso não existe, é uma asneira de proporções mastodônticas. A dominância do open source é um efeito da acirrada competição na área de tecnologia. Produtos proprietários não sobrevivem se houver equivalente de código aberto. Isto só não atingiu ainda uns poucos mercados em que há monopólio (e.g. Windows). O Adobe Photoshop só sobreviverá, custando o quanto custa, enquanto o Gimp continuar sendo muito inferior. Numa situação de equivalência (ou quase), isso mudará.

O último parágrafo da notícia é tão errado que é incompreensível. Confunde software que roda no servidor (Apache) com software que roda no cliente (navegador do Windows). Também chama de desvantagem do “programa gratuito” a incompatibilidade que na realidade é causada pelo outro lado (sites de bancos que exigem o Internet Explorer). Teria sido melhor não dizer nada.

Finalmente, além de falar de software livre versus software pago, o texto deixa de mencionar que o software livre não é só software. É uma filosofia libertária, é uma causa moral. O primeiro passo para suprimir essa causa foi a invenção do “open source” (código aberto), que é o mesmo software livre, porém sem o argumento de que todo software deveria ser livre pois isto é que é ético.

A IBM fez uma campanha milionária de marketing em prol do Linux. Ao mesmo tempo, gosta de ter alguns produtos proprietários sempre que possível. A IBM não se interessa, destarte, em promover a causa ética do software livre. Por isso falam em open source. Sempre os vi falar em open source.

No Brasil, os meios de comunicação não têm a mesma hombridade. Eles causam mesmo a confusão, usando o termo software livre. Quem lê a notícia da Globo pensa que entendeu e já sabe tudo sobre o assunto. Sequer pode imaginar que a questão é bem mais profunda, é uma questão de liberdade individual mesmo, de direito público e privado. Uma questão que deve ser discutida, não apagada.

Conclusão: mesmo quando dá boas notícias, a indústria cultural o faz de maneira repugnante e estúpida. O propósito é cultivar o framework mental do público, excluindo ou confundindo o que não interessa ao sistema. As razões e o como disto tudo são bem explicadas no documentário “Manufacturing Consent: Noam Chomsky and the Media”. A primeira hora desse filme é devagar, mas depois esquenta.

E quem quiser entender corretamente o software livre conheça o homem que o inventou.

]]>
Fri, 28 Mar 2008 00:00:00 +0000
http://dev.nando.audio/2008/03/27/girias.html http://dev.nando.audio/2008/03/27/girias.html <![CDATA[Balada legal é da hora]]>

Balada legal é da hora

A indústria cultural também é responsável pela idiotice de algumas novas gírias.

A gíria é uma força que leva ao desentendimento entre diversos tempos. Por exemplo, “Erotik” não é o que você pensou, e sim uma bonita peça para piano de Edvard Gried. “Erótico” significava “amoroso” ou “relativo ao amor”. A palavra, faz pouco tempo, especializou-se no sexo, longe do significado que lhe davam os filósofos.

Outro exemplo. Há anos tento tocar (mas é difícil) a terceira balada para piano de Chopin — uma cativante peça de uns 7 minutos de duração, com um incrível equilíbrio dramático e formal. Quando uma amiga pronuncia a palavra “balada”, o que me vem à mente primeiro é o significado original da palavra: obra musical ou poesia narrativa épica, geralmente de caráter folclórico.

O triste é que eles, os estúpidos, nossos inimigos de sempre, pegaram essa palavra e inventaram uma gíria, significando “festa noturna, geralmente em boate”. Esta página sobre gírias data o fato de 1997 e o atribui aos “espertos da mídia dance (novamente eles)”.

Minha amiga replica: Qual o problema da gente usar a palavra balada, se hoje ela tem esse significado?

O problema é que é necessário resistir à estupidez promovida pela indústria cultural (pois cultura não é mercadoria). Vejamos mais algumas gírias a serem evitadas:

  • “Da hora”, “do momento” etc.: É justamente o que o capitalismo quer que você pense: o que é bom é a última novidade, alardeada pelos meios de comunicação. Ao contrário, o bom é o que não é efêmero, e sim eterno.
  • “Something rocks!”: mesma crítica, cumulada com mau gosto musical. Eu prefiro exclamar: “É cláaassico!”
  • “Legal”: quando surgiu, provavelmente significava “é bom porque não é ilegal”. O problema aqui é aceitar passivamente a presunção de que tudo o que é bom é legal e tudo que não é bom é ilegal.
  • “Animal”, “irado”...
]]>
Thu, 27 Mar 2008 00:00:00 +0000
http://dev.nando.audio/2008/03/09/sqlalchemy_decl.html http://dev.nando.audio/2008/03/09/sqlalchemy_decl.html <![CDATA[SQLAlchemy has a new, easy declarative layer]]>

SQLAlchemy has a new, easy declarative layer

A historic transcript from the #sqlalchemy IRC channel

<zzzeek_> deitarion: we just added a new declarative layer which removes a little of the verbosity, not sure if thats where you saw “too much boilerplate”

<justsomedood> woot, declarative layer part of SA? So not an extension?

<zzzeek_> its in ext/

<zzzeek_> we’ve had activemapper its just terrilby out of date

<justsomedood> way out of date

<zzzeek_> this is way smaller than activemapper

<zzzeek_> its 90 lines

<justsomedood> I ran into a lot of problems with it, and sent some fixes to johnathan but it ended up being too much work

<zzzeek_> i doubt this one has any big problems

<zzzeek_> since it does almost nothing :)

<justsomedood> hehehe

<Gedd> justsomedood: what kind of problems?

<justsomedood> It deferred class loading / table creation to make sure all dependencies were met before it did, that didn’t always work

<justsomedood> I ran into cases where if I didn’t define my classes in the correct order it would never create them, or get stuck in a loop

<justsomedood> I haven’t used it since 3.10-ish I think though

<Gedd> ah ok

<Gedd> that explains it :)

<NandoFlorestan> zzzeek_, the synonym stuff in the declarative layer is sweet!

<NandoFlorestan> I think this may be an Elixir killer

<jek> nah

<Gedd> NandoFlorestan: FWIW, Elixir handles synonyms too

<NandoFlorestan> hmm, didnt know that.

<zzzeek_> NandoFlorestan: elixir has a ton of stuff this does not

<justsomedood> So on this one, when defining “complex” relations(), with a primaryjoin on a table/object that hasn’t been defined yet you’d probably have to make that at the end with a class_mapper()?

<zzzeek_> you can stick it on later, like User.someprop = relation(SomeOtherObject, priamryjoin=foo.c.bar==bat.c.foo)

<zzzeek_> theres no class_mapper() needed here really since the class goes right to the mapper.....its also there as class.__mapper__

<justsomedood> k

<justsomedood> cool

<justsomedood> it would definitly condense my models and make them easier for others to read, and I wouldn’t have to worry about the syntax changing

<justsomedood> me likes

<NandoFlorestan> that is why I like it: I already know the syntax

]]>
Sun, 09 Mar 2008 00:00:00 +0000
http://dev.nando.audio/2008/03/03/pylons_without_buffet.html http://dev.nando.audio/2008/03/03/pylons_without_buffet.html <![CDATA[Pylons without Buffet, and a critique of TurboGears]]>

Pylons without Buffet, and a critique of TurboGears

Ben Bangert has decided to remove Buffet from Pylons. Of course it will still support all those templating languages, just not through Buffet.

The replacement? Just a few basic render functions. They make it much easier to see how you’d modify parts if you needed to tweak options — something you cannot do if Buffet is in the equation.

Here is ltbarcly’s version of the same thing.

ltbarcly agrees. Why do we need one function that knows how to render every possible type of template? Just have a function called “render_genshi”, one called “render_mako” etc., then you can do things like streaming in genshi, or form filling, and use all the caching etc in mako. Buffet doesn’t do anything for you really — except give you the lowest common denominator.

He thinks, as I do, that dot notation for template names is stupid. If you write a common path instead, such as “test/blah.html”, it looks for “test/blah/html”... Who needs the additional text replacement code — who ever needed dot notation for templates?

(Mitsuhiko answers: Kid was the one that needed dot notation, because it compiled the template, then imported it.)

I wish TurboGears 2.0 does without Buffet, too...

]]>
Mon, 03 Mar 2008 00:00:00 +0000
http://dev.nando.audio/2008/03/03/turbogears_pylons_ram.html http://dev.nando.audio/2008/03/03/turbogears_pylons_ram.html <![CDATA[Do you really need 21 MB of RAM for a Python website?]]>

Do you really need 21 MB of RAM for a Python website?

I made a little experiment and found that using CherryPy 3.1, plus the packages I need, instead of the whole TurboGears stack, can save a lot of RAM.

How can a TurboGears website use 1/3 less RAM?

(If you host at WebFaction, your account is mainly constrained on memory usage.)

My TurboGears 1.0.4.2 application is using 23,888 KB on startup, then 27,512 KB after many requests for different pages. Pylons is more or less the same, since a Hello World takes up 21 MB.

(Python 2.5, Ubuntu 7.10. I understand this varies a lot based on OS.)

I decided to see what would happen if I rolled my own “framework” on top of CherryPy 3.1, which is vastly superior to CherryPy 2.3 — pity TG hasn’t upgraded!

So I tried a memory consumption test for a CherryPy 3.1 based website.

I started with the CherryPy Hello World, then added import by import, measuring the impact in memory usage. The total memory used is annotated besides the corresponding import.

You can see memory usage with the following Linux shell commands:

ps aux
ps aux | grep python
ps aux | grep hello.py

Don’t confuse virtual memory with resident memory. I am worried about the latter only.

The answer: A CherryPy 3.1 Hello World amounts to mere 7 MB. After I import everything I remember that I need (including Genshi, SQLAlchemy and Routes), I’m using 14 MB.

Here is the (very simple) test for you to reproduce.

Why this enormous difference?

Robert Brewer, CherryPy author, explains to me at #cherrypy:

  • well, I know Sylvain went on a tear recently to make sure we weren’t importing things too early
  • so CP 2.x -> 3.1 might be a good chunk of the difference by itself
  • I also ripped out some of the stdlib modules from CP and rewrote them myself in order to be faster (e.g. no sense importing the whole MIME module when you’re just doing http headers–a lot of the mime stuff is for email)

Of course, I owe my whole Python web programming experience to TurboGears. It provides sane defaults, especially for beginners. I learned Kid, then Genshi. I learned SQLObject, then SQLAlchemy. I also learned how to use Routes as the TG URL dispatcher. And there was the help of a large community.

But now that I am not a beginner, just using plain CherryPy could be a very similar experience.

Based on the result of this simple test, I am thinking of assembling a small TurboGears-like web framework. I would really just steal the things I really use. Make them work under CherryPy 3.1 (TG really should have upgraded.)

TurboGears 2.0 is being implemented on top of Pylons for good reasons... but CherryPy still seems to have several advantages over Paste or even WebOb, so it is not such an easy decision. At least for me.

]]>
Mon, 03 Mar 2008 00:00:00 +0000
http://dev.nando.audio/2008/02/03/cantata95.html http://dev.nando.audio/2008/02/03/cantata95.html <![CDATA[A maravilhosa Cantata 95]]>

A maravilhosa Cantata 95

Não sou um homem religioso mas sei apreciar música, e garanto que é difícil encontrar coisa melhor que as cantatas religiosas de J. S. Bach.

Estou escutando-as todas, na ordem. A Cantata BWV 95 chamou minha atenção. Ao escutá-la seguindo a partitura, fui levado às lágrimas, coisa que nunca acontece. É que só nesse momento vi a letra da música. Não entendo alemão, mas na partitura há uma tradução para o inglês.

Johann Sebastian Bach escreveu mais de 300 cantatas, porém só nos restaram umas 195. Cada Cantata era apresentada num domingo do ano (durante a missa) e seu assunto era determinado pelo calendário religioso luterano.

Cada cantata é um conjunto de peças tais como corais, recitativos, árias etc.

Um famoso relato revela que, ao escutar uma peça de Bach, Mozart exclamou “eis uma coisa com a qual se pode aprender!”, sentou-se com as partituras e não levantou até ter lido todas. Beethoven chamava Bach de “o pai da harmonia”. O compositor de que Chopin provavelmente mais gostava e mais tocava era Bach.

Para o idiota moderno, acostumado a nulidades musicais como as da MTV e da rádio Jovem Pan, pode haver bastante estranhamento no início. Vencida essa barreira, que de resto é culpa de nosso estúpido estilo de vida e não do genial compositor, as cantatas de Bach trazem muita alegria, afinal veiculam um conteúdo humano e divino ao mesmo tempo.

A Cantata BWV 95, intitulada “Christus, der ist mein Leben” (Cristo é minha vida) contém uma famosa ária com pizzicato: “Ach, schlage doch bald”.

http://www.youtube.com/watch?v=_5-mmfof4H8

Página em inglês sobre a Cantata 95

]]>
Sun, 03 Feb 2008 00:00:00 +0000
http://dev.nando.audio/2008/02/03/webpyte.html http://dev.nando.audio/2008/02/03/webpyte.html <![CDATA[Webpyte, framework web escrito em Python]]>

Webpyte, framework web escrito em Python

Publiquei o código-fonte do Webpyte, novo framework para desenvolvimento de sites inspirado no excelente framework web TurboGears, mas usando componentes atualizados. Se você é um desenvolvedor Python, colabore! Aqui está a página do projeto no Google Code.

Webpyte ]]>
Sun, 03 Feb 2008 00:00:00 +0000
http://dev.nando.audio/2008/01/17/helvetica_and_arial.html http://dev.nando.audio/2008/01/17/helvetica_and_arial.html <![CDATA[Typography: Helvetica and Arial]]>

Typography: Helvetica and Arial

The history of the design of Helvetica and the subsequent scourge of Arial are pretty interesting.

]]>
Thu, 17 Jan 2008 00:00:00 +0000
http://dev.nando.audio/2008/01/15/alucinacoes_musicais.html http://dev.nando.audio/2008/01/15/alucinacoes_musicais.html <![CDATA[Alucinações Musicais]]>

Alucinações Musicais

Alucinações Musicais

Os livros do neurologista Oliver Sacks são todos muito bons e este é especial para mim por tratar da audição. Passa por ouvido absoluto, sinestesia, danos ao ouvido, danos ao cérebro etc. O tema principal são as alucinações musicais. Sabe quando alguém perde uma perna e continua a senti-la? Quando alguém perde a audição, pode acontecer coisa parecida: começa a ouvir música, não como ouvimos internamente todos os dias, mas com a ilusão de que a música realmente vem de fora. Para mim esse é só mais um argumento para não suportar a música vagabunda que toca em tantos ambientes por aí. Não dá pra escolher as alucinações musicais, e se forem de má qualidade, serão duplamente detestáveis...

]]>
Tue, 15 Jan 2008 00:00:00 +0000
http://dev.nando.audio/2008/01/08/resources_for_learning_python.html http://dev.nando.audio/2008/01/08/resources_for_learning_python.html <![CDATA[Resources for learning to program in Python]]>

Resources for learning to program in Python

Python is a great language for beginners. (It is also a great language for any application: imperative programming, object-oriented programming and functional programming.)

Enlightening blog posts

For advanced programmers

]]>
Tue, 08 Jan 2008 00:00:00 +0000
http://dev.nando.audio/2008/01/02/here_comes_another_bubble.html http://dev.nando.audio/2008/01/02/here_comes_another_bubble.html <![CDATA[Here comes another bubble]]>

Here comes another bubble

Here is a funny but perhaps true music clip:

http://www.youtube.com/embed/YuAJHaXKgFk

]]>
Wed, 02 Jan 2008 00:00:00 +0000
http://dev.nando.audio/2007/11/09/wrong_cs_research.html http://dev.nando.audio/2007/11/09/wrong_cs_research.html <![CDATA[What's wrong with CS research]]>

What’s wrong with CS research

What’s wrong with Computer Science research

Same subject: Hackers and painters

]]>
Fri, 09 Nov 2007 00:00:00 +0000
http://dev.nando.audio/2007/10/31/asimov_last_question.html http://dev.nando.audio/2007/10/31/asimov_last_question.html <![CDATA[Beautiful short story by Isaac Asimov]]>

Beautiful short story by Isaac Asimov

http://www.multivax.com/last_question.html

...and since we are in a science fiction mood: Are we living in a computer simulation?

]]>
Wed, 31 Oct 2007 00:00:00 +0000
http://dev.nando.audio/2007/09/28/c2i2.html http://dev.nando.audio/2007/09/28/c2i2.html <![CDATA[Project management: C²I²]]>

Project management: C²I²

The C2I2 Hypothesis

The Big Rewrite

]]>
Fri, 28 Sep 2007 00:00:00 +0000
http://dev.nando.audio/2007/09/08/interesting_talks.html http://dev.nando.audio/2007/09/08/interesting_talks.html <![CDATA[Interesting talks at Google Video]]>

Interesting talks at Google Video

The Paradox of Choice - Why More Is Less

How Open Source Projects Survive Poisonous People (And You Can Too)

Practical Common Lisp is a great book by Peter Seibel

Advanced Python

]]>
Sat, 08 Sep 2007 00:00:00 +0000
http://dev.nando.audio/2006/12/14/restoring_grub.html http://dev.nando.audio/2006/12/14/restoring_grub.html <![CDATA[Restoring Grub]]>

Restoring Grub

If you install Ubuntu, then Windows in a different partition, the GRUB boot loader vanishes. But don’t panic and reinstall Ubuntu — you can recover it.

Boot to the Ubuntu Live CD, open up a Console window and type:

# Create a directory called “mounted”:
mkdir mounted
# In there, mount the partition where Ubuntu is installed:
sudo mount /dev/sda2 mounted
# (For the above step you need to find the partition name on your own.)
# However, replace the /dev directory in the mounted partition with the
# current /dev directory:
sudo mount –bind /dev mounted/dev
# Change the root for now
sudo chroot mounted
# Finally, install grub to the first SATA disk:
sudo grub-install –recheck /dev/sda

For more information:

https://help.ubuntu.com/community/RecoveringUbuntuAfterInstallingWindows

https://wiki.ubuntu.com/phbc50/howtos/how-to_reinstall_grub

]]>
Thu, 14 Dec 2006 00:00:00 +0000
http://dev.nando.audio/2006/12/08/contentamento.html http://dev.nando.audio/2006/12/08/contentamento.html <![CDATA[Os inimigos: esperança, contentamento e oportunismo]]>

Os inimigos: esperança, contentamento e oportunismo

O contente não sabe ou não reconhece que está tudo errado.

O esperançoso sabe que está tudo errado, mas aceita temporariamente. Este “temporariamente” tende ao infinito, afinal a paciência é uma virtude. Talvez “comodismo” fosse uma palavra melhor que “esperança”.

O oportunista aproveita que está tudo errado.

O oportunista é pior do que o contente é pior do que o esperançoso:

oportunista < contente < esperançoso

O esperançoso pode ser convencido. O contente só merece ser ignorado, pois é quase impossível convencê-lo. Ao oportunista deve-se reservar somente o insulto:

— Seu seguidor de ambulância!!!

]]>
Fri, 08 Dec 2006 00:00:00 +0000
http://dev.nando.audio/2005/02/13/orchestration.html http://dev.nando.audio/2005/02/13/orchestration.html <![CDATA[Orchestration by Berlioz]]>

Orchestration by Berlioz

Here is a website that contains excerpts from Berlioz’s Grand Traité d’Instrumentation et d’Orchestration Modernes:

http://www.hberlioz.com/Scores/BerliozTreatise.html

]]>
Sun, 13 Feb 2005 00:00:00 +0000
http://dev.nando.audio/2005/02/09/grip.html http://dev.nando.audio/2005/02/09/grip.html <![CDATA[Grip, for ripping CDs]]>

Grip, for ripping CDs

Grip is a great CD ripper/encoder for GNU/Linux. If you have never tried it, give it a go. It rips to wave using cdparanoia or others. It can simultaneously encode the ripped tracks to the format of your choice. Supports cddb too. Easy to use.

I usually encode to the ogg vorbis format (...)

Ogg Vorbis is much better than MP3 (roughly the same audio quality for half the file size) and is free of patents.

On Windows, Winamp has always been able to play ogg files. If you don’t like Winamp there is plenty of other options too – ogg vorbis really is the successor to MP3.

]]>
Wed, 09 Feb 2005 00:00:00 +0000
http://dev.nando.audio/2005/02/02/zero_install.html http://dev.nando.audio/2005/02/02/zero_install.html <![CDATA[Zero Install: packaging software for multiple distros]]>

Zero Install: packaging software for multiple distros

Zero Install looks very useful for free software developers.

Listaller is another perspective.

]]>
Wed, 02 Feb 2005 00:00:00 +0000
http://dev.nando.audio/2004/11/09/msn_password.html http://dev.nando.audio/2004/11/09/msn_password.html <![CDATA[Where to change your MSN / Passport password]]>

Where to change your MSN / Passport password

If you ever need to change your Passport / MSN password, you might lose half an hour searching for this function. It is buried here.

]]>
Tue, 09 Nov 2004 00:00:00 +0000
http://dev.nando.audio/2004/11/05/feed_optin.html http://dev.nando.audio/2004/11/05/feed_optin.html <![CDATA[Feeds: The ultimate opt-in solution]]>

Feeds: The ultimate opt-in solution

David Sklar wants to receive marketing, billing, and other corporate communications via RSS instead of e-mail. Me too. http://www.oreillynet.com/pub/wlg/5680

By the way, the new version of Mozilla Thunderbird (the great free e-mail client) is also a feed reader.

]]>
Fri, 05 Nov 2004 00:00:00 +0000
http://dev.nando.audio/2001/01/27/pontuacao.html http://dev.nando.audio/2001/01/27/pontuacao.html <![CDATA[Anedota sobre pontuação]]>

Anedota sobre pontuação

Um professor meu gostava de dizer que “vírgula não é orégano”. E às vezes umas poucas vírgulas podem assumir importância insuspeita. Eis um exemplo:

Um homem rico estava à beira da morte. Pediu papel e pena e escreveu assim:

Deixo meus bens à minha irmã não a meu sobrinho jamais será paga a conta do alfaiate nada aos pobres.

Morreu antes de fazer a pontuação. A quem deixava ele a fortuna? Eram quatro concorrentes.

  1. O sobrinho fez a seguinte pontuação:

    Deixo meus bens à minha irmã? Não! A meu sobrinho. Jamais será paga a conta do alfaiate. Nada aos pobres.

  2. A irmã chegou em seguida. Pontuou assim o escrito:

    Deixo meus bens à minha irmã. Não a meu sobrinho. Jamais será paga a conta do alfaiate. Nada aos pobres.

  3. O alfaiate pediu cópia do original. Puxou a brasa pra sardinha dele:

    Deixo meus bens à minha irmã? Não! A meu sobrinho? Jamais! Será paga a conta do alfaiate. Nada aos pobres.

  4. Aí, chegaram os descamisados da cidade. Um deles, sabido, fez esta interpretação:

    Deixo meus bens à minha irmã? Não! A meu sobrinho? Jamais! Será paga a conta do alfaiate? Nada! Aos pobres.

Assim é a vida. Nós é que colocamos os pontos. E isso faz a diferença.

]]>
Sat, 27 Jan 2001 00:00:00 +0000
http://dev.nando.audio/2001/01/23/blade_runner.html http://dev.nando.audio/2001/01/23/blade_runner.html <![CDATA[On Blade Runner]]>

On Blade Runner

Blade Runner, the cult movie, faced many problems in post-production. People wouldn’t get it, including, it appears, some of its producers. I have recently watched the director’s cut for the tenth time and it is still growing on me. It certainly is one of the more perfect movies I have ever seen.

A very interesting read is the Blade Runner FAQ. It reveals things that certainly didn’t occur to you as you watched, but will intrigue you now...

Spoiler warning: Do not read the Blade Runner FAQ if you haven’t seen the movie yet!

]]>
Tue, 23 Jan 2001 00:00:00 +0000
http://dev.nando.audio/2001/01/12/bulb2.html http://dev.nando.audio/2001/01/12/bulb2.html <![CDATA[Bulb 2]]>

Bulb 2

Back in the year 2000, as a young music composer wannabe, who even had some music published at the mp3.com phenomenal website, I was looking up the internet for some opportunity to create music for animations and I came across the young filmmaker Ryan Foss. He had just posted a very short scene of a work-in-progress of his, featuring a bulb-headed robot in dark surroundings. I watched the few seconds of silent video and felt an atmosphere... eerie... almost religious... but heavy.

I didn’t talk to Ryan. I proceeded to compose some music on my computer, using the sounds of a church organ, a cello and a fake choir. Then I sent the music to him while also introducing myself.

I remember he said he didn’t immediately like the music, but as soon as he heard it with the video, he found they matched. A partnership was born – he did need music – and the result, a very short 3d animation, can be seen at:

http://www.pocketmovies.net/download/bulb

If you are seeing this much later, bear in mind this was the year 2000 and the whole thing was done in our personal computers...

Bulb, a 3d animation

Now we have completed the animation Bulb II, which shows that we both made a lot of progress in one year.

http://www.pocketmovies.net/download/bulb-ii

This time, there was much more work to do, so in addition to the music, I am responsible for part of the story and part of the sound effects.

2A in the first short meant 2 amperes. But now we think of it as a serial number. Thus, 2B. But the real mysteries in the story are to remain unanswered.

Here is something nobody has ever noticed: Near the end of the music, I quote Schumann’s Warum? (“Why?”, third piece from the Fantasiestücke op.12). That is such a beautiful piece of counterpoint!

For the sequel I have been able to use better sounds and equipment. I feel the lack of words makes the music entirely responsible for setting the mood and explaining the feelings. I like that responsibility. Reminds me of old silent film, such as Metropolis. There now exist countless soundtracks to this classic movie, written by different composers. Not many are good, but at least one is: Descent, written by the Australian composer Carl Vine.

I don’t think the 2 videos can change people’s lives, but they were great as creative exercises and they actually got included in 2002 in Volume One of North America’s Best Independent Animated Shorts.

Hell, my name even got into IMDb, the largest website about cinema.

I have never met Ryan in person. Isn’t it amazing what we can do over the internet these days?

Now if you are tired of the heavy atmosphere of these 2 shorts, I have the perfect antidote for you. Another australian artist, Dave Jones, makes wonderful, funny Flash animations. Browse his Transience website, click Animations, then watch The Heist. (No, I didn’t work with him, I just love The Heist.)

I enjoy composing serious music for film and I would like to do it again...

]]>
Fri, 12 Jan 2001 00:00:00 +0000
http://dev.nando.audio/1994/11/10/alexandre_levy_en.html http://dev.nando.audio/1994/11/10/alexandre_levy_en.html <![CDATA[Alexandre Levy, romantic Brazilian composer]]>

Alexandre Levy, romantic Brazilian composer

I want you to meet romantic Brazilian composer Alexandre Levy, who lived only 27 years but left important works of very good taste.

While you read about this fantastic musician, listen to the Tango Brasileiro, his most famous work, recovered from an old vynil, as played by the wonderful pianist Eudóxia de Barros:

Eudóxia de Barros

Thanks to pianist Eudóxia de Barros for allowing me to publish here her recordings of compositions by Alexandre Levy!

Alexandre Levy’s historical significance

Interest in this great composer is justified mainly by the high quality of his output, all in the romantic tradition.

Further, Levy was a pioneer of Brazilian musical nationalism, as shown in the Tango Brasileiro, for piano, and the Suite bresilienne. In spite of the title in French, the fourth part of the suite is a Samba.

He is considered one of the best Brazilian composers of the romantic period. One wonders what could have happened if only he hadn’t died so early and had had the chance to write more music...

Tango Brasileiro

Tango Brasileiro was published in 1890 in the newspaper O Diario Popular, “as a gift to our graceful readers”. What does this mean?

In those times – well before women’s suffrage –, all the well-born ladies had a piano at home and were taught to play it. But well beyond these youngens’ delight, the piece is now part of the standard Brazilian repertoire of piano music. Guiomar Novaes, Antonieta Rudge and Eudóxia de Barros are some of the pianists that have recorded it.

(The tango brasileiro as a genre is a Brazilian ballroom dance that was in vogue in Rio de Janeiro in the last decades of the XIX century. It is very different from the tango argentino. Another pianist from those times, Ernesto Nazareth, wrote many famous Brazilian Tangos. Finally, the chorinho genre took over both Nazareth’s music and the tango brasileiro, as if both had always been choro.)

Brief musical analysis

Here is the first page of the score of the Tango Brasileiro.

Levy’s piece is built on the contrast between two themes, the first in A Major, the second in A Minor (0:14-1:19). The last section is in A Major, but the final chord is, surprisingly, of A Minor. This is the opposite of the Picardy third, which Walter Piston explains in his Harmony:

“In the eighteenth century it was almost a mannerism to end on a major tonic triad even though the movement had been unmistakably in minor throughout. This major third was called the tierce de Picardie or Picardy third.”

Can I, then, call Levy’s procedure an anti-Picardy third?

The function of this final surprise is to wrap or synthesize, in a single chord, the entire tension of the piece, as in the most daring romantic fragments.

Impromptu-caprice op. 1

This elegant and good-humoured piece for piano, opus 1 by Alexandre Levy, was composed between 1881 and 1882. The interpretation is by Eudóxia de Barros.

Little biography of Alexandre Levy

Alexandre Levy

Alexandre Levy was born in November 10th, 1864. He grew up in a very musical environment. His father, Henrique Luis Levy, owned the Casa Levy, a music store that was very important in the cultural life of the city of São Paulo, Brazil’s largest metropolis. The Casa Levy survives today as a piano store.

Alexandre Levy’s first music teacher was his brother Luis Levy, an excellent pianist and a good composer as well. Later Alexandre studied with Gabriel Giraudon, a French teacher who lived in São Paulo.

French culture must have influenced Alexandre Levy. The family probably used to speak French at home: his father was born French and his mother was from the French part of Switzerland. The composer used to name his works in French.

In 1887 Alexandre went to Europe in order to complete his education. In Paris he studied harmony and counterpoint with Emile Durand, who would also teach Claude Debussy.

Back to São Paulo, Levy composed some masterpieces until his mysterious premature death on January 17th, 1892. He did not suffer from any illness that we know of, but suddenly passed away, leaving an amazing production for a 27 year-old. “An announcement of a genius”, said Mario de Andrade.

Romance sans paroles op.4 n.1

An interesting romantic miniature, very quiet, in the tradition of Felix Mendelssohn’s songs without words. Played by Eudóxia de Barros.

Influences

Levy’s music took a strong influence from Schumann. But his works are highly original and sometimes built on Brazilian popular forms (the case of the Tango Brasileiro) or use Brazilian folk themes as raw material, which makes him a pioneer of Brazilian musical nationalism.

In fact, even if his art is fundamentally European, Alexandre Levy was classified by Mario de Andrade (perhaps irresponsibly) as a more characteristically Brazilian composer, along with Antonio Carlos Gomes (1836-1896) and Alberto Nepomuceno (1864-1920), than others whose attempts at creating Brazilian music seem more a concession to the exotic, since they couldn’t free themselves enough from European lessons (Leopoldo Miguez (1850-1902), Henrique Oswald (1852-1923), Francisco Braga (1868-1945), João Gomes de Araújo, Barroso Neto (1881-1941) and Glauco Velásquez (1884-1914)).

It cannot be said that Alexandre Levy was the very first composer to use Brazilian popular elements as a thematic basis because in 1857 Antônio Carlos Gomes wrote Cayumba, a negro dance, inspired in folk sources. Another important work which preceded Levy’s was the piano rhapsody A Sertaneja, written in 1869 by diplomat and composer Brasílio Itiberê da Cunha (1848-1913). The song he used was Balaio, from the south of Brazil.

This however does not diminish Alexandre Levy’s historical importance, which is also due to the quality of his compositions.

Allegro appassionato op. 14

Belkiss Carneiro de Mendonça

This important and difficult piano piece, from 1887, reveals how much Levy admired Robert Schumann. The appassionato (passionate) isn’t in the title gratuitously; this is one of Levy’s most romantic pieces.

This haunting performance is by sensational pianist Belkiss Carneiro de Mendonça, who lived in Goiás and passed away in 2005.

Variations sur un thème populaire brésilien (Vem Cá, Bitu)

Nowadays the Brazilian folk song “Vem cá, Bitu” is better known by its alternative lyrics “Cai, cai, balão”. The first theme with variations ever written on a Brazilian folk song is this interesting piece by Alexandre Levy, with 16 variations.

I intend to write a post about these variations, using Eudóxia de Barros’ recording. Are you interested?

]]>
Thu, 10 Nov 1994 00:00:00 +0000
http://dev.nando.audio/1994/11/10/alexandre_levy.html http://dev.nando.audio/1994/11/10/alexandre_levy.html <![CDATA[Alexandre Levy, compositor romântico paulistano]]>

Alexandre Levy, compositor romântico paulistano

Faço questão que você conheça o compositor romântico paulistano Alexandre Levy, que viveu apenas 27 anos mas deixou uma obra importante e de muito bom gosto.

Enquanto você lê sobre este fantástico músico, ouça o Tango Brasileiro, sua obra mais famosa, na interpretação da maravilhosa pianista Eudóxia de Barros, recuperada de um velho vinil:

Eudóxia de Barros

Agradeço à pianista Eudóxia de Barros pela permissão para publicar aqui as suas gravações das músicas de Alexandre Levy!

Importância histórica de Alexandre Levy

O interesse no grande compositor justifica-se principalmente pela alta qualidade de suas obras, inseridas na tradição romântica.

Além disso, Levy foi um pioneiro do nacionalismo musical no Brasil, com obras como o Tango Brasileiro para piano e a Suite bresilienne. Apesar do título em francês, a quarta parte da suíte é um Samba.

É considerado um dos melhor compositores brasileiros do período romântico. Imagine se não tivesse morrido tão cedo e tivesse produzido mais...

O Tango Brasileiro

O Tango Brasileiro foi publicado em 1890 no jornal O Diario Popular, “como um presente às suas graciosas leitoras”. O que significa isto?

Naquela época – bem antes do sufrágio feminino –, as moças bem-nascidas tinham um piano em casa e eram ensinadas a tocá-lo. Mas muito além do deleite dessas jovens, o Tango entrou para o repertório brasileiro de música para piano. Guiomar Novaes, Antonieta Rudge e Eudóxia de Barros são só algumas das pianistas que o gravaram.

(O tango brasileiro é uma dança de salão brasileira que esteve na moda no Rio de Janeiro nas últimas décadas do séc. XIX. É bastante diferente do tango argentino. Outro pianista da época, Ernesto Nazareth, escreveu muitos tangos brasileiros famosos. Finalmente, o chorinho apropriou-se tanto de Nazareth como do tango brasileiro, como se ambos sempre tivessem sido choro.)

Breve análise musical

Veja a primeira página da partitura do Tango Brasileiro.

A peça de Levy é construída sobre o contraste entre dois temas, o primeiro em lá maior, o segundo em lá menor (0:14-1:19). A última seção é em lá maior, mas o acorde final é – surpresa sonora! – de lá menor. Isto é o oposto da terça picarda, explicada por Walter Piston em seu livro Harmonia da seguinte forma:

“No século 18 era quase um maneirismo terminar numa tríade de tônica maior embora o movimento tivesse certamente sido todo em modo menor. Esta terça maior era chamada tierce de Picardie ou terça de Picardia.”

Posso então chamar o procedimento de Levy de terça anti-picarda?

A função desta surpresa final é resumir num único acorde toda a tensão da peça, como nos mais geniais fragmentos românticos.

Impromptu-caprice op. 1

Esta elegante e bem-humorada peça para piano, opus 1 de Alexandre Levy, foi composta entre 1881 e 1882. A interpretação é de Eudóxia de Barros.

Breve biografia de Alexandre Levy

Alexandre Levy

Alexandre Levy nasceu em 10 de novembro de 1864. Cresceu num ambiente muito musical. Seu pai, Henrique Luis Levy, foi o fundador da Casa Levy, uma loja de música muito importante na vida cultural da cidade de São Paulo. Existe ainda hoje como comércio de pianos.

O primeiro professor de música do menino foi seu irmão Luis Levy, excelente pianista e também compositor. Mais tarde, Alexandre estudou com Gabriel Giraudon, professor francês que vivia em São Paulo.

A cultura francesa certamente influenciou Alexandre Levy. A família provavelmente falava francês em casa: seu pai era francês de nascimento e sua mãe vinha da parte francesa da Suíça. O compositor costumava dar títulos em francês às suas obras.

Em 1887 Alexandre foi para a Europa para completar sua educação. Em Paris ele estudou harmonia e contraponto com Emile Durand, que haveria de ser também professor de Claude Debussy.

De volta a São Paulo, Levy compôs algumas obras-primas até sua misteriosa morte prematura, no dia 17 de janeiro de 1892. Ao que se saiba não sofria de nenhum mal, mas subitamente faleceu, deixando já uma produção espantosa para quem teve apenas 27 anos de vida. “Um anúncio de gênio”, disse Mario de Andrade.

Romance sans paroles op.4 n.1

Uma interessante miniatura romântica, quietinha, na tradição das Canções sem palavras de Felix Mendelssohn. Tocada aqui por Eudóxia de Barros.

Influências

A música de Levy mostra forte influência de Schumann. Mas suas obras são altamente originais e às vezes construídas em formas populares brasileiras (o caso do Tango Brasileiro) ou usam temas folclóricos brasileiros como matéria prima, o que o torna um precursor do nacionalismo musical brasileiro.

De fato, mesmo se sua arte é fundamentalmente europeia, Alexandre Levy foi classificado por Mario de Andrade (talvez irresponsavelmente) como um compositor mais caracteristicamente brasileiro, juntamente com Antonio Carlos Gomes (1836-1896) e Alberto Nepomuceno (1864-1920), do que outros cujas tentativas de fazer música brasileira parecem mais uma concessão ao exótico, pois não conseguiam se libertar o suficiente das lições europeias (Leopoldo Miguez (1850-1902), Henrique Oswald (1852-1923), Francisco Braga (1868-1945), João Gomes de Araújo, Barroso Neto (1881-1941) e Glauco Velásquez (1884-1914)).

Alexandre Levy não foi o primeiríssimo compositor a usar elementos populares brasileiros como base temática porque já em 1857 Antônio Carlos Gomes escrevia Cayumba, uma dança de negros, inspirada em fontes populares. Outra obra importante que precedeu às de Levy foi a rapsódia para piano A Sertaneja, do diplomata e compositor Brasílio Itiberê da Cunha (1848-1913), composta em 1869. A canção usada foi Balaio, do sul do Brasil.

Mas isto não diminui a importância histórica de Alexandre Levy, que também se deve à qualidade de suas composições.

Allegro appassionato op. 14

Belkiss Carneiro de Mendonça

Esta importante e difícil peça para piano, de 1887, revela o quanto Levy admirava Robert Schumann. O appassionato (apaixonado) não está no título por acaso; é uma das peças mais românticas de Levy.

Esta arrebatadora performance é da sensacional pianista goiana Belkiss Carneiro de Mendonça, falecida em 2005.

Variations sur un thème populaire brésilien (Vem Cá, Bitu)

Hoje em dia a canção folclórica brasileira “Vem cá, Bitu” é mais conhecida pela letra alternativa “Cai, cai, balão”. O primeiro tema com variações jamais escrito sobre uma canção folclórica brasileira é esta interessante obra de Alexandre Levy, com 16 variações.

Pretendo escrever um post somente sobre essas variações, usando a gravação de Eudóxia de Barros. Você se interessaria?

]]>
Thu, 10 Nov 1994 00:00:00 +0000