18

According to a recent Wired article, US President Barack Obama was the first president to write code:

President Barack Obama told the world that everyone should learn how to code. And now he’s putting his money where his mouth is.

Earlier today, to help kick-off the annual Computer Science Education Week, Obama became the first president ever to write a computer program. It was a very simple program—all it does is draw a square on a screen

[...]

Partovi says the president himself didn’t complete the tutorial from start to finish, but instead went from station to station watching the students work. He did, however, complete some of the exercises, which involved both using Google’s Blockly tool, and writing a line of code using the programming language JavaScript.

I'm wondering whether that is truth or not.

14
  • 7
    Define "computer program". There are languages in which any string is a valid program which outputs itself, which would make anything written "a computer program". What criteria would you like to use to determine what a computer program is?
    – rumtscho
    Dec 9, 2014 at 11:12
  • 2
    If you're asking whether he definitively did it, the answer is yes: you can watch a video right here. As for whether he was the first, it would be impossible to say for certain that no president ever wrote any code, but you can assume that. I think it would be news if a previous president had done something like this. So the answer is probably yes. Dec 9, 2014 at 12:35
  • 6
    Is the question if he is the first President to do so while President, or first President to ever do so? Would GW or Clinton possibly have done some while in school?
    – JasonR
    Dec 9, 2014 at 14:48
  • 9
    @rumtscho I think a safe qualifier is something intentionally written to be run as a program. I don't think counting "everything ever written on a computer" is very useful here.
    – Is Begot
    Dec 9, 2014 at 15:34
  • 9
    @DVK: That he coded something is reasonably indisputable. That he's the first... that's still unsettled. I personally find it a bit amazing that none of them would before, but I also know that I grew up in a different era, where it was a given that people learned at least BASIC and Logo in elementary school. I don't think my parents have ever programmed anything. Dec 10, 2014 at 14:48

2 Answers 2

3

According to White House sources, yes. Per the official White House blog, "President Obama became the first US president to write a line of code as part of the "Hour of Code", an online event to promote Computer Science Education Week". The US President Barack Obama wrote 'moveForward(100)' as his first line of code using the computer programming language JavaScript, which was the part of an online exercise on 8 December 2014.

The president wrote a single line of JavaScript in a tutorial based on Disney's film "Frozen," explained Hadi Partovi, the CEO of Code.org. The line, "moveForward(100);" moved main character Elsa 100 pixels to draw a square. President Barack Obama also did a "fist bump" with a student Adrianna Mitchell during the event in the Eisenhower Executive Office Building on the White House complex in Washington, Monday, Dec. 8, 2014, attended by middle-school students from Newark, N.J.

6
  • 8
    I didn't find this very convincing; they didn't quote their sources. It is pretty much a repeat of the claim rather than an evidence-based answer.
    – Oddthinking
    Jul 8, 2015 at 8:03
  • 3
    @Oddthinking: It is better than nothing. At least some authoritative source.
    – My Name
    Jul 8, 2015 at 8:17
  • 1
    @Oddthinking: Adrianna Mitchell and 29 other middle-school students from Newark, New Jersey and Brooklyn, New York present during the coding event are the only evidence that can be produced for the President coding for the first time. Jul 8, 2015 at 8:18
  • 1
    @Oddthinking The question runs into the difficulty of proving a negative. The blog demonstrates that, as far as the white house knows, no president has previously written programming code.
    – Taemyr
    Jul 8, 2015 at 9:45
  • 3
    The answer also assumes the blog is factually correct. Given the volatile and partisan nature of many things in this administration, it may just be political propaganda to make Obama look good.
    – jwenting
    Jul 8, 2015 at 10:41
0

I think it depends how we define "write a program". He appears to have used a Code.Org tutorial that I often use with my students (I'm an elementary computer teacher.)

The president wrote a single line of JavaScript in a tutorial based on Disney's film "Frozen," explained Hadi Partovi, the CEO of Code.org. The line, "moveForward(100);" moved main character Elsa 100 pixels to draw a square. Source

This is the tutorial in question Source (same as above)

As you can see in the tutorial, you "write" code by dragging pieces and attaching them to the "program". You can see the code that you have "written" by clicking the "show code" button in the top right hand corner. There is no way to manually type in any code in this tutorial, it is purely dragging pieces (with behind-the-scenes code attached to them) to the correct spot.

So it is highly unlikely that the president typed in "moveForward(100);", or typed in anything for that matter, because there is nowhere to type anything in during that tutorial. What he probably did do, however, is place the correct piece in the correct spot (mind you at this level it is not very difficult as there are only two other pieces to choose from), and Code.Org created the code to execute his "program" for him behind the scenes.

Does that count as writing code? You tell me.

As for whether he was the first to do this or not, admittedly I have no idea. I'm not sure there is any way to prove that a previous president didn't "write" code short of asking all of the presidents who have lived since code was a thing.

6
  • 3
    I encourage you to cite additional reputable sources to back up your answer.
    – HDE 226868
    Jul 8, 2015 at 18:57
  • According to everything I read they said he did type "moveForward(100);" However, typing Excel formulas is more like programming than that so the claim is dubious anyways.
    – Sam I Am
    Jul 8, 2015 at 21:05
  • What did you read that explicitly says that he typed out that command? Code.Org uses language like "Write Your First Computer Program" but the tutorials are "block-based" aka drag and drop only. I haven't gone through literally every one to confirm this but the one linked in the article on Obama is definitely drag and drop only. You can see the code your dragging and dropping produces but you cannot type code directly. Jul 8, 2015 at 21:29
  • I don't have strong feelings on Obama one way or the other but it appears "write a computer program" means "drag the correct block out of the three choices provided to the other side of the screen" in this case. Whether you want to call that writing a computer program or not... that's debatable I suppose. I wouldn't myself, though the site is a great tool for teaching beginners the basic concepts behind coding. Jul 8, 2015 at 21:31
  • @AndrewHatsworth forbes.com/sites/quora/2014/12/10/… "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." That was from Hadi Partovi, the CEO of Code.org.
    – Sam I Am
    Jul 10, 2015 at 3:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .