Monthly Archives: September 2011

Principles of Programming Languages

I referred to Bruce J. MacLennan’s Principles of Programming Languages in my previous post, then discovered I can’t find the list anywhere on the ‘net, at least not as I was taught them. They are (AFIK) derived from his book, also named Principles of Programming Languages, so it may not be precisely kosher to put them online, but I’m going to post a copy anyway, because they are terribly useful to refer to.

  1. Abstraction: Avoid requiring something to be stated more than once; factor out the recurring pattern.
  2. Automation: Automate mechanical, tedious, or error-prone activities.
  3. Defense in Depth: Have a series of defenses so that if an error is not caught by one, it will probably be caught by another.
  4. Elegance: Confine your attention ot designs that look good because they are good.
  5. Impossible Error: Making errors impossible to commit is preferable to detecting them after their commission.
  6. Information Hiding: The languages should permit modules designed so that (1) the user has all of the information needed ot use the module correctly, and nothing more, and (2) the implementer has all the information needed to implement the module correctly, and nothing more.
  7. Labeling: Avoid arbitrary sequences more than a few items long. Do not require the user to know the absolute position of an item in a list. Instead, associate a meaningful label with each item and allow the items to occur in any order.
  8. Localized Cost: users should pay only for what they use; avoid distributed costs.
  9. Manifest Interface: All interfaces should be apparent (manifest) in the syntax.
  10. Orthogonality: independent functions should be controlled by independent mechanisms.
  11. Portability: Avoid features or facilities that are dependent on a particular computer or a small class of computers.
  12. Preservation of Information: The languages should allow the representation of information that the user might know and that the compiler might need.
  13. Regularity: Regular rules, without exceptions, are easier to learn, use, describe, and implement.
  14. Responsible Design: Do not ask users what they want, find out what they need.
  15. Security: No program that violates the definition of the language, or its own intended structure, should escape detection.
  16. Simplicity: A language should be as simple as possible. There should be a minimum number of concepts, with simple rules for their combination.
  17. Structure: the static structure of the program should correspond in a simple way to the dynamic structure of the corresponding computations.
  18. Syntactic Consistency: Similar things should look similar, different things different.
  19. Zero-One-Infinity: The only reasonable numbers are zero, one, and infinity.
  20. Avoid Creeping Featurism: Do not add features which are expensive to implement and rarely used. [I think Rafi added this one himself, but I learned them from him, so here it stays. Also, I feel like there was a more elegant phrasing presented at some point.]

I’m not entirely fond of all the rules, particularly 6 and 7, which encourage trusting other people’s code and space inefficiency respectively, but it is generally a wonderful compact way of evaluating languages, that should resonate with anyone who programs.

Posted in Computers, General, School | Tagged | Leave a comment

Vala

Yesterday I decided to indulge my language fiddling impulse and spent some time reading about Vala and writing some simple programs in it. As far as I can tell, it is the answer to the running “My ideal language…” conversation my lab mate and I have, with only a few tiny exceptions. Even from a more formal view, evaluating based on Bruce MacLennan’s Principles of Programming Languages (not the book, just the list of aphorisms) Vala does INCREDIBLY well.

The syntax and feature set is based on C#, but instead of compiling to another unwanted virtual machine (Microsoft’s CLR or its second class citizen implementation, Mono), it compiles to (human readable) C, then native code, so it can piggyback on the platform CC. Most of the fancy language features are actually implemented with glib and GObject, so if you are running anything GTK based all the bits and pieces will be in memory anyway.

Rather than repeating the entire tutorial, the things I find exciting are: Array slicing. Proper Strings. Regular expressions. An optional garbage collector. A reasonable object system with limited inheritance and overloading. Coroutines(-ish) and iterators. Pointers of both the object-respecting and real varieties. Closures. Assertions/contract features. It also has incredibly clean interfaces for writing GUIs (in GTK) and network code, which are definitely weak points for most languages low-level enough for my tastes.

It does have a few interesting quirks (get and set methods allow you to override assignment, string concatenation is “+”, etc.), some dumb inherited things (were long and short ever a good idea?), and a handful of missing features (nothing has powerloops), but those are all minor quibbles.

The only real issues I have with Vala are that it isn’t terribly widely adopted, and that it is maintained by the GNOME foundation (which has a proud history of doing horrible things on a whim), but I think I’ll try writing all my random little bits of code in it for a while, because it is fun in a way I rarely find pure software.

Posted in Computers, General, Objects | Tagged , | Leave a comment

Note Synchronization?

I’ve started the hunt for a suitable new note taking program. My demands are simple: I want a stack of text documents with persistent offline access on my Linux and Android devices, Web access from elsewhere, and automated synchronization between them.

I’ve been using xfce4-notes-plugin, which has been adequate, is backed by plaintext, and is ridiculously light on resources — but it has no capacity synchronization. I wish Google hadn’t abandoned notebook, since that would provide a mechanism to build around without an extra entity I have to trust with my data, but its viability is long gone. In a similar vein, I’m getting a strong urge to find and punch the dropbox folks for using a goofy proprietary protocol instead of something I can trivially self host (hint).

Evernote, with the Nevernote Linux-compatible client, looked like a generally acceptable solution (persistent local copies mitigate the cloud trust issue) until I got a good look at Nevernote – a 55MB blob of crude, crudely-packaged Java code, which seems to function, but consumes 3-6% CPU and 3% memory to sit in the background empty on my i7M620/8GB system. I don’t care how snazzy it is, this is not a solution for a persistent tool.

Hacking something together with text-file-backed editors, rsync, and my web hosting is a last ditch option, since it really is all I want, but there must already be something light, functional, and not dripping with proprietary cruft floating around… right?

Posted in Computers, DIY, General, Objects | Tagged , | 1 Comment

I’m mystified by how much I miss having a little kickstand on my handheld computer. The n810’s didn’t even work very well – only the “Closed” and “45° to the table” detents actually held – but being able to have … Continue reading

Posted on by pappp | Leave a comment

Too Much Toolchain Time

Having my “work project” be finishing the code generator and simulator fronted for LARK, and my “play project” be coaxing uClibc and TCC to build for Android (demonstrably possible, it’s just a question of if I’m clever and/or tenacious enough…) is giving me a little too much time working with compiler toolchains to be healthy. It does make me understand how compilers people get their — characteristic — personality traits, though.

Posted in Computers, DIY, General, Navel Gazing, School | Leave a comment

Android Love of the Day: Like Things are Handled Alike

[This post is part of a series on my initial Android impressions.]
I think I’ve covered most of the really problematic things Google needs to get on. Some other issues are either already being fixed – they’re apparently already working on the notification shittyness – or unsolved problems for developers – like the fact that landscape mode is a definite second-class citizen, despite a profusion of landscape keyboard sliders.
And now a change of pace for the end of the week: this post is about something I think the Android designers did right, and certainly did better than many competing platforms.

Mobile platforms are especially guilty of treating otherwise indistinguishable objects as different. For years there has been the ringtone scam, with carriers and third party assholes charging for suitably down-sampled and/or converted music tracks, even when it is often visible that devices internally use .mid or .mp3 tracks for the function. Likewise, a couple of the mobile platforms distinguish between editable and non-editable text, which is absurd.

Android doesn’t pull that shit. Music is any compatible audio file the indexer can find. Ringtones are any native audio file that you point at as a ringtone, with a default /sdcard/Media/Audio/Ringtones directory for things you intend to use that way. Notification sounds are likewise audio files you point at as notification sounds, with a default /sdcard/Media/Audio/Notifications folder.
Text, with the occasionally irritating but entirely understandable exception of certain UI elements, is text. The same (clunky) select/copy mechanism works on all text, and it all goes to the same system-wide clipboard. Because I have a Sense ROM, the mechanism is actually this one(video), which is slightly less clunky than the default, but still inelegant. The important thing is that it’s consistent.

All in all, I like my MT4GS. It has some quirks, many of them in software which can and will likely be fixed with updates or third party extensions as time passes, and it costs a fortune to feed, but it does the vast majority of things I want in a little handheld computer, and it does them more elegantly than the competitors I’ve tried. I may not find Android to be an exciting platform, but it is a solid platform, with multiple, reliable companies backing it, a parent company actively trying to improve it, and enough market penetration to be a first-class citizen for years to come. It even appears the native code situation is improving, which should let me work around many of the things *I* would like to work differently that aren’t concerns for most users.

Posted in Computers, DIY, Electronics, General | Tagged , | Leave a comment

Android Hate of the Day: Missing Basic Functionality

[This post is part of a series on my initial Android impressions.]
Just to be clear, my Android criticism is because I want this shit fixed in the last promising mobile platform standing, not because I hate it. Platform specific comments are based on the default MT4GS Android 2.3.4 with Sense 3.0 ROM, rooted and largely de-bloated. And now for the hate.

Android doesn’t come with a file manager. It doesn’t come with a terminal emulator, or a task manager, or almost any of the things one has come to reasonably expect an operating system to have. This makes it excessively hard to share instructions, since everyone is using interfaces broken in slightly different ways, and means the first few days of using a new device are spent on “Damnit! why won’t it do $Basic_function? Now I have to sort through the crap pile in the app store until I find one that actually works.” (which, come to think of it, is likely the objective.)
The file handler functionality is as good as any desktop platform (I don’t actually know if it is based on XDG like most other *nixes, or some homegrown solution) so it wouldn’t debilitate third party solutions to have sane defaults, and the argument that most users wouldn’t want all of those functions is completely specious… it took me a couple hours to strip most of the unwanted crap off my new phone, and that crap was certainly less useful than the things I’m complaining about being missing.
Also, most of the third party solutions suck. I’ve been using ConnectBot for a shell, which is better than the other free options I’ve tried, but handles the keyboard differently than every other program, and thus has problems with entering symbols like “|” and “>” which are sort of important on the command line. Likewise, after several seriously disappointing alternatives, I’ve settled on ES File Explorer for file management (also a solid [s]ftp/smb client), which is a little quirky about permissions and different file systems, and is nearly unusable in landscape mode (a rant for later), but is generally adequate. I’ve heard there may be some paid alternatives which are significantly better, but the idea of paying for this kind of basic functionality is infuriating – it is basically the same situation of coughing up for a Mac then having to buy one of a dozen Finders from some random dude for $20 before you could use it.

Posted in Computers, DIY, Electronics, General | Tagged , | Leave a comment