Older blog entries for ralsina (starting at number 587)

Your Editor is Not the Bottleneck

This may cause some palpitations in some friends of mine who laugh at me for using kwrite, but it really is not. Any time you spend configuring, choosing, adjusting, tweaking, changing, improving, patching or getting used to your editor is time invested, for which you need to show a benefit, or else it's time wasted.

Let's look at SLOC, which while discredited as a measure of programmer's productivity, surely does work as a measure of how much a programmer types, right?

Well, estimates of total code production across the lifetime of a product vary (just take the SLOC of the product, divide by men/days spent), but they are usually something between 10 and 100 SLOC per programmer per day. Let's be generous and say 200.

So, 200 lines in eight hours. That's roughly one line every two minutes, and the average line of code is about 45 characters. Since I assume you are a competent typist (if you are not, shame on you!), it takes less than 20 seconds to type that.

So, typing, which is what you often tweak in your editor, takes less than 15% of your time. And how much faster can it get? Can you get a line written in 10 seconds? Then you just saved 8% of your day. And really, does your editor isave you half the typing time?

How much time do you lose having your eyes wonder over the sidebars, buttons, toolbars, etc?

So while yes, typing faster and more efficiently is an optimization, it may also be premature, in that, what the hell are we doing the other 80% of the time? Isn't there something we can do to make that huge chunck of time more efficient instead of the smaller chunk?

Well, I think we spent most of that time doing three things:

  1. Reading code
  2. Thinking about what code to write
  3. Fixing what we wrote in that other 20%

The first is easy: we need better code readers not editors. It's a pity that the main interface we get for looking at code is an editor, with its constant lure towards just changing stuff. I think there is a lost opportunity there somewhere, for an app where you can look at the code in original or interesting ways, so that you understand the code better.

The second is harder, because it's personal. I walk. If you see me walking while my editor is open, I am thinking. After I think, I write. Your mileage may vary.

The third is by far the hardest of the three. For example, autocomplete helps there, because you won't mistype things, which is interesting, but more powerful approaches exist, like constant running of tests suites while you edit. Every time you leave a line, trigger the affected parts of the suite.

That's much harder than it sounds, since it means your tools need to correlate your test suite to your code very tightly, so that you will see you are breaking stuff the second you break it, not minutes later.

Also, it should enable you to jump to the test with a keystroke, so that you can fix those tests if you are changing behaviour in your code. And of course it will mean you need tests ;-)

Which brings me to a pet peeve of mine, that editors still treat the file as the unit of work, which makes no sense at all. You never want to edit a file, you want to edit a function, or a class, or a method, or a constant but never a file. Knowing this was the sheer genius of ancient Visual Basic, which was completely ignored by all the snobs looking down at it.

So, instead of tweaking your editor, get me a tool that does what I need please. I have been waiting for it since VB 1.0. And a sandwich.

warning

This post is 99% lies, but I want to hear the arguments against it. If I tell you now it doesn't count as a real lie, I have learned from financial press ;-)


Syndicated 2012-07-15 22:22:12 from Lateral Opinion

Quick Hack to Catalog your Books

If you have actual, paper books and want to catalog their info quickly, this bookdata.py script may be handy:

import sys
import time
import gdata.books.service
import json

def get_book_info(isbn):
    print "Looking for ISBN:", isbn
    google_books = gdata.books.service.BookService()
    result = google_books.search('ISBN %s '%isbn)
    data = [x.to_dict() for x in result.entry]
    if not data:
        print "No results"
        return
    title = data[0]['title']
    with open(title+'.json','w') as f:
        f.write(json.dumps(data))
    print "Guardada info de '%s' en '%s.json'" %(isbn, title])

if __name__ == "__main__":
    while True:
        isbn = sys.stdin.readline().strip()
        if isbn:
            get_book_info(isbn)
        time.sleep(1)

What does it do? It reads ISBN numbers from standard input and saves the book's info in a title.json file for later processing and formatting.

If you want to edit that information, you can just do it or you can try doing a little script using jsonwidget like this:

python -c 'import jsonwidget; jsonwidget.run_editor("abook.json", schemafile="gbooks.schema")'

Where abook.json is a file generated by the previous script and gbooks.schema is this file.

Oh, and if your books have barcodes, you can just do:

zbarcam --raw | python bookdata.py

Show your computer your books and let it do the rest :-)

PS: I would love if someone gathered all this and made a nice personal book cataloguing thing.


Syndicated 2012-07-13 12:22:00 from Lateral Opinion

The Arrows of Outrageous Fortune

You know how I know we live in a unicode world now? Of the 300+ unicode arrows, all display correctly by default on Windows, Mac and Ubuntu, except maybe ~25.

