Saturday, November 26, 2011

Girls hack Arduino

In all my programming life I never tried communicating in code with real-world objects. But now there is something to make it easy (or at least doable): Arduino. Sharon Cichelli demonstrated it at the All Girl Hack Night in October of 2011. Arduino is a microcontroller that lets you program blinky LED lights, or things that make buzzing alarm sounds, or all sorts of other electronic. It also accepts input from buttons or sensors, or anything that translates a physical action into electric pulse. You can plug things into one of its pins (there are 13 of them, if I recall), and have it "read" electric pulses from those pins, or "write" to them.

"Read" and "write" probably shouldn't be in quotes, because they are the same programming concepts as reading and writing to/from any input/output device. So, to switch on an LED light that's plugged into pin 13, you would digitalWrite(13, HIGH). As with all things digital, the function digitalWrite only recognizes on/off, or in this case, HIGH/LOW values. HIGH means the device plugged into the pin is on, LOW -- off. Simple, right? These basics allow one to sit down and program a primitive blinky light in minutes. The programming language is fairly high level. Its function names, as one can see, resemble human language -- this isn't assembly, where you push bits around with three-letter commands. It enables you to quickly do simple demos, like Sharon Cichelli did. Just as you digitalWrite to a pin to turn a device on, you digitalRead from a pin to recognize, say, a button press. Again, you pass to it the number of a pin into which the button is plugged in.

You write the code in an IDE, and with one mouse click upload it to an Arduino connected to your computer via USB.

Sharon Cichelli dictates the code that Anne types up on the laptop Sharon Cichelli demonstrates Arduino programming.

Arduino programming seems encouragingly simple at first, but as with everything, once you get deeper into it, you discover complexities. In fact, one's lack of electronics background might put brakes on the progress. Having been told that a LED light is plugged into a pin number 13, you (and by you, I mean me) might notice that the light actually has two wires, both plugged into tiny slots. Why are there two wires, and which of them is # 13, you ask. Oh, it's because the light needs to be grounded. The other wire is plugged into the grounding pin, you can ignore it for the purposes of your program. Yes, grounding is something you should have remembered from physics classes, but didn't. Then you digitalWrite to it, and it still doesn't light up -- that's because something is wrong with the hardware, and the circuit does not close as expected. Maybe the light isn't plugged in firmly enough. So, there are two dimensions to debugging Arduino code: a programmatic and an electrical dimension. As if catching just the software bugs wasn't tricky in itself!

