Xah's Programing Blog

On programing, languages, functional programing, Unicode, keyboard, hacker culture, ….

Want to master JavaScript in a week? Buy Xah JavaScript Tutorial.

see bottom, for a collection of hand exercise toys for repetitive strain injury. How to Avoid the Emacs Pinky Problem

my JavaScript tutorial is on the 8th page of Google search. First few pages are all big commerical sites with money to burn. Help me move it to top. Share on social networks, or link from your blog. Thank you. Xah JavaScript Tutorial

the idiocy of java interface. What's Interface in Java?

Computing Culture: What's Hacker? (repost)

Ergonomixx Mykey keyboard. Function keys in a circle! Vintage Ergonomic Keyboards

Linux: ImageMagick Command Line Tutorial (old goodie)

new video review. Microsoft Sculpt Ergonomic Keyboard Review

(Knowledge + Love) / Disrespectfulness

another keyboard layout: Coleman!

another keyboard layout: Coleman! it's a mix of Colemak & Workman, and presumably “better”! http://omidnikta.github.io/colman/

see also: Keyboard Layouts Fight! Dvorak, Colemak, Workman, NEO, Bépo, …

xah's rumination extempore, on meta syntax, formal language, and logic

(xah's rumination extempore, is when i have something on my mind and type as fast as i can to express it, where i dunno what am saying or where am i going, and you rip my brain out)

currently worrying about issues in meta syntax, such as BNF.

for example, there's these pages

i'll be using CSS syntax here to discuss the issue, but the issue is about meta syntax language and applies to all.

you see those italized words? those represent variables. (for clarity, i'll angle bracke them in this post, like this ‹x›)

in CSS, this ‹tag› will match anything, where ‹tag› is any html element name. Since any html tags is a finite set, so, ‹tag› actually stands for a restricted set of strings, not ANY.

however, CSS selector is not just for html, but for xml as well. Meaning, the ‹tag› is potentially infinite, however, still not arbitrary string.

So, here we have a issue of what ‹x› actually means. It can be any element of a finite set, or it can be potentially infinite, or it sometimes can be arbitrary string.

by the way, the context of this articles, is about meta syntax, formal language, logic, and computer software documentation format. Basically, i write a lot tutorials, so i need to use some syntax to represent syntax.

I'm into formal languages, so i want my syntax to be precise as some variation of computable BNF or particular pattern matching language (say in Mathematica), but i also need it to be human readable, because it is used in tutorials. First question is whether it's possible the have a syntax description language that is very human readable (as suitable to be used in API or tutorial), i believe yes.

see also Pattern Matching vs Lexical Grammar Specification

the other thing is the naming of a variable ‹x›. For example, 「convertToFloat(‹integer›)」. There, the name “integer” gives reader a good sense of what string ‹integer› can be. One must be careful here, because by definition, ‹x› can stand for anything, a particular set of things, and the set can be infinite set, such as integers. The problem here is that, unless you actually define, by a formula, the precise meaning of ALL your ‹x›, otherwise a wrong naming introduces paradox or may be misleading.

for example, normally we'll see any of these in programing docs

「coordinate(‹x›, ‹y›)」

intuitively and sloppily, we understand what they mean without problems. (actually, with problems, but am not sure how extensive it is. See On the Idiocy of Dot Notation of Object Oriented Programing Languages ) but they are not precise. For example, in any language, the format of a number is a specific pattern of sequence of symbols. Depending on whether it's python, java, lisp, html, you may have


another example 「‹s›.replace(/‹regex›/,‹replace›)」 here, if you write 「‹x›.replace(/‹n›/,‹i›)」 it's still technically good, but misleading.

the important thing to note here is that, the NAMING of your pattern actually have significant significance. Something we don't think about much, but has great consequences.

In another way to look at this is that, if you think of your syntax as formal language, then the naming really doesn't matter (actually…), provided that you do have the complete system definition of all your ‹x› (which are basically patterns. a pattern language)

so, here we must consider, what you gonna do? When you write

「convertToFloat(‹integer›)」 or 「‹s›.replace(/‹regex›/,‹replace›)」 in a tutorial or lang documentation, do you actually go all the way and define all those ‹integer› and ‹s› etc? Is this practical such that it can be done in a tutorial?

meanwhile, you can take a sloppy and broader approach, such that anything ‹x› is just meant to be arbitrary symbol or sequence of symbols, and the naming (the english interpretation of the x in ‹x› is just a hint). But if this approach is taken, the naming actually has a meaning, and becomes critical, because 「convertToFloat(‹function›)」 would be dead wrong.

here's another example, from css, where you can't random name 「‹tag›[‹attr›="‹val›"]」 vs 「‹t›[‹a›="‹v›"]」

in the latter, since it's single letters, so it gives you a lot flexibility. But it's not intuitive. if you change their order 「‹a›[‹v›="‹t›"]」 it can still work, or even 「‹x›[‹y›="‹z›"]」 is good.

While using names {tag, attr, val} is intuitive. But here, note that each named placeholder has meaning attached to them.

here's another thing to consider. Sometimes we want to document function, we write


you see 2 very different approach? the question on my mind, is to logically clarify the whole ontology of this. Here, we are entering another level of semantics. Note, when you say “arg”, it means argument. Good. Note, when you say “number”, it means a number, also Good. Now consider this:

f(‹arg1›, ‹arg2›, …)
f(‹num1›, ‹num2›, …)

which one should you use? what's their differences? what is their consequence, to the following english wording for the function?

ok, the above is mostly about the naming of a pattern.

ok, but there are other issues. Sometimes, you want to write, for example in css: 「t1>t2」 where the t1 and t2 are 2 different tags. In general, as in math, when you have 2 variables with different names, it does not imply that they may not be equal. For example,


here, we may have both ‹x› and ‹y› to be 2.

CSS example:


here, both ‹t1› and ‹t2› can be the same tag, say “div”.

but, sometimes we need to have a syntax that contains 2 different things. e.g. in math, typically it's done as a added condition in english, example

「‹x›+‹y›=4」 and x≠y.

that's simply ugly and out of it. (totally out of the realm of formal languages. (you know? it's interesting. In math, some subject say geometry or algebra, there are ofter different axioms or foundations. When you use a different foundation, all things, concepts, defintions, needs to be changed or rephrased. (am thinking universal algebra vs classic abstract algebra)))

