Part I: Is There a Such Thing as Real World Haskell?

Part II:   How not to Start Your Haskell Program >

Here’s a bit of sardonic code, that I’d like to propose to any Haskell advocate out there.

data Works = Works | Does_not
computerApp a ::  Maybe a -> Works
computerApp a
     | isJust a = Works
     | otherwise = Does_not

I have been playing around with functional programming in Haskell.    I have to say that it has more than certainly improved my ability to code in other languages, and probably has reduced the number of bugs I have to fix after the fact.    On the other hand, it has driven me absolutely batty.

To be fair, I need to say that I am not a computer engineer.    I have a BA in English.    My Masters are in Public Administration and Information Management.      I engaged in Haskell code simply as a curiosity and a challenge.    I love math, and became curious about Monads and Lambda calculus.    I am probably not smart enough to be a great Haskell programmer.   However, I do understand two things.    1)  Not-smart-enough people can and want to participate in application development   2)  Coders, while making apps that do what they expect them to do, do not always understand (or care) about the sustainability and/or scalability of their code.

Web Development is an important test case.      Just about anyone, with a reasonable amount of time and effort, can learn to develop a website in PHP, probably supported by some content management system as Drupal or ModX.    Somewhere, their development goes overboard, the system does an upgrade to support some security risk or vulnerability, and ‘pop’ –>  all that likely un-documented and messy code goes nowhere and wheels need to be reinvented.

That’s why learning Haskell is probably a good idea.    Without getting into the code itself, it insists that a function always causes the same result to happen with any given input(s).    Once developed, the documentation pretty much always exists in a minimal form (via Type declarations).    So many bad habits would disappear if only people were forced into developing this way.

The problem, unfortunately, is that Haskell coding is confusing.     There is no popular development framework to use it.     Once you try to apply the examples provided in text books to real world development, things go wonky.    I won’t go into the many reasons why, but I do have an observation based on what I’ve seen in responses from various gurus to newbies like me.

It’s this ->   Users think computers do things.    Computer engineers think computers solve problems.     In Haskell terms, any interaction between users and engineers results in a type error.    Somewhere along the line, an IO() monad needs to be created to turn what engineers like about Haskell into something that users will like about it.

I would like to propose a management framework, similar to extreme programming, to manage the development of functional code for regular people.   While Programming it in Haskell is not a bad start, it uses a problem solving model, rather than a ‘how do you make the software do x’ model.    It focuses on mathematical abstractions rather than simple actions.     For instance, I would like to see a book that uses the development of a rogue-like rpg game in Haskell as an example.    Instead of worrying about efficient computation, abstractions about ‘laziness’ and recursive factorial examples, the writer would have to focus on managing complex (a tuple of a lists of tuples) types, worrying about random numbers and IO issues that are inherent to Haskell.   In approaching such a game, should I worry about creating newtypes first, or work from what I want main to do and fill in the gaps?

But while I make this suggestion, I really have no idea of what kind of advice I can offer your typical new-to-haskell coder.     But I have some hypotheses:

  • work from the main :: IO() first and build a framework of functions to develop your outputs.
  • possibly create type variables for each of your functions, making it equal in Type to a typical output you would like to see.    Then work backwards from there to create a lazy output, then involve possible recursion and so on.
  • use generic types (eg. Int, String, Char etc.) with comments first, then develop types to make your code more clear.
  • unit tests should include the System.IO.Unsafe module (cheating should be allowed when you are testing your code – let the learning happen when you are developing real code)

I’ll add what I can as I continue to learn more about coding in Haskell.    The bottom line is that I think more people should be coding in a language like Haskell, but they are unlikely to work with it if they end up spending a bajillion hours just to get it to choose randomly from a list of monsters (for example).   Especially when they can learn how to do the same in three minutes using an imperative language like Python.

For the greater good and more sustainable code overall, what high-level tips or approaches can you offer any newbie coders of Haskell, so they can develop without becoming absolutely bogged down in failure with their Haskell programs?

UPDATE:   After writing this, I found a great powerpoint tutorial by Graham Hutton that uses Hangman as an example of interactive Haskell code development.

Initial Thoughts on the ASUS EEE PC for Public Use

