Sunday, November 9, 2008

Microsoft and Evangelism

What does Microsoft have to do with Christian churches?

Nothing, except that they both exhibit a certain behaviour: aggressive evangelism. Both operate in ways that tend to reduce freedom of choice and make it hard for people to choose alternatives. Their behaviour on this count is similar because their motivations are similar. Both wish to monopolize society.

When Google became popular in search, Microsoft tried to beat Google at search. When Google began its mail service, Microsoft tried to beat Google at mail. When Google began getting into maps, books, Microsoft put some serious effort into the same fields. This is reminiscent of church planting in Indian villages.

When a Hindu temple undertakes a major activity that might get people interested (such as renovation of a temple or appointment of a new priest), Christian organizations often rush to plant a church and engage in a publicity and incentive blitz to attract villagers.

Microsoft has been doing the same thing in the tech domain. If there's any tech development that attracts people, Microsoft tries to enter it in a big way in order to attract customers to the Microsoft fold.

Both Microsoft and church have practically unlimited financial resources compared to their competitors, and both are extremely resistant to the existence of alternatives.

It's no secret that I'm on the side of Freedom here: freedom as in free software, and freedom of religion. Makes me wonder: do Microsoft vs. open source and evangelism vs. freedom of religion have the same solution?

Saturday, November 1, 2008

Automatically Inserting Matching Parentheses for LaTeX in Emacs

My use of emacs varies, but a good chunk of my time is spent writing in LaTeX for mathematical formulae. AuCTeX simplifies my life quite a bit, and whizzytex makes it awesome. But one feature that would really save me some typing is auto-completion of matching parenthetical symbols. In LaTeX, such matching delimiter pairs are $$, [], {}, \{\}, \left\{\right\}, \left(\right), etc. I found a major mode called Ultratex that does exactly this (and much more), but unfortunately it replaces AuCTeX rather than augment it, and isn't maintained any more.

Here's some trivial emacs lisp code for a minor mode that accomplishes this. You can easily modify it yourself to add or remove simple matching completions. You can put it directly in your .emacs file, or in a file called dlmins.el, and add the line

(load "/path/to/dlmins.el" t t)

to load it. If you want this to be activated every time LaTeX is fired up, put the following line in your .emacs file:

(add-hook 'LaTeX-mode-hook 'dlmins-mode)

To toggle the mode manually, use command M-x dlmins-mode. Here's the code for the minor mode.

;;; dlmins.el -- Trivial minor mode to insert matching LaTeX
;;; delimiters automatically.
;; Copyright (c) 2008 Rajeev Ayyagari

;; Author: Rajeev Ayyagari
;; Keywords: Parenthesis matching
;; Version: 0.01 of Sat Nov 1 11:22:44 EDT 2008

;; This file is not part of GNU Emacs.

;; Minor mode: dlmins-mode
;; Entering a left-parenthetical symbol causes the corresponding
;; right-parenthetical symbol to be inserted automatically, and point
;; is positioned appropriately.
;; To use, place this code in a file called dlmins.el and add the line
;; (load "/path/to/dlmins.el" t t)
;; to your .emacs. To make the mode start automatically when a latex
;; document is opened, add the line
;; (add-hook 'LaTeX-mode-hook 'dlmins-mode)
;; to your .emacs after the above "load" line. Manually toggle (enable
;; or disable) the mode using M-x dlmins-mode.

