http://livingcode.org/feed/atom 2009-11-13T19:33:25Z Living Code Programming for the Fun of It Copyright 2009 WordPress http://livingcode.org/?p=179 <![CDATA[Go Language and Functional Programming]]> 2009-11-13T19:33:25Z 2009-11-13T19:33:25Z Dethe delza@livingcode.org http://livingcode.org/ There is a cool new language on the block, coming from The Google courtesy of (among others) Rob Pike and Ken Thompson. The language is called Go (and the debugger is called Ogle, so put ‘em together for a secret message) and it attempts to be both a low-level, type-safe, compiled language, like C, while being garbage-collected, concise, with high-level structures and idioms like Python and Javascript. There are a lot of things to like in it, and I am exploring what it can and cannot do. My first question was whether you could use it for functional programming, i.e., are functions first-class objects that can be passed to other functions, returned from functions, stored in variables, etc. This wasn’t in the FAQ or the Language Design FAQ, but there were some hints of it in the description of channels, so I went ahead and wrote my own tests to see if it would work.


package main

import fmt "fmt"

type Stringy func() string

func foo() string{
return "Stringy function"
}

func takesAFunction(foo Stringy){
fmt.Printf("takesAFunction: %v\n", foo())
}

func returnsAFunction()Stringy{
return func()string{
fmt.Printf("Inner stringy function\n");
return "bar" // have to return a string to be stringy
}
}

func main(){
takesAFunction(foo);
var f Stringy = returnsAFunction();
f();
var baz Stringy = func()string{
return "anonymous stringy\n"
};
fmt.Printf(baz());
}

This compiled and ran, giving the right output, so it looks to me like functional programming is indeed possible in Go, and on the Effective Go page we learn, “In Go, function literals are closures: the implementation makes sure the variables referred to by the function survive as long as they are active.” So that’s kind of cool.

Go also has rich, high-level concurrency support similar to Erlang, several features that prevent random memory from being read or written, and both strings and maps (dictionaries, hash tables) are built-in datatypes. It has a small, but powerful standard library.

One puzzle down, several to go. I still want to explore how I can talk to Cocoa from Go (for GUIs), how to wrap libraries such as libxml2 and cairo for Go, and basically how to map more Python/Javascript library goodness into Go’s world.

I have smaller questions too: can I add methods to existing types? How do I load the contents of a URL? It’s looking good so far! Tune in next time for more exploration.

]]>
http://livingcode.org/?p=171 <![CDATA[Schools of the Future]]> 2009-10-13T05:13:49Z 2009-10-13T05:13:49Z Dethe delza@livingcode.org http://livingcode.org/ The impact of technology on everything else

Recently when I was at BarCamp I was repeatedly reminded of an article about Craigslist, explaining why bigger, more capitalized companies had failed over and over to compete successfully with Craigslist. It came down to their credo: “unbrand, uncompete, and demonetize.” Essentially, they took a potentially $22 Billion market and cut it down to a $1 Billion market, or less. The AOLs and Ebays of the world cannot survive while scrapping over fractional parts of a $1B market, they’re just too big. But Craigslist, with its 30 employees, can thrive just fine with $100M annual revenues. It comes down to the basic math of mammals vs. dinosaurs.

And classified ads are simply where the battle has already been fought and written up for the history books. The same effect is happening in every industry you can name. Musicians are learning to route around their own industry titans to reach their fans directly, there are efforts underway to open source the law, movie making has gotten to the point where fan films and low-budget pro films can be much better than Hollywood blockbusters, microlending (like Kiva) is profitable while building economies, rather than destroying them, newspapers (already financially gutted by Craigslist itself) are finding that there is no economic model which lets them survive in the form they have grown accustomed to. The list goes on and on.

“When you can’t imagine how things are going to change, that doesn’t mean that nothing will change. It means that things will change in ways that are unimaginable.”—Bruce Sterling

You can argue about whether any of this is “good” or not, but the clear trend to me is that it is inevitable. If you are in a business now that is still doing business the way it was 20, 50, or 100 years ago, get ready to jump, because someone out there is about to steal your lunch money. On the other hand, all of these new businesses reduce costs to citizens, empower people rather than corporations, and make good money for their small staffs. It’s a good time to be a mammal.

The past of schools (is now)

How does all of this relate to education? Schools have changed a lot in the past 100 years: Girls no longer have to wear bonnets, kids write with pencil and paper (or netbooks) rather than scratching on a slate. On the other hand, everyone is still reading from a state-approved book, facing the front of the classroom, where a state-approved teacher is expected to know all the answers and who writes the requirements on a board while lecturing. In other words, if you took a teacher from 100 years ago and dropped them in a modern classroom, it wouldn’t take much adjusting for them to get up to speed. That is not true of many professions. In fact, H. G. Wells made the same points about schools, and he made his points over 100 years ago.