anyway, i think i stop here. I started to write this because i was just working on this page

CSS Selector Syntax

recently i removed all the ‹› and 「」 brackets, because for most readers, it's distracting. The convention is to use italic for ‹x› instead. But that has lots of problems i recently discussed. Basically, using slated font is a rendering issue, it helps reading, but took out the formal language aspect.

also note, of all computer language documentation out there, none are specific and precise. All are rather extreme garbage. (fk the programer hackers scbgs & fk their moms) for a example of the garbage that another issue, see:

Optional Function Parameters in Computer Language Docs (the idiocy thereof)

see also related:

comment at https://plus.google.com/+XahLee/posts/7GDsk4L6Kiv

slanted font for variable?

i've now succumbed to the pop. The sample code syntax on my site:「code ‹var›」, now don't have the special brackets. Instead, coloring and italitics are relied on.


the convention of italics for var names is historical. It's purely a rendering issue. It helps reading, but doesn't function as formal language. For example, if you use ‹var›, it has formal semantics as part of the text. But the extra brackets is confusing for vast majority of readers.

this mouse, Logitech Wireless Marathon Mouse M705 With 3-year Battery Life , the packaging is $30% of the mouse.

Xah's {Python, Perl, Ruby} Tutorial

now my Xah's {Python, Perl, Ruby} Tutorial is just $14.99. This is a Xah Style tutorial. Meaning, it's example based, practical, concise. No babbling about software engineering, patterns, agile, unit testing, coding style, nor inane holding-hands humor and tale and patting-your-back introduction.

You want to learn the language? If you have the will, you will. And my tutorial helps you in just that. You learn exactly about the language, with warning and notes about practical efficiency & idioms, and links to the official documentation when appropriate. Buy it. Share. Thanks.

change'd my site's “see also” unicode marker from 〔☛ link〕 to 〔➤ link〕. For detail, see: Semantics & Symbols: Examples of Unicode Symbols Usage

New, SVG background. Nice! Netiquette Anthropology: a Tale of Tech Geekers

see also Xah SVG Tutorial

Logitech Trackman Marble Mouse (updated)

A video review of Slimblade vs L-Trac Trackball. See bottom there.

major reorg. all you don't need to know about software engineering

Linux: Virus Scanner for Linux

Complete guide to choosing a mouse. Which one is for you? Computer Mouse, Trackball, Input Devices

Logitech Trackman Marble Mouse (updated)

i'm doing more and more JavaScript. Visit my Xah's Web Dev Blog for goodies. Click subscribe web dev blog.xml.

updated on the JavaScript + svg. Computer Languages Character Distribution

See also: Xah SVG Tutorial

Idiocy of Keyboard Layouts: QWERTZ, AZERTY, Alt Graph (minor update)

atom feed broken relative link, base url. No, hackers are broken.

in atom feed (aka webfeed, rss), by spec one can have a base url where other url are relative to, ⁖

<feed xmlns="http://www.w3.org/2005/Atom" xml:base="http://ergoemacs.org/emacs/">

this is required by spec.

