Skip to main content

Ralsina.Me — Roberto Alsina's website

Posts about programming (old posts, page 58)

Marave 0.1 released, please test!

The first "good" ver­sion of Mar­ave my re­lax­ing text ed­i­tor is out!

What is Mar­ave?

Mar­ave is an ed­i­tor that does­n't dis­tract you. It has a fullscreen in­ter­face, and most of the time, while you write, you will on­ly see your tex­t, and maybe a back­ground:

marave1

Of course it is al­so quite con­fig­urable:

marave2

Some of the fea­tures:

  • Cus­­tom back­­­grounds (im­ages or col­ors)

  • Font and font size are con­­fig­urable

  • Re­­size­able ed­i­­tor of con­­fig­urable opac­i­­ty

  • "Van­ish­ing" UI, when you tipe, it all goes away

  • Op­­tion­al me­­dia play­er (right now aimed at stream­ing au­­dio, maybe sound­s­capes some­­day)

  • Op­­tion­al au­­dio feed­back for the key­board (just in case you miss the old type­­writer)

  • Theme sup­­port

  • Mul­ti­lin­gual spellcheck­­ing (re­quires pyen­chan­t)

Mar­ave is im­ple­ment­ed us­ing PyQt, so it should work in all ma­jor plat­form­s, Win­dows, Lin­ux and Mac OS­X, as long as you have PyQt in­stalled.

In the fu­ture, easy to use bi­na­ries will be pro­vid­ed for Win­dows and Mac.

This ver­sion is not fea­ture com­plete. Specif­i­cal­ly:

  • Search+Re­­place is not done

  • There may be some cus­­tomiza­­­tions not im­­ple­­men­t­ed

Down­load Mar­ave 0.1

UP­DATE 0.2 is out, at http://­code.­google.­com/p/­mar­ave/­down­load­s/list

Apple's iPad is a sad, sad thing.

What the Ipad means

Ev­ery­thing I will say here was prob­a­bly bet­ter said by Mark Pil­grim but what the heck, let's give it a shot.

Here's what's wrong with the iPad: it sucks for me.

Be­fore any­one says "don't buy it then!" I'll say it first: I don't in­tend to buy one.

I think there is a place for iPads and it would go agains most of my be­liefs to say it should­n't ex­ist, but I al­so ex­pect it to make our world poor­er, if it's pop­u­lar enough.

Yes it's hos­tile to tin­ker­ing. Yes, to read about that, see Mark Pil­grim's ar­ti­cle, he's a much bet­ter writ­er than I.

I once post­ed the README file for a piece of soft­ware called At­last. It said things like "make ev­ery­thing pro­grammable" and "[It is] far bet­ter to in­vest the ef­fort up front to cre­ate a prod­uct flex­i­ble enough to be adapt­ed at will, by its user­s, to their im­me­di­ate need­s."

The iPad and most oth­er Ap­ple prod­ucts are the an­tithe­sis of that. They are prod­ucts meant to be ex­act­ly as they are, and that's all they are goint to be. If you want to change the way it act­s, you need to pay and be sub­ject of Ap­ple's whim, or "break in­to" your own de­vice.