”…our universities, I suggest, are not half-way out of the fifteenth century. [...] The three or four years’ course of lectures, the bachelor who knows some, the master who knows most, the doctor who knows all, are ideas that have come down unimpaired from the Middle Ages. Nowadays no one should end his learning while he lives and these university degrees are preposterous. [...] Educationally we are still for all practical purposes in the coach and horse and galley stage.”—H. G. Wells

If school has not changed much in well over 100 years does that mean it has to change? For all of that time people have been saying that schools must change, have been working to change them, yet schools have remained remarkably the same all this time. Could this be because we’ve got schools right, that they are resilient and stable because they’ve been perfected? Or does it mean that school has become calcified and too broken to change? (too big to fail?)

Well, there have been some changes in that time. Even in my lifetime I have seen schools become more and more like prisons, with smaller (or no) windows, bigger classrooms, metal detectors, locked doors. On the bright side, corporal punishment has been banned from school. And of course, once upon a time school was not mandatory.

“Our form of compulsory schooling is an invention of the state of Massachusetts around 1850. It was resisted - sometimes with guns - by an estimated 80% of the Massachusetts population, the last outpost in Barnstable on Cape Cod not surrendering its children until the 1880’s when the area was seized by militia and children marched to school under guard. Now here is a curious idea to ponder. Senator Ted Kennedy’s office released a paper not too long ago claiming that prior to compulsory education the state literacy rate was 98% and after it the figure never again reached above 91% where it stands in 1990. I hope that interests you.”—John Taylor Gatto

In The End of Education, by Neil Postman, he argues (using the double meaning of “end” as both goal and the final part of something) that school as we know it now has no working goal and needs to find one if it is to continue. He also proposes five goals that school could adopt to give it a reason for being.

In The 7-Lesson Schoolteacher, John Taylor Gatto lays out what is taught in modern schools: confusion, class position, indifference, emotional dependency, intellectual dependency, provisional self-esteem, and you can’t hide. In the short essay, linked above, he explains why these are the real lessons of school, and in his book The Underground History of American Education he explains how we got in this situation.

Postman and Gatto were both teachers in the school system. Postman continued to fight the system from within until he died, Gatto left after winning awards for his teaching and began a new career of lecturing and writing about the pitfalls of school. Both were probably influenced by an Austrian philosopher and Roman Catholic priest named Ivan Illich, whose book Deschooling Society focused on schools as the most resilient of institutions for preventing positive change in the world.

“A second major illusion on which the school system rests is that most learning is the result of teaching. Teaching, it is true, may contribute to certain kinds of learning under certain circumstances. But most people acquire most of their knowledge outside school, and in school only insofar as school, in a few rich countries, has become their place of confinement during an increasing part of their lives.”—Ivan Illich

Illich provides not only a scathing critique of institutionalized schooling, but also recommendations for change, some of which are now being implemented. With the technology tools we have at our disposal today, people can afford to connect with each other and make real change, as we’ll see below.

Who am I?

“Everyday, millions of innocent children are unwillingly part of a terrible dictatorship. The government takes them away from their families and brings them to cramped, crowded buildings where they are treated as slaves in terrible conditions. For seven hours a day, they are indoctrinated to love their current conditions and support their government and society. As if this was not enough, they are often held for another two hours to exert themselves almost to the point of physical exhaustion, and sometimes injury. Then, when at home, during the short few hours which they are permitted to see their families they are forced to do additional mind-numbing work which they finish and return the following day. This isn’t some repressive government in some far-off country. It’s happening right here: we call it school.”—Aaron Schwartz

Who am I to talk about the future of school? I’ve quoted some old white guys on why today’s school needs to change, but I haven’t said anything about where I’m coming from with all of this. I am a product of those schools. I moved a lot growing up, and we were poor, but sometimes lived with rich(er)friends. I attended public schools, private schools, hippie “free” schools, Catholic school, east-coast school, west-coast school, deep-South school, small schools and big schools. I had some wonderful teachers, some mediocre teachers, and a handful of teachers so awful I still can’t believe they are allowed near children.

Mostly I did very well in school without trying too hard. I was often called an underachiever. Sometimes I was called a class clown and told “don’t get smart,” which was amusing, given the context. I hated school, by and large. Once, around sixth grade or so, I woke with a spontaneous nose bleed and my mom let me stay home from school. I hit myself in the nose every morning for a week trying to repeat the experience, with no luck. That’s how much I hated school.

