Resolutions for The New Year – 2011

here’s an interesting list of 5 resolutions for programmers for 2011.  To summarize:

  • Get up to speed on C++0x
  • Write an app a cloud computing platform
  • Write an app for a mobile device
  • Write a browser Add-on
  • Write a Facebook-integrated app

Clojure Concurrency

A presentation by Rich Hickey to the Western Mass. Developers Group on Clojure and concurrency. Brief overview of Clojure, discussion of concurrency issues, locking, and immutabiity. In-depth look at Clojure’s refs, transactions and agents. Demonstration and review of code for a multithreaded ant colony simulation.

I am a half hour into this, I’m up to the part on using Explicit locks for implementing concurrency.  This is the old way of doing concurrency, as Clojure has built in support for concurrency.  About 2 more hours in this video.  Rich Hickey is the author of Clojure, this looks like a good talk.

There is another video at blip.tv by Rich Hickey, that looks interesting, called Hammock-driven Development.  Described as: Rich Hickey’s second, “philosophical” talk at the first Clojure Conj, in Durham, North Carolina on October 23rd, 2010.

Ryan Dahl: Node.js

I watched a video presentation of Node.js, by the author Ryan Dahl.  It explained the concept.  He used some simple  code examples.  Mainly he emphasized that blocking I/O should be avoided.  One thing that bugged me, he dropped down to the shell to illustrate, and while it was projected on a screen, the camera man, if there was one, did not pan to the screen.  The first few characters of each line was visible, which made it that more frusrating.

This video was 48 minutes and kind of thin as compared to Martin Odersky’s presentation on Scala, which was dense with material.

There are more Node.js videos at blip.tv, including:

Scala is the Java of the Future

I watched a video tutorial called Scala – A Scalable Language by Martin Odersky, the author of the language.  He described the design and syntax of Scala.  He blazed through the tutorial which had lots of example code, occasionaly dropping down into emacs, which was projected onto to the screen, to illustrate the REPL (Read-Evaluate-Print-Loop).

Scala handles concurrency, has closures, traits and pattern matching.  Traits are a sort of interface.

Functions are first class objects.

The REPL is called scala and their is a web framework called lift.

Martin talked about the tools available for Scala and mentioned with a straight face that he “uses emacs because he is old.”  There was no reaction from the audience to this statement, even though there were older programmers present.

Scala interacts well with Java.  In fact it seems like knowing Java would be a good idea.

Javascript Is the Future

I just finished watching the Loopage video by David Crockford.  He claims, at the end of the video, that Javascript is leading the way to Event Driven I/O.  He compares threads to non-blocking I/O:

  • Threads Have These Problems
    • Races and deadlocks are difficult to reason about.
    • They are the most difficult problems to identify and control
    • they are often unobservable during testing.
  • Non Blocking Evented I/O.Javascript is a functional language.
  • The creator of Javascript wanted to implement Scheme in the browser, but was dissuaded on the basis that the parenthetical nature of a lisp dialect would be off putting to most programmers.
  • Javascript has no Read statement.  Some think this is a flaw, but really is an advantage, because Reads are traditionally blocking.
  • Node.js is a server side implementation of Javascript based on Google’s V8 Javascript engine.
  • Node.js is a web server in an event loop.  The best part of the web browser is its event loop.
  • We are unfortunately stuck with the stateless HTTP.
  • Crockford thinks relational databases present a bottleneck for web applications, they don’t scale well, he prefers a No SQL.
  • Templating systems like PhP are not such a good idea any more.
  • Elko session server is a good idea.
  • Javascript needs tail recursion.
  • Javascript is leading the way to a new future of evented, non-blocking I/O.
  • Programmers get stuck in the past and are slow to pick up new ideas.

Installing node.js

after running ./configure get these:
Checking for header port.h               : not found
Checking for header sys/event.h          : not found
Checking for function kqueue             : not found
Checking for library execinfo            : not found
went ahead and built any way, the node google group says it is okay.

Lvm’ing A Drive

I decided to repartition a 320 Gig drive I had, that was already partitioned into 4 lvm partitions.  I needed something to use for backuppc, which I installed on my Ubuntu desktop. This time I created 1 big pv partition of the whole drive.  Then I created a vg partition and used the name of the drive to name it, because I always get confused what lvm partition is on what drive.

  1. cfdisk /dev/sdd – create one big primary partition of type lvm (8E)
  2. pvcreate /dev/sdd1
  3. vgcreate vg_ATA_MAXTOR_320G /dev/sdd1
  4. lvcreate –size 160G –name backuppc vg_ATA_MAXTOR_320G
  5. mkfs.ext4 /dev/vg_ATA_MAXTOR_320G/backuppc
backuppc filled up the 160 Gbytes pretty quick so I extended the partition, to use all the remaining size of the Physical Volume, which I did with:
> lvs
LV          VG                 Attr   LSize   Origin Snap%  Move Log Copy%  Convert
backuppc    vg_ATA_MAXTOR_320G -wi-ao 160.00g
> pvs
PV         VG                 Fmt  Attr PSize   PFree
/dev/sdc1  vg_ATA_MAXTOR_320G lvm2 a-   298.09g 138.09g
> /etc/init.d/backuppc stop
> umount /var/lib/backuppc
> lvextend /dev/vg_ATA_MAXTOR_320G/backuppc /dev/sdc1
> e2fsck -f /dev/mapper/vg_ATA_MAXTOR_320G-backuppc
> resize2fs /dev/mapper/vg_ATA_MAXTOR_320G-backuppc
> mount /var/lib/backuppc
> /etc/init.d/backuppc start

Node.js Camp Homework

How to Get Ready

1. Install Node on your laptop.

Instructions here.

Pick one of the install methods in this gist.

2. Explore creationix’s Game Code

npm install connect socket.io

Attempt to run it locally.

3. Get WebOS emulator running on your laptop

Instructions here.

4. Install node-redis and redis

# start the redis server
wget http://redis.googlecode.com/files/redis-2.0.4.tar.gz
tar -zxf redis-2.0.4.tar.gz
cd redis-2.0.4
make
./redis-server
# install the node library:
npm install redis hiredis

LESSOPEN

I just discovered how to use less on non-text files, thanks to Linux Journal.

In Ubuntu, at least, we have /usr/bin/lesspipe.  Then set the LESSOPEN environment variable like so:

> export LESSOPEN=”| /bin/lesspipe %s”

Which allows us to do this:

> less archlinux-2010.05-netinstall-i686.iso

CD-ROM is in ISO 9660 format
System id: LINUX
Volume id: ARCH_201005
Volume set id:
Publisher id: Arch Linux <http://www.archlinux.org>
Data preparer id: prepared by mkarchiso
Application id: Arch Linux Live/Rescue CD
Copyright File id:
Abstract File id:
Bibliographic File id:
Volume set size is: 1
Volume set sequence number is: 1
Logical block size is: 2048
Volume size is: 81799
El Torito VD version 1 found, boot catalog is in sector 321
NO Joliet present
Rock Ridge signatures version 1 found
Eltorito validation header:
Hid 1
Arch 0 (x86)
ID ‘Arch Linux <http://www.’
Key 55 AA
Eltorito defaultboot header:

CD-ROM is in ISO 9660 formatSystem id: LINUXVolume id: ARCH_201005Volume set id: Publisher id: Arch Linux <http://www.archlinux.org>Data preparer id: prepared by mkarchisoApplication id: Arch Linux Live/Rescue CDCopyright File id: Abstract File id: Bibliographic File id: Volume set size is: 1Volume set sequence number is: 1Logical block size is: 2048Volume size is: 81799El Torito VD version 1 found, boot catalog is in sector 321NO Joliet presentRock Ridge signatures version 1 foundEltorito validation header:    Hid 1    Arch 0 (x86)    ID ‘Arch Linux <http://www.’    Key 55 AA    Eltorito defaultboot header:

Pandigital Novel & Virtual Box

2 things  I finally got around to doing:

  • Flashed my Pandigital Novel White e-reader, which turned it into a 7″ Android tablet running 2.0
  • Install Virtual Box on my Ubuntu home computer.  First virtual machine I installed was Arch Linux and the 2nd was Linux Mint, Fluxbox version
backside disaster revert, yo