That hurts me. I see peo­ple give up even the pos­si­bil­i­ty of chang­ing what a (let's say it) pret­ty, use­ful, pow­er­ful de­vice is ca­pa­ble of, just be­cause they don't what that free­dom. I can un­der­stand that from, say, a used car sales­man, or what­ev­er, some­one with­out any in­cli­na­tion for that craft.

But I see freak­ing pro­gram­mers buy­ing ap­ple kit. And I see them hap­py with their iPhones and iPods and (soon, sure­ly) iPad­s, buy­ing apps from the on­ly source en­abled to sell them, buy­ing the apps that are al­lowed by a sin­gle par­ty, that de­cides, hey, this ap­p? you won't need it!

I see them and I say to my­self, dude, that thing you hold in your hand is more pow­er­ful than any­thing we had 10 years ago, there must be some­thing cool you could do with it that noone else is do­ing.

What's the vi­sion a pro­gram­mer has of his fu­ture if he en­dors­es Ap­ple's closed kit? A fu­ture where he can pro­gram some­thing on­ly if Ap­ple ap­proves? A fu­ture where a "re­al" com­put­er is a SDK for the things "re­al peo­ple" use in their ev­ery­day lifes?

What is wrong with you? What hap­pened to you? Are you now the kind of guy that's just hap­py with what he's given? Are you now a freak­ing util­i­tar­i­an? Are you old now?

Have you no­ticed the trend in Ap­ple's new prod­ucts is to­wards less con­trol by the user? First it was just hand­held­s, now there's a tablet. What was the last new in­ter­est­ing Ap­ple prod­uct that was­n't locked up?

Here they had a de­vice which could have OSX or Iphone OS, and they went with Iphone OS. There is a rea­son for that: it makes them more mon­ey.

For OS­X, they make mon­ey of the hard­ware, the OS up­grades, and some app­s. On the iPad, they make mon­ey ev­ery time you buy any ap­p, ev­ery time you buy a book to read in it, ev­ery time you use 3G with the pre­paid plan, and I am sure they are go­ing to find oth­er ways too.

And what's the key to mak­ing mon­ey that way? Con­trol. If they had no ex­clu­sive con­trol of the App store, they lose a source of rev­enue. If they al­lowed for easy de­vel­op­ment of hob­by app­s, they would lose rev­enue. If they could let you re­place the freak­ing bat­tery, they would lose rev­enue.

And if there's one thing com­pa­nies hate is los­ing rev­enue. Ap­ple saw two paths ahead, one lead­ing to huge mon­ey, the oth­er to just big mon­ey. They have tak­en the huge mon­ey path, and it's work­ing for them. They are not go­ing back.

If ev­ery­one goes along for the ride, it will be a sad thing.

New project: marave, a relaxed text editor

An­nounce­men­t:

Mar­ave (noth­ing, in guaraní) is a re­laxed text ed­i­tor. Its goal is to let you fo­cus in your writ­ing, free of vis­ual dis­trac­tions and clut­ter.

It is writ­ten us­ing PyQt, so it should work in all ma­jor plat­form­s, and it is li­censed un­der the GPLv2 so it is free soft­ware.

You can find the cur­rent SVN (no re­lease yet) at http://­mar­ave.­google­code.­com

Screen­shot­s:

snapshot10snapshot9snapshot8

Sta­tus:

It's not fin­ished yet, but it has the fol­low­ing fea­tures:

  • You can ed­it text

  • Min­i­­mal­is­tic, "van­ish­ing" us­er in­­ter­­face

  • (Op­­tion­al) au­­dio feed­back for the key­board

  • (Op­­tion­al) re­lax­ing mu­sic (re­quires in­­ter­net ac­cess)

  • You can cus­­tom­ize the back­­­ground, font, colours, and sounds

  • Live spell check­­ing (re­quires pyen­chan­t)

There are al­so some ma­jor miss­ing fea­tures:

  • Search and Search/Re­­place is not im­­ple­­men­t­ed

  • UI cus­­tomiza­­­tions are not stored

  • UI has to be cleaned up a lot more

  • It does­n't ask to save when clos­ing

  • Au­­tosave not im­­ple­­men­t­ed

And at least one known bug:

  • In win­­dows the wid­gets are not well placed Fixed in SVN

A litte his­to­ry:

A few days ago, I saw ommwrit­er men­tioned in a tweet or some­thing sim­i­lar.

I was think­ing "nice thing", but in the back of my mind I was al­so think­ing "that can't be too hard to do". Af­ter al­l, the hard part of cre­at­ing a pro­gram is mak­ing it do things, right?

Well, yes and no. I did man­age to cre­ate a some­what rea­son­able fac­sim­i­le in a day, but tweak­ing the looks of it is driv­ing me nuts :-)

Happy 10th blogiversary to me!

Since yes­ter­day this blog is ten years old so, time for some his­to­ry.

It all start­ed in ad­voga­to where you could still read it to­day! (Please read it here in­stead ;-)

Then it moved to PyDS an ear­ly python desk­top blog plat­form with a web in­ter­face, and was host­ed in PyC­S, a free ser­vice.

Then PyCS kin­da died, and I start­ed gen­er­at­ing a stat­ic blog and host­ing it in my IS­P's free host­ing. That sucked bad.

Then I start­ed my own com­pa­ny, and I had my own server­s, so I start­ed host­ing it there (even to­day this blog is com­plete­ly stat­ic HTM­L!)