Since most of my teachers were good or ignorable, aside from a handful of really bad ones over the years, I don’t blame the teachers for my hating school so much. I moved so much that I was usually the New Kid, which made things difficult, and I was a “nerd,” which also made things difficult. Most of my problems and fears came from the other students, who were also products of the schools we went to. We were taught from an early age to label and be labeled: “smart,” “jock,” “underachiever,” and ruder things.

I did get one thing of value from moving between all of these schools. I learned from an early age that 90% of it was bullshit. I learned how to play the game. I learned that it really doesn’t go on your permanent record (although modern technology may change that). I learned most of all, that most learning happens outside of the school, and only inadvertently within the school walls. That you don’t learn to read and write well by diagramming sentences, or to balance a checking account by using number lines. School is the boring place that kids are kept so their parents can go to their boring jobs, and where they learn to cope with boring rote work so that someday (if they’re lucky) they can have boring jobs too. By high school I’d attended thirteen schools, and that was the lesson I’d learned most.

My high school closed during my third year there, it dropped out on me and I didn’t re-enlist. I took the GED, which was pathetically easy, and later attended a technical college and university. Eventually, I received a master’s degree without encountering anything which fundamentally altered my perceptions of school. I did learn things while in university, but again, it was mostly a matter of wanting to learn and finding things to learn, rather than absorbing knowledge from a teacher lecturing at the front of the class. Those classes were a bad joke.

I am a computer programmer, and I hire computer programmers. The best predictor of their skills is not their job history or their education, but whether they have helped with open source projects, or program on their own time, as a hobby. Because if they program for the love of doing it, they are going to be the kind of people who love learning and can find it for themselves, without waiting for the teacher at the blackboard to deliver it.

I did not study education in school. My wife is nearing her Ph.D. in Philosophy of Education. She reads about all of the attempts that have been made over the years to make schools better, mostly by well-meaning people (but not always). I cannot read those things, I find it too depressing.

Finally, I am a parent. I have two kids, and yes, they go to school. I find my job as a parent is to minimize the damage school can do, and maximize the good aspects. I don’t count on school to teach my kids, they are learning all the time, from me, from books, from the internet, from other kids, sometimes even from teachers (it does happen). But mostly, school can be a place to make friends, to learn to deal with duties and people you don’t always get along with, and to have access to resources we don’t have at home (wood shop, metal shop, gym). Overall, the best school experiences appear to be when they get out of school, when they work in a community garden, or attend a play. Also, in our experience with the kids Montessori schools seem to be a healthy approach, as far as schools go.

If not school, then what?

In thinking about what could be better than today’s schools, I am troubled by even calling it “school.” I attended an arts program in Seattle for some time called the “Factory for Visual Arts,” but “factory” doesn’t feel like an improvement on “school.” Near my home there is a similar arts program called the “Arts Umbrella,” which is a little better, but “Learning Umbrella” doesn’t really tell me anything.

Looking back at other industries which were forced into change by changing technology, it’s clear that this is not a new problem. Horseless carriages had nothing to do with either horses or carriages, except that they replaced them. Moving pictures were an entirely new thing, but needed to be described in some way that people could understand, and indeed it was a long time before they broke out of the idea that they were simply a way of recording plays and the medium really came into its own. Radio is named for the waves it was transmitted on, not for what really was: stories broadcast into our homes. So I will stick with School of the Future for now, even though I’m not really talking about school, or the future. It gives a metaphor to hang on to.

There are several paths to the future of school. Students can learn at their own pace, using teachers they find in the community using a matching service. School can carry on much as it does now, but interface more with the community, sending kids out to community gardens, to volunteer service, to ecosystem restoration. Students can work with adults to learn skills in the real world, as apprentices, but with the understanding that they will have multiple apprenticeships over the years. Students can tune into online courses, for free or for a small sum, to view lectures and do coursework. Physical schools can be organized, permanently or temporarily, for courses that are not taught elsewhere, and for students to meet in person. All of these are happening now, at least in experimental form, and more experiments will be coming up alongside them. None are the single future path, but all will be part of the big fractal future. There is no one right answer.

More on these ideas in practice in the section On Beyond School

The future of schools (is now)

“To change something, build a new model that makes the existing model obsolete.” -R. Buckminster Fuller

Here is what my daughter thinks a school of the future should be:

We need better schools, schools that prepare kids for their lives in the unknown.

A school should…

  • Be a place where kids can come to learn because they want to.
  • Be a place where kids can come to interact with other kids and learn from each other.
  • Allow kids to develop their skills and passions.
  • Have teachers who are able to help kids find their skills and passions.
  • Be a place to try new things.
  • Be a place where kids are not afraid to make mistakes.
  • Be a place where a kid can start making a difference in the world.
  • Be mostly run by kids.