As a big advocate of laptops in public libraries as a way to engage community, it was a no-brainer that I would experiment with some of the latest sub-notebook class of computers, such as the Everex Cloudbook or ASUS EEE PC.   The obvious advantages would include:

  • Reduced costs:   you can pretty much buy anywhere from 3-5 subnotebooks for the price of a regular laptop.
  • Open-source alternative OS:  the “lean and mean” sub-notebook hardware begs for a linux-based operating system, creating a good opportunity to introduce your customers to non-windows alternatives at the public terminals.
  • portability:   unlike regular-sized laptops, taking a lab of 5-10 subnotebooks on the road could be done with a simple backpack (and a back to go with it).   There is a great opportunity for community technology outreach with these machines.

Step one was to convince the powers that be that I need one of these things to play with.   At a mere $399 for the ASUS EEE PC (the one I’m going to speak about today), this was an easy ask.    When it came in, there was enthusiasm all around about this machine from all levels of staff.   It looks good; it can fit in a purse; it’s sexy; it surprises the heck out of people when you say it’s dirt cheap.

The Xandros install that comes with the EEE is intuitive to most I’ve shown it to.    My initial thoughts are that Xandros is fine for most public use.

That said, having asked a few staff about its potential, there are a good number of cons that need to be considered as well:

  • the keyboard, monitor and mouse pad are way too small for anyone with hands larger than a 12 year-olds.   Libraries would almost definitely require a separate mouse and keyboard for these machines.   People with vision issues would need a separate display as well.
  • Xandros is pretty limited for all but the most basic productive uses.   One of the reasons I would want to introduce linux to the public is to have interesting and/or unique software (like noteedit, Emacs, the kde line of software, sqlite etc.) available for use, not to mention Ubuntu’s for-free Assistive Technology options.
  • Installing and configuring another system (like Ubuntu) does require someone with some linux experience (although Justin Gill has done a great job with instructions for configuring wireless in Ubuntu 8 (Hardy Heron).    I’ve also had to reconfigure the wireless after a standard update using the synaptics package manager as well.    This could be quite a pain in the long run, unless you have techie front-line staff.
  • Although not confirmed, the size of the EEE PC does make it a likely victim of a theft.
  • It gets really hot.   It’s not a laptop really, because it’s intended for a table or desk, not your lap.   And using this on a couch, bed, carpet or anything that would block a square centimeter of the ventilation areas would really kill the lifetime of this laptop.
  • No really cool games are available despite the linux distribution you use.    Even if you install XP, it is not likely you will be able to get any large-scale software on it afterwards.    No Second Life.   No World of Warcraft.

So far, we’ve experimented with the EEE PC as a support for ESL classes.   The bottom line is that the computer is too small to be used for most learners in this group.   However, I do think there are some realistic uses for it:

  • It could be a lost-cost alternative for presentations in branches.
  • The keyboard is the right size for smaller children — so a program with educational games seems appropriate.
  • A number of them could be useful as a lab for state/provincial libraries to offer professional development to rural libraries.
  • A combination of a laptop, keyboard, mouse and screen projector could be really good for a one-to-one IT clinic for older adults (and it would still be cheaper than buying a laptop).
  • It could be useful as a lender program, provided that customers will understand that this is a linux-based, teeny-tiny laptop.
  • There is an opportunity here as a support piece for programs as well.   For instance, people who attend our ESL programs often bring their children.    It could be good to hand children a EEE PC while they are waiting for their mom or dad to finish their ESL sessions.
  • Add a wifi package to a EEE and you could provide bibliographic instruction to people who use homebound or books by mail services.
  • The EEE could be good to expand roving reference services, balancing the portability of a hand-held with the usability of a desk/laptop.

In the end, I do not think the subnotebook is going to solve all our problem regarding providing flexible and effective access to information and technology inside and outside the library.   The future is promising, but I need to see a little bit more before I am going to go bandwagon on this model of service.

Under the Hood of Web 2.0 : the top ten programming concepts for librarians to understand

So, you “get” the Library 2.0 thing, and you’ve been through the 23 things. You are up-to-date on web services like blogs wikis and the like. You even know a bit of html. But you feel there is something missing in your understanding of Web 2.0. You do not want to get into programming your own web service, but you are the sort who liked those field trips you took at the local print shop. You want to see what’s under the hood of a Web 2.0 service so you can understand what all this stuff is really about. You saw The Machine is Us/ing Us and it got you part of the way there, but it seemed a little too dumbed-down for you. You want to *really* look under the hood of web services.

That said, your mind doesn’t work like a programmer. You are not going to be coding in PHP any time soon. You don’t like manipulating variables and handling loops and all those other weird systems-oriented stuff that the big O’Reilly books tell you about. And when you are honest with yourself, you understand that you will probably always choose television over web development.

The question you have in your mind is “Will I understand what is happening with emerging trends better if I understand more about programming.” My answer to this question is “yes.” But you do not have to learn how to program to understand about programming. Most programming concepts are fairly benign — the devil is always in the details. The good news is that Google and Wikipedia are chock full of good information about most technology. The bad news is that the language techies use to describe what they do is shaded in three-letter-acronyms, technical jargon and obscure references to text-based adventure games. It’s as if they do not want you to know what they are talking about.

Well, I decided to come up with 10 programming concepts that could help you get a better understanding of what brings Web 2.0 about. That way, you don’t have to cover a lot of ground that may not matter to you. I wouldn’t exactly call this mandatory reading, but it is meaningful, trust me. On the other hand, you’ll have to accept some jargon at the same time — so this is not exactly beginner stuff. Either way, you’ll benefit from Googling at least one or two of these concepts, I guarantee it.

So here it is. 10 programming concepts that would benefit a librarian who spent five minutes reading about them.

  • Object-oriented Programming (OOP)

In a nutshell: Creating code that can be re-used in multiple programs.

Why it matters: OOP marked an important change in computing and is probably the main reason you are using a mouse instead of text-based commands. Back when I had my Commodore 64, I was taught to create programs in linear fashion. Do this. Do that. If this is the case, then do that — otherwise do something else. Programs had numbers to show the modus operandi (ahem — notice how, er MARC still uses numbers?).

OOP is different. Instead of “do this, do that,” I create an object. I say “here is a cat. It has whiskers, and fur and a tail. It does some funny things like meow and scratch and puke furballs.” Then I can put that cat into my old-fashioned programs. I can call my cat George. George has long whiskers, blue fur and a bushy tail. He meows when he sees food and scratches when you pull his tail. That’s neat. Except, the real trick is that other programmers can make their own cats too with their own names, shapes and behaviors.

But that’s not all either. Set up a form and you can make it so that your users can create cats too. Aha! Now you know why OOP connects to library 2.0. OOP has been around for a while, but it is the kind of coding practice that makes open source and user-driven products possible.

How can you learn more (besides Wikipedia)? : Any good programming book will have a chapter on OOP.

  • Client-side scripting (AJAX)

In a nutshell: Client-side scripting means Javascript. Javascript is code that makes things happen by giving instructions to a user’s (or “client’s”) browser (like Internet Explorer or Mozilla Firefox). The major advantage to javascript is that it doesn’t require page reloading.

Why it matters: AJAX (Asynchronous Javascript and XML) is the major driver behind alot of Web 2.0 services. The key to AJAX is that it loads up XML data from some server, then it uses that data while the user interacts with the page. Jazzed-up RSS feeds is one result of AJAX. Another common AJAX service is a “suggestion” service for searches. Meebo uses AJAX to provide online Internet Messaging via the web. Though often criticized for being too slow, AJAX can also be used for online gaming.

How can you learn more (besides Wikipedia)? : I like this article by PC Magazine.

  • Relational Database

In a nutshell: Have you ever used a spreadsheet and wished you could take the cells of a particular column and break it into further columns? A relational database makes that sort of thing possible — except it does it through a series of tables that are interconnected (related) which are later accessed through something called a query (a search).

Why it matters: I think most library school students are learning about relational databases in their MLIS classes, but it is important enough that it deserves mention. When David Weinberger speaks about everything being miscellaneous, he is really affirming the value of the relational database. Because the relational database uses relationships instead of a tree-style taxonomy, it reduces needless repetition of data and opens the door to unforseen connections between different sets of data. The many-to-many relationship, in particular, really makes the prospect of mashing up huge masses of data from projects like Wikipedia in “god” databases like Freebase a possibility (while relational databases have been around for a long time, they have become fast and big enough now to handle huge amounts of data quickly).

How can you learn more (besides Wikipedia)? Hopefully library school taught you about relational databases. If not, you might want to play with a GUI(graphical)-style database product like Access. (For geeks: Yes, I know MySQL pwns Access, but I’m talking about using it to learn what a relational database is).

  • Server-side scripting (PHP, Perl, Java, Ruby etc.)

In a nutshell: Server side scripts give instructions to the computer (the server) that hosts a webpage, instead of using a browser on the user’s desktop. Server side scripts are usually faster than client side ones, and most AJAX programming requires at least some server-side scripts.

Why it matters: It matters mostly for the same reasons that AJAX matters. Server side scripts make the major of the web happen. What has happened is that scripts like PHP are becoming more easy for the neophyte programmer to understand (PHP uses natural language alot) and are therefore creating an environment where alot more people are coding. Another thing that many people do not realize is that when you “view source” on a webpage, most frequently it is not a “page” of html that you are seeing, but code that is “outputted” by a server-side script like PHP.

How can you learn more (besides Wikipedia)? : Pick up a book on Java or PHP. Or go for the W3 Schools tutorials.

  • Http Protocol

In a nutshell: These are the rules for transferring information on the internet.

Why it matters: I’m not sure how much this does really matter. I guess I just think librarians should have a little more in-depth knowledge about how computers talk to each other.

How can you learn more (besides Wikipedia)? : The James Marshall Tutorial is a classic.

  • Open Source Software (OSS)

In a nutshell: Software that is released without protections that prevent users from viewing the “source code” of the product, and with licenses that encourage users (within certain boundaries) to distribute the product freely and change the product to their own needs.

Why it matters: If websites were all hosting using expensive proprietary software, you would never see the kind of boom in internet services that you see now. All of the client-side products I have mentioned are open source. But it’s not just that the products are free — it’s that communities have built themselves around the development of these open source products. And many open source products have built themselves into Web 2.0 services. Take WordPress, for instance. See, when you have huge communities working together, they need advanced services that promote collaboration. Look at the documentation for any open source product (how about Drupal?) and you are almost certain to find a wiki hanging around somewhere.

How can you learn more (besides Wikipedia)? : The Open Source Initiative is a good resource.

  • The Document Object Model (DOM)

In a nutshell: Basically the DOM is the rules for retrieving data from XML or html documents. AJAX uses the html object model to make its magic happen, and other scripts use the DOM to extract information from RSS feeds.

Why it matters: XML is kind of like the universal solvent for data. If two services do not play well together, you always have XML to fall back on. Even so, XML is about taxonomies which is at the core of the library profession. We should be aware of how our taxonomies are turned into web interfaces, if only in a superficial way.

How can you learn more (besides Wikipedia)? : I think the W3 schools covers the DOM fairly well. There is a separate tutorial on the html DOM (same principles, just a tad different approach).

  • Encryption and Digital Rights Management (DRM)

In a nutshell: Encryption is nothing new. You have information; you have a code to represent that information; you have a key or solution that will turn one into the other. Maybe you need to look at encryption tools like MD5, or SSL but in the end it’s all still like the Little Orphan Annie Ovaltine-Advertising decoder ring from A Christmas Story. DRM uses encryption to prevent users from breaking copyright on their products (software, DVDs, CDs, e-books etc.).
Why it matters: Copyright and DRM is the real battlefield of the Web 2.0 movement. Many Web 2.0 folks are outspoken about such products, saying that they put needless restrictions on paying customers. Others steadfastly argue that DRM is necessary to keep people from stealing their intellectual property. You oughta know about this stuff, because where the chips fall will say alot about the future of the Web and the business of business in general.

How can you learn more (besides Wikipedia)? : Cory Doctorow is a good source. Though he obviously sits to one side of the issue, Cory always points out the cases where the bad guys (to him) are making their arguments.

  • Platforms

In a nutshell: All computer software requires a platform to make the things you do on the key board and mouse make sense to a computer. Windows is a platform. So is Linux.

Why it matters: In the end, the platform you use will dictate in the end how the software will perform. That said, there are three more reasons why I added this to the list. 1) One of the tenets of Web 2.0 is that of the “Web as platform.” Basically, this means that what can be done on Windows can be done on the web. If you look at Google Documents, you will get an idea of what this means. 2) I always think its good to remind people that Windows is just one of many possible platforms that people can use to make software work. 3) Platforms are changing. The battle of platforms continues onto handheld devices, and both the iPhone and the upcoming “Surface Computer” appear to be offering widely different platforms for the future.