← → ↑ ↓ ↔ ↕ ↖ ↗ ↘ ↙ ↮ ⇦ ⇨ ⇧ ⇩ ⬄ ⇳ ⬀ ⬁ ⬂ ⬃ ⬅ ➡ ⬆ ⬇ ⬈ ⬉ ⬊ ⬋ ⬌ ⬍ ⇐ ⇒ ⇑ ⇓ ⇔ ⇕ ⇖ ⇗ ⇘ ⇙ ⇍ ⇏ ⇎ ⟸ ⟹ ⟺ ↤ ↦ ↥ ↧ ⇤ ⇥ ⤒ ⤓ ↨ ⇆ ⇄ ⇅ ⇵ ⇈ ⇊ ⇇ ⇉ ⇠ ⇢ ⇡ ⇣ ⇚ ⇛ ⤊ ⤋ ⭅ ⭆ ⟰ ⟱ ↩ ↪ ↫ ↬ ↞ ↟ ↠ ↡ ↚ ↛ ↜ ↝ ↢ ↣ ↰ ↱ ↲ ↳ ⬐ ⬎ ⬑ ⬏ ↴ ↵ ↺ ↻ ⥀ ⥁ ⟲ ⟳ ↶ ↷ ⤾ ⤿ ⤸ ⤹ ⤺ ⤻ ↼ ⇀ ↿ ↾ ↽ ⇁ ⇂ ⇃ ⇋ ⇌ ⇜ ⇝ ⇽ ⇾ ⇿ ⟻ ⟼ ⟵ ⟶ ⟷ ⬳ ⟿ ⬱ ⇶ ⥊ ⥋ ⥌ ⥍ ⥎ ⥏ ⥐ ⥑ ⥒ ⥓ ⥔ ⥕ ⥖ ⥗ ⥘ ⥙ ⥚ ⥛ ⥜ ⥝ ⥞ ⥟ ⥠ ⥡ ⥢ ⥣ ⥤ ⥥ ⥦ ⥨ ⥧ ⥩ ⥮ ⥯ ⥪ ⥫ ⥬ ⥭ ⇷ ⇸ ⤉ ⤈ ⇹ ⇺ ⇻ ⇞ ⇟ ⇼ ⬴ ⤀ ⬵ ⤁ ⬹ ⤔ ⬺ ⤕ ⤂ ⤃ ⤄ ⬶ ⤅ ⬻ ⤖ ⬼ ⤗ ⬽ ⤘ ⤆ ⤇ ⤌ ⤍ ⤎ ⤏ ⤙ ⤚ ⤛ ⤜ ⤝ ⤞ ⤟ ⤠ ⤡ ⤢ ⤣ ⤤ ⤥ ⤦ ⤪ ⤨ ⤧ ⤩ ⤭ ⤮ ⤯ ⤰ ⤱ ⤲ ⤫ ⤬ ⥼ ⥽ ⥾ ⥿ ⤶ ⤷ ⤴ ⤵ ⤼ ⤽ ⥂ ⥃ ⥄ ⭀ ⥱ ⥶ ⥸ ⭂ ⭈ ⭊ ⥵ ⭁ ⭇ ⭉ ⥲ ⭋ ⭌ ⥳ ⥴ ⥆ ⥅ ⬷ ⤐ ⬸ ⤑ ⬿ ⤳ ⥹ ⥻ ⬰ ⇴ ⥈ ⬾ ⥇ ⬲ ⟴ ⥷ ⭃ ⥺ ⭄ ⇱ ⇲ ↸ ↹ ↯ ↭ ⥉ ⥰ ☚ ☛ ☜ ☝ ☞ ☟ ◄ ► ⇪ ⇫ ⇬ ⇭ ⇮ ⇯ ⇰ ➔ ➘ ➙ ➚ ➛ ➜ ➝ ➞ ➟ ➠ ➡ ➢ ➣ ➤ ➥ ➦ ➧ ➨ ➩ ➪ ➫ ➬ ➭ ➮ ➯ ➱ ➲ ➳ ➴ ➵ ➶ ➷ ➸ ➹ ➺ ➻ ➼ ➽ ➾

A few years ago, many apps and fonts were confused by simple letters with diacritics like á. So, yes, real progress happens.


Syndicated 2012-07-12 22:10:00 from Lateral Opinion

The Long Post About PyCamp 2012

As I have mentioned in half a dozen posts already, I spent the last weekend at PyCamp 2012. But what I have not written about is what exactly it was, and why anyone would want to attend one, or maybe organize one. So that's what this post is about.

PyCamp was organized by PyAr, the Python Argentina community. PyAr is a very special bunch of people, who are completely amateur, and do everything for love and fun. Since PyAr is a very special group of people, the things PyAr causes, inspires or creates are special as well.