A school should not…

  • Cause stress.
  • Be a place where kids are bullied.
  • Be the center of a kid’s life. (You go to elementary school to learn how to get through high school, which is to learn how to get a job and/or go to university, and you work, work, work and then you die. Any questions?)
  • Prevent kids from reaching their full potential in any way.
  • Make learning into a chore, and teach kids to hate it.

—Mina Elza

I have my own list that I’ve been sketching out, for what I imagine the school of the future to be. It largely resolves around making resources accessible, having places to meet as needed, and interfacing with the community. It does not make any assumptions about the student’s age, educational level, or socio-economic status.

A school built for the future should:

  • Grow much of its own food
  • Have a Fab Lab, be able to make whatever it needs
  • Make computer training ubiquitous, computer literacy is crucial
  • Have martial arts as part of the curriculum
  • Make practical economics part of the curriculum
  • Have a storefront
  • Have a restaurant/coffeehouse
  • Have a bookstore/library
  • Have its own micro-currency
  • Use community outreach extensively, with sister institutions, partner businesses, etc.
  • Have its own publishing imprint
  • Have a music label and recording studio
  • Make the boundary between student and non-student flexible, permeable, and transparent

This isn’t a school to be attended, it is a school to be used, a school that can serve as a anchoring point for a resilient community, a place where lifelong, overlapping apprenticeships can take place. I’d like to talk about each of these points in turn.

Grow much of its own food

Schools that have added organic gardens have found students care more about what they eat, eat better, and learn about sustainable ecosystems.

The garden suggests there might be a place where we can meet nature halfway. —Michael Pollan

Have a Fab Lab

We live in a world where we can manufacture anything imaginable. This can be high tech, with 3D printers and laser cutters, medium tech with welding and machine tools (engine block machine-shop), or low tech with pottery and weaving. Learning how to use these tools is empowering, and a form of modern literacy.

Make computer training ubiquitous

“It goes against the grain of modern education to teach children to program. What fun is there in making plans, acquiring discipline in organizing thoughts, devoting attention to detail and learning to be self-critical?”—Alan Perlis

Most computer training teaches you to work the way the computer wants you to work. Better to teach how to make the computer work for you, how to use the computer to produce art and tools, how to use it to communicate effectively.

Have martial arts as part of the curriculum

I firmly believe that martial arts, learning basic self defence and self discipline, is something students of any age can benefit from. My personal favourite is Aikido, because the philosophy is non-violent, turning the opponent’s energy against themselves, but other styles have benefits too.

Make practical economics part of the curriculum

Well, insofar as there even is a curriculum. Too many people have not learned how to balance a checkbook, or how much money their credit cards really cost them. Learning to manage money sanely is one of the basic survival skills in this world. We live in an economic society, and learning what that means and how to swim in its waters is not really taught in schools now.

Have a storefront

This can help make the school self-sustaining, allow students to make some money selling things they’ve made. It can also provide real-world economic experience for students to learn how retailing works. Finally, it can be one part of a good interface to the community. The storefront itself can be humorous. At 826 Valencia their storefront sells supplies for time travellers. Its counterpart in New York City sells superhero supplies. Another sells pirate supplies. I suggest selling mad scientist supplies.

Have a restaurant/coffeehouse

For similar reasons to the storefront, having a coffeehouse and/or restaurant would be good for the school. Besides learning the economics and business routines of a restaurant, students can also learn to cook and take care of customers. Food is such a basic element of our lives, and so often overlooked. By focusing on providing good food, cooked with local ingredients (some grown by the students) and providing discounts to students, you complete a circle that many people have never known they are a part of.

Have a bookstore/library

Books are essential to the learning process. A good source of books becomes a community of its own, with readings, reading groups, and discussion to help the books come alive. Books written by the students should become a focal point for the book space. This can also be a space where students from other schools come to get help with homework and tutoring.

Have its own micro-currency

Local currencies, like Ithaca Hours, Comox Valley Community Way Dollars, and Salt Spring Dollars keep money flowing in the community, rather than going out to national and multinational corporations.

Use community outreach extensively, with sister institutions, partner businesses, etc.

It is important for any community hub to network with other community hubs. Buy food from local farmers. Share resources and knowledge with other schools. Neighbours helping neighbours.

Have its own publishing imprint

Students should be encouraged that they can write their own books, tell their own stories. The school can help bring to print student books in a variety of ways, with small run press and print on demand.

Have a music label and recording studio

Making music is another basic human drive, and being able to share music is too important to be left to the toxic recording industry. The tools for making, recording, and sharing music with others should be easily accessible, with help available to make it non-threatening to learn and use.

Make the boundary between student and non-student flexible, permeable, and transparent

The terms student and teacher break down in the school of the future. There are participants, who care enough about the school to dedicate time and resources to it, who want to learn and share what they’ve learned. That is the essence of community.