How you can learn more (besides Wikipedia)? : Try linux out. Or a Mac.

  • Stylesheets (CSS & XSLT)

In a nutshell: Let’s say someone offers to do dishes for you, but after every plate he cleans, he asks you where it goes. Annoying, right? You want all plates to go in the same spot, right? A cascading stylesheet (CSS) is a way for a programmer to say “ok. All headers are going to be green, 12 point Times New Roman font.” An XSLT stylesheet is a way for a programmer to say “ok. all data with “this” tag is going to appear at the top of the page. Either way, you are looking at the rules for style being separated from the rules for content.

Why it matters: Stylesheets are behind any service that lets you change the “skin” of the webpage you view. It is also behind all the fancy templates that WordPress and other services offer. If you are a Horizon user, you may want to know that the current Horizon Information Portal uses XSLT stylesheets to display the available data.

How you can learn more (besides Wikipedia)? : Back to the W3 Schools.

That’s it. Just a challenge for you to brush up on your technology if you so desire. I don’t think it’s mandatory to learn this stuff, but taking a bit of time to familiarize yourself with these concepts does help make some extra sense about where the web, and a whole whack of other IT services are going in the future.

UPDATE: Nicolas Morin has a nice response to the list. He suggests adding Unix, SQL, Apache (and web servers) and the notion of API to the list. He is also curious about the order I put them in. Responses below:

The order: no real priorities there. The list was intended as a grab bag of things to look through.

I’m inclined to think Unix and Apache are the sort of things you can leave to systems people. If you are installing products on your lonesome, maybe you want to learn more about these.

SQL falls under “relational database” — it’d be nice if librarians knew more SQL, but I think it’s too much like programming. Suffice it to say that you need to give instructions to a computer to tell it how to search, store & organize your data. This is called a “query.” SQL is the language to do that. For most people I know, SQL is intimidating. I don’t want the list to be intimidating — learn what a relational database is first, then if you get enthusiastic, go for SQL.

API goes along with “Object oriented programming” although, I agree it’s a pretty big miss there. Using my analogy above, once you’ve created your cats, you can give people the list of things the cat will do. That list is the API. Once you share an API, people can do all kinds of wonderful things with your cat. Maybe even mash it up with a dog. Then you can see the fur fly! 🙂

He suggests replacing DOM with XML. Probably a good suggestion, although I find most tutorials on XML talk about syntax more than they explain why you would use it. DOM explains a bit more about the structure of an XML document and how you might extract data from it. It’s pretty much 6 of one, 1/2 a dozen of the other.

He also suggests taking out encryption and platforms. For one, Unix is a platform, so that’s why I put it in. I wanted to avoid the typical geeky acronyms and products names out as much as possible. Also, as I said before, I think platforms are going to change in the near future. This is a heads up.

