2017-06-25T02:16:31Z via Identi.ca Web To: Public CC:Somebody on lobste.rs rhetorically asked why anyone should care if the general public finds it difficult to learn to program. After all, we nerds learned well enough without help, and the average Joe doesn't really need an algorithm to pay his rent or buy his groceries.My reply:People need to know programming for the same reason people need to know arithmetic or how laws get made: because other people already know those things, and many of those other people are quite happy to use that information to exploit people who don’t know those things. Consider how much of an advantage payday loan sharks have over people who haven’t internalised the mechanics of compound interest, or how much of an advantage organisations with professional lobbyists have over other organisations, and compare that to how much of an advantage Google and Facebook have over people who don’t understand data-mining and automated data processing in general.People really need to know programming, but it’s the kind of need that’s most obvious in retrospect, when it’s too late to do anything about.
Claes Wallin (韋嘉誠) likes this.
2017-06-18T00:55:32Z via Identi.ca Web To: Public CC:Note to self: if I'm ever making up monsters for a story or game, I should have a metallic icthyoid and refer to it as "the Silverfish, or argentuna".
2017-06-04T05:44:09Z via Identi.ca Web To: Public CC:Yesterday on Hacker News, I read an article that claimed to be an inside perspective on What Really Happened With Windows Vista. It's pretty interesting, but there was one idea that I hadn't previously encountered. A given software implementation balances functionality against the resources (time, storage, etc.) available, but both user expectations and hardware resources change over time. The article mentions two different responses to such changes:
- Hardware Supports Software: software is always complex and difficult, so if we can add complexity to the platform (OS, compiler, runtime) in a way that makes applications simpler, more reliable, more maintainable with the same level of functionality, we should. If that means spending extra hardware resources on computational overhead like runtime checks and managed code, that's a trade worth making. The article claims this was Microsoft's mindset at the beginning of Vista's development.
- Software Supports Hardware: people buy hardware to fulfil some particular function, but while some software is necessary to make it work, too much software just slows everything down. Therefore, software should be restricted to what's necessary to provide functionality, and extra hardware resources should mean everything just runs better. The article claims this was the mindset behind Apple's iOS.
Both viewpoints have merit, but they're clearly incompatible. Now that they've been pointed out, I suspect a lot of the technical discussions I've participated in over the years were at least partly based on "Hardware Supports Software" people looking at a project based on "Software Supports Hardware" ideals and boggling, or vice versa. For example, I reckon the systemd and GNOME teams are squarely in the Hardware Supports Software camp, while Software Support Hardware presumably hosts the suckless guys, and anybody who owns an Arduino.
joeyh likes this.
2017-05-26T14:31:09Z via Identi.ca Web To: Public CC:For a Python script parsing command-line arguments, it seems there's only a few candidates:
Argparse is definitely not great with subcommands, but that's the one I've settled on. I would like to try click sometime, but the framework thing is a barrier. I also would like to try Google's "fire" at some point to see where it might be appropriate to use: https://github.com/google/python-fire
- "optparse" in the standard library, which is quite limited, and besides which was removed in Python 3
- "argparse" in the standard library, which is pretty flexible, but which produces weird, un-intuitive "--help" output if you have subcommands.
- "docopt", which generates a parser from "--help" output, but traditional "--help" output glosses over a lot of details that I want to specify, like which options are valid with which commands.
- "click", which seems to support all the features I need and produce the pretty output I want, but it's a framework that takes over your program rather than a library you call into, and I find that kind of API endlessly frustrating.
2017-05-23T04:19:53Z via Identi.ca Web To: Public CC:I decided to write up the instructions for combining GNOME Flashback and i3 that I mentioned the other day, and in the process I figured out how to make them simpler, and not require root access. I'm pretty pleased with that:It's pretty nice to have fast, space-efficient i3 on my tiny laptop screen, and have the special screen-brightness and audio-volume keys Just Work.
2017-05-22T10:12:40Z via Identi.ca Web To: Public CC:Writing technical documentation, trying not to start every single paragraph with "However" or "Unfortunately" or "Luckily" or "Previously" or "Therefore".
2017-05-21T05:58:38Z via Identi.ca Web To: Public CC:The weak misanthropic principle: "humans can be hard to get along with"The strong misanthropic principle: "humans are fundamentally horrible"
2017-05-20T07:09:07Z via Identi.ca Web To: Public CC:Welp, I managed to cobble together the "GNOME Flashback" desktop with the i3 window manager, so I get convenient, automated window-management with all the GNOME goodies like handling media keys and auto-mounting USB disks.
Unfortunately, it requires dropping a bunch of files in /usr/share (GNOME components don't seem to check /usr/local/share, annoyingly) so I'm not sure how I can package up or document this to make it more widely available.
2017-05-08T06:25:03Z via Identi.ca Web To: Public CC:I love i3 for being super-light-weight and super-productive, I love GNOME for being pretty and making all the funky bits of my laptop Just Work, and I wish there was a way to make them play nice together.I still haven't found one, but I came across a gnome-shell extension called ShellTile, which lets me easily group windows side-by-side, subdivide them and resize the inner borders... a bit like panes in tmux. It doesn't have any of the keyboard shortcuts of i3 and doesn't make GNOME any lighter-weight, but it might be a nice way for GNOME users to try out the idea of a tiling WM without going all the way.
Charles Stanhope likes this.
2017-05-05T07:58:40Z via Identi.ca Web To: Public CC:I read somewhere once that the original Unix documentation was written in a style where each clause or section of each sentence got put on a separate line. The typesetter was going to re-layout the text anyway, and with line-oriented editors like ed(1) and ex(1), it was easier to retype a whole line than to edit a few words in the middle.In the modern age, nobody uses ed or ex, and reflowing a paragraph isn't hard, but having changes localised to a single line makes diffs easier to read and text-editor keyboard shortcuts are still fairly line-oriented, so there's still some benefit to the practice.But when I read back over what I've written, it's hard to avoid reading it as free-verse poetry.
2017-04-25T01:49:44Z via Identi.ca Web CC: Public
2017-04-23T09:38:43Z via Identi.ca Web To: Public CC:Today, I spent some time investigating terminal UI libraries. You know, the kind of library that lets you draw coloured text to your terminal, and tells you which key the user pressed. Turns out, it's a lot messier than I imagined.
curses is the grandaddy, of course. It supports Every Terminal Ever, it's available on every platform, it's wicked-smart about updating the screen, what's not to like? Well, because it supports Every Terminal Ever, the API has this odd fascination with colour-pairs instead of just setting foreground and background colours. It doesn't support mouse-drag events, or any mouse events past column 224, or keyboard events involving the Alt modifier, or the true-colour output that some terminals support these days. And on top of everything else, the API is weird and archaic to modern eyes—definitely a product of its era.
But curses gets its wide compatibility from terminfo, right? So we'll just write to the libterminfo API and build our own abstractions on top. We'll lose the cleverness of curses, but we'll get the features we want, right? Right? Unfortunately, terminfo has a weird dynamic-typing thing going on: for a given terminal, a given capability can be a boolean, integer, string, or a string-template, and you just have to assume what it's going to be, you can't query it, so you don't want to venture too far outside the well-known capabilities terminfo defines. Worse, terminfo doesn't support as much as you'd like. Some keys have regular and shifted capabilies (for example, "key_left" and "key_sleft" for the Left arrow and Shift-Left respectively), most do not. Terminfo supports ~60 function keys, so typically Shift-F1 is mapped to F13 (or F11), Ctrl-F1 to F25 (or F21), etc. There's a sequence for mouse input, but it assumes details of the traditional xterm mouse protocol, so you're stuck with the 224-column limit.
Most other libraries are built on top of curses, or are just designed to support very basic formatting and positioning, so they're not much good for the general case of full-screen terminal applications.
One library that seems to be well designed is libtermkey - it only deals with input, but it deals with it the right way: you feed in bytes, you get out UTF-8 strings, key symbols with modifiers, or mouse events (autodetecting what protocol is in use). Unfortunately, libtermkey is officially deprecated, although it does see minor development work.
libtermkey's official replacement is libtickit, by the same author. Unfortunately, that library has only just (in early April 2017) reach version 0.1, and is not yet widely available. Time will tell whether it becomes the One True Text UI library.
Claes Wallin (韋嘉誠) likes this.
2017-04-08T01:37:41Z via Identi.ca Web To: Public CC:“So my name is Tim, and I’ll be your first interviewer today…” Tim is making every effort to be cheery. His ears stick out a bit, and in his dark-brown hoodie and cream shirt, perched expectantly at the table, he resembles something of a pine marten. You like pine martens, and therefore Tim as well.
2017-01-22T09:27:04Z via Identi.ca Web To: Public CC:Where some people get in a writing mood by maximizing their Word window, or dragging out their old Smith-Corona, I like to set my terminal to full-screen mode and crank up the font-size until my target line-length just about fits on the screen.
Right now, I'm using Envy Code R, which is one of those monospaced fonts designed to look good at a very specific pixel height, which is a lot smaller than it happens to be in my full-screen terminal right now. It's a very weird mixture of stubby, blocky glyphs rendered lovingly, crisply in super-high resolution, an incongruity that feels appropriate for a display that uses an LCD panel and 3D acceleration to emulate a VT220.
Alex Jordan likes this.
2017-01-15T08:17:23Z via Identi.ca Web To: Public CC:It's been a long time since I did any photography, but on Thursday I went on a photo-walk around a new park that opened last year (on the site of the old commercial wharves) and found some things I liked:
2017-01-08T01:11:48Z via Identi.ca Web To: Public CC:I forget where I found it, but somebody pointed me to a YouTube playlist called "Category Theory for Programmers", and I'm about half-way through it (up to the end of lecture 5.2, Algebraic Data Types).
Having dabbled in Rust and read some blog-posts about Haskell, I already knew some of this stuff (like the existence of sum and product types, or Void and unit), but having them all described with all the connections between them is kind of blowing my mind. For example, I knew algebraic data types were "algebraic" because they're a bit like "addition" and "multiplication", but the video pulls out a whole bunch of high-school algebra, translates it into data-type notation and shows that it not just works, but that it's actually useful things a programmer would recognise.
It's a long series of videos—it seems like a university professor recorded an entire semester's worth of lectures—but I'm more than happy to have spent the time to watch them on my Christmas holidays.
der.hans shared this.
2016-12-31T10:51:31Z via Identi.ca Web To: Public CC:I've been a tea-drinker for years, but having experienced tepid and room-temperature tea, the idea of "iced tea" sounded thoroughly revolting. But, my parents had a bottle of peach-flavoured ice-tea, and it wasn't too bad, so I decided to try making my own.
In particular, I filled a mug with boiling water, dropped a tea-bag into it, waited 4 minutes (my usual span) then took the tea-bag out and dissolved a teaspoon of honey into it. Finally, I stuck it in the fridge for a few hours.
When it was cold, I pulled it out, sprinkled some ice-cubes into it, and... ugh. Not as disgusting as room-temperature tea, but still quite bitter. Maybe it needs more honey?
I normally have tea with milk and no sugar, but I assume milk in iced tea Just Wouldn't Work; I've never heard of anybody ever trying it.