Overall, these are interlocking goals, each helping to support and sustain the others. The important things are to teach real skills that students can see the relevance of and apply to improve their own lives and the lives of those around them, while providing a permeable membrane with the community so that there is a constant exchange of energy, ideas, creativity, and support.

Learning is finding out what you already know. Doing is demonstrating that you know it. Teaching is reminding others that they know just as well as you. You are all learners, doers, and teachers. —Richard Bach

On Beyond School

“By the time I got to school, I had already read a couple hundred books. I knew in the first grade that they were lying to me because I had already been exposed to other points of view. School is basically about one point of view — the one the teacher has or the textbooks have.”—Alan Kay

This essay grew out of a series of notes and links I’ve been collecting for some time, with a few recent trigger points along the way.

I have been reading Make Magazine and while every issue has great projects and inspirational ideas, the first issue had a short article on Fab Labs that demonstrated how utterly the landscape has changed for school (and everything else). Computer technology has radically altered businesses of every kind, but now it is altering physical reality, and learning to harness this process will be crucial in making it a net social benefit.

Also, this summer I found a copy of Seymour Papert’s Mindstorms: Children, Computers, And Powerful Ideas, which I’d been meaning to read for some time. I finally read it and have been thinking about the implications ever since. I think that with the recent growth of electronic books, Papert’s ideas (strongly influenced by the Constructivist principles of Piaget) are finally ready for widespread adoption. He wanted learning to take place immersively, just like language does. For language, we live in a world of language, and we absorb it naturally. For math, things are more difficult, but on the computer we can build a Math World that can be explored and worked in so that the concepts are absorbed in much the same way as language. This extends to much more than math, of course. I envision new e-book readers which have active content, that is, while you read on a subject, there is a window where you can actually play with that subject, work with the concepts, and push on the boundaries. I think a lot of what we now consider education can be better done with this kind of exploration.

I have been following Vinay Gupta’s writings on open-source infrastructure (among other things) and while I got a lot out of his videos at the Temporary School of Thought, I was really grabbed by Dougald Hine’s talk on Deschooling Everything (mp3 audio), which began by summarizing Ivan Illich’s work, especially his book Towards a History of Needs, which I felt was basically valid criticism, but with no proposed solutions. So I’d been meaning for years to read Deschooling, but hadn’t gotten to it. After listening to Dougald I pulled it off the shelf and read it (reading John Taylor Gatto’s Dumbing us Down: The Hidden Curriculum of Compulsory Schooling at the same time, the two books interleave pretty well).

Deschooling was not just a critique, but had very concrete suggestions for change, and Dougald (and friends) has taken some of Illich’s suggestions to make the School of Everything.

As I was pulling together my notes and links for this essay, Laura Blankenship pointed to an article about StraighterLine offering college for $99 a month, and the legal troubles they faced, with the comment, “Over time, colleges and universities have built sturdy walls and deep moats around their academic city-states.” I responded, “The walls and moats of Academia will hold back the Internet just as well as castles dealt with jet fighters.”

Indeed, as Michael Wesch so aptly demonstrates in his videos, most recently at the University of Manitoba on The Future of Education (I highly recommend watching all his videos, they are amazing and eye-opening), schooling is being changed by modern technology without its cooperation. Indeed, even when educational institutions cooperate, it is not clear whether this helps them stay relevant. I think that programs like MIT’s OpenCourseware (part of the OpenCourseware Consortium) is an important part of the future, I don’t know that MIT as it stands now is part of the same future. I am happy that I can download university lectures through iTunes U., making content from dozens of universities only a click away, and I think that will be a crucial part of future learning, and like Craigslist, it demonetizes education.

Small, focused, fast, even temporary schools will thrive in this ecosystem, but I don’t see how there will be the money to support huge infrastructures, campuses, stadiums, sports teams, administration, and other overhead to learning. It’s mammals vs. dinosaurs again.

There are more great resources for taking control of your own learning than I could possibly point to, and more coming every day, from WikiBooks to Textbook Revolution, from the Make Science Room to Academic Earth. There are free, public domain resources like the Internet Archive to the many commercial-but-mostly-free services of Google for Educators.

Two important resources I do want to call out are groups of people who are actually out there living these ideas and ideals, taking risks, experimenting, and making changes. I mentioned earlier the 826 Valencia project, which has inspired many successful project like it around the world, best summarized in Dave Egger’s TED talk, Once Upon a School. More information is available at the Once Upon a School site.

The other resource is one I am particularly excited about, because in many ways they are following similar ideas to the ones I discuss here, but instead of dreaming and writing about it, they’ve been spending the last five years doing it, making it happen. I’m talking about the W2 Community Media Arts centre, here in Vancouver on the downtown east side. It will feature open spaces, a TV studio, FM radio studio, Fab Lab, coffeeshop, a letterpress, space for social media entrepeneurs, and much more. I had no idea how far along this project was, or how ambitious its scope, until I met April and Irwin at Barcamp last week. I am excited to find some way to be a part of the W2 project and make more of these ideas a reality, which in turn helped me to find a way to collect my haphazard notes into this essay. I hope you’ve found something useful in it.

“Person who says it cannot be done must not interrupt person already doing it.”—Chinese Proverb

]]>
http://livingcode.org/?p=163 <![CDATA[Cities dream underwater]]> 2009-08-31T21:10:15Z 2009-08-31T20:46:51Z Dethe delza@livingcode.org http://livingcode.org/ Castle In The Air Underwater

When I was about 14 years old, my aunt took me tubing down a river in northern Florida. At the beginning of the river you could look down, down into the spring the water came up from, a deep tunnel into the earth. I remember people scuba diving into the spring, but I don’t know now if they were really there at the time, or have been inserted by my imagination because I thought it would be so cool to dive down into that tunnel to explore. Tubing down the river seemed so unexciting in comparison, but I did almost get bitten by a rattlesnake that was on a branch over-hanging the river, so the trip turned out to be pretty exciting after all.

I was reminded of this when I read the recent BLDG|BLOG post on Scuba Diving Beneath Hagia Sophia. I’ve wanted to visit the Hagia Sophia since reading about in college, and now my imagination of the subterranean waters below it makes me want to visit even more.

Similarly, a post on Wired Science did not grab me so much for the poisonous, fanged crustacean that was discovered, but for the image (scroll down) of scuba diving in a submarine lava tube. Wow.

Back to BLDG|BLOG, and the theme of the city, the idea of fishing in the lost creeks covered up by the city is intriguing. I live on False Creek, in a co-op built on what was once a swamp, but if I ever were to buy a house in Vancouver (dreaming here, obviously), I would be tempted to locate it over one of the cities lost creeks. Some of these have memorials to mark their passing, and there is an ongoing effort to bring back Still Creek, but most of the creeks are gone, into pipes and covered by layers of the city.

Since I don’t scuba dive, and am a very amateur spelunker, it may be strange that these images which are simultaneously underwater and underground should be so moving. Or perhaps not, since often what we find most beautiful in the world is not what we do and know and understand, but what remains mysterious.

]]>
http://livingcode.org/?p=143 <![CDATA[Watershed du jour – 3D coming of age]]> 2009-07-26T19:09:25Z 2009-07-26T19:09:25Z Dethe delza@livingcode.org http://livingcode.org/ While software and hardware have made great strides, some things still remain in the realm of specialized software. One way to look at this is, what can you still not do on the web? I can think of a few things: 3D, sound synthesis, video editing. I have hopes for all of these, but 3D in particular looks to be on the edge of a real breakthrough, and not necessarily from where I expected it.

For years I have been tracking X3D, the XML-based 3D specification that is the successor to VRML. I’ve been watching and working with the open-source FreeWRL tool, and it has been making good progress. However, the Age of Plugins appears to be on the decline. If it isn’t built-in to the browser (or ubiquitous, like Flash, and I have doubts about the long-term viability of Flash), there is little chance of getting viewers to install a plugin for your media format. That’s why I’m excited to see that Firefox is experimenting with a 3D context for the <canvas/> element, which will base its API on OpenGL ES, and significantly will support import of Collada models (presumably Collada Digital Asset Exchange, or .dae files).

But Firefox alone does not make a viable ecosystem. The other things I have come across recently that have convinced me that Collada models are going to springboard 3D into the hands of ordinary users are that Spore patch 5 (available now for PC, coming soon for Mac) supports exporting creatures (with textures and ready for animation) in Collada format, so you can work with them in the 3D tool of your choice, and that the next major release of Mac OS X, Snow Leopard, will support Collada as a built-in file type (scroll down to “Digital Asset Exchange support”). Collada has kept pretty quiet, at least in my world, but the support for it is pretty widespread, including open-source tools such as Blender and OGRE, plus all the usual suspects such as Maya and 3dsMax. Sadly, my editor of choice, Cheetah3D does not yet support it, but I understand they’re working on it.

I, for one, welcome our new 3D asset exchange overlords. Along with improved user creation tools like Spore, SecondLife, and SketchUp, 3D is almost ready for prime time.

]]>
http://livingcode.org/?p=140 <![CDATA[Moped Syndrome]]> 2009-07-23T18:16:37Z 2009-07-23T18:16:37Z Dethe delza@livingcode.org http://livingcode.org/ [This is an essay I wrote in 2002, found in an old journal]

What do you get when you cross a clock and a computer: a computer. An
airplane and computer: computer. A VCR and computer: computer. [This argument I believe was my summary of something Donald Norman said in The Design of Everyday Things.]

Of course, computer here is used as a code word for Something which is
perverse and complicated, which most computer *are*, but they don’t have to
be. It doesn’t imply that you can program your clock radio with Python, for
instance.

These are examples of moped compromises. I owned a moped once. It was too
heavy to pedal and too underpowered to go up hills. It combined all the
worst features of bicycles and motorcycles, with few of the advantages of
either.

These bad compromises are everywhere. When I studied to be an EMT, we learned
some Greek and Latin, a little CPR, but mostly we learned how to cover our
asses in case we were sued. By becoming professionals we would no longer be
covered by Good Samaritan laws, and the nature of the job (trying like hell to
save somebody’s life, often when it’s too late) meant lots of times the
patients died or lost a limb or whatever. Whenever the outcome is less than
optimal, the American knee-jerk reaction is to sue. So we inadvertently
became lawyers.

What do you get when you cross a paramedic with a lawyer: A paralegal.

Now I’m in computing and it seems that just writing code, pretty simple and
harmless code, not viruses or anything like that, can get you thrown in jail
or sued in all kinds of remarkable and unpredictable ways. In fact, you can
break the law without even knowing it, because what you’ve created is already
a secret. Add that to the awesome array of software licenses and we’re
inadvertently becoming lawyers again (or outlaws).

What do you get when you cross a computer scientist with a lawyer: A lawyer.

]]>
http://livingcode.org/?p=136 <![CDATA[Come up to the lab, and see what’s on the slab]]> 2009-05-09T18:14:14Z 2009-05-09T18:14:14Z Dethe delza@livingcode.org http://livingcode.org/ There is no truth to the rumor that PostgreSQL has been acquired by TransMeta to be renamed TrangreSQL. It is a further baseless rumor that they will build a new web framework on this, based on a suite of custom applications. Finally, it is patently untrue that their new motto will be the following.

Just a suite TransWebSite from TrangreSQL, TransMeta

Dr. Frank N. Furter declined to comment on any of these unsubstantiated rumors, saying only (and with emphasis, “Ha ha!”

]]>
http://livingcode.org/2009/aspect-oriented-python <![CDATA[Aspect-oriented Python]]> 2009-02-25T06:09:18Z 2009-02-25T06:09:18Z Dethe delza@livingcode.org http://livingcode.org/ A friend asked me for an example of AOP in Python. I started to write up my response, then realized it might be worth sharing more widely.

Briefly, AOP is about separating out Aspects which are are interspersed throughout your code (in AOP lingo, cross-cutting). The canonical example is logging, but there are others.

For Python, as long as you’re content with before/after aspects, the situation is good. In Python 2.5 and up there are two main tactics: decorators and context managers. Decorators use the @ syntax and context managers are used with the “with” keyword.

Decorators

Decorators are only usable on functions and methods in 2.4 and 2.5, but in 2.6, 3.0 and beyond they can be used on classes as well. Essentially they are callables (functions, methods, objects) that accept a function object and return a function object. They are called when the function is defined, so they get a chance to have their way with it: annotate it, replace it, or wrap it. The common case is to wrap it.

Quick example:

import logging
def before(fn):
    def wrapped(*args, **kws):
        logging.warn('about to call function %s' % fn.func_name)
        return fn(*args, **kws)
    return wrapped

def after(fn):
    def wrapped(*args, **kws):
        retVal = fn(*args, **kws)
        logging.warn('just returned from function %s' % fn.func_name)
        return retVal
    return wrapped

OK, those are three basic wrappers, you can use them like so:

@before
def foo():
    logging.warn('inside foo')

@after
def bar():
    logging.warn('inside bar')

@before
@after
def baz():
    logging.warn('inside baz')

foo()
bar()
baz()

This will result in the following output:

WARNING:root:about to call function foo
WARNING:root:inside foo
WARNING:root:inside bar
WARNING:root:just returned from function bar
WARNING:root:about to call function wrapped
WARNING:root:inside baz
WARNING:root:just returned from function baz

You will note that when we use two decorators on baz, the name of the function called by before is “wrapped.” This is because what before is called on is the result of after. The functools.update_wrapper function is useful in this case to make a wrapped function look more like the original function.

For more, please see PEP 318 Decorators for Functions and Methods: Examples and PEP 3129 Class Decorators. For convenience when creating new decorators, see the standard library functions functools.update_wrapper and functools.wraps.

Context Managers

Context Managers are used with the with statement, and are handy for resource aquisition and release. In Python 2.5 you have to “from __future__ import with_statement” to use them, but they are built-in in Python versions later than that. Also, objects such as files and locks are context managers now, so you can use patterns like

with open('example.txt') as example:
    for line in example:
        do_something(line)

This will automatically close the file when leaving the with block. And for locks the pattern is similar:

with myThreadingLock:
    do_something_threadsafely()

It is important to note that the lock will be release properly, or the file closed, even if an exception is thrown inside the with block.

If you want to create your own context managers, you can add two methods to your objects: __enter__(self) and __exit__(self, exception_type, exception_value, traceback). The return value from __enter__ will be passed to the optional as variable (seen in the file example). The __exit__ method will be called with exception info if there was an exception. If no exception is raised in the with block, then all three arguements will be None. If __exit__ returns True then any exception will be “swallowed”, otherwise the exception will be re-raised after any cleanup.

For more info, see PEP 343 The “with” Statement, especially the examples section, and also the helper functions in the standard library contextlib.

AOP and 80/20

Full-on aspect-oriented programming is beyond the scope of this post and involves join-points, code weaving, and other such arcanery. There are multiple Python libraries which target aspect-oriented coding styles, but for my money, the simplicity of the methods in the standard library, coupled with my impression that they cover at least 80% of the uses of AOP, make me favour these built-in techniques over any of the special purpose tools.

]]>
http://livingcode.org/2009/great-works-of-art-in-social-media <![CDATA[Great works of art in social media]]> 2009-02-22T00:04:11Z 2009-02-22T00:04:11Z Dethe delza@livingcode.org http://livingcode.org/ image_28_cropped.jpg

At Northern Voice, Darren Barefoot is asking why there is so little profound art on the web, but I think there is so much profound art that I cannot keep up with it. Perhaps it is because we have different filters for what is profound, but here are some sites that I frequently find art that speaks to me.

Dresden Codec: Dungeons and Discourse
http://dresdencodak.com/cartoons/dc_031.htm
http://dresdencodak.com/cartoons/dc_059.html

Industrial Decay
http://industrialdecay.blogspot.com/

NASA Astronomy Picture of the Day
http://apod.nasa.gov/apod/astropix.html

Algorithmic Art
Nodebox: http://nodebox.net/code/index.php/Gallery
Structure Synth: http://flickr.com/groups/structuresynth/
Processing: http://processing.org/exhibition/index.html

GapMinder (profound statistics)
http://www.gapminder.org/

Afrigadget
http://www.afrigadget.com/

Film is not dead, it just smells funny
http://www.thiaps.com/

BLDBLOG
http://bldgblog.blogspot.com/

We Make Money Not Art
http://www.we-make-money-not-art.com/

While I cannot keep up with all the art that I come across, I can find a social connection between all of these. The best, most moving art doesn’t just inspire me to admire it or think about it, but to share it with my friends and to create art that I wouldn’t have created otherwise.

]]>
http://livingcode.org/2009/balding-for-dollars-the-movie <![CDATA[Balding for Dollars: The Movie]]> 2009-02-19T05:46:35Z 2009-02-19T05:46:35Z Dethe delza@livingcode.org http://livingcode.org/

This will be my last post on the topic for awhile. I just wanted to thank everyone who helped out: Julie, Joanna, David, Fiona, Daniela, Hashim, Wil, Frank, Berenice, Hashim, Jim, Judy, Keith, Mary, Mike, Rachel, Stewart, Mag, Tom, Vince, Angelina, and Anonymous. Together we met the goal and raised over $1000 for B.C. Children’s Hospital! Above is the documentary that Frank and Berenice made of the shave itself. And if you still haven’t had enough about balding for dollars, there are more videos on YouTube here.

Time to start thinking about the Northern Voice conference in two days! Hope to see you there!

]]>
http://livingcode.org/2009/balding-for-dollars-update <![CDATA[Balding for Dollars Update]]> 2009-02-17T05:49:12Z 2009-02-17T05:49:12Z Dethe delza@livingcode.org http://livingcode.org/ balding_after.jpg

Well, my Balding for Dollars event was a success. I have raised $717.37 for Children’s Hospital (there is still time to help bring it to my goal of $1000 if you’d like to donate). Thanks to everyone who helped with donations, words of support, and especially to Frank for his photography, to Berenice for helping with the cutting, to my wife Daniela for her encouragement and help, and to our kids for their patience. I couldn’t have done it without all of you.

There has been one change of plans. I had wanted to donate the hair to a Canadian foundation making wigs for kids with cancer, but couldn’t find it. Daniela’s google-fu skills were better and tomorrow my hair will go off to the Eva and Co. hair donation program. And to clarify, my daughter didn’t shave her head, we’re sending a ponytail from when she went from a long hairstyle to a short one.

Thanks also, to everyone who offered me a toque, but I’m well covered.

]]>