but it's quite annoying that most webfeed/rss clients are broken about it. i regularly got complaints about my feed links being broken. My guess is that many saw the broken links and simply stopped subscribing.

(many clients, simply don't support the atom feed to this day. This include Emacs GNUS at least last year.) (Atom feed format is far superior than rss created by the scmbg Dave Winer. see 〔Atom vs. RSS By Christopher Wellons. @ http://nullprogram.com/blog/2013/09/23/〕)

many moons ago, when Google Reader was around, in the beginning, it was also broken, but later on they fixed it. Same for yahoo.

recently, Christopher Wellons's https://github.com/skeeto/elfeed/issues/37 also had this problem.

No, the hacker idiots are broken. The hackers, the industry coders, the agile fk, the extreme programing fk, the google io fk, the linux fk, and the RFC fffffffffkk, n one thousand frameworks fk.

see the section “Webfeed Reader Bug on Relative Link” at Atom Webfeed Basics

see also Complexity & Tedium of Software Engineering

comment at https://plus.google.com/+XahLee/posts/5JrhNjhtXRT

How to unadd a file?

# unadd a file
git reset myFileName
# unadd all added files in current dir
git reset .

is programing math?

How to Stop Xfce from Loading Last Session

marketing is the primary government of lang popularity. If JavaScript was named LispScript with nested parens, it'd have failed.

LispyScript. A javascript With Lispy Syntax And Macros! http://lispyscript.com/

just wtf is closure❓

One of the things i'm most annoyed with hacker types is closure. The hacker types, always clamor about closure, how powerful it is.

but, functionally, mathematically, closure is equivalent to using global variables. But the hacker types, don't get it.

Mathematica Expression Forms

mathematica7 expression forms 2014-07-11
Mathematica expression forms. Top: InputForm. Middle: StandardForm. Bottom: FullForm.

note: the indentation is automatic. There's no Tab character anywhere.

The FullForm at bottom, is isomorphic to lisp's sexp. In lisp, you have (f a b c). In Wolfram Lang, it's f[a,b,c].

comment at https://plus.google.com/+XahLee/posts/apFFHAZtksB

JavaScript functional programing flexible coding style problem

one problem with functional programing in JavaScript and Wolfram Language is that, when there are a team of coders, the code becomes incomprehensible.

because, the function can be chained, function return functions, and the chaining function or method syntax is too convenient. So, everyone has a different coding style (here, the style refer to the semantic construct, not formatting). So, code become hard to understand.

lisp doesn't have this problem because the parenthesis prevents people chaining functions arbitrarily.

this is when python shines. First of all, it has a crippled lambda, so you can't have arbitrary functions inline or chain them. You have to define it by itself. Then, the language syntax prevents you from writing one-liners.

java, also works here. Because, the lang is so inflexible that you have to write everything out, each line can only do very little.

though, as a language designer, what can you say about this? what can you do?

isn't it ironic that if you create a language so powerful & flexible that it backfire? Something must be wrong with this logic? how to resolve this paradox?

in my way of thinking, whenever result of mathematical analysis conflict with human intuition or practice, it is human that needs to adopt. (⁖ relativity, flat earth, concept of size, dimension, time. Habit. superstition. religion, etc.) but we must be very careful.

so here, if we verify by science truly that powerful language with flexible syntax indeed create a problem due to multitudes of incompatible programing style, then, the issue is about how to create or enforce a style. Because, math tells us that ensuring a unified style is a problem by itself.

many language designers, cut corners. They think, O that's too flexible and create a multi-style problem, therefore my language will not have this syntax. That is confounding of issues. It will solve the problem near-term, not long-term. It's like the qwerty layout for typewritters. When typists types too fast and the key jams, the problem was solved by changing the layout so typists can't type fast.

comment at https://plus.google.com/+XahLee/posts/jdhaR786KDg

Linux: Control Sound Level with Command Line (on its own page)

Java Tutorial: The “extend” Keyword (minor update)

The Sounds of Obsolete Technologies 1990 〜 2000 (repost)

(xd.draw_vertical_grids(0,φwidth,0,φheight, lang_chars.length + 1)).map(function (x) {φsvg_element.appendChild(x);});

am starting to code javascript like Mathematica. Sweet!

and this is a major problem that lisp can't do, due to the nested paren. see Programing Language: LISP Syntax Problem of Piping Functions

this is a syntax induced semantic problem. similar happens to python, see Why Python's Lambda is Broken and Can't be Fixed

Concerning the Cut Off of the Flow of the Code

so, i have this nice code:

// …

            var xlink = getRandomPath();

            // 338 pages. 1/338 = 0.002958
            if ( xlink.search(/hrefgram2/) !== -1 ) {
                if ( Math.random() < 0.0029 * 0.0029 ) {
                    return xlink;
                } else { return getRandomPath(); }

            // 203 pages. 1/203 = 0.004926
            if ( xlink.search(/monkey_king\//) !== -1 ) {
                if ( Math.random() < 0.0049 * 0.0049 ) {
                    return xlink;
                } else { return getRandomPath(); }

            return xlink;

jslint is telling me:

Unnecessary 'else' after disruption.

after looking up, it means he says that my else is redundant, that i should do

if (…) {
            return xlink;
        return getRandomPath();

Redundant his ah.

didn't my mom say, if you can't say things nice, shuddayap?

actually, after thinking about it, i think the jslink style is better. My thought flow goes like this:

comment at https://plus.google.com/u/0/+XahLee/posts/F7CpXB3w3ES

Programing Language: Function Dependency

Hackers and the Foobar Phrase

JavaScript variable hosting, should you move variables declaration to top?

so, recently i've been thinkin about JavaScript's name hoisting. 〔➤ JavaScript: Variable & Function Declaration Order: Name Hoisting

am thinking, what a bizaro behavior. Was it accidental or by design? I think it must be design, because it can't happen by accident. But who would design a loon like that?

then, it just dawn'd on me now, there's precedence: lisp!

(let (x y z)
 ; ...

so, thinking about it, it's really alright. A bit odd, but alright.

i think i'll adopt to actually do move all my var declarations to top.

see this for context: JavaScript Name Hoisting and One-Liner Functional Style

comment at https://plus.google.com/+XahLee/posts/A4QLPLNi2QB

Programing Language: Fundamental Problems of Lisp

What'S the Airspeed of Unladen Swallow?

python unladen swallow wolfram alpha 3

Programer Humor: Wolfram Alpha Ad: Python Unladen Swallow

How Many Keystrokes Programers Type a Day?

most programing languages are garbage, when compared to Wolfram Language (aka Mathematica)

on power, practical useness, flexibility, and simplicity. Counting fancy ones like Haskell.

this is Mathematica: http://blog.wolfram.com/2012/07/20/on-the-importance-of-being-edgy-electrostatic-and-magnetostatic-problems-with-sharp-edges/

and, look at the use of math symbols.

Syntax Coloring in Editors

i can't decide which is the worst hack.

Windows Programing: AutoHotkey Syntax Problems

or, unix perl sh�t. Example: Unix Pipe as Functional Language

or Second Life, the Worst Hack in Universe

or web dev with JavaScript html css dom. Example: JavaScript: Array vs NodeList vs HTMLCollection

in comparison, i think my complaints about perl, python, are penuts.

of the above, i think the winner is either Second Life or JavaScript web dev. Second Life probably worse.

comment at https://plus.google.com/+XahLee/posts/Y4YKYApbMM4

Git: Save Working Tree in a Temp Storage: git stash

Computer Language: Predicate Function, Terminology, and Naming Convention

Language Syntax: Brackets vs Begin/End vs Indentation for Nesting (updated)

Keyboard: What's the Difference Between Alt Graph Key, Compose Key, Dead Key?

Unicode: Greek Alphabet α β γ δ ε ζ η

Unicode: Math Symbols ∑ ∞ ∫ π ∈ ℝ² (updated)

Linux Command to Download YouTube Video (updated. Thank to Christopher Wellons)

Keyboard Enter/Return Key Symbol — a Survey (updated)

Short Survey of Keyboard Shortcut Notations (minor update)


What are OOP's Jargons & Complexities (OOP as Functional Programing) (old article. Updated dead links.)

Math Font, Unicode, Gothic Letters, Double Struck, ℤ ℚ ℝ ℂ ℍ ℜ ℑ ⅇ ⅈ (updated)

The Moronicities of Typography: Hyphen, Dash, Quotation Marks, Apostrophe (minor update)

Scala, Lift Web Framework

Lift (web framework)

Lift is a free web application framework that is designed for the Scala programming language. It was originally created by David Pollak who was dissatisfied with certain aspects of the Ruby on Rails framework.[4] Lift was launched as an open source project on February 26, 2007 under the Apache 2.0 license. A commercially popular web platform often cited as being developed using Lift is Foursquare.[5]

Beginning Scala by David Pollak amazon

Why You Need a Jog-Wheel? (updated)

How to Get Your Github ID

this is how you get your github id: https://api.github.com/users/xahlee

see also: Git: Setting Up Git on GitHub.

A value proposition is a promise of value to be delivered and acknowledged and a belief from the customer that value will be appealed and experienced.

Value proposition

Unicode in Ruby, Perl, Python, JavaScript, Java, Emacs Lisp, Mathematica (minor update)

new crotchet: all function parameter names should start with φ. Sigil for Function Parameter Names

Linux: Bash Manual in Chapters, Using Emacs for Info (updated)

Past Articles by Date