Sharon couldn't help but demonstrate troubleshooting techniques, as things malfunctioned. Pins "floated". Still we had enough time to progress to a more advanced part of the lesson: Pulse Width Modulation. If you can only send "on" or "off" signals to a LED, how would you dim the lights, or produce nice, slow fade on / fade off effects? The fading or increase in brightness is caused by flickering very fast between on and off positions. If the light spends more time in the "off" position than "on", it appears to fade; if in on position, it grows brighter. If we graph HIGH and LOW signals versus time, where every HIGH signal is a vertical bar, we'll see that the "width" of the HIGH signal decreases (increases) over time. So that, simply put, is Pulse Width Modulation. Sharon pair-programmed with someone (sitting another person down at her laptop's keyboard, and dictating code to her) to implement the slow fade.

Besides blinking and buzzing things, you can connect Arduino to vibrating things. Erm. I mean, like a mat under a cat food bowl. A vibrating mat would scare off a cat that is afraid of vibration. This was the idea one of the girls had. How do you make a cat lose weight, if you also have a normal-weight cat, and each time one sees the other eating, she will eat too? The goal is to make the fat cat to eat less frequently than the normal-weight cat. So, this girl got an idea to put a vibrating mat under the cats' food bowl, so that when the cat steps on it, her weight would send an input to Arduino, which would trigger the vibration, scaring the cat off. The smaller cat's weight would not trigger this response. And the fat cat's weight would only do it at certain times but not others, otherwise the pudgy feline would never eat.

And if you don't have problematic cats, there is still a wide variety of applications for Halloween costumes, such as blinky eyeballs like Sharon made for her own Halloween costume.

Friday, November 11, 2011

ArmadilloCon 2011: The Singularity panel

Singularity is commonly associated with emergence of strong artificial intelligence, and the panelists don't think strong AI is any closer now than it was at the time this topic was discussed on ArmadilloCon panels of the past. Or 30 years ago. Or ever. Singularity is certainly no closer than when Vernor Vinge debated it at ArmadilloCon 2003, or Charles Stross at ArmadilloCon 2006. Moreover, some panelists disagreed whether moderator John Gibbons' question "What do you see as a fundamental block towards strong Artificial Intelligence?" is even the right question to ask. They disagreed whether it is possible to bring an AI into being by programming it.

This was a well-reasoned analysis of common Singularity tropes.

Trope 1: Singularity will come from the emergence of strong AI

Bruce Sterling admits that he used to find the idea of strong AI seductive, but doesn't see any evidence of it emerging any time. More, he doubts whether the products of intelligent mind, such as new ideas or inventions, can be attained computationally. "I know many very intelligent people, and they don't reason stuff out of the first principles," said Bruce Sterling. It certainly doesn't "feel like" creative insights come to us algorithmically. And if flashes of insight can't be simulated by a Turing machine, then they are not achievable by a computer. "Computation is not like human intelligence," says Sterling. "It's like mathematics. You could say, mathematics will one day overtake the human brain! But that would be a category error."

Left to right: authors Alexis Glynn Latner, Adrian Simmons, John Gibbons Left to right: authors Alexis Glynn Latner, Adrian Simmons, John Gibbons at the Singularity panel. More pictures from ArmadilloCon 2011 are in my photo gallery.

Bruce Sterling thinks collective intelligence is more interesting than artificial intelligence. When you are starting a company, would you hire HAL 9000, an intelligent machine who never sleeps, or a bunch of engineers who use Google, he asks. Google would immediately defeat HAL. He didn't answer another panelist Adrian Simmons' question if it wouldn't be even better to hire a HAL who uses Google.

Then Bruce Sterling left the panel to go help his daughter who was at the other end of town, adding "Real futurists have children!"

Trope 2: Moore's law will inevitably lead to strong AI

Both the panelists and the audience doubted whether the advance of AI has hardly anything to do with Moore's law. We already have extremely powerful computers for extremely complex weather and economic simulations, but you can't speak about their IQ.

Trope 3: Sentient computers care about the existence of humankind one way or another

Would we even want a sentient machine? John Gibbons reminds us that Charles Stross, author of Singularity-themed novels, asked this question in a recent blog post. What do we need a sentient machine for? While we conceivably might want an intelligent computer to run a spaceship on a long mission, like HAL 9000, in general there's not much advantage to sentience in a software program, argued John Gibbons. And it raises a huge batch of ethical questions. Using a genetic algorithm to derive sentient software? You're committing genocide along the way, because you're killing off versions that don't meet your goals.

Left to right: authors Katy Stauber, Marshall Ryan Maresca, and Bruce Sterling Left to right: authors Katy Stauber, Marshall Ryan Maresca, and Bruce Sterling at the Singularity panel. More pictures from ArmadilloCon 2011 are in my photo gallery.

Even if a sentient AI is benevolent to the humankind, it can't be expected to do what humans would like it to do, Adrian Simmons pointed out. You may ask it how to make better gadgets, but it will instead turn around and ask you personal questions, because it might feel it's human now, and wants to experience a human perspective of the world. (Even that, I should say, is a bit human-centric, if not to say myopic. An AI might not be interested in learning from humans, since by necessity it would develop its own way of learning about the world: else it would not be an AI. It is a common trope in science fiction that a robot or AI yearns to know what it is like to be human, but I think we as humans overestimate our interestingness to the machines. We absolutely can't expect them to take an interest in our problems, let alone serve us. -- E.)

Trope 4: Singularity will come from augmentation of human brain

But machine intelligence is not the only way for Singularity to come about. Bruce Sterling said: increase of a metabolic efficiency of certain regions of the brain (that are dedicated to higher functions), and it will feel like Singularity. Our brain is very inefficient -- the biggest parts of it are dedicated to such functions as walking. So an increase in efficiency of higher reasoning parts of the brain could bring about enormous changes for the humankind. Science fiction has already addressed something similar, such as repurpose visual cortex to do other computations, an audience member pointed out.

Trope 5: Singularity will come from uploading a human personality to a machine

The panelists doubt whether that will ever be possible, because it seems like such a stretch between the chemistry of "wetware" and computational substrate. Here, too, science fiction has shown how horrific unintended consequences of this can be -- case in point is Greg Egan's story "Learning To Be Me".

Trope 6: Singularity will come from the web "waking up"

A person in the audience asked: if we organize semantic connections on the web, will the web "wake up"? John Gibbons reply was what I would have said too: becoming conscious requires a model of self. And it's hard to see how that model of self would emerge simply by organizing semantic connections on the web.

Tuesday, November 08, 2011

Am I the only one to want this? Linking to any part of an HTML page

Here is a pipe dream. I would like HTML to have ability to link to any paragraph in any web page. I would like to make it so that when the user clicks the link, the page would open with the paragraph of interest at the top of the browser window.

I only know how to do it if some section of a web page has an <a name="xxxxxx"> in it. And if the page I'm linking to isn't created by me, I have no control over placement of <a name>'s in it. But is it possible to link to any element of a page? If not with HTML, then with Javascript or CSS? Can one write a Javascript that, when a user clicks on a link, will bring up the desired element of the page that has loaded? I kind of doubt it, because once a page has loaded in a browser, the scripts of the previous page stop executing, correct?

And I'm pretty sure there is no way to do this if the desired paragraph is not in any uniquely-identifiable HMTL element -- for example, if it only separated from other paragraphs with <br/>

If there is really no way to do this, I wonder if such functionality was never considered by They Who Design HTML? Has nobody ever wanted it? I wish for it when an explanation or example of something I'm writing about is buried deep in some other web page, and I know that my reader, if he/she clicks on the link, is not likely to find it quickly, or to spend much time searching for it.

I suppose one can write a third-party application that would let you mark up snippets of web pages and save them; then you could link to the paragraph on the third party website. It could provide a link to the original article, for those interested in the context. But that's an additional layer of complexity. There may even have been such a service, called iLighter; it allowed you to highlight web pages and save those highlighted snippets on its servers. I know I installed it in one of my web browsers a couple of years ago, but didn't do much with it. I had app fatigue even then (too many new web applications to try), which only got worse since. And iLighter doesn't seem to be around anymore -- I guess not too many people found it useful.

I know, I could write a Javascript that would pop up just the paragraph I want to link to, when the user's mouse hovers over the link to the article. So the user could get just the quote, but read the article for context if they'd like. Of course, this is inefficient, because the quote may change some time in the future, and somehow I would have to become aware of the change (which won't happen unless I monitor that web page every day), and modify my script. So, it's not a real solution.