So, since a few years ago, what happens is someone finds a place with bunk beds, a large room, perhaps somewhat isolated, that provides meals, and is cheap (it's as hard as it sounds) and rents it for a long weekend. Then everyone is invited to chip in for the rent money.

This year, 4-days, all inclusive, costed roughly U$S 100. Sure, it's not exactly luxury accomodations, but it does what it has to do, which is give us shelter and protect us from wild animals.

Thus, you end up with a few dozen nerds with computers, one of them is great at setting up wireless (Joac!), one is the MC (Alecu!), one helps around (Facundo!) one is the liaison with the location (Pindonga!) and so on, the work is spread around, and we have time and company to hack.

So, on the first morning, everyone proposes what he would like to work on. Those proposals are voted by the public, and those with more votes are assigned slots (5 a day), where they will be the main focus of attention.

So, what happens if your proposal is not voted? Well, you either find a proposal you like, and join it, or you just do your thing. Because this is not a democracy, this is anarchy, the votes are just a way for everyone to know what people will be doing, and to find places to fit in if you want (BTW, there is a situation in LeGuin's The Disposessed which is so much like this, it's scary).

After that, you just do what you want. You can put your headset on, and code, or mingle and chat, or join a group, or do a bit of everything. Since meals are catered, you don't have to worry about breaks. When the meal is ready, everyone breaks at the same time and socializes in communitary tables.

Does all this sound as strange to you as it does to me? A bunch of grown professionals acting like hippies. Well, it feels strange too, but that doesn't mean it doesn't feel great. It even works great. Once you see what the others are doing, things you wouldn't expect start looking like fun (Celery!?! Juggernaut! Android!) and the sheer excitement of people telling you "look, I did this!" is infectious, and exhilarating.

Also, RC cars, kinect hacking, android hacking, electric guitar hacking, juggling, monocycle lessons, a firepit, alcohol, coffee, mate, boardgames, cardgames, music, jokes, adrenaline, huge spiders, asado, cold, vim, ninja, ping pong, robot spaceships, people you see only twice a year if that, questions, not knowing the answers, figuring things out on the run, getting help in that thing you have been stuck for weeks, having the piece someone else has been stuck on for weeks, feeling like some sort of bearded buddha and a total ignoramus in 5 minutes...

And at least I, at least this year, had a very productive weekend. I got help from a bunch of people in things I was daunted by, I felt like an active programmer instead of a suit, which is always nice, since I don't own a suit, and had a great time. Laughed a lot. Made a couple new friends. Saw a bunch of old ones. Helped a few people.

So, I would like other people to have as great a time as I had. Of course coming to Argentina is probably not a great idea. It's an expensive trip, if you don't speak spanish you will miss a lot, and if PyCamp gets too big it may stop being fun at all.

But why not do something similar? Doesn't have to be about Python, you can do it about making stuff, about programming in general, whatever. Just get a somewhat comfortable, somewhat isolated place with a reasonable catering and get your 50 nearest geeks there, and have a ton of fun.

You may get something useful done, too.


Syndicated 2012-07-11 22:28:00 from Lateral Opinion

The Event I Wish Existed

I spent a long weeked at PyCamp. It was awesome. How could spending 4 days with 50 geeks hacking things and programming python not be awesome. But I was alone, because really, my wife (a lawyer) and son (too young to code yet) would have been bored to tears.

And I know something similar happened to a bunch of others there. Let's face it, we geeks are getting older. While there is still an influx of young people, we old ones are refusing to go away, and we are now married, and have kids, and leaving for days is unfair to our families.

So, I wish there was an event where I could go and do this, while my wife could go as well, and my son too, and there would be something for everyone. Maybe we would not hack all day long, but just half a day. Maybe we wuold hack more games and then beta test them on the kids.

One good thing about kids is that once you cross a certain threshold, in a controlled environment, the need for adult monitoring decreases. In m experience, 1 kid needs 1 adult, 2 kids need 1.5, and 5 kids need .5 adults.

The board games at night would be inclusive (my wife likes role games, for example), the juggling classes could include kids, people could work on artwork... I don't know, do things that are not exclusively hacking. I love hacking but it's a smaller part of my life than it was in the past.

So, anyone has any good ideas? Know of such a place or event?


Syndicated 2012-07-11 10:49:00 from Lateral Opinion

Programando Cross-Platform

Sorry again, spanish only, because it's another video of me speaking in spanish (this time with a spaniard)


Si querés tener muchos usuarios de tu programa, es fundamental que el universo de "gente que puede usar el programa" sea lo más grande posible. El mejor camino para ello es hacer que el sistema operativo que usa/sufre tu potencial usuario esté soportado. Hacer eso no es increíblemente difícil, pero siempre hay alguna cosa rara. La conferencia tuvo lugar en la ciudad de Junín ( Buenos Aires, Argentina ) en Septiembre de 2011, y fué organizada por PyAr ( Python Argentina ).

Video:

Slides:

New Advogato Features

New HTML Parser: The long-awaited libxml2 based HTML parser code is live. It needs further work but already handles most markup better than the original parser.

Keep up with the latest Advogato features by reading the Advogato status blog.

If you're a C programmer with some spare time, take a look at the mod_virgule project page and help us with one of the tasks on the ToDo list!