FYI.

This story is over 5 years old.

Tech

An Analysis of Barack Obama’s First Line of JavaScript

President Obama became the first president to publicly code—here’s what he wrote.
​Screengrab: White House

​Yesterday, Barack Obama became the first pr​esident to ever "write a computer program" (at least publicly) as part of a White House event. But now that Obama has mastered JavaScript, can we expect him to fix any future bugs on Healthcare.gov? Not quite.

Obama didn't actually write a computer program. Instead,  ​he wrote one single line of JavaScript that moved Elsa, a cartoon character from the Disney movie Frozen, forward exactly 100 pixels.

Advertisement

That's according to Hadi Partovi, CEO of Code.org, the group that hosted the hour-long basic coding le​sson for 20 elementary school students (and the President). The initiative challenges teache​rs around the country to teach their students coding skills.

Here's what Obama's code looked like:

moveForward(100);

"Hello World!," it ain't.

There's not all that much to analyze here, but Obama apparently has good coding instincts. The President typed the code himself after a short tutorial, Partovi wrote on the quest​ion-and-answer site Quora.

Obama knew that JavaScript is a case-sensitive language. He also apparently knew that if you don't close your parentheses, you tend to screw things up. And if you leave out the semicolon, the computer doesn't know that the line of code is done. Or maybe he didn't know any of that, and is just good at following instructions.

"The President asked if he needs to type the F in upper-case, and he got the () and the ; right too, he was very precise and didn't make a typing mistake," Partovi wrote.

The code is "not rocket science," Partovi wrote, but that's the point (Obama used an as-of-yet unreleased version of Patovi's coding tutorial, apparently). "That's how computer science starts," he said. "You don't write a fully-fledged game when you write your very first line of code."

He's right, of course. And it's probably worth getting children into the the idea that they can code. In general, more people should learn how to code, or at least know how it works. But as for the idea that everyone should learn how to code? Well, Obama should probably keep running the country for the time being, at least.