October 20, 2016

By the People, For the People

Our presidential debates have turned into a reality-TV shouting match, which should not be surprising given the background of the Republican candidate. Here is an antidote to the vitriol, and a reminder of what self-governance is all about. Please volunteer, organize, contribute, and vote.

Posted by David at 01:41 PM | Comments (0)

October 08, 2016

Integrity in Government

More than half of GOP insiders believe the Trump campaign can weather his misogyny and racism, which speaks volumes about the vision that Republicans have for government. For them, the racist vote is a path to power, principles be damned. And it clarifies how the GOP is destroying our democracy. Moderate Republicans such as Kelly Ayotte have started to disavow Trump, but the fact remains: a 2016 vote for any Republican is unconscionable. A vote for a Republican of any stripe feeds the destructive cynicism that created Trump.

In contrast, efforts by Russian spies to leak the most damaging emails from the Clinton offices actually reveal how squeaky-clean the Democrats are. At Goldman Sachs she was critical of banks behavior leading up to 2008; she supports free trade if it benefits labor and environment. And her emails reveal her close consultation with Elizabeth Warren on economic policy. Clinton in private is even better than I had assumed: she is a tireless coalition-builder who talks to both bankers and progressives and keeps her eye on the ball. Let's give her a Congress that isn't poisoned with cynicism.

Please join me in donating to as many Democratic congressional candidates as you can afford. This year I am donating more money than I have ever donated before, and I hope you join me. Senate candidates like the wonderful Governor Maggie Hassan need support, but even more, the highest impact can be had by donating to smaller Congressional races. House races can be surprisingly small-money affairs, and even just a few well-placed donations could help flip a seat.

Can your one donation move the needle? For non-incumbents in congressional races, it can. Consider that in an average congressional district, flipping about 3000 votes swings the election by 1%. Good candidates who start off unknown can earn several votes per dollar of outreach, because yard signs, door-knocking, local events, and advertisements can dramatically improve name recognition. So with one $2700 donation, you can easily move the outcome by a percent.

Can we flip Congress to the party that demands integrity in government? As stewards of the fragile American democratic experiment, it is our solemn duty to try.

Donate to these candidates to flip Congress:

MI-07: Gretchen Driskell - Pro-infrastructure pro-education state representative. Has $1m vs $1m opposing pro-gun pro-war partisan nut Tim Walberg.

NY-23: John Plumb - Navy veteran, representing Corning, Has $556,393 vs $1.1m opposing NRA candidate Tom Reed.

VA-05: Jane Dittmar - Moderate businesswoman and county supervisor. Has $282k vs $54k opposing anti-immigrant Tom Garrett for open seat.

PA-16: Christina Hartman - Civic activist from Lancaster County. Has $205k vs $203k opposing Republican nut Lloyd Smucker.

CO-03: Gail Schwartz - State senator advocating environment and education. Has $549k vs $986k opposing banking deregulator Scott Tipton.

CA-49: Doug Applegate - Military vet in San Diego. Has $135k vs $3.7m. 45.5% vs 50.5% opposing partisan nutjob Darrell Issa. Issa is the wealthiest member of congress, and a real asshole. Surprisingly, in his heavily republican district, Applegate is polling even, so a donation here could swing the district and also help change the tenor in Congress.

CA-21: Emilio Huerta - Representing agricultural workers in one of the poorest districts in the country, with majority latino demographics that should not vote for the party of Trump; yet Huerta is an underdog. He is a labor lawyer who won a contested democratic primary. Has $57k vs $1.3m and opposes oil-industry-supported David Valadao.

FL-07: Stephanie Murphy - Vietnamese-American Banker/Consultant/Defense specialist representing central Florida including Orlando. Has $154k vs $750k opposing anti-immigrant partisan John Mica. Constituents dislike Mica but do not know Murphy: in polling she is statistically tied with Mica despite having only 30% name recognition in the district (vs Mica's 60%), so a donation here could win the race.

CA-25: Bryan Caforio - Young lawyer advocating for the middle class, energetic campaigner. Has $137k vs $650k, opposing anti-tax pro-gun Steven Knight.

IN-09: Shelli Yoder - Former Miss Indiana and business school lecturer competing for an open seat. In a statistical tie, has $504k vs $612k opposing super-rich tennessean out-of-towner Christian Conservative Trey Hollingsworth.

CA-10: Michael Eggman - Small bee farmer representing small business in one of the poorest agricultural districts in the country. Has $461k vs $2.5m. 27.6% vs 47.7% opposing anti-tax Jeff Denham. Itís a rematch: Denham beat him with 56% of the vote in 2014.

AZ-02: Matt Heinz - Gay doctor, state representative for Gabby Giffordís seat. Has $290k vs $2m opposing Raytheon money recipient Martha McSally.

Posted by David at 10:26 AM | Comments (0)

June 17, 2016

Thinking Slow

For decades, high speed trading has been sucking the blood out of the world's capital markets, and the answer has been clear for some time: find some way to force transactions to move more slowly.

So today's approval of IEX as an exchange is a big deal. How much do you have to slow down trades to get a fair deal? IEX has found that 350 microseconds is enough! Less than 1/100 of the time of an eyeblink for a human, that's enough time for a photon to travel about 60 miles. For computers, that is apparently slow enough to make high-speed arbitrage completely untenable.


Posted by David at 10:01 PM | Comments (0)

May 01, 2016

Whose Country?

When Trump said today "we can't allow China to rape our country," it reminds me of my conversations with folks on an airplane to Tennessee a few weeks ago, which is deep Trump territory.

No matter how often I reminded my airplane seatmates that I grew up in New York, I am an American citizen, I work for an American company, I went to school in America, I do not speak Chinese, that my family has been in America for more than 100 years, that my ancestors served in the U.S. army, that I do not like China or the way their government is run, it did not matter.

I look Chinese. So the Trump supporters kept referring to China as "your country," telling me how terrible "your country" was (meaning China) and telling me what they thought of "your people" and "your leaders". Watch the pronouns "us" and "them" when you chat with a Trump supporter: they can't help it. It doesn't matter how American I am. I am "them." I am the bad guy.

The Trump supporters proudly reminded me they do not believe anything in "the media." They also did not believe anything I would say unless I happened to agree with them. That conversation was frightening in so many ways.

How to Mobilize a Mob

I hate how dishonest and corrupt the Chinese government is, and I hate the direction China is bringing the world: they have built an economy on exploitation, pollution, poor safety, and lack of ethics, and they have gotten the world to follow suit. But when Trump talks about China "raping" the U.S., he is not making the same economic argument I make when I criticize China. He is using racist code to mobilize the mob against the Chinaman. He is turning his supporters violently against me. Because of the way I look.

My father is a Massachusetts Republican and just returned from the GOP caucus where delegates get picked. He says the depth and strength of the feeling of support for Trump should not be underestimated. All these white guys think Trump is very interesting, that his language is just colorful. They think it will be great for him to "tell it like it is," and that it's "time for a change." They are incredibly defensive if you criticize Trump.

But they are wrong. Trump's game is not honesty and it is not change: his game is conflict.

First he went after Mexicans. Then the Muslims. Now he has started on the Chinese.

Who is Raping This Week?

If you are a wealthy white male BMW-driving Catholic highly-educated engineer living in the suburbs, you might not understand the problem. But make no mistake: Trump is not on your side. Trump only operates by turning people against each other, which means that eventually it will be your turn to be the minority.

There is something about you that the mob does not like. It might be your religion, your job title, your education, your weight, your bank account, your travels, your child's condition, or something your parents did. You won't anticipate it because your offense has nothing to do with who you really are. But Trump's skill is to find that reason that you are the "other." When he comes after you, it will be too late for you to speak up. The mob will already see you as the enemy, and nothing you say will matter. I experienced that in Tennessee.

This is how the Cultural Revolution played out. This is now Nazi Germany worked. We remember the Nazi's rounding up the Jews, but a mob under the spell of a despot will round up anybody they find disgusting: professors; landowners; church-goers; the infirm; the elderly; the Polish; the leaders; the unemployed; the writers; or the people who seem too sympathetic to all those disgusting people. Being white does not make you safe: it just means that you are not first.

Please do not support this monster.

Posted by David at 11:43 PM | Comments (1)

September 17, 2015

Starting at MIT

A couple decades ago I never finished a CS PhD at Cornell (really, I barely got off the starting block - I left with a masters soon after passing quals). So I've decided to go back to school. This September, I'm starting work on a CS PhD at MIT. It's been almost 20 years since I've taken any classes, and computer science has gone through several sea changes in the intervening years.

I am taking two classes at MIT this term: 6.858 and 6.869. That is, a systems security class, and a vision deep-learning class.

I've devoted the last few years of my life to the idea that it's important to teach people how to program and that the key is to learn how to program intentionally, to understand how to make things with software.

But the takeaway from security and deep learning so far seem to be (1) even if you do your best to make things intentionally, they can be defeated (we're learning a whole spectrum of security exploits); and (2) there are ways to build systems without detailed intention that outperform intentionally designed systems (deep learning is winning).

In this new world, how to people put together software on purpose? How are we supposed to improve, collaborate on, and evaluate what we're doing?

Anyway, it's very fun to go back to school. Lots of interesting stuff going on to learn.

Here is my academic homepage at MIT.

Posted by David at 03:50 PM | Comments (0)

September 06, 2015

When to Sell

I guess a good time to sell is when I start writing blog posts about the stock market, down about 8% since I posted.

I do think that the big problems haven't in China haven't hit yet, though: a pile of (difficult to discern) bad debt related to government influence over the banking system's investment in state-owned enterprises.

There is an overhang of bad investments in China which is on a scale which perhaps the world has never seen before. Entire ghost cities in plain view. When will the bad debt behind these projects unwind?

Posted by David at 01:00 PM | Comments (0)

August 12, 2015

One-Off Depreciation

On vacation in Greece, reading about the big economy that is even more screwed up than here: China. It is interesting to read about how the yuan depreciation is related to markets as far and wide as copper and corn.

Here is the most interesting reading for the day, a discussion of the Chinese copper carry trade written a couple months ago.

The copper carry-trade is a mechanism that western banks use extend loans to Chinese companies at high Chinese interest rates, while denominating the loans in dollars instead of yuan. It is a way of circumventing Chinese currency controls and make a pile of money for very little risk.

Did you know that China holds about 40% of the global copper stock in warehouses, due to this banking trick? That number doesn't include ongoing consumption, by the way. All this copper is held as collateral for financial transactions that circumvent Chinese currency controls, supplying foreign capital to Chinese business, making up about 31% of the short-term capital in China.

The carry trade has only been possible because the Chinese government has pegged the yuan to the dollar. Suddenly today the game has changed: a rapidly dropping yuan means the copper carry-trade is no longer a guaranteed money-winner.

From the carry-trader's point of view, the yuan drop looks like an attack.

"It is a lot of leverage and we may be just at the beginning of the unwind.... The PBOC can transfer the pressure offshore, they are saying you guys, foreign demons, have to foot the bill."

It is doubtful that China really has it in for London commodities traders, however. The real concern, from the point of view of China, appears to be a weak banking system plagued by nonperforming loans to government-run enterprises. From the other article:

... It actually gets directly to one the puzzles of Chinese monetary policy. That is, if Chinese banks are flush with cash as the PBOC claims and loan demand is low, why does the PBOC continue to release cash into the system via reserve rate cuts rather than cut interest rates when even the best SOE is facing real interest rates of approximately 10%? This would seem to have a much larger impact on the economy...

There appears to be a couple of reasons. First, China is still heavily dependent on capital inflows to finance its continued development.... The PBOC appears to be making the tradeoff of trying to continue to attract capital by keeping interest rate high even if that risks choking off businesses with absurdly high real interest rates...

Second, despite all public pronouncements to the contrary, this implies that banks are weaker than is believed... Given the PBOC and government mandate to buy up low yielding government bonds and continue lending to LGFV whether they are paying or have any prospect of paying, banks already appear weaker than public pronouncements. Slowing the capital inflow or giving reason for capital to flow out could really create problems for China's major banks.

So basically, China has been pumping cash from its huge foreign reserves to prop up the yuan and keep domestic interest rates high, to attract foreign capital and prop up its weak banks.

But Chinese investors have been using the opportunity to move money out of China. And rather than shoring up Chinese banks, the high interest rates enable the copper carry trade that siphons Chinese reserves into copper holdings by western banks. The declining foreign reserves in China are a measure of the drain of yuan-denominated capital from its economy, and the high cost of borrowed yuan is making it hard to do real business in China.

Now that China has let is currency drop, it seems to be giving up on private capital: no more copper carry trade, no more foreign capital, and no more holding the line against capital flight. The shift would seem to goose China's real economy at the expense of its bankers. But it is not clear if the strategy will work, because it will also rob China of its major source of capital. China is in a pickle because it doesn't have a very healthy internal banking system. It depends on the strength of foreign banks. We can now see if capital flight with a declining yuan "could really create problems for China's major banks," and if this is a situation that will cause real problems for the Chinese economy.

In the next couple days we will see how China responds to an estimated $1.1 trillion of US denominated carry-trade debt being sucked out of the country. How quickly will the capital take flight?

Yesterday, China promised that the 2% devaluation was a "one-off depreciation" only. But they lied, and they repeated it again today. How many times can China repeat its "one-off" currency devaluation before causing a bit of panic? One estimate is that the dollar peg has resulted in a 16% overvaluation in the yuan, and that China will have to depreciate more than that amount if it wants a cheap currency that will bring back the pricing advantage it saw a few years ago.

Posted by David at 08:38 AM | Comments (0)

July 29, 2015

Confidence Games

This month I have been re-balancing my retirement savings, but it is a sobering exercise.

If we have money to save, where do we put it today? Let us review the major asset classes.

You get the distinct feeling that the wealthy-powerful class in Asia, Europe, and North America have steered capital into their own pockets for so long now that there is a huge imbalance in the distribution of capital in the world.

  1. Every asset class globally is experiencing a bubble simultaneously.
  2. So much capital has been idled that real economic activity is being starved.

So... if we have money to save, it seems like this situation is of our own making. What the heck are we doing to ourselves?

Where would you invest today?

Posted by David at 06:32 AM | Comments (1)

October 17, 2014

Making a $400 Linux Laptop

At some point, every programmer should learn how to use the Unix command-line.

So I started teaching Piper a bit about how to use a command line shell this week. We installed crouton on her Chromebook, and we used it to look at a couple files and build little shell script. That continuing adventure is a story for another time.

But crouton was the surprise for me. I immediately fell in love it. The Linux-on-chromebook setup was so great that a few days later, I made another one. It's an amazing deal: for about $400, I got a lightweight linux box with 4GB RAM, 128G SSD mostly empty, 8 hours of battery, and a touchscreen! Here is what I bought:

The new C720P with 4GB ram, but the cheap configuration with a 16G SSD

MyDigitalSSD SC2 Super Cache 2 42mm SATA III 6G M.2 NGFF M2 SSD Solid State Drive (128GB)

It was a terrific little project, very easy. The basic idea is to follow the SSD upgrade instructions here

There are only a couple gotchas. One is at the start: you want to begin by burning a recovery image on a USB stick, which should just take a couple minutes. But the instructions above say to use the URL "chrome://imageburner" to make this, and it doesn't actually work on the c720p (it runs, but then it hangs). Instead, go to the Chrome App store and search for the Chromebook Recovery Utility. That will make a recovery image quickly.

Then you're ready to upgrade the disk! Piper and I unscrewed the laptop and followed the instructions here - it was a great chance for us to take a look at all the innards of the computer, and it was a very easy upgrade.

The only other gotcha is that he M2 SSD card doesn't go in either way: there is a "right" and a "left" - one side with four gold connectors and the other side with five. The big brand-name sticker on the new SSD we got was on the opposite side as the old one, which confused us; it just needed to be flipped upside-down, sticker down.

Then we reassembled and rebooted the computer, stuck in the recovery USB drive, and then followed this page's advice on how to enable developer mode. In short: ESC-F3 and Power. Then control-D, and then wait. Apparently converting the huge 128G SSD to developer mode, takes a little while; but there is an ASCII art progress bar at the top of the screen.

Finally, we downloaded crouton from goo.gl/fd3zc, and then we used ctrl-alt-T to bring up a crosh tab; entered shell; then ran the crouton script to install a command-line-only debian.

It's terrifically functional - I used it to build a current build of node.js and some other things. It's not terribly secure, because anybody who can log into the machine can get root access. But for student work, it's great!

Posted by David at 08:27 PM | Comments (0)

October 03, 2014

Teaching About Data

How do you teach beginning programmers about data in the internet age?

  • Teach the kids how to learn on their own: for example, can you find and use technical data sources using Google? Self-teaching is a key hallmark of successful students.
  • Teach using real-world mainstream idioms: Javascript, jQuery, HTML5. This lets kids directly apply code examples from the web. We take advantage of Pencil Code to make this easy.
  • Keep things real: it is more meaningful if we use real data to answer real-world questions!

It is a real pleasure to see students learning to learn independently this way.

Last week I taught a class about data that went very well. It was interesting enough that maybe others might want to try to do the same.

Using Google to find a Technical Article

The class started with an acronym: JSON. A lot of data on the internet is made available using a technology called JSON, so we began by searching Google for code ideas by using the query [Using JSON to get public data]. That query lead us to a few articles, including a blog post by Mark Lee....

Continue reading "Teaching About Data"
Posted by David at 12:54 PM | Comments (0)

July 10, 2014

Code Gym

At the first Google I/O Youth program this year, we used a new open-source website, the Pencil Code Gym, and it was a smashing success!

The website is a place where beginners can create open-ended creative projects in graphics, music, or interactive fiction, all using a little bit of simple code.

It is based on Pencil Code, which means that you program in CoffeeScript with the Pencil Code editor and turtle library. It comes with lots of ideas, hints, and a nice on-line reference. The students who came through to use it had a wide range of backgrounds and knowledge, with many first-time coders and also a few experienced code-jockeys.

The kids were bold and tried every project we had to offer. I was surprised by the musical talent of some of the kids (check out the projects), and I particularly enjoyed working with the deaf kids who attended - some of the deaf kids even did musical projects.

You can see the projects put together by code gym students here, at the Code Gym Stage.

Posted by David at 05:18 PM | Comments (0)

May 23, 2014


Here is musical.js, which is a small (less than 17K minified) javascript library that can translate from ABC notation into WebAudio, for playing simple tunes on any modern browser. It has no dependencies, and it can be used as a plain script, an AMD module, or as a node.js module. It also includes a simple synthesizer for creating your own instrument, including a basic electric piano sound.

The library is really simple to use. Basically, include the script musical.js, and then:

piano = new Instrument('piano');

Then with any WebAudio browser, you will be Baahing with the Black Sheep, Twinkling with the Stars, or singing your ABCs with me. The notation used is called ABC Notation, and it is used for a lot of simple sheet music online.

Less-simple music can be played just as easily. Here are some short examples: Minuet, September, Sonata and Moonlight.

The library comes out of work from beefing up music support in Pencil Code. The WebAudio sequencer in that library has improved enough that it deserves to be a separate library.

You can also play with it as part of the turtle library on pencil code here: that example is a simple interactive piano keyboard where you can see the keys.

Have fun. Let me know if you encounter any problems, or if you have any ideas for improvements. Always looking for open-source contributions.

Posted by David at 03:39 PM | Comments (1)

January 31, 2014

Pencil Code at Worcester Technical High School

I spent a day last week at Worcester Technical High School with all their CS students, using Pencil Code as a teaching tool.

Vocational students are motivated by real-world applications, and the teachers at WTHS are amazing. They bring their entire group of students through four years of rigorous CS classes, ending with AP computer science in their Senior year. "There is a difference," the teachers explain, "between offering CS exposure and teaching mastery. We teach mastery."

For this group of CS-focused students who have been learning Java, ASP.NET, and HTML, Pencil Code is a terrific tool. The instant feedback lets them apply and experiment with difficult concepts quickly. And because it is so open, Pencil Code is lets them assemble concepts from varied areas.

Here are the worksheets we used in Worcester:

Combining Three Languages using HTML
Exploring Recursion with Fractals
Using Subclasses to make Moving Sprites

In all three of these lessons, the turtle is a starting point, but it is just a stepping stone into real-world applications and deeper concepts.

The day was terrific. We found that we taught some unexpected lessons. The teachers pointed out that the indent-based syntax of CoffeeScript (and the instant-error checking in the IDE) connected with several kids for the first time who now could really "get" how scoping works. Some kids never indent their blocks, but with CoffeeScript, they have to! And surprise - once it is indented, they can see clearly how it works.

After the day, the AP students in the group suggested "We should start with Pencil Code!"

I am holding hackathons to build more lessons and materials that take advantage of the Pencil Code environment, and to improve the tool itself based on what we are seeing in classrooms. The first hackathon is on February 14 - sign up at hack.pencilcode.net.

Posted by David at 08:56 AM | Comments (0)

January 19, 2014

A Bad Chrome Bug

The latest version of Chrome has a bad bug that seems specific to the GPU in my (Samsung series 9) laptop. It actually took me a couple days to notice the problem and realize it was Chrome's fault and not the fault of the underlying website.

Here is the bug: when you visit a fast website that has no images (and no javascript-rendered changing content), Chrome does not render anything. It just leaves the page blank. It will render as soon as you scroll or cause something to redraw.

My laptop does not have an exotic configuration - it is a 2012-era windows laptop with a very vanilla Windows 7 setup, so I suspect many people may be affected by the bug.

The funny thing, the bug is something you may not have noticed because almost every webpage we might visit day-to-day contains an image. And pages that do not have images - well, as soon as you scroll, they render, so you might have thought that the webpage was slow and then popped in when you scrolled.

If you use Chrome, try it out on your computer. Does it happen to you? To test, here are a couple links to webpages that have no images. If they render for you, try pressing "refresh" to see if they render once they're cached and fast:



If you see the problem, put in information about your hardware, and vote for the bug to be fixed here:

(Update: found an old issue that appears to have reported the same problem in beta - https://code.google.com/p/chromium/issues/detail?id=325309)

Posted by David at 10:58 AM | Comments (1)

January 09, 2014

PhantomJS and Node.JS

I'm setting up a guide for contributing to PencilCode.

There are now integration tests. In about 20 seconds, the "grunt test" command starts a local development server, starts a headless webkit, and tests most of the core functionality on the website, including browsing users and directories, loading, editing, running, saving, and deleting programs, and using passwords to log in. You get this all for free by just installing node.js and the grunt build tool, and building the source.

The integration tests look like this: edit_code.js - they are low-level but surprisingly clean and quick. The tests are designed to be run by mocha (a command-line javascript test runner), and they depend on node-phantom-simple, which is the lightest-weight headless webkit I could drive from a node.js build environment. The Gruntfile sets up everything. One of the curious things is that the development server actually runs as a proxy server. This allows it to intercept test-browser requests to full DNS names even though it doesn't own the DNS name.

Why Tests are Awesome

The test setup is designed to maximize developer productivity: the default test target runs tests very similar to production, with all the code compiled and minified, but the "devtest" target runs the same tests directly against unminified unoptimized source code, for easier debugging.

The beauty of a good integration test is that the code can now be aggressively changed without fear that the change will break something important. If some change breaks something, we can know in 20 seconds.

Right now my integration tests run quickly, because my test matrix is small. As the test matrix grows larger, many open source projects use jquery-turtle as well; then it will be time to refactor the code so some interesting features can be added.

Posted by David at 07:29 PM | Comments (1)

January 03, 2014

Integration Testing in Node.js

What's the best way to run integration tests on an AJAX-heavy website?

I have been toughening up the pencilcode.net deployment environment. (git repos here.) While the pencilcode server is an nginx webserver backed by a small python-uwsgi app server, the pencilcode development environment is 100% javascript, with a node.js and npm and grunt-based build, and a small express.js test server that proxies backend calls to the production server.

If you think that's just a lot of hipster coder buzwords, wait... there's more.

This morning I broke pencilcode.net due to a code change: while refactoring the editor source code to use proper require.js organization, I messed up by bringing in an old version of seedrandom that wasn't compatible with AMD loading. Seedrandom is my own library, and so it was doubly my own fault! The result was that all password checking was broken on the site for a few hours. The bug took about 10 minutes to fix: I just had to use bowercopy to upgrade seedrandom to its latest bower package, then run the requirejs optimizer, then redeploy.

But the real bug? I don't have any integration tests on pencilcode.net. I should have never pushed broken passwords in the first place. While I have some little unit tests, I really need end-to-end integration tests that bring up the whole website, browse it with a headless browser, and click around authenticating and editing and running and saving, to make sure it all works as expected.

The 2010 way of doing this used to be a big system like Selenium. But it feels like in 2013 I should be able to do this in lighter-weight way. I have seen that grunt-phantomjs works pretty well with QUnit unit tests. But almost all the javascript-based tools I've seen are designed for tiny unit tests.

How do I run tests that exercise the whole system end-to-end? Maybe something like travist's jquery.go.js? Has anybody found the right way to do integration tests in the node.js world?

Posted by David at 06:52 PM | Comments (0)

December 20, 2013

Second Edition of Pencil Code

The best parenting advice: before your children grow up, teach them something. They will remember it forever.

So in that spirit, here is an activity to do with your daughter or son over the holidays: give and play with the second edition of Pencil Code (just released). Teach them how to write little computer programs.

The new edition adds a 20 page appendix with a CoffeeScript tutorial, which is particularly helpful if Mom and Dad do not create software for a living. If you already got the first edition and you wish you had the tutorial, do not worry - get the tutorial on the web here and print it.

While you are playing with Pencil Code, also be sure to look at the extra free materials on guide.pencilcode.net - there are handy printable protractors, reference sheets, activities, and videos. And almost all the material in the book is available online for free. If you do not want to use paper, you can just go to pencilcode.net and play for free.

Still, the book makes a terrific present. Children show their incredible sense of wonder when leafing through a little handbook of examples of magical code, each one illustrated in color. Each page is a map to a little adventure, a puzzle and a discovery waiting to unfold.

The book has more than 100 little programming projects, and they range in depth and ability from 1st grade up to 12th grade. The first page hows how to make a webpage that draws a simple line. The last one shows how to make an artificial intelligence that will beat you at tic-tac-toe. In between, draw a flower, make a game of tag, or draw the Mandelbrot set.

It is a little book crammed with ideas, designed to last for a decade. As long as it is in your house, it is a reminder: there is something much cooler than playing computer games: making your own.

(Also, while you're getting the book - Amazon didn't bring the reviews of the first edition along to the second edition, so leave a nice review!)

Posted by David at 12:22 PM | Comments (0)

December 18, 2013

Learning to Program with CoffeeScript

Is CoffeeScript a good first programming language to learn?


I have written a new tutorial for beginners to learn to program with CoffeeScript.

Like Python, CoffeeScript has a punctuation-light syntax that is easy to type so that beginners can get straight to the essential concepts instead of fiddling with semicolons and matching curly braces. And yet it is a real language used by pros, so you can learn the essential concepts that you will see in other languages: variables, algebraic expressions, control flow, functions, lists, objects, classes, closures, exceptions, and (if you use Iced) even continuations.

The big advantage of learning CoffeeScript over Python is that you can start right now in your browser, without installing anything! Although CoffeeScript doesn't have the same full-featured standard library that Python has, jQuery makes a fine standard library. To help beginners, I have put together jQuery, a turtle graphics plugin jQuery-turtle, and a syntax coloring editor on pencilcode.net.

The tutorial teaches you how to program in CoffeeScript by building a game of hangman from scratch. It takes a couple hours to learn enough programming to make hangman. You will learn about:

  • Memory and naming
  • Computer arithmetic
  • Using functions
  • Simple graphics
  • How to make a program
  • Input and output
  • Loops and choices
  • Delays and synchronization
  • Connecting to the internet

At the end we will have a game we can play.

Here is the tutorial: Learning to Program with CoffeeScript.

Posted by David at 10:30 AM | Comments (0)

October 2016
Sun Mon Tue Wed Thu Fri Sat
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31

Recent Entries
By the People, For the People
Integrity in Government
Thinking Slow
Whose Country?
Starting at MIT
When to Sell
One-Off Depreciation
Confidence Games
Making a $400 Linux Laptop
Teaching About Data
Code Gym
Pencil Code at Worcester Technical High School
A Bad Chrome Bug
PhantomJS and Node.JS
Integration Testing in Node.js
Second Edition of Pencil Code
Learning to Program with CoffeeScript
Teaching Math Through Pencil Code
Hour of Code at Lincoln
Hour of Code at AMSA
A New Book and a Thanksgiving Wish
Pencil Code: Lesson on Angles
Pencil Code: Lesson on Lines
Pencil Code: a First Look
CoffeeScript Syntax for Kids
CSS Color Names
For Versus Repeat
Book Sample Page
Teaching Programming and Defending the Middle Class
TurtleBits at Beaver Country Day
Book Writing Progress
Lessons from Kids
Await and Defer
Ticks, Animation, and Queueing in TurtleBits
Using the TurtleBits Editor
Starting with Turtlebits
Turtle Bits
No Threshold, No Limit
Local Variable Debugging with see.js
Mapping the Earth with Complex Numbers
Conformal Map Viewer
Jobs in 1983
The Problem With China
Omega Improved
Made In America Again
Avoiding Selectors for Beginners
Turtle Graphics Fern with jQuery
Learning To Program with jQuery
Python Templating with @stringfunction
PUT and DELETE in call.jsonlib.com
Party like it's 1789
Using goo.gl with jsonlib
Simple Cross-Domain Javascript HTTP with call.jsonlib.com
Dabbler Under Version Control
Snowpocalypse Hits Boston
Heidi's Sudoku Hintpad
Social Responsibility in Tech
The First Permanent Language
A New Framework For Finance
Box2D Web
Lincoln School Construction
Stuck Pixel Utility
Fixing the Deficit
Cancelled Discover Card
Tic Toe Tac
Toe Tac Tic
Tutorial: Root Finder
Wiki Javascript at dabbler.org
What SAT Stands For
Computer Club
Tutorial: Cannon Game
Tutorial: Pascal's Triangle
Tutorial: Custom Poem
Tutorial: Concentration
Tutorial: Histogram
Tutorial: Maze Maker
Tutorial: Tic Tac Toe
Tutorial: Mastermind
Tutorial: Polygon Drawing
Tutorial: Caesar Cipher
Tutorial: Guess My Number
Tutorial: Ten Followers
Tutorial: Fifteen Puzzle
Handheld Glasses-Free 3D
Making a Time Machine
The Next Grand Deception
There is Brilliance in this Language
Minimum Hint Sudoku Hunt
Collected Hacks
Python pi.py Spigot
The Mystery of 355/113
It's Not About The Answer
Solid Geometry
Teaching is Hard
A Mathematical Notation Question
Second Coming of Wyden-Bennett?
Reading JQuery Sources
Older Writing