Cover photo
Douglas Crockford
Works at PayPal
Lives in San Jose
19,352 followers|2,400,201 views


Douglas Crockford

Shared publicly  - 
That's Morse Code! They're Still Alive!

Unicode is (or should be) the single encoding for the transmission of all of the world's text. But Hollywood teaches us that when all else fails, our very survival may depend on our knowledge of Morse Code. Samuel Morse was a portrait painter with an interest in electricity. He designed his telegraph code so that the most frequent characters would require the least time to transmit, so it was not only a character encoding, it was also a data compression algorithm.

Morse code is a useful thing to know in case you are ever trapped in a submarine, or in a mine, or on a starship, and you need to communicate with your rescuers or the rebel fleet. Having to learn 26 things is hard, especially when motivated by such an unlikely contingency, so some mnemonic assistance is desired.

You should already know V (for Victory!) from the opening movement of Beethoven's Fifth.

  V is dot dot dot dash.

You know S and O from the SOS distress signal.

  S is dot dot dot.
  O is dash dash dash.

That knocks the number of things we have to learn down to 23.

There is the frequency clue. The most frequently used letters in English have short and simple Morse encodings, so

 E is dot.
 I is dot dot.
 T is dash.
 M is dash dash.

That knocks the number of things we have to learn down to 19, which is still a huge number. You could hope to save the day with 7 letters, but I think it is pretty unlikely.

So let's translate the remaining codes into words, where a dot becomes a vowel, and a dash becomes a consonant. We will form words that include the letter that the word represents.  

 A is AM dot dash
 B is BEAU  dash dot dot dot
 C is COCO  dash dot dash dot
 D is DIE  dash dot dot
 F is OOFY  dot dot dash dot (that's right, oofy)
 G is GNU  dash dash dot
 K is KIT  dash dot dash
 L is ALOE  dot dash dot dot
 N is NO  dash dot
 P is EXPO  dot dash dash dot
 R is ORE  dot dash dot
 U is OUT  dot dot dash
 W is OWL  dot dash dash
 Y is YUCK dash dot dash dash

 Think of the 4H club and their advisor, Mister 4H himself: Harry Herbert Hoover Heever.

H is dot dot dot dot.

That leaves the four lousy letters J, Q, X, and Z.

 J is IJJJ  dot dash dash dash
 Q is QQUQ  dash dash dot dash
 X is XOOX  dash dot dot dash
 Z is ZZOO  dash dash dot dot

Don't ever forget this. The fate of the galaxy may depend on it.

Douglas Crockford

Shared publicly  - 
• With a bullet

Some of the early programming languages used a period to indicate the end of a statement, mimicking the use of the period in prose. This had problems due to the overloading of the dot: It can also mean decimal point and member selection, so it was mostly abandoned. (But Erlang still uses it.)

Denoting of the end of a statement is not necessary if there is a perfect mapping of statements to lines. If each line contains exactly one statement, and if each statement is fully contained in a line, then line breaks are sufficient to determine the beginning and end of statements.

But that is not sufficient. Sometimes a statement cannot fit on a single line. So FORTRAN allowed for having continuation cards so that a statement could be continued on the next card. FORTRAN did this by putting a character in column 6, a column that must be blank for the first line of a statement. FORTRAN was extremely influential. There are nasty FORTRANisms that can be found in most of our modern languages. But fortunately, the nasty column 6 bit has died away. Other languages dealt with continuation in other ways, with signalling characters, or indentation, or incompleteness.

The C languages rely on ; and } to explicitly terminate statements. JavaScript attempts to make termination optional with a mechanism called Automatic Semicolon Insertion, but unfortunately it is not  competent.

I think a better approach would be to explicitly indicate the beginning of statements. A statement could continue as needed onto subsequent lines until the beginning of the next statement.

Every statement should start with a • character. We can then read a program like a bullet list or outline.
Douglas Crockford's profile photoGreg A. Woods's profile photoDor Kleiman (configurator)'s profile photo
+Douglas Crockford not too stupid, too lazy. 

Douglas Crockford

Discussion  - 
Should JSLint warn on get and set?

We are transitioning way from use of mutation and side effects. Getters and setters, by enabling side effects on simple assignment, seem to be going in the wrong direction.
50 votes  -  votes visible to Public
Warn on get and set
No warning
Douglas Crockford's profile photoFelix E. Klee's profile photoJames Long's profile photoVishal Srivastava's profile photo
+Евгений Орехов The practicality is there. There are a lot of beautiful pattern that gets enabled by using a functional approach.

For example, if things dont change after being created then the concept of memoization gets enabled which improves performance significantly.

Hope that helps :)
Add a comment...

Douglas Crockford

Shared publicly  - 
Small group sharing from Google

Douglas Crockford

Shared publicly  - 
JavaScript's function scope rule says that an inner function can implicitly see the variables of outer functions and must explicitly declare its own variables.

|   function javascript() {
|       var a = 0;
|       function inner() {
|           var b = a;
|       }
|   }

So imagine another language that does it the other way. There is no 'var' statement because variable declaration is implicit. But to see an outer variable, you must first use a 'see' declaration.

|   function another() {
|       a = 0;
|       function inner() {
|           see a;
|           b = a;
|       }
|   }

Any program that could be written JavaScript could also be written in the another language. The difference is in programmer convenience (very low value) and error avoidance (very high value).

Which language would be better at avoiding declaration and scope errors?
266 votes  -  votes visible to Public
Neither has a significant advantage
Yoan Blanc (greut)'s profile photoDouglas Crockford's profile photoJoe Gibbs Politz's profile photo
Yup, my point with the see/var example was that the "see" was unnecessary/not meaningful there, underscoring the benefits of having explicit declarations.

Agreed on "used-to" arguments.

My position is:

1. I don't think "see" adds much value for capture of immutable variables, because I don't believe that capturing immutable variables is the source of many errors. (What's an example of this happening?)

2. I do think it could add value for mutable variables, where I think capture is more fraught.
Have him in circles
19,352 people
Sunil Parekh's profile photo
Aguirre Maira's profile photo
Emmanuel de Saint Steban's profile photo
Ashutosh Verma's profile photo
Jim Gorman's profile photo
Britische Andrews's profile photo
Jerry Peralta's profile photo
Eric Goforth's profile photo
Cristiano D'Avila's profile photo


Douglas Crockford

Shared publicly  - 
Distrust & caution are the parents of security.

Be neither silly, nor cunning, but wise.

Three may keep a Secret, if two of them are dead.

To whom thy secret thou dost tell, to him thy freedom thou dost sell.

If you would keep your Secret from an enemy, tell it not to a friend.

[Benjamin Franklin, Poor Richard's Almanack]

Douglas Crockford

Shared publicly  - 

How much do you make? Have you ever contemplated suicide? Are you now or have you ever been... ? Are you aware of the fact... ? I have here before me.... Electrical information devices for universal, tyrannical womb-to-tomb surveillance are causing a very serious dilemma between our claim to privacy and the community's need to know. The older, traditional ideas of private, isolated thoughts and actions--the patterns of mechanistic technologies--are very seriously threatened by new methods of instantaneous electric information retrieval, by the electrically computerized dossier bank--that one big gossip column that is unforgiving, unforgetful and from which there is no redemption, no erasure of early "mistakes." We have already reached a point where remedial control, born out of knowledge of media and their total effects on all of us, must be exerted. How shall the new environment be programmed now that we have become so involved with each other, now that all of us have become the unwitting work force for social change? What's that buzzzzzzzzzzzzzzzzzzing?

[Marshall McLuhan, The Medium Is The Massage, 1967]

Douglas Crockford

Shared publicly  - 
I will be headlining at Midwest JS in Minneapolis.
August 10th, 11th & 12th, 2016 in Minneapolis, Minnesota! Midwest JS is a premier technology conference focused on the JavaScript ecosystem. The conference has been a tremendous success the past two years and we hope to make it even better in 2016! The conference will be held in downtown ...

Douglas Crockford

Shared publicly  - 

Douglas Crockford

Shared publicly  - 
I will be headlining at the Great Indian Developer Summit in Bangalore and Pune.
With over 35000 attendees benefiting from over eight game changing editions, GIDS is the gold standard for India's software developer ecosystem. The summit has seen participation from 200+ sponsors and 600+ speakers since 2008. Join the 2016 edition for cutting-edge content that will squarely ...
Gopal Venkatesan's profile photo
This is great.

+Douglas Crockford I have relocated back to Bangalore, so let me know when you'll be here I'll try to meet you :)

Douglas Crockford

Shared publicly  - 
Edward Snowden is an American Hero.

It is time that we bring him home.
Have him in circles
19,352 people
Sunil Parekh's profile photo
Aguirre Maira's profile photo
Emmanuel de Saint Steban's profile photo
Ashutosh Verma's profile photo
Jim Gorman's profile photo
Britische Andrews's profile photo
Jerry Peralta's profile photo
Eric Goforth's profile photo
Cristiano D'Avila's profile photo
Map of the places this user has livedMap of the places this user has livedMap of the places this user has lived
San Jose
_ __ ___ ____ _____ In the Twenty First Century!
On the internet, nobody knows you're a Doug.
Bragging rights
I discovered the JSON Data Interchange Format. I also discovered that JavaScript has good parts. That was the first important discovery of the 21st Century.
The Boss of You
  • PayPal
Basic Information