Advogato blog for habeshttp://www.advogato.org/person/habes/
Advogato blog for habesen-usmod_virguleSun, 2 Aug 2015 18:27:32 GMTSun, 4 Sep 2005 01:15:50 GMT4 Sep 2005http://www.advogato.org/person/habes/diary.html?start=7
http://www.advogato.org/person/habes/diary.html?start=7Last week I was complaining how complicated terminal emulation is, but it turns out the situation is much worse than I thought.
<p> <a href="http://vt100.net/emu/vt500_parser.png" >Here is the state diagram required to parse VT escape sequences robustly.</a>
<p> Something needs to be done. We need a new text-mode interface network protocol that is much, much simpler. Emulating VT100s in 2005 is nuts.Sat, 27 Aug 2005 07:13:57 GMT27 Aug 2005http://www.advogato.org/person/habes/diary.html?start=6
http://www.advogato.org/person/habes/diary.html?start=6<b>The current suckiness of terminal technology</b>
<p>
Text-mode interfaces rock. It's too bad that the technology surrounding them is so crufty and antiquated.
<p>
The vast, vast majority of terminals currently in use are software terminals: xterm, eterm, Terminal.app, putty, etc. And yet, terminal technology is centered around emulating and supporting the interfaces of hardware terminals long since deceased: vt100, vt102, etc.
<p>
Say it's 2005 and you are implementing a terminal emulator from scratch. You want to be conscientious and pick a standard terminal type that you can implement robustly. You're in for a rude awakening: the truth is that pretty much every software terminal emulation program in existence is a mish-mash of whatever escape sequences the authors felt like implementing.
<p>
For example, <a href="http://www.eterm.org/" >Eterm</a> claims to be a vt102 emulator. But it certainly doesn't implement:
<blockquote>
<b>Invoke Confidence Test (DECTST)</b>
<p> ESC [ 2 ; 1 y
<p> Power-up test. Terminal resets and performs power-up test.
</blockquote>
<p> And why should they? Half the escape sequences for these historical terminals make no sense for software-based terminals. And yet, you're never sure what escape sequences client applications will use.
<p>
And for all these obselete escape sequences that no one cares about, we <i>still</i> don't have an escape sequence that will change the text color to an arbitrary RGB value. We're still in 8-color world (not even 8-bit, 8 <i>color</i>), even though 99% of "terminals" out there today are capable of doing better.
<p>
Because there is no reasonable standard terminal type for software terminal emulators to support, authors of this software just do whatever works. Many programs put the name of the program in $TERM (for example, <b>xterm</b> and <b>screen</b>), which basically demands that everyone else add that program to their terminfo/termcap. Or they'll reuse existing bastardized term types like <b>xterm-color</b> (Terminal.app does this), even though they almost certainly don't support all the same escape sequences.
<p>
The story is just as bad on the client side. Your only hope for writing an interoperable text-based application is to use either terminfo or termcap, which are huge databases of historical terminals that no one owns but that the UNIX community won't let go of. Instead of hard-coding escape sequences in your program, you look up the escape sequences for abstract capabilities (like "move the cursor") and use those. That will work, as long as the user actually set his/her TERM variable correctly, and their terminal type is actually in your termcap/terminfo file.
<p>
In practice, most programs give up on that idea and use a library like ncurses to do that work for them. You might hope that ncurses would make your life as a terminal application author simple, but you would be wrong about that. Ncurses has 257 functions in it, most of them with names like mvaddchnstr().
<p>
Ncurses isn't horrible, but it's not particularly nice to use, and it doesn't expose the full capabilities of the underlying terminal in some cases. For example, many software terminals support an extension where you can set the foreground or background color to -1 which means "the default color" (ie. the color you see before a program mucks with the colors). This effectively allows 81 color combinations (8 colors plus the "default", so 9 foreground times 9 background colors). But ncurses only supports 64 color pairs.
<p>
Then there's the whole mess of pseudo-terminals. If you are like me, you might wonder at first why pseudo-terminals are necessary. Why not just fork a shell and communicate with it over stdin/stdout? Well, the bad news there is that UNIX special-cases terminals. They're not just full-duplex byte streams, they also have to support some special system calls for things like setting the baud rate. And you might think that a change of window size would be delivered to the client program as an escape sequence. But no, it's delivered as a signal (and incidentally, sent from the terminal emulator as an ioctl()).
<p>
Of course, you can't send ioctls over a network, so sending a resize from a telnet client to a telnet server is done in <a href="http://www.faqs.org/rfcs/rfc1073.html" >a totally different way</a>.
<p>
As you can see, it's a big mess. This is unfortunate, because text-mode terminal interfaces can offer a lot, especially to us computer programmers.
<p>
<b>Dreaming of Solutions</b>
<p>
The problem is pretty clear. Solutions are a bit harder to come by. Here are some ideas.
<ol>
<li>Authors of software terminal emulation programs need a reasonable standard they can target. It should be a very small set of escape sequences -- just the basics of movement and setting character attributes. Realistically, for such a thing to gain any traction at all, it would need to be a subset of either vt102 or more likely xterm. Hopefully, such a thing could be integrated into ESR's canonical termcap/terminfo databases, so that existing clients could communicate with them without sending escape sequences that they can't understand.
<li>Authors of text-mode applications could use a library that is a lot slicker than Ncurses. Perhaps it could be built on ncurses for now, with the option to leave all that cruft behind later.
<li>There needs to be a standard way of making extensions to the existing set of escape sequences. For example, there should be an escape sequence extension that supports specifying an arbitrary color in RGB. Clients should be able to ask terminals what extensions they support, instead of having a static TERM type to decide what is supported. Terminals should know how to ignore escape sequences they don't implement.
<li>Everything should be migrated to use XML.
</ol>
OK, I was just kidding about that last one. :)
<p> <b>My Related Pet Project</b>
<p> I'm creating a text-mode environment that seeks to integrate all your core text-mode apps (terminal, mail reader, editor) into one uber-scriptable environment. Think Emacs, but object-oriented, and written in Ruby.
<p> It's not ready for prime-time, but it can already multiplex terminal windows (like screen does) well enough to run VIM. It's called <a href="http://silkscreen.sf.net" >silkscreen</a>Thu, 4 Mar 2004 21:01:21 GMT4 Mar 2004http://www.advogato.org/person/habes/diary.html?start=5
http://www.advogato.org/person/habes/diary.html?start=5<p><b>CodeCon</b>
<p> <p> <p>I was really happy with our <a href="http://www.advogato.org/proj/Audacity/" >Audacity</a> talk at <a href="http://www.codecon.org/2004" >CodeCon 2004.</a> We had the last slot because I had to fly in that morning, and I feel like we ended the conference with a bang. Dominic's demo went over well; his final gesture was to record a voiceover on top of the introduction to a "demo" jazz track, adjusting the volume envelope so that he could be heard over the music. He played it all back, and I saw looks of satisfaction and amusement in the audience while they applauded. It wasn't anything revolutionary, the point was that he did something cool and effective with a minimum of effort. Audacity is genuinely useful to people.
<p> <p> <p>I was really disappointed that I had to miss the first two days. I heard there were some really great presentations. I would have especially liked to see the version control software demos.
<p> <p> <p>It was good to see Dominic and <a href="http://www.advogato.org/person/mbrubeck/" >mbrubeck</a> again. I also got to meet another Audacity developer, Vaughan Johnson.
<p> <p> <p><b>CSS</b>
<p> <p> <p>It seems to me that a major reason that people are still using table-based layouts is that tables are such a natural way of arranging things. Look at any web site and you'll see how it can be naturally broken down into tables.
<p> <p> <p>So why on earth does CSS ditch this model and instead work with boxes that are logically unconnected? It is absolutely ludicrous to me that a simple three-column layout, with two of the columns static and one dynamic, is considered <a href="http://glish.com/css/7.asp" >a holy grail</a> with CSS. The code is complex and counterintuitive (hence a holy grail to find). Two of the columns have to be absolutely placed and sized, and the middle column has to have margins big enough to not overlap the other columns (of course the three boxes don't interact at all, nor are they aware of the other's existence). With a table-based layout it is dirt simple: one row, three columns. Of course the resizing will work correctly. Of course you'll never have two boxes inadvertently overlap. That's just the way tables work, and it maps pretty well onto the way design really works.
<p> <p> <p>I believe that CSS got its positioning model fundamentally wrong. What stylesheets should provide is a way to assemble block elements like &lt;div&gt; into tables (grids) in a flexible way. The three-column layout should be as simple as saying:
<p> <p> <p>make a row consisting of (left-to right) div "leftcolumn" with absolute width 200px, div "centercolumn" variable width, and div "rightcolumn" with absolute width 200px. Done.
<p> <p> <p>There's no reason browsers can't do this; this expressive power is already available with tables. It's just not possible to separate this kind of layout from the HTML as CSS is designed to do.
<p> <b>Certification weirdness</b>
<p> <p>What happened to my certification? I used to be Journeyer, I am certified "Journeyer" by two other Journeyers and one Master, so why am I not certified at all any more?
<p> <p>I intend to post an article soon. If you could take a few minutes and decide whether you think I am a Journeyer based on my work on Audacity and PortAudio, I would appreciate it. I also wrote FLAC tagging support for Rhythmbox. Thanks.Mon, 24 Feb 2003 03:49:56 GMT24 Feb 2003http://www.advogato.org/person/habes/diary.html?start=4
http://www.advogato.org/person/habes/diary.html?start=4<b>Audacity</b>
<p>
I'm really happy with what I've managed to accomplish on Audacity in the last month or so. Everyone is starting to itch for a new stable release, so I have been working on trying to knock the audio i/o into shape in time for 1.2. A few months ago we moved to a thread-based model for audio i/o that decreased latency and improved resourse utilization, but there were some kinks that it took some time to discover and diagnose.
<p>
Audacity can now build against <a href="http://www.portaudio.com" >PortAudio</a> v19. PortAudio v19 is still unfinished, but it will have the ability to support OSS, ALSA, and JACK in a single build (all natively)! I was hoping this would be finished in time for Audacity 1.2, but since it won't our audio i/o is #ifdef'd to support either v18 or v19.
<p>
<b>Looking for Summer Work</b>
<p>
I would really like another internship this summer. Initially I placed a lot of eggs in the <a href="http://www.real.com" >RealNetworks</a> basket, since I figured my experience with Audacity would make me a prime candidate. But Real is a wall of silence: I never heard a word back from them. I need to pursue it more proactively.
<p>
I also need to think of other places where I could find work. I would like to stay in the Seattle area if possible (though I would willingly relocate like I did last summer), and hopefully I could find something having to do with audio or multimedia in some form.
<p>
Sometimes I worry that choosing work in a field similar to the work I do on free software will force me to close off part of myself and my knowledge to the free software community. I half-heartedly approached employees of Syntrillium (makers of CoolEdit) last week at a presentation and asked if they hired interns. When I said I was interested in programming they blew me off and said that wouldn't really be possible. But what if they did have internships available? It would be extremely similar work to what I do on Audacity, would I be forced to sign NDAs and wall off the insider knowledge of Syntrillium products to the work I do freely?
<p>
It seems difficult to find employment opportunities that would utilize my free software experience.Tue, 15 Oct 2002 00:40:20 GMT15 Oct 2002http://www.advogato.org/person/habes/diary.html?start=3
http://www.advogato.org/person/habes/diary.html?start=3I desperately wish I had infinite time to be able to contribute to any free software project that interested me. I am constantly exposed to really neat projects that I want to learn about and help improve. I want to do everything I can to advance the power, usability, and range of available free software.
<p> Every time I feel this urge, I remind myself that the most productive I can possibly be is when I am working on a project I already know well. In other words, the best way to achieve my goal of furthering free software in general is to do lots of good work on Audacity and PortAudio. Meanwhile, the people who have found different niches, whether it be in the libraries that do all the grunt work or in the desktop environments that present the gateway to individual applications for the user, are simultaneously advancing the state of their pet projects also.
<p> Not that I have the time to code much of anything these days, with school and all...
<p> Another thing I constantly have to remind myself is that the best way to solve a problem is usually not to start with a clean slate and attempt to make an ultimate design. Though it's much less sexy, the better solution is to build on what has already been done. Every time I tell myself "we need to trash X!! It's way too hard for users to configure, the fonts suck, and you can't change resolutions," I step back and remind myself that improving X is probably the better long-term solution. My sense of aesthetics makes me want to use something like <a href="http://www.directfb.org" >DirectFB</a> instead, since it's clean, sleek, and new, but it would take so much to get to where X already is today.
<p> Another place I struggle with this is all the way down to the Linux kernel. "How is my mother ever going to use Linux if configuring the network requires decyphering driver names like 'ne' and 'rtl8139?' How is Linux ever going to become robustly GUI-configurable as long as we keep using text configuration files? How far can open()/read()/ioctl()/write()/close() really take us??"
<p> Free software is really becoming kickass in some cases. I prefer Galeon to any web browser available for Windows. Though I don't use them much, I continue to hear that Evolution and Gnumeric and Gnucash are kicking some serious ass. But how is my mother ever going to use free software if there's no free platform (meaning kernel+userspace+standard APIs) that works straight out of the box, without configuration pains?
<p> And speaking of standard APIs, I think lack of them is a problem on Linux. How does an application play sound on Linux? Well, it's very simple! OSS will probably work, ALSA is better if it's available, JACK is best for low-latency, inter-app work, but ARtS if you're using KDE and ESD if you're using Gnome!
<p> Challenge 2: set the resolution to 800x600 and play a movie file fullscreen. There's no obviously standard way to do this on a basic Linux/X11 box. Stuff is written for SDL, Allegro, ggi, even svgalib. Some may work on your box, others might not. This is where cathedral-engineered OS's have a one-up on us: there are standard ways to do things like this that will always work.
<p> What Linux needs is something like LSB, but much more far-reaching.
<p> And perhaps what I'm looking for already exists in Gnome and KDE. These are real platforms, in that a Gnome application will use the same set of APIs that any other Gnome application will. And if everything was a Gnome app or everything was a KDE app everything would be peachy.
<p> But they're not, so we're still stuck with a situation where some apps may play sound fine, while others pop up a dialog box saying "esd not running."
<p> That's enough for now. I want so badly for free software to succeed on laypeople's desktops. I think we're on a good track, we just need time to fill in the gaps and polish everything.Mon, 15 Jul 2002 22:34:43 GMT15 Jul 2002http://www.advogato.org/person/habes/diary.html?start=2
http://www.advogato.org/person/habes/diary.html?start=2<a href="http://audacity.sourceforge.net" >Audacity</a> is getting major publicity this week!
<p>
First off, we hit 1,000,000 downloads, which are mostly from the last year and a half. That was exciting.
<p>
Then Audacity was mentioned on the TechTV program "<a href="http://www.washingtonpost.com/wp-dyn/articles/A64024-2002Jul13.html" >The Screen Savers."</a> I got it on tape this morning: an incoming caller wanted to know a way to do noise reduction on mp3s, and the hosts recommended Audacity and brought up the web page. That was even more exciting.
<p>
Then today I noticed Audacity was <a href="http://www.washingtonpost.com/wp-dyn/articles/A64024-2002Jul13.html" >reviewed in the Washington Post</a>! That was the most exciting of all. (well, besides sharing <a href=" http://slashdot.org/article.pl?sid=02/06/11/0322200&mode=thread&tid=106" >a front page slashdot story a few weeks back</a>).
<p>
Please accept my apologies for bragging, but these are exciting times.Sat, 15 Jun 2002 07:37:27 GMT15 Jun 2002http://www.advogato.org/person/habes/diary.html?start=1
http://www.advogato.org/person/habes/diary.html?start=1<a
href="http://www.advogato.org/proj/Audacity/">Audacity</a>
1.0 is released! This is exciting for so many reasons. The
two biggies:
<ul>
<li>we can forget about the 1.0 branch now. The 1.1 branch
is so much better that maintaining 1.0 was becoming a pain.
<li>a bunch of subprojects that we were putting off for the
release are now progressing full speed ahead. The most
exciting one is a split of the GUI and audio engine modules:
this allows us to write rigorous tests to hammer at the
audio engine code, as well as opening up the opportunity to
implement alternate GUIs on top of libaudacity.
</ul>
<p>
I finally have internet at home, which means I can do all
the things I've been planning: a <a
href="http://www.portaudio.com">PortAudio</a> implementation
for <a href="http://jackit.sf.net" >JACK</a> and/or <a
href="http://www.alsa-project.org">ALSA</a>, a media player
for <a href="http://www.picogui.org" >PicoGUI</a> using <a
href="http://www.gstreamer.net">gstreamer</a> in Python, and
who knows what else. Now that I have weekends the sky is
the limit. Unfortunately I've gotten too used to working 10
and 11 hour days, so I don't have too much time during the
week...Wed, 24 Apr 2002 09:51:51 GMT24 Apr 2002http://www.advogato.org/person/habes/diary.html?start=0
http://www.advogato.org/person/habes/diary.html?start=0This week I took time that I didn't have to code two
long-overdue features for <a
href="http://www.advogato.org/proj/Audacity/">Audacity</a>:
Ogg exporting and command-line exporting. There was no good
reason why I hadn't written these features yet and I got
tired of Audacity not having them, so I caved and tabled all
my homework (including "compose a three voice fugue") to
write these new features.
<p>
Ogg exporting is working nicely, and though command-line
exporting works fine for me on my little-endian Athlon, I
forgot to add code for byte-swapping the WAV header. <a
href="http://www.advogato.org/person/mbrubeck/">Matt</a>
wisely suggested I dump my custom WAV code and just use
libsndfile like the rest of the PCM exporting code does.
Though it won't be as efficient since we have to copy the
data in and out of libsndfile's buffers, the robustness and
reliability will be worth it.
<p>
The gap between Audacity's 0.9 branch (which we are
releasing from these days) and the 1.1 branch (which we are
hacking on) is becoming wider all the time. The 1.1 branch
has so many significant improvements over the 0.9 branch
that I wish we could dump the 0.9 branch completely. But
then we would lose some of the freedom to make drastic
changes on a regular basis, so it's probably a good thing in
the end.