;; Set up keymaps and list of delimiter pairs.
(defun dlmins-setup ()
"Initialize delimiter auto-insertion."
;; Order matters in the list below!
;; The rule is if STR2 is a suffix of STR1, then STR2 should come
;; after STR1.
(setq dlmins-dlm-list
("\\left\\{" "\\right\\}")
("\\{" "\\}")
("\\frac{" "}{}")
("{" "}")
("\\left(" "\\right)")
("(" ")")
("\\left\\|" "\\right\\|")
("\\|" "\\|")
("|" "|")
("\\left|" "\\right|")
("\\left[" "\\right]")
("[" "]")
("$" "$")
(define-key (current-local-map) (kbd "{") (lambda () (interactive) (insert "{") (dlmins-pair)))
(define-key (current-local-map) (kbd "[") (lambda () (interactive) (insert "[") (dlmins-pair)))
(define-key (current-local-map) (kbd "(") (lambda () (interactive) (insert "(") (dlmins-pair)))
(define-key (current-local-map) (kbd "$") (lambda () (interactive) (insert "$") (dlmins-pair)))
(define-key (current-local-map) (kbd "|") (lambda () (interactive) (insert "|") (dlmins-pair))))
;; Called when left delim is typed, finds and inserts appropriate
;; right delim.
(defun dlmins-pair ()
"This should be called as soon as an opening delimiter has been typed.
When called, looks backward to see which delimiter has just been typed.
It inserts the matching closing delimiter.
Eventually it will be smart enough to take care of \left and \right as well."
(catch 'getout
(lambda (dlm)
"If expression before point matches open dlm, insert close dlm."
(if (looking-back (regexp-quote (car dlm)))
(insert (car (cdr dlm)))
(throw 'getout nil))))
;; Toggle the parenthesis matching mode
(define-minor-mode dlmins-mode
"Minor mode LaTeX matching delimiter auto-insertion. use
\"dlmins-mode\" to toggle."
:init-value nil
:lighter " DlmIns"
:keymap '()

Sunday, October 12, 2008

Is User-Friendly the Way to Go?

Everything in the computer world: search, social networking, operating systems, even system administration, is going towards user-friendliness. User-friendliness is the carrot used by various manufacturers to lure consumers towards their products. It relies on humans' inherent laziness: if you can do something more easily, why do it the hard way?

That is also a good argument for user-friendliness: why expend effort (i.e. incur costs) learning how to do things the hard way when the same things can be done the easy way (i.e. at lower cost)?

But there is a hidden cost. It is hidden in the words "same things" above. I think there are things that cannot be done without using more sophisticated methods than the basic, user-friendly, point-and-click methods. How would you rename all files in your system with the extension ".bin" to ".exe" in a user-friendly fashion? This is just an example of a common task. If people could all write basic code, there would be a lot of advanced tasks that would become common. This would lead to greater complexity in the use of computers, and hence faster innovation.

As an analogy: It takes more effort to learn 5th grade math than to learn 1st grade math. 1st grade math is more user-friendly than 5th grade math. But you can do more with 5th grade math than with 1st grade math. Everyone should learn 5th grade math. However, only specialists need to learn masters-degree level math.

So the question is: where are consumer digital products currently poised? If they are poised at the 10th or 12th grade level, there is no need to educate people any more; only specialists need to learn anything more from this point on. If they are poised at the 1st or 5th grade level, people should be expected to learn more; that will lead to more effective use of digital resources.

Wednesday, October 8, 2008

Open Source versus Innovation?

I'm reading The World is Flat by Thomas Friedman, and he asks a question about open source that really made me think. What is the motivation for innovation if everybody gives their innovations away for free and nobody gets paid for their innovations, which is what open source seems to suggest?

I don't have a good answer, but it seems to work. As Friedman himself points out, many important innovations have come out of open source, including the Apache web browser. I would go so far as to say that most innovations in the field have come from not-for-profit efforts. Google's entire search infrastructure runs on Linux; Amazon's entire web presence runs on Apache. It's as real as it gets.

The question is tied to (and perhaps motivated by) statements from Microsoft bigwigs. Here is one that Friedman quotes (the inserts are his):
You need capitalism [to drive innovation.] To have [a movement] that says innovation does not deserve an economic reward is contrary to where the world is going. When I talk to the Chinese, they dream of starting a company. They are not thinking, 'I will be a barber during the day and do free software at night.'... When you have a security crisis in your [software] system, you don't want to say, `Where is the guy in the barbershop?' -- Bill Gates
But Bill Gates is hardly in a position to talk of innovation. Microsoft has not made any significant technical innovations in the last 10 years. Windows Vista's UI is (feature-wise) just a bloated version of Windows 95, with some bling. Microsoft's innovations are almost entirely on the business end: it has figured out effective ways to stifle innovation by competitors. So Bill Gates talking about what drives innovation is like a thief lecturing about honesty.

Gates' comment about security is even more perplexing in light of the extensively poor track record Microsoft has in security. Open source alternatives are far more secure in every way than anything Microsoft has. Maybe the reason you don't want the guy in the barbershop is if you know there's something wrong with the security, it's probably the Microsoft guy who's responsible.

But what Gates says is not really relevant here. None of this actually answers the question: how can you justify, theoretically, the claim that innovation can be sustainably executed within Open Source frameworks?

I don't have a good answer.

Friday, September 26, 2008

PGF and TikZ

I guess I'm just completely out of touch, but there's an excellent package that allows you to draw sophisticated graphics within LaTeX (using a graphics programming language) I hadn't heard of till recently.

It's called PGF, and the component you use in your LaTeX/TeX source code is called TikZ. You enter simple LaTeX-style commands to tell it what to draw, in an environment right in your (La)TeX code, and it does the job for you. The excellent user manual can be found here, including instructions for installing and a tutorial. (If you're a Ubuntu user, of course, there's already a package you can install with a few clicks.) Great examples can be found here. Wow! What a package.

Saturday, August 9, 2008

Emacs Word Wrap

Real word wrapping in emacs isn't automatic, but here's how it can be done. I found these instructions at It's not perfect; despite the comments on that website, I don't yet know how to make word-wrap work after vertical splitting. First, get longlines.el and put it somewhere. Then, add the following lines to your .emacs:

(load "/path/to/longlines.el" t t)
(autoload 'longlines-mode "longlines.el" "Minor mode for editing long lines." t)
;; Uncomment the next line to wrap by default in text mode
;;(add-hook 'text-mode-hook 'longlines-mode)

To activate manually, do M-x longlines. More info at

Adding An Emacs Menu

Here's some template code for adding a menu item to the main emacs menu bar. I don't know hos this works; I just use it as a template!

;;;;;;; Add items to menu bar
(modify-frame-parameters (selected-frame) '((menu-bar-lines . 2)))
;; Make a menu keymap (with a prompt string)
;; and make it the menu bar item's definition.
(define-key global-map [menu-bar MyMenu] (cons "MyMenu" (make-sparse-keymap "MyMenu")))
;; Define specific subcommands in this menu.
(defun MyMenu-linkify() (interactive) (replace-regexp "^\\(.*\\)$" "\\1
(define-key global-map
[menu-bar MyMenu linkify]
'("Linkify" . MyMenu-linkify))
(define-key global-map
[menu-bar MyMenu truncate]
'("Truncate em" . toggle-truncate-lines))