Encryption is there mostly because DRM is such a big issue these days. Also, if we are helping clients evaluate good websites, we ought to know a little more about how secure sites work. There are other, more mind-blowing things that are interesting about encryption as well. Some of it is covered in a couple of great books I’m reading: The Man Who Knew Too Much (biography of Alan Turing, the man who invented the computer) and Decoding the Universe (about information theory).

Superpatrons at the cusp of a Neo-Progressive Movement?

Edward Vielmetti, the ever illustrious Super-patron left a comment on my post called “We asked for 2.0 Libraries and we got 2.0 Librarians.” To spare you the use of your back button, I’ll put it here (it’s not long):

“library patron 2.0″. discuss

For a librarian to respond to this call is a bit like playing with a loaded gun. A librarian calling for a pseudo-reform in his/her patrons is kind of like reverting to librarian 1.0. I don’t think this is what Ed intended by the statement, however, so here is the best response I can offer for a patron to “take it to the next level” so to speak:

  1. Learn what you love to learn (until it hurts).
  2. Read what you love to read (until it hurts).
  3. Develop a sense of community, and foster it in others (until it hurts).
  4. Insist that your library support #s 1-3 (until it hurts [us]).
  5. Shame your library with cool inventions when we fail at #4.
  6. Share (via technology if you can) what you know if you think it will make another patron’s life better.

That’s my first crack at a patron 2.0, and now it is out of my brain and on to this blog, I realize that only #5 is that different from the kinds of reforms we have asked from our patrons for, like, ever.

Are we taking advantage of our Superpatrons?

Clearly, there is an opportunity for libraries to engage the broader community of online patrons to work actively toward improving library service. Why not an online advisory board? Whether requested via an Expression of Interest or hand-picked from some influential open-source community (Linus Torvalds as library tech advisor? That might light a fire under some tech innovators at your library), the technology is out there to engage superpatrons in ways that get them thinking proactively about their libraries’ web presence. Just a thought.

Neo-progressivism is Coming! What is the Response?

Though not a term I have coined, I believe that a sort of neo-progressive movement is upon us, and that the interest of people in libraries is part of this movement. By neo-progressive, I mean that certain circles of people are echoing the principles that founded such things as the Olympics, the Salvation Army, libraries and prohibition (ok. not everything about a movement can be good). That is, make yourself better physically, intellectually and morally so you can become a more proficient member of your community.

But there is an added piece to this, for the future I think: even if you are not the strongest, smartest, or goody-two-shoes in your community, do simple, proactive things that will improve the world’s situation. Examples:

  • environmentalists asking people to take small actions (buy fluorescent bulbs, quit idling at drive-thrus etc.) to help reduce greenhouse gas emissions.
  • Bill Gates et. al. spending billions of dollars to support international efforts in a kind of philantropy termed “social entrepreneurship.”
  • Increased community outrage over violence by teenagers.
  • Blogs, wikis, Facebook groups, emails etc. advocating just about everything.

Granted, individuals can look at many of these actions with a great deal of skepticism — but the key component is a world on the look out for intelligent and effective “should dos” to help provide meaning in their lives.

Where Libraries and “Should Dos” Connect

If you listened to me when I blogged the Kings of Philantropy podcast from CBC’s Ideas podcast (if you didn’t listen to me then, it’s too late — CBC only keeps about a month’s worth of shows live at any one time), you may have heard the criticism of social entrepreneurs. For instance, if you puts millions of dollars into (say) a polio vaccine in Ghana expecting to save millions of lives, you might want to think again. Why? Well, you have to think about the real problem.

Real Problems and Measureable Solutions

What’s the real problem, you say? Well, so you prevent people from getting polio. Great — but that doesn’t mean you’ve saved a life. Why? Well, when a child is undernourished, Polio may only be the first of a large number of nasty diseases just waiting to attack the poor soul. While a child might not die of Polio, he or she may die of malaria, or cholera or a minor infection or any large number of serious diseases. See, the “problem” is not polio per se, but a poverty-stricken population that is susceptible to polio.

Meanwhile, your actions to solve the polio “problem” may convince government, NGOs and other aid agencies to divert resources away from other activities to jump on the “cure polio” bandwagon. In the end, you may make the community worse off with your great intentions.

Knowledge — global and local — the Library’s Competitive Advantage

If libraries were able to help communities understand their key problems in a local environment, while bringing them access to global technologies, we may be able to offer something, not only to the developing world, but everwhere.

The key difference is that librarians can no longer assume that the world of knowledge is sitting behind them, among the stacks. In the neo-progressive world, knowledge stands opposite the desk — with the patron. Our role is two-fold. 1) keep the “desk” from getting in the way of the patron’s access to information and 2) create an environment where the patron can see the answers to his or her problems from within — within the community and within him/her self. If we can do this, then we can solve real problems. . .

. . . and Library Patron 2.0 will take its place as the real Library 2.0.

Converted? Converted!

It’s official.   I now have Ubuntu installed and will be playing around with it in the next  while for a variety of things.   Details about the differences between linux and Windows will be mentioned somewhere between now and September or so.


Like everyone else is saying, Ubuntu is easy to install.    The partitioning part took a while and it would have been nice to have a “here’s an approximate amount of time for the changes” piece, but otherwise it was pretty painless.


That’s that.   I am back to being a non-blogger.   You’ll get an occassional impromptu post here and there, that’s all.  🙂