Then PyDS start­ed act­ing weird, so I wrote my own blog­ging soft­ware, which is a re­al mess, per­haps 25% fin­ished, but it does things ex­act­ly the way I like them.

Cur­rent­ly, this blog is syn­di­cat­ed in Plan­e­ta PyAr, Plan­et Python, Plan­et Qt, Plan­e­ta LUGLI, and a cou­ple oth­er places.

This year, I de­cid­ed to make the blog com­plete­ly bilin­gual (English and Span­ish), but I hate trans­lat­ing it.

Ac­cord­ing to the stats I have avail­able, the blog is in av­er­age more pop­u­lar now than ev­er (but yes, my most pop­u­lar posts were years ago ;-)

stats

These are the most pop­u­lar pages in the last year:

Lesson­s:

  1. I need to write more about Qt and/or start flame­wars with clue­­less IT writ­ers

  2. I need to search for an­­cient ma­te­ri­al and de­p­re­­cate it

  3. Hav­ing your own host­ing and blog­ging soft­­ware is neat

  4. 10 years is a lot of time: 860 posts (or 913, de­pend­ing on how you coun­t)

With iterpipes, python is ready to replace bash for scripting. Really.

This has been a pet peeve of mine for years: pro­gram­ming shell scripts suck. They are ug­ly and er­ror prone. The on­ly rea­son why we still do it? There is no re­al re­place­men­t.

Or at least that was the case, un­til to­day I met iter­pipes at python.red­dit.­com

Iter­pipes is "A li­brary for run­ning shell pipe­lines us­ing shel­l-­like syn­tax" and guess what? It's bril­liant.

Here's an ex­am­ple from its PYPI page:

# Total lines in *.py files under /path/to/dir,
# use safe shell parameters formatting:

>>> total = cmd(
...     'find {} -name {} -print0 | xargs -0 wc -l | tail -1 | awk {}',
...     '/path/to/dir', '\*.py', '{print $1}')
>>> run(total | strip() | join | int)
315

Here's how that would look in shel­l:

find /path/to/dir -name '*.py' -print0 | xargs -0 wc -l | tail -1 | awk '{print $1}'

You may say the shell ver­sion looks bet­ter. That's an il­lu­sion caused by the evil that is shell script­ing: the shell ver­sion is bug­gy.

Why is it buggy? Because if I control what's inside /path/to/dir I can make that neat little shell command fail [1], but at least in python I can handle errors!

Al­so, in most ver­sions you could at­tempt to write, this com­mand would be un­safe be­cause quot­ing and es­cap­ing in shell is in­sane!

The iter­pipes ver­sion us­es the equiv­a­lent of SQL pre­pared state­ments which are much safer.

It's near­ly im­pos­si­ble to do such a com­mand in pure shell and be sure it's safe.

Al­so, the shell ver­sion pro­duces a string in­stead of an in­te­ger, which sucks if you in­tend to do any­thing with it.

And the most im­por­tant ben­e­fit is, of course, not when you try to make python act like a shel­l, but when you can stop pre­tend­ing shell is a re­al pro­gram­ming lan­guage.

Consider this gem from Arch Linux's /etc/rc.shutdown script. Here, DAEMONS is a list of things that started on boot, and this script is trying to shut them down in reverse order, unless the daemon name starts with "!":

# Shutdown daemons in reverse order
let i=${#DAEMONS[@]}-1
while [ $i -ge 0 ]; do
        if [ "${DAEMONS[$i]:0:1}" != '!' ]; then
                ck_daemon ${DAEMONS[$i]#@} || stop_daemon ${DAEMONS[$i]#@}
        fi
        let i=i-1
done

Nice uh?

Now, how would that look in python (I may have in­vert­ed the mean­ing of ck­_­dae­mon)?

# Shutdown daemons in reverse order
for daemon in reversed(DAEMONS):
    if daemon[0]=='!':
        continue
    if ck_daemon(daemon):
        stop_daemon(daemon)

Where stop_­dae­mon used to be this:

stop_daemon() {
    /etc/rc.d/$1 stop
}

And will now be this:

def stop_daemon(daemon):
    run(cmd('/etc/rc.d/{} stop',daemon))

So, come on, peo­ple, we are in the 21st cen­tu­ry, and shell script­ing sucked in the 20th al­ready.


Contents © 2000-2023 Roberto Alsina