Time Mag, Julian Assange, video

Perm url with updates: http://xahlee.org/Periodic_dosage_dir/US_diplomatic_cables_leak.html

time mag cover 2010-12-13 Julian Assange

Time Mag cover 2010-12-13 Julian Assange

  • 〈TIME's Julian Assange Interview: Full Transcript/Audio〉 (2010-12-01) Source www.time.com

A very interesting video: 〈WikiLeaks's Julian Assange Reviews TIME's Top 10 Leaks〉 Source www.time.com.

See also: Julian Assange Raped Women?


what emacs/lisp tutorial you like to see?

Last poll results:

There's no emacs cookbook or elisp cookbook on the market. If i write a emacs book (published in printed form), are you likely to buy it?

  • Yes, if it's good. 41 (70%)
  • No, am not likely to spend money on emacs/elisp book. 14 (24%)
  • N/A. I don't use emacs... 3 (5%)
  • Total votes: 58

This week's poll:

For emacs tutorial, what would you like to see more?

  • 1. More howto about GNU Emacs's bundled features and modes.
  • 2. More tutorial about installing/use 3rd party modes and packages.
  • 3. More tutorial on elisp programing for text manipulation.
  • 4. More tutorial on writing modes (working with fonts, buffers, keys, menu, frames/windows, syntax highlight, shell IO...).

In the past i pretty much just wrote what i personally learned or need to do. I'm not sure so far which particular area i'm missing that people wish to see. In the above choices, basically the latter are more difficult, especially number 4.

  • «1. More howto about GNU Emacs's bundled features and modes.» This is pretty easy, for anyone who use emacs for years.
  • «2. More tutorial about installing/use 3rd party modes and packages.» This is not so difficult, but the question is which package people like to see? There are so many, and each 3rd party package's quality varies a lot. Some doesn't have any documentation.
  • «3. More tutorial on elisp programing for text manipulation.» This i've written a lot already, but mostly for processing html. Any thing you need?
  • «4. More tutorial on writing modes (working with fonts, buffers, keys, menu, frames/windows, syntax highlight, shell IO...).» This is not easy. I haven't wrote much about it. Of what i've written, such as basics of writing a major mode for language, i don't have a complete understanding, such as all the ways to use font-lock for syntax highlight or using overlay.


For emacs tutorial, what would you like to see more?

  • 6 (24%) More howto about GNU Emacs's bundled features and modes.
  • 3 (12%) More tutorial about installing/use 3rd party modes and packages.
  • 11 (44%) More tutorial on elisp programing for text manipulation.
  • 18 (72%) More tutorial on writing modes (working with fonts, buffers, keys, menu, frames/windows, syntax highlight, shell IO...).

Total Votes: 25

Hilarry Clinton: goto jail!

According one of the US Diplomatic Cables Leak, US Secretary of State Hillary Clinton has ordered espionage on UN officials.

Here's a Gardian article: 〈US diplomats spied on UN leadership〉 (2010-11-28) By Robert Booth and Julian Borger, guardian.co.uk. At: Source www.guardian.co.uk

A classified directive which appears to blur the line between diplomacy and spying was issued to US diplomats under Hillary Clinton's name in July 2009, demanding forensic technical details about the communications systems used by top UN officials, including passwords and personal encryption keys used in private and commercial networks for official communications.

It called for detailed biometric information "on key UN officials, to include undersecretaries, heads of specialised agencies and their chief advisers, top SYG [secretary general] aides, heads of peace operations and political field missions, including force commanders" as well as intelligence on Ban's "management and decision-making style and his influence on the secretariat". A parallel intelligence directive sent to diplomats in the Democratic Republic of the Congo, Uganda, Rwanda and Burundi said biometric data included DNA, fingerprints and iris scans.

Washington also wanted credit card numbers, email addresses, phone, fax and pager numbers and even frequent-flyer account numbers for UN figures and "biographic and biometric information on UN Security Council permanent representatives".

So, the United States, with its justice obsession and all, is now spying on not Iran, China, or some rogue enemy states, but United Nations, a org for world peace that US touts to have helped build. How ironic. And the US want things including passwords, credit card numbers, DNA, iris scan. This is getting serious.

I think UN or something should prosecute Hillary Clinton to the fullest extend of international law.

Emacs Lisp: writing a url-linkify

Perm url with updates: http://xahlee.org/emacs/elisp_html-linkify.html

Emacs Lisp: writing a url-linkify

Xah Lee, 2010-12-03

This page is a little lisp tutorial. A example on writing a function that transform the text under cursor on the fly. If you are not familiar with elisp, see: Emacs Lisp Basics.


I need to write a elisp command, so that, when pressing a button, the url under cursor, such as:


becomes this:

<a class="sorc" href="http://some.example.com/xyz.html"
title="accessed:2010-12-03">Source some.example.com</a>

And pressing another button, the link become this:

<a class="sorcdd" href="#" 
title="accessed:2010-12-03; defunct:2010-12-03; http://some.example.com/xyz.html">Source some.example.com</a>


In writing blogs, often you need to cite links. The links may be other blogs, news sites, or some random site. Many such url are ephemeral. They exst today, but may be a dead link few months later. Typically, if the url doesn't have a domain, but is hosted blog service site, it is more likely to go bad sooner.

For me, i write many blogs on xahlee.org, so have hundreds of links. When you update your pages years later, you find dead links like 〔http://someRandomBlog.org/importantToday.html〕, and may not remember what that link is about. No author, no title, no idea when that link was active or become dead. Sometimes, link is still good but the domain name owner of the link has changed, so the linked page may become porn site or been bought by domain squatters.

One partial solution is to add access date together with the link.

<p>blab blab news!
See <a href="http://some.example.com/xyz.html">here</a>!
(Accessed on 2010-12-03)</p>

With a access date, at least you know when the link was good. If the link went bad, you or your readers can at least try to see the link thru web archive site such as Internet Archive.

This way, at least you know when the link was good. However, this requires manual insertion of the date. It would be better, if the access date is somehow embedded in the link in some uniform format. HTML4 or even html5 does not have a way to embed access date. So, i decided to use the “title” attribute, like this:

<a class="sorc" href="..." title="accessed:2010-12-03">...</a>

This is not a ideal solution, because the “title” attribute is supposed to be title, not a date stamp. But in practice, i decided it's ok for me to adopt this solution.

I prefer this embedded access date approach because otherwise adding the access date besides the link text is distracting. If you have a paragraph with 3 or more links, each one says “accessed on ...”, that's very annoying.

When later on if i found a link is dead, i can press a button, and emacs will change the link to this format:

<a class="sorcdd" href="#" title="accessed:2010-12-03; defunct:2010-12-03; http://some.example.com/xyz.html">Source some.example.com</a>

Notice that the class value has changed from “sorc” to “sorcdd”. With proper css, the link will be shown as crossed out. Like this: Source some.example.com.

A uniform format to embed accessed date is good. Because, if later on HTML6 or other HTML Microformat has a way to add access date to links, i can easily write a script that change all my thousands of external links to the new format.


Here's the code:

(defun source-linkify ()
  "Make url at cursor point into a html link.
If there's a text selection, use the text selection as input.

Example: http://example.com/xyz.htm
<a class=\"sorc\" href=\"http://example.com/xyz.htm\" title=\"accessed:2008-12-25\">Source example.com</a>"
  (let (url resultLinkStr bds p1 p2 domainName)

    ;; get the boundary of url or text selection
    (if (region-active-p)
        (setq bds (list (region-beginning) (region-end))  )
      (setq bds (bounds-of-thing-at-point 'url))

    ;; set url
    (setq p1 (car bds))
    (setq p2 (cdr bds))
    (setq url (buffer-substring-no-properties p1 p2))

    ;; get the domainName
    (string-match "://\\([^\/]+?\\)/" url)
    (setq domainName  (match-string 1 url))

    (setq url (replace-regexp-in-string "&" "&amp;" url))
    (setq resultLinkStr
          (concat "<a class=\"sorc\" href=\"" url "\""
                  " title=\"accessed:" (format-time-string "%Y-%m-%d")
                  "Source " domainName

    ;; delete url and insert the link
    (progn (delete-region p1 p2))
    (insert resultLinkStr)))

The code is easy to understand. If you find it difficult, try reading this page Emacs Lisp: Writing a Wrap-URL Function, which has more explanation.

You can assign a hotkey for this command.

The following is the code to turn a link into a dead link format.

(defun defunct ()
  "Make the html link under cursor to a defunct form.
If cursor is on this line
<a class=\"sorc\" href=\"http://example.com/\" title=\"accessed:2008-12-26\">...</a>
 (and inside the opening tag.)

It becomes:
<a class=\"sorcdd\" href=\"#/\" title=\"accessed:2008-12-26; defunct:2008-12-26; http://example.com\">...</a>"
  (let (p1 p2 linkStr url)

      ;; get the boundary of opening tag
      (search-backward "<a " ) (setq p1 (point) )
      (search-forward "\">") (setq p2 (point) )

      ;; get linkStr
      (setq linkStr (buffer-substring-no-properties p1 p2))

      ;; change the “class” attribute value
      (setq linkStr (replace-regexp-in-string "class=\"sorc\"" "class=\"sorcdd\"" linkStr t t)) 

      ;; (setq linkStr (replace-regexp-in-string "href=\"\\([^\"]+\\)\" +title=\"accessed:\\([^;]+\\)\""
      ;; (concat  "href=\"#\" title=\"accessed:\1; defunct:" (format-time-string "%Y-%m-%d") ";\2\"" )
      ;;  linkStr t t))

      ;; insert defunct date and url etc
        (insert linkStr)
        (goto-char 1)
        (search-forward-regexp  "href=\"\\([^\"]+\\)\"")
        (setq url (match-string 1))
        (replace-match "href=\"#\"")
        (search-forward "\"")
        (search-forward "\"")
        (backward-char 1)
        (insert "; defunct:" (format-time-string "%Y-%m-%d") "; " url)
        (setq linkStr (buffer-string))))

    (delete-region p1 p2)
    (insert linkStr)))

Here's the css for the deadlink:

a.sorcdd:link:active, a.sorcdd:link:hover, a.sorcdd:visited:hover, a.sorcdd:visited, a.sorcdd:link
{color:black; cursor:text; text-decoration:line-through}


Emacs Lisp: Replace String Based On File Name

Perm url with updates: http://xahlee.org/emacs/nav-bar.html

Emacs Lisp: Replace String Based On File Name

Xah Lee, 2006-11-29

This page is emacs lisp lesson on a real-world task. It show how emacs lisp is used in creating HTML navigational bar for a online book. Specifically, we need to insert proper text to each file for a set of files. You should be familiar with Elisp Language Basics.

The Problem


I want to insert the “Next Chapter”, “Previous Chapter” links to a series of HTML files that are chapters of a book.

This lesson essentially teaches you how to do a regex pattern replace by a function that return text based on the current file's name.


I have a lot of books in HTML form. Usually, the file names have this pattern: “chap1.html”, “chap2.html”, “chap3.html”... etc.

Each file is a chapter of a book. And in each file, I need to place a navigation bar, so that there's a Next Chapter and Previous Chapter links at the bottom of each page.

Normally, this can be done by writing a short Perl or Python script. The script will open the file, parse the file name so that it knows which chapter this file is. If the current file is “chapter3.html”, then the script will generate a string like this:

<div class="navbar">
<a href="chapter2.html">PREVIOUS</a>|
<a href="index.html">TOP</a>|
<a href="chapter4.html">NEXT</a>

For a person familiar with scripting languages, the job can be done in about 20 minutes. Basically, your script will traverse a directory and determine which files to process. For each file, your script will parse the file name and generate the navigation bar string appropriate for the file. Then, your script will open the file, insert the nav bar at the appropriate place, then close the file. Your script will need do a backup if you want it to be robust. With that, you'll also have to make sure that the file's owner, group, permissions etc meta data are kept intact.

In the end, some simple script can end up taking twice or trice the time you expected.

However, if you know elisp, you only need to write half of the code, since the file selection, file opening and reading, text decoding, backing up, saving and encoding, etc are all part of the emacs environment. All you really need to write is a elisp function that takes in a file name and returns the navigation bar string. This significantly saves your time. As a added benefit, you get to do this in a interactive, visual process. So, errors are much reduced, and you don't have to worry about your code making a mistake erasing parts of the file or missing some files.


First, mark the files you want to process in dired. Then, use “dired-do-query-replace-regexp” to do a find and replace operation on a particular string. For example, replace 「<body>」 with 「<body> someNavbarString」. (For a tutorial on using “dired-do-query-replace-regexp”, see: Interactively Find and Replace String Patterns on Multiple Files. )

The trick lies in your replacement string. You want to use a elisp function that returns the appropriate nav bar for the chapter. (so that the Next and Previous links are correct, according to the chapter number of the current file)

In emacs 22, there's a new feature that allows you to put a elisp function as your replacement string. This is done by giving the replacement string this form 「 \,(functionName)」, where functionName is the name of your function. So, if the function that returns the nav bar string is called “ff”, then in your replacement string you can say 「\,(ff)」

Here is the ff function:

(defun ff ()
  "Returns a navigation bar string with Prev and Next links based on the current file name."
(let (fname navbarStr chapterNum )
  (setq fname (file-name-nondirectory (buffer-file-name)) )
  (setq chapterNum (string-to-number (substring (file-name-sans-extension fname) 4)))
  (setq navbarStr 
        (concat "<div class=\"nav\">★ <a href=\"" "chap"
                (number-to-string (- chapterNum 1))
                ".html" "\">◀</a> <a href=\"index.html\">▲</a> <a href=\"" "chap"
                (number-to-string (+ chapterNum 1))
                ".html" "\">▶</a> Flatland</div>"))
  ) )

In the above code, the buffer-file-name returns the full path of the file of the current buffer. The file-name-nondirectory truncates the path to just the file name. The line

(setq chapter-num (string-to-number (substring (file-name-sans-extension fname) 4)))

extract the chapter number from the file name.

For a example of a online book with Next/Previous navigation bar, see: Flatland.

Emacs is beautiful!

Second Example


Today, i need to do similar again. I have a dir with names like this:


These are pages for the novel Journey To The West (Monkey King). The first part of the file name is the chapter number. Each chapter has 2 html pages, indicated in the second part of the file name.

In each page, there's a nav bar code like this:

<div class="nav">
<a href="monkey_king.html" title="up">▲</a>
<a href="x002-2.html" title="next">▶</a>

It allows readers to go to the Table Of Contents page, or go to the next page. But it is missing a nav bar button to go to the previous page. I'd like to fix it, so it should be like this:

<div class="nav">
<a href="x001-2.html" title="previous">◀</a>
<a href="monkey_king.html" title="up">▲</a>
<a href="x002-2.html" title="next">▶</a>

So, the task is to add this:

<a href="x001-2.html" title="previous">◀</a>

to every page, and the link depends on the current file name.


Here's what i do to solve it, in the quickest way i know possible with emacs.

First, use find and replace on all files. Replace all occurance of

<div class="nav">
<a href="monkey_king.html" title="up">▲</a>


<div class="nav">
<a href="htnshtns" title="previous">◀</a>
<a href="monkey_king.html" title="up">▲</a>

The 「htnshtns」 is just a random string. We use a fixed random string so that we can do multi-file find replace one more time, where the find string will be this fixed string, and the replace string will be generated by a lisp function.

(If you don't know how to do find replace on multiple files, see: Interactively Find and Replace String Patterns on Multiple Files.)

Now, here's the lisp code quickly written:
(defun ff ()
  (let (fname mylist chapterNum pageNum chapterNumNew pageNumNew )

    (setq fname (file-name-nondirectory (buffer-file-name)) )

    (setq mylist (split-string (substring (file-name-sans-extension fname) 1) "-" ) )
    (setq chapterNum (string-to-number (nth 0 mylist) ))
    (setq pageNum (string-to-number (nth 1 mylist) ))

    (if (= pageNum 1) 
          (setq chapterNumNew (- chapterNum 1))
          (setq pageNumNew 2)
        (setq chapterNumNew chapterNum)
        (setq pageNumNew 1)

    (concat "x" (format "%03d" chapterNumNew) "-" (format "%d" pageNumNew) ) ) )

So, with this code, i just call find replace, with find string 「htnshtns」, and replace value of 「\,(ff)」

Emacs is fantastic!

Proliferation of Computing Languages

Perm url with updates: http://xahlee.org/UnixResource_dir/writ/new_langs.html

Proliferation of Computing Languages

Xah Lee, 2008-07, 2008-11, 2010-01-26

There is a proliferation of computer languages today like never before. In this page, i list some of them.

In the following, i try to list some of the langs that are created after 2000, or become very active after 2000.

Lisp family or similar:

  • Mathematica. Computer algebra system background. Used mostly for math and research in science community.
  • newLISP. Lisp scripting style. Verdant community of new generation of hobbyist programers.
  • Arc. Paul Graham squeezing juice out of his celebrity status.
  • Qi. Common Lisp added with modern functional lang features. Primarily academic and language research.
  • Clojure. A new lisp dialect on Java platform. Poised as the next industrial lisp, but faces serious competition with other JVM based langs such as Scalar, Groovy.
  • Scheme, notably PLT Scheme. Used mostly for teaching.
  • (Dead. Dylan. Apple's re-invention of lisp for industrial programers, active in the 1990s.)

ML Family:

  • OCaml. Almost all current theorem proofing systems are based on.
  • Alice. Concurrent, ML derivative. Saarland University, Germany.
  • F#. Microsoft's offer, based on OCaml.

ML/OCaml derived Proof systems in industrial use:

Modern Functional langs:

  • Erlang. Functional, concurrent. Mostly used in a telecomunication industry for corcurrency and continuous up-time features.
  • Haskell Oldish, classic functional lang. Mostly used in academia for teaching and lang research.
  • Mercury. Logic, functional.
  • Q. Functional lang, based on term rewriting. Replaced by Pure.
  • Oz. Concurrent. Multiparadigm. Mostly used in teaching.

Perl Family or derivative:

  • PHP. Perl derivative for server side web apps. One of the top 5 most popular langs.
  • Ruby. Perl with rectified syntax and semantics. Somewhat used in industry. User numbers probably less than 5% of Perl or Python.
  • Perl6. Next generation of perl. In alpha stage.
  • Sleep. A scripting lang, perl syntax. On Java platform. sleep.dashnine.org/

On Java Virtual Machine:

  • Scala. A FP+OOP lang on Java platform as a Java alternative.
  • Groovy. Scritping lang on Java platform.

C derivatives:

  • ObjectiveC. Strict superset of C. Used as the primary language by Apple for OS X app dev.
  • C#. Microsoft's answer to Java. Quickly becoming top 10 lang with Microsoft's “.NET” architecture.
  • D. Clean up of C++.
  • Go. Google's new lang as improvement of C.

2D graphics related.

  • Scratch. Derived from SmallTalk + Logo. Primarily for teaching children programing.
  • ActionScript. Based on Javascript but for interactive 2D graphics. Quickly becomes top 10 lang due to popularity of Adobe Flash.
  • Processing. 2D graphics on Java platform. Primarily used for art and teaching.


  • JavaScript. Mostly for web browser scripting. One of the top 10 most popular lang. Quickly becoming the standard lang for general purpose scripting. (used by Adobe Flash, Dashboard Widgets, scripting Adobe PDF files, scripting Microsoft Windows, scripting Java)
  • PowerShell. A modern shell. A scripting lang desgined also for interactive use. Syntax similar to Perl and unix shell tools, but based “.Net”.
  • Tcl. Scripting, especially for GUI.
  • Lua. Scripting, popular as a scripting lang in games.
  • Linden Scripting Language. Used in virtual world Second Life.

Some Random Thoughts

Following are some random comments on comp langs.

Listing Criterion and Popularity

In the above, i tried to not list implementations. (e.g. huge number of Scheme implemented in JVM with fluffs here and there; also e.g. JPython, JRuby, and quite a lot more.) Also, i tried to avoid minor derivatives or variations. Also, i tried to avoid langs that's one-man's fancy with little followings.

In the above, i tried to list only “new” langs that are born or seen with high activity or awareness after 2000. But without this criterion, there are quite a few staples that still have significant user base. e.g. APL, Fortran, Cobol, Forth, Logo (many variants), Pascal (Ada, Modula, Delphi). And others that are today top 10 most popular langs: C++, Visual Basic.

The user base of the langs differ by some magnitude. Some, such as for example PHP, C#, are within the top 10 most popular lang with active users. Some others, are niche but still with sizable user base, such as LSL, Erlang, Mathematica. Others are niche but robust and industrial (counting academia), such as Coq (a proof system), Processing, PLT Scheme, AutoLISP. Few are mostly academic followed with handful of researchers or experimenters, Qi, Arc, Mercury, Q, Concurrent Clean are probably examples.

For those of you developers of Java, Perl, Python for example, it would be fruitful to spend a hour or 2 to look at the Wikipedia articles about these, or their home pages. Wikipedia has several pages that is a listing of comp langs, of which you can read about perhaps over 2 hundreds of langs.

Why The List

I was prompted to have a scan at these new lang because recently i wrote a article titled Fundamental Problems of Lisp, which mentioned my impression of a proliferation of languages (and all sorts of computing tools and applications). Quote:

10 years ago, in the dot com days (~1998), where Java, Javascript, Perl are screaming the rounds. It was my opinion, that lisp will inevitably become popular in the future, simply due to its inherent superior design, simplicity, flexibility, power, whatever its existing problems may be. Now i don't think that'll ever happen as is. Because, due to the tremendous technological advances, in particular in communication (i.e. the internet and its consequences, e.g. Wikipedia, youtube, youporn, social networks sites, blogs, Instant chat, etc) computer languages are proliferating like never before. (e.g. erlang, OCaml, Haskell, PHP, Ruby, c#, f#, perl6, arc, newLISP, Scala, Groovy, Goo, Nice, E, Q, Qz, Mercury, Scratch, Flash, Processing, ..., helped by the abundance of tools, libraries, parsers, existence of infrastructures) New langs, basically will have all the advantages of lisps or lisp's fundamental concepts or principles. I see that, perhaps in the next decade, as communication technologies further hurl us forward, the proliferation of langs will reduce to a trend of consolidation (e.g. fueled by virtual machines such as Microsoft's .NET.).

Creating A Lang Is Easy

In general, creating a lang is relatively easy to do in comparison to equivalent-sized programing tasks in the industry (such as, for example, writing robust signal processing lib, a web server (e.g. video web server), a web app framework, a game engine ...etc.). Computing tasks typically have a goal, where all sorts of complexities and nit-gritty detail arise in the coding process. Creating a lang often is simply based on a individual's creativity that doesn't have much fixed constraints, much as in painting or sculpting. Many langs that have become popular, in fact arose this way. Popularly known examples includes Perl, Python, Ruby, Perl6, Arc. Creating a lang requires the skill of writing a compiler though, which isn't trivial, but today with mega proliferation of tools, even the need for compiler writing skill is reduced. (e.g. Arc, various langs on JVM. (10 years ago, writing a parser is mostly not required due to existing tools such as lex/yacc))

Some lang are created to solve a immediate problem or need. Mathematica, Adobe Flash's ActionScript, Emacs Lisp, LSL would be good examples. Some are created as computer science research byproducts, usually using or resulting a new computing model. Lisp, Prolog, SmallTalk, Haskell, Qi, Concurrent Clean, are of this type.

Some are created by corporations from scratch for one reasons or another. e.g. Java, Javascript, AppleScript, Dylan, C#. The reason is mostly to make money by creating a lang that solves perceived problems or need, as innovation. The problem may or may not actually exist. (C# is a lang created primarily to overrun Java. Java was created first as a lang for embedded devices, then Sun Microsystems pushed it to ride the internet wave to envision “write once run everywhere” and interactivity in web browser. In hindsight, Java's contribution to the science of computer languages is probably just a social one, mainly in popularizing the concept of a virtual machine and automatic memory management (so-called Garbage Collection), and further popularizing OOP after C++.)

Infinite Number Of Syntaxes And Semantics

Looking at some tens of langs, one might think that there might be some unifying factor, some unifying theory or model, that limits the potential creation to a small set of types, classes, models. With influence from Stephen Wolfram book “A New Kind of Science” (see: Notes on A New Kind of Science) , i'd think this is not so. That is to say, different languages are potentially endless, and each can become quite useful or important or with sizable user base. In other words, i think there's no theoretical basis that would govern what languages will be popular due to its technical/mathematical properties. Perhaps another way to phrase this imprecise thought is that, languages will keep proliferating, and even if we don't count langs that created by one-man's fancy, there will still probably be forever birth of languages, and they will all be useful or solve some niche problem, because there is no theoretical or technical reason that sometimes in the future there would be one lang that can be fittingly used to solve all computing problems.

Also, the possibilities of lang's syntax are basically unlimited, even considering the constraint that they be practical and human readable. So, any joe, can potentially create a new syntax. The syntaxes of existing langs, when compared to the number of all potentially possible (human readable) syntaxes, are probably a very small fraction. That is to say, even with so many existing langs today with their wildly differing syntax, we probably are just seeing a few pixels in a computer screen.

Also note here all langs mentioned here are all plain-text linear ones. Spread sheet and visual programing langs would be example of 2D syntax... but i haven't thought about how they can be classified as syntax. (nor do i fully understand the ontology of syntax )

Just some extempore thoughts.


New programing languages.


Discovered a new programing language. Factor (programming language).

See: Point Free Programing.

what do programers do all day?

What Do Programers Do All Day?

In the past few years, i've been wondering why software engineering is so cumbersome and time consuming. Usually, something that's conceptually trivial, something you think can be done in 10 minutes, ends up hours. In the past few years, i tried to write a account of it whenever this happened to me. See these essays:

(and it is quite time consuming to document this experience. Each essay above usually takes 4 hours to write.)

In all the above cases, they are typically about installing a package, setting a preference, compress a file, get spelling checker to work, setting a environment variable. If you know the technologies well, usually you'd imagine it's just 5 to 10 minutes job. But in each case, i ends up spending hours or half of a day.

In the past week, another 2 such situation happened. One is renaming a file in Subversion (svn) by changing a letter case of a file. See the problem described here: http://groups.google.com/group/ergoemacs.

The other problem is about writing a script to zip up a directory. See: Unix zip Utility Path Problem.

You might have worked in the software industry as a programer for years. Sometimes, you might wonder, “what i've actually been doing in the past few months?”. In a day job situation, half of the time is spent on meeting and communication and other miscellaneous, non-nondescript stuff. Perhaps you actually get to code only for 1/3 of your working time. Of that time, a large part, probably more than half of the time, is probably spent on getting something conceptually trivial to work, among the hacks, spaghetti code, non-existent documentations, problem in tools, etc.

As a programer, i think intuitively we think that programing is actually writing new functions, new libraries, something that doesn't exist before. But i think in reality, more than half the time a working programer spend daily on coding, is actually about fixing stupid problems, working around tools, using knowledge about the environment and past experiences.


Emacs Lisp Date Time Formats

Perm url with updates: http://xahlee.org/emacs/elisp_datetime.html

Emacs Lisp Date Time Formats

Xah Lee, 2010-11-29

A little emacs lisp tips on working with date time.

ISO 8601 Format

Elisp provides a very convenient function “format-time-string” for printing data time. For example, you can write a command to print date in the yyyy-mm-dd format using 「(insert (format-time-string "%Y-%m-%d"))」. Here's the full code:

(defun insert-date ()
  "Insert current date yyyy-mm-dd."
  (when (region-active-p)
    (delete-region (region-beginning) (region-end) )
  (insert (format-time-string "%Y-%m-%d"))

The “region-active-p” may be new in emacs 23. For emacs 22, use 「(and transient-mark-mode mark-active)」.

In many web tech spec (e.g. Atom Webfeed Format), a full ISO 8601 format is required, like this: 「2010-11-28T13:55Z」. You can code it like this:

(defun insert-date-time ()
  "Insert current date-time string in full
ISO 8601 format.
Example: 2010-11-29T23:23:35-08:00
See: URL `http://en.wikipedia.org/wiki/ISO_8601'
  (when (region-active-p)
    (delete-region (region-beginning) (region-end) )
    (format-time-string "%Y-%m-%dT%T")
    ((lambda (x) (concat (substring x 0 3) ":" (substring x 3 5)))
     (format-time-string "%z")))))

Ordinal Date

“format-time-string” also supports ordinal date format. For example, “2010 Jan 1st” is “2010-001”, and “2010 December 31” is “2010-365”. The code is this:

(format-time-string "%Y-%j") ; "2010-334" for 2010-11-30

Names for Month and Week

You can also print names for month and week, both full name or abbrevation.

(format-time-string "%B %b") ; "November Nov"
(format-time-string "%A %a") ; "Tuesday Tue"

Unix time format

To print Unix time format (i.e. number of seconds since 1970-01-01 00:00:00 +0000.), use 「%s」. Like this:

(format-time-string "%s") ; "1291104066"

Documentation of format-time-string

Call “describe-function” to see the inline doc of “format-time-string”. Here's the output:

format-time-string is a built-in function in `C source code'.

(format-time-string FORMAT-STRING &optional TIME UNIVERSAL)

Use FORMAT-STRING to format the time TIME, or now if omitted.
TIME is specified as (HIGH LOW . IGNORED), as returned by
`current-time' or `file-attributes'.  The obsolete form (HIGH . LOW)
is also still accepted.
The third, optional, argument UNIVERSAL, if non-nil, means describe TIME
as Universal Time; nil means describe TIME in the local time zone.
The value is a copy of FORMAT-STRING, but with certain constructs replaced
by text that describes the specified date and time in TIME:

%Y is the year, %y within the century, %C the century.
%G is the year corresponding to the ISO week, %g within the century.
%m is the numeric month.
%b and %h are the locale's abbreviated month name, %B the full name.
%d is the day of the month, zero-padded, %e is blank-padded.
%u is the numeric day of week from 1 (Monday) to 7, %w from 0 (Sunday) to 6.
%a is the locale's abbreviated name of the day of week, %A the full name.
%U is the week number starting on Sunday, %W starting on Monday,
 %V according to ISO 8601.
%j is the day of the year.

%H is the hour on a 24-hour clock, %I is on a 12-hour clock, %k is like %H
 only blank-padded, %l is like %I blank-padded.
%p is the locale's equivalent of either AM or PM.
%M is the minute.
%S is the second.
%Z is the time zone name, %z is the numeric form.
%s is the number of seconds since 1970-01-01 00:00:00 +0000.

%c is the locale's date and time format.
%x is the locale's "preferred" date format.
%D is like "%m/%d/%y".

%R is like "%H:%M", %T is like "%H:%M:%S", %r is like "%I:%M:%S %p".
%X is the locale's "preferred" time format.

Finally, %n is a newline, %t is a tab, %% is a literal %.

Certain flags and modifiers are available with some format controls.
The flags are `_', `-', `^' and `#'.  For certain characters X,
%_X is like %X, but padded with blanks; %-X is like %X,
but without padding.  %^X is like %X, but with all textual
characters up-cased; %#X is like %X, but with letter-case of
all textual characters reversed.
%NX (where N stands for an integer) is like %X,
but takes up at least N (a number) positions.
The modifiers are `E' and `O'.  For certain characters X,
%EX is a locale's alternative version of %X;
%OX is like %X, but uses the locale's number symbols.

For example, to produce full ISO 8601 format, use "%Y-%m-%dT%T%z".

Unix zip Utility Path Problem

Perm url with updates: http://xahlee.org/comp/unix_zip_problem.html

Unix zip Utility Path Problem

Xah Lee, 2010-11-30

This page describes a problem with unix's zip utility that's related to the problem of unix's environment variable.

Unix has a command line zip utility to compress files and folders. Very convenient. For example, suppose you want to archive this folder: 〔c:/Users/xah/ErgoEmacs_Source/〕. All you have to do is “cd” to the parent folder 〔c:/Users/xah/〕, then type 「zip -r ErgoEmacs_Source.zip ErgoEmacs_Source」. A archive file named “ErgoEmacs_Source.zip” will be created.

But suppose you need to call “zip” in a program. I know the dir i want to archive, and i know the dir i want the archived output to be.

Suppose in your program, you have:

zip -r "c:/Users/xah/output/ErgoEmacs_Source.zip" "c:/Users/xah/ErgoEmacs_Source"

This will create the archive, however, there's a problem. In the archive, it records the full path of each file. So, when user tries to unzip 〔ErgoEmacs_Source.zip〕 on her machine in her current dir at 〔c:/Users/mary/Downloads/〕, it'll try to create the files and dir at 〔c:/Users/xah/ErgoEmacs_Source〕 or create them at 〔c:/Users/mary/Downloads/Users/xah/ErgoEmacs_Source〕. Worse, if you use relative paths in your program, then some unzip software will claim it's a error.

Problem with Unix Environment Variable

There does not seem to be a option in the unix zip command line utility to solve this. The best you can do, is in your script, change the current path then call 「zip -r ErgoEmacs_Source.zip ErgoEmacs_Source」 just as if you are doing it manually.

The problem with this is that, once you introduce the “current dir” environment variable in your code, you have to be careful for every line of your code that deals with directories. Because env var are global variables, and wrong value of “current dir” will effect all functions that takes relative dir as path. This is especially important for build scripts that deals with lots directories. If you forgot to set current dir before a particular function call that takes relative path, you might deleting dir or files.

I was working on a emacs lisp script that builds a ErgoEmacs lisp packages for public release. I got a bug report that on the default unzip utility in Windows 7, and also the “7-Zip v9.17” claims that my zip archive is empty. The problem is caused by relative path in my zip archive, which is caused by using relative paths when calling zip utility like this 「zip ErgoEmacs_v1.9.zip ../」. When unarchiving using unix unzip, it gives a warning but otherwise works.

So, i tried to fix my build script. Spent 2 hours and realized there's no option in the zip util to do what i want. So, in the end, i set current dir to the parent dir of the dir i want to zip, full aware of the danger. Yet, because of this setting of current dir, by mistake first i copied my entire 〔~/〕 dir (a few gigabytes, was wondering why it took so long), then later on i deleted my entire svn checkout dir.

The essence of this prbolem is unix's concept of current dir as a environment variable. The environment variable is basically a global variable. Env var and current dir might be unavoidable and useful concept for operating the command line, but the essential problem of unix is the unixers do not realize what env var is, thus we have a problem like the zip util today, where it does not have option to clearly understand the input path, output path, and paths in archives.

What's the Big Deal?

Some unixer might say “what's the big deal?”. The problem is that as a software programer, you spend hours on seemingly trivial problems, caused by million of these little things.

If you do not introduce environment variable into your program, it is impossible to create the correct the zip archive using the unix zip program. If you introduce env var, you basically introduced a pest into your script, that you have to be careful on everyline to set the current dir correctly. If you forgot (which is normal), it causes disaster. If you do functional programing, or using a functional lang, this causes headache.

See also:

Version Number and Test Files

For testing purpose, here's a zip file with relative path in them: http://ergoemacs.googlecode.com/files/ergoemacs_1.9.1.zip

The unzip program discussed here is:

c:\Users\xah\web\xahlee_org\comp>unzip --help
unzip --help
UnZip 6.00 of 20 April 2009, by Cygwin. Original by Info-ZIP.

The zip version is:

c:\Users\xah\web\xahlee_org\comp>zip --help
zip --help
Copyright (c) 1990-2008 Info-ZIP - Type 'zip "-L"' for software license.
Zip 3.0 (July 5th 2008). Usage:

They are both from cygwin. I'm running Windows Vista.

Another unix fuckup is that, right now i tried to find the version of zip and unzip that i'm using, for the record. There does not seem to be any option to print the version number. It does not seem to be documented in the man pages. In the end, it appears, the version number is printed when you use the “--help” option. (the “--help” option is not even mentioned in the “unzip”'s man page.)

Another problem with unix is that, it's documentation (man page) always start like this:

       zip  [-aABcdDeEfFghjklLmoqrRSTuvVwXyz!@$] [--longoption ...]  [-b path]
       [-n suffixes] [-t date] [-tt date] [zipfile [file ...]]  [-xi list]

who the fuck understand what gook it is talking about?

For the record, this is my elisp build script as it currently is.

; -*- coding: utf-8 -*-

;; 2009-10-01, 2010-11-15
;; This elisp script builds a ErgoEmacs elisp package.
;; Effectively, it creates a new zip file, nothing else.

;; This script is experimental. Best to use the make util at
;; ergoemacs/Makefile
;; for now.

;; What does it do:
;; copy the whole “ergoemacs” dir into some dest dir. The “ergoemacs” is the dir from root checked out from svn.
;; remove all .svn dirs.
;; remove other files and dir such as Makefile and win32-setup etc.

;; First, change the version number in variable zipDirName”.
;; then, just eval-buffer.
;; The result will be a new zip file (and a unzipped dir) at the root of your svn checkout.
;; For example, if your svn checkout path is
;;   c:/Users/xah/ErgoEmacs_Source
;; then the following are created
;;   c:/Users/xah/ErgoEmacs_Source/ergoemacs_1.9.1
;;   c:/Users/xah/ErgoEmacs_Source/ergoemacs_1.9.1.zip

;; This script requires unix “find”, “rm”, “cp”, etc.

(defvar zipDirName nil "the zip file/dir name")
(setq zipDirName "ergoemacs_1.9.1.1")

(defvar sourceDir nil "The ergoemacs source code dir in repository. By default, this is parent dir of the dir this file is in.")
(setq sourceDir (expand-file-name  (concat (file-name-directory buffer-file-name) "../")) ) ; e.g. "c:/Users/xah/ErgoEmacs_Source/ergoemacs/"

(defvar destDirRoot nil "The output dir. Will be created if doesn't exit. By default, this is 2 dir above this file.")
(setq destDirRoot (expand-file-name  (concat (file-name-directory buffer-file-name) "../../"))) ;

(setq destDirWithZipPath (concat destDirRoot zipDirName "/"))

;; set to absolute path if not already
(setq sourceDir (expand-file-name sourceDir ) ) 
(setq destDirRoot (expand-file-name destDirRoot ) )
(setq destDirWithZipPath (expand-file-name destDirWithZipPath ) )

;; main

;; if previous build dir and zip file exist, remove them.
(let ()
  (if (file-exists-p destDirWithZipPath) (delete-directory destDirWithZipPath t))
  (if (file-exists-p (concat destDirWithZipPath ".zip" )) (delete-file (concat destDirWithZipPath ".zip" )) ) )

;; create the new dest dir
(make-directory destDirWithZipPath t)

;; copy stuff over to dest dir
;; (shell-command (concat "cp -R " sourceDir " " destDirRoot) )
(copy-directory sourceDir destDirWithZipPath )

;; delete “.svn” dir and other files we don't want
(shell-command (concat "find " destDirWithZipPath " -depth -name \".svn\" -type d -exec rm -R {} ';'" ) )

;; (require 'find-lisp)
;; (mapc 'my-process-file
;;  (find-lisp-find-files destDirWithZipPath "\\.svn$")
;;  (find-lisp-find-files "c:/Users/xah/xx2/ergoemacs_1.9.1.1/build-util/" "")
;;  (find-lisp-find-dired-subdirectories "c:/Users/xah/xx2/ergoemacs_1.9.1.1/build-util/")
;; )

;; delete emacs backup files
;; (shell-command (concat "find " destDirWithZipPath " -name \"*~\" -exec rm {} ';'" ) )
(require 'find-lisp)
(mapc 'delete-file (find-lisp-find-files destDirWithZipPath "~$"))

;; delete Windows specific setup dir
;; (shell-command (concat " rm -R " destDirWithZipPath "win32-setup"))
(delete-directory (concat destDirWithZipPath "win32-setup") t)

;; delete misc files we dont need
(delete-file (concat destDirWithZipPath "Makefile"))
(delete-file (concat destDirWithZipPath "build-util/build_ergoemacs_package.el"))

;; byte compile elc files
(load-file (concat destDirWithZipPath "build-util/byte-compile_lisp_files.el"))

;; zip it
(cd destDirRoot)
(shell-command (concat "zip -r " zipDirName ".zip " zipDirName ) )

;; change current dir back
(cd (expand-file-name (file-name-directory buffer-file-name)))

;; ideally, change all shell calls to elisp functions so it's not dependent on shell.
;; using elisp for build is just experimental. We can revert to unix shell in the future.

;; currently, the version number is hard coded. We probably want to make use svn's tag feature for version stapm, for building both Windows release and elisp package release.


CSS hack: multiple background and borders to create icons

Nicolas Gallagher created a interesting, extreme, css hack. See: 〈Pure CSS GUI icons〉 (2010-11-16) By Nicolas Gallagher. At nicolasgallagher.com.

nicolas gallagher css icons

Nicolas Gallagher's no-images css icons.

He created some 80+ icons. No images are used whatsoever, not even in css file. They are done by combining layers of several border, background. Each layer is specifically positioned, z-indexed, and with width and height spec, then using css3 features of rotating or oherwise transform them. The final result is the icon you see. A very advanced hack.

Though, hack they are. In practice, it's much better to use Unicode characters (See: Computing Symbols in Unicode) or images. (more than half of the icons he created doesn't exist as Unicode chars.)

To help me understand how he did it, i copied and reduced and created a much simpler file with just 2 icons. See: CSS Hack to Create Icons.

To understand it, you'll at least need to understand:

US Diplomatic Cables Leak

Perm url with updates: http://xahlee.org/Periodic_dosage_dir/US_diplomatic_cables_leak.html

Wikileak: US Diplomatic Cables Leak

Xah Lee, 2010-11-29, 2010-12-08

Big news: United States diplomatic cables leak. Quote:

The United States diplomatic cables leak is the ongoing public release of 251,287 documents, detailing correspondence between the U.S. State Department and U.S. embassies around the world. The documents were obtained by WikiLeaks and distributed to five major newspapers under embargo, with the first set of 220 cables published on 28 November 2010.[1][2][3] The release includes approximately 100,000 documents labelled "confidential" on the classification scale and around 15,000 documents at the higher level "secret", but none marked "top secret". Most of the documents focus on diplomatic relations between the U.S. and Middle East states.[4] WikiLeaks plans on releasing the entirety of the cables in phases over several months.[2]

Also of interest, is this. Quote:

On 26 November, via his lawyer Jennifer Robinson, Wikileaks founder Julian Assange sent a letter to the US Department of State, inviting them to "privately nominate any specific instances (record numbers or names) where it considers the publication of information would put individual persons at significant risk of harm that has not already been addressed".[13][14][15] Harold Koh, Legal Adviser of the Department of State, refused the proposal, stating, "We will not engage in a negotiation regarding the further release or dissemination of illegally obtained U.S. Government classified materials".[15] Assange responded to this by writing "You have chosen to respond in a manner which leads me to conclude that the supposed risks are entirely fanciful and you are instead concerned to suppress evidence of human rights abuse and other criminal behaviour".[16][17]

Hooray for Wikileaks. Keep up the good work.

The US goverment sent to Wikileads regarding the upcoming release this letter at media.washingtonpost.com. In it, it says, quote:

As you know, if any of the materials you intend to publish were provided by any government officials, or any intermediary without proper authorization, they were provided in violation of U.S. law and without regard for the grave consequences of this action. As long as WikiLeaks holds such material, the violation of the law is ongoing.

Publication of documents of this nature at a minimum would:

  • Place at risk the lives of countless innocent individuals – from journalists to human rights activists and bloggers to soldiers to individuals providing information to further peace and security;
  • Place at risk on-going military operations, including operations to stop terrorists, traffickers in human beings and illicit arms, violent criminal enterprises and other actors that threaten global security; and,
  • Place at risk on-going cooperation between countries – partners, allies and common stakeholders – to confront common challenges from terrorism to pandemic diseases to nuclear proliferation that threaten global stability.


Harold Hongju Koh
Legal Adviser

Basically, the US government takes “law” and stern approach, using the name of “protecting lives”. I don't know if wikileak's document would endanger lives, but i know it's far better to release this lie-exposure than, say, continuing US government's “war on terror” or whatnot other secrecy that caused some hundred thousands of Iraq civilian dead. (See: Iraq War Photos)

The Wikipedia article also contain summary of the leaks so far.


To donate to Wikileaks, go to (their DNS and server have been under heavy attack, by US pressure and others. That's why the ip address.)

Time Mag Voice and Video Interview

time mag cover 2010-12-13 Julian Assange

Time Mag cover 2010-12-13 Julian Assange

  • 〈TIME's Julian Assange Interview: Full Transcript/Audio〉 (2010-12-01) Source www.time.com

A very interesting video: 〈WikiLeaks's Julian Assange Reviews TIME's Top 10 Leaks〉 Source www.time.com.

Julian Assange Raped Women?

〈The Wikileaks sex files: How two one-night stands sparked a worldwide hunt for Julian Assange〉 (2010-12-07) By Richard Pendlebury. Source www.dailymail.co.uk.

Summary of the article: When Julian was visiting Stockholm, Sweden, two women admirers sought him out. (we'll call them Jessica and Sarah) Sarah offered her apartment for him to stay. Both had sex with him. Sarah created a party at her house the next morning for him. Jessica had a second sex the morning after. Few days later, the two women met, found out that each slept with him, then they started to visit police. The main accuser Jessica, wanted to know if there's a way to force Julian to take a HIV test, because no condom was used in their second sex. LOL.

Wikileaks = Time for a Revolution by People

The Wikileaks situation is getting out of hand. (See: Wikileak: US Diplomatic Cables Leak) In the past week, they got kicked out by amazon hosting, then paypal, then Mastercard, and Vista card, and the a Swiss bank closed their account. Due to gonvernment's political pressure, mostly from US government. Here's a detailed timeline of the attacks:

  • 〈Wikileaks under attack: the definitive timeline〉 (2010-12-16) By Charles Arthur. guardian.co.uk. At: Source www.guardian.co.uk

You can still donate, here: http://wikileaks.ch/support.html.

Also, you can help hosting the site, here: There are currently over 1k mirror sites already.

I think Google and Free Software Foundation should step up to make a gesture for hosting.

The severity of this government and big org censorship, is kinda a revolution material (think of Frenh Revolution, Russian Revolution.). We, the people, should stand up against them.

729px-Liberty Leading the People

A renowned painting “Liberty Leading the People” (1830) by the French romantic painter Eugene Delacroix (1798-1863). (See: Freedom Goddesses.)

Was this page useful? If so, please do donate $3, thank you donors!

Madman tank rampage

Madman drives a self-built, modified-to-armored bulldozer on a destruction rampage. He's Marvin Heemeyer.

Madman drives a stolen tank thru street. He's Shawn Nelson.

See also: Unabomber Manifesto (Industrial Society and its Future).


Plants vs Zombie; Thoughts on Strategy and Game Formulation

Perm url with updates: http://xahlee.org/math/plants_vs_zombie.html

Plants vs Zombie; Thoughts on Strategy and Game Formulation

Xah Lee, 2010-11-28

Plants vs. Zombies amazon is a very popular game.

plants vs zombie last boss.

The game, according to Wikipedia, is a type of game called Tower defense. As you can see in the video, each type of plant has particular properties, such as shield level, energy level, fire power, and position etc. Same for zombies. If you watched the video, you might wonder what's the optimal strategy, given the number of incoming zombies, their type, and position.

This aspect is similar to many games, for example Second Life's Tech Warfare, and lots other video games. In a sense, hundreds or thousands of these video games arbitrarily creates a math optimization problem.

If you are the designer of the game, you also might wonder what's the optimal strategy. In fact, if you are math oriented, you might start with a formalization of the math core of the game. To understand this, let's use the game chess as a example. Given a chess game, for example, you know all the positions of the pieces, you want to have a algorithm that can tell you who's winning and by how much. In other words, a score system or evaluation system. This is almost the first thing you need to do.

In the “plants vs zombies” game, the cute plants, the monstrous zombies, their animations, are not relevant to the core mathematical aspect of the game. The core math aspect is just several plants, their types, their position, available plants, and each plant type's attack/defense properties. Same for zombies. Once you have the game play abstracted this way, you could easily create different games that feels vastly different, yet mathematically the same. The zombies could be aliens, monster, or missiles. The plants can be policemen, warriors. It could be naval warfare, or like Sim City's building vs nature. Or, the whole game can be abstract like chess, where the zombies are just black abstract pieces, and the plants are just white pieces, and their types represented by different shapes of the piece.

I don't think many games started with a formal system in their gameplay. But am pretty sure some games are started as some abstract gameplay system, then theme and animation are added on. For example, i think TRON's Light Cycle game might be such. (See: TRON Light Cycle Optimal Strategy.)

This optimal strategy and formulation of a game reminds me of Cellular Automata as discussed by Stephen Wolfram's A New Kind of Science. You can easily generate almost infinite varieties of simple systems, yet it's basically impossible to derive some theorems or optimal strategy for it.

Also, in programing games, you have to create a AI system of the characters controlled by computer. (e.g. those ghosts chasing pacman; the paths they take.) If you have some formalization of the gameplay, i suppose it might help in designing the AI.

Video games is truely fantastically fascinating. I think they are the forefront of computing and research in many aspects.

Principia Mathematica

Perm url with updates: http://xahlee.org/math/principia_mathematica.html

Principia Mathematica

Xah Lee, 2010-11-28

Interesting article:

I learned the book Principia Mathematica (PM) in about 1991, as a college student. At the time my math isn't good enough for the prospect of reading it. In early 2000s, i'm ready to read the book, always wanted to, but never did. In fact never saw a single page of the book. Though, today, i don't think the book is worth a detailed reading even if you specialize in math logic. Rather, as a required acquaintance.

Here's some explanation of the notation used.

  • 〈The Notation in Principia Mathematica〉 (2004-08-19) By Bernard Linsky. At: plato.stanford.edu

It seems, to read the book and have some basic understanding would require at least a year full time. (assuming you already understand the basics of logic and some history of math foundation.)

  • 《Principia Mathematica - Volume One》 By Mathematica Alfred North Whitehead and Bertrand Russell. amazon
  • 《Principia Mathematica - Volume Two》 amazon
  • 《Principia Mathematica - Volume Three》 amazon

Wolfram said that Russell commented that there are only about 6 people who read the whole thing. Today, perhaps the number of people alive who have read it might be under a hundred.

Also, Wolfram said, quote:

In my own work, Mathematica shares with Principia Mathematica the goal of formalizing mathematics—but by building on the concept of computation, it takes a rather different approach, with a quite different outcome. And in A New Kind of Science, one of my objectives, also like Principia Mathematica, was to understand what lies beneath mathematics—though again my conclusion is quite different from Principia Mathematica.

That's typical bullshit from Wolfram. PM was intended to be a math foundation. Mathematica was a computer algebra system, and is never any sort of math foundation nor even a computer based proof system. At best, one might call Mathematica as the best math calculator that exists today, but the nature of math calculator is very different than a proof system. Even if we consider Wolfram|Alpha being 10 times better, it's still can't do a bit of proofs. There are proof systems, such as Coq, HOL Light, Isabelle, etc. (See: State Of Theorem Proving Systems 2008)

But Wolfram later says:

Beyond these notational issues, there is a much more fundamental difference between the formalization of mathematics in Principia Mathematica and in Mathematica. For in Principia Mathematica the objective is to exhibit true theorems of mathematics, and to represent the processes involved in proving them. But in Mathematica, the objective is instead to compute: to take mathematical expressions, and evaluate them.

Well, so it is a calculator, not a proof system.

✻ ✻ ✻

I think what's interesting is Wolfram's systematic exploration of all possible axiom systems. He went on to talk about that.

Wolfram says that logic that PM have “chosen” to build on is not basic, and compared that to his investigation of all simple computations as in his A New Kind of Science (ANKS). I appreciate very much his systematic investigation of all simple computations, but i find it hard to take that to claim that logic is not basic. These 2 are different things, different contexts. You can consider symbolic logic or formal math as a computational system, or vice versa. If you do consider logic as a computational system, then of course, it's not the simplest. All cullular automatica can be rephrased as logic, logic can be rephrased as a particular cellular automatica. In either case, they become more complex.

I guess he's saying in the context of building up a formal math system based on some sort of cellular automata or simple rules... conceivable, but nobody has done that, and nobody knew what the result would be like, or what or which simple system should be the “foundation”. Logic being logic, because it is based on something we understand and in touch: true, false, and sets (things).

So can one say that the idea of logic somehow underlying mathematics is wrong? At a conceptual level, I think so. But in a strange twist of history, logic is currently precisely what is actually used to implement mathematics.

Hard to take this. He says “logic is currently precisely what is actually used to implement mathematics.”. But most professional mathematicians do not take logicism as their approach, nor vast majority of math publications. Basically, they “implement math using logic” only in the sense that they use reasoning. In this sense, what possibly could be the alternative? I imagine Wolfram would imagine mathematicians that when they do a proof, the proof goes like “because CA xyz at step n is this way, therefore this lemma is true”?

We know from computational universality—and more precisely from the Principle of Computational Equivalence—that things do not have to work this way, and that there are many very different bases for computation that could be used. And indeed, as computers move to a molecular scale, standard logic will most likely no longer be the most convenient basis to use.

But so why is logic used in today’s computers? I suspect it actually has quite a bit to do with none other than Principia Mathematica. For historically Principia Mathematica did much to promote the importance and primacy of logic, and the glow that it left is in many ways still with us today. It is just that we now understand that logic is just one possible basis for what we can do—not the only conceivable one.

In the above, it makes a good point about his ANKS, about how a particular type of computer, the DNA computer, where CA will be a better model than logic. Though, it seems silly the way he suggest why today's computer are based on logic. Computer uses electronics, with electricy flowing or not flowing as on and off, true and false, which seems the simplest to do with electronics. That's basically why, if one wants to say it's basic on logic. Rather, it's not “based on logic”, but a “2 states system”. We might call it boolean algebra, or we might say it's based on math, or we might just say it's based on properties of eletricity or physics. What does it mean to say that today's computer are based on “logic” anyway?

I suppose he's suggesting that the process of designing a cpu, memory, bus, circuit design, etc, could be more based on some arbitrary CA or other system.

✻ ✻ ✻

To resolve this, Russell introduced what is often viewed as his most original contribution to mathematical logic: his theory of types—which in essence tries to distinguish between sets, sets of sets, etc. by considering them to be of different “types”, and then restricts how they can be combined. I must say that I consider types to be something of a hack. And indeed I have always felt that the related idea of “data types” has very much served to hold up the long-term development of programming languages. (Mathematica, for example, gets great flexibility precisely from avoiding the use of types.)

The intro of types considered as a hack is common opinion. What's interesting is his opinion about “data types” in programing languages. This is also a common debate. I was never good at typed languages... One obvious reason is that most of them are low level langs (C, C++, Java), and i despise low-level langs (was never a systems programer). However, i thought i might like it with typed high-level langs such as Haskell and OCaml. Tried to learn them in mid 2000s but didn't went far.

google propaganda, html5

20thingsilearned.com. A fancily designed website, that is a kinda educational article for the general public that teaches them what is the web and web technologies, together with some opinions mixed in. A sorta propaganda, from Google. However, it demonstrates what html5 can do.

The site seems to be created sometimes this month (2010-11) (or, opened to public), and it's just about 20 pages of content, but the site's already ranked 21k in the world. (See: alexa.com.) For context, my site xahlee.org is ranked world's 68k, and has about 8k daily visitors. A quick estimate seems to indicate the site gets 286k visitors per day.

See also: HTML6, Your HTML/XML Simplified.