Is code protected as speech by the First Amendment?
<pre><code>Import module sys.
Sys dot stdout dot write, quote:
Hello world, end quote.

import sys
sys.stdout.write(&quot;Hello world&quot;)
</code></pre>
<p>Is computer code protected as speech by the First Amendment? If the government passed a non-intellectual-property-related law that made a certain type of software illegal, without a compelling interest, would the law be constitutional? For example, suppose Congress passed a law banning hello world programs. Would that be constitutional?</p>
<p>What about the code &quot;translated&quot; into English, as in the hello world haiku above?</p>

<blockquote>
<p>Is computer code protected as speech by the First Amendment?</p>
</blockquote>
<p>Why wouldn't it be?  Media of expression that are far more distant from speech, even to the point of having no linguistic content whatsoever, enjoy first amendment protection (flag burning comes to mind).</p>
<p>Having said that, I should note that first amendment protection is not absolute.</p>
<blockquote>
<p>suppose Congress passed a law banning hello world programs. Would that be constitutional?</p>
</blockquote>
<p>No, unless the law stands up to <a href="https://en.wikipedia.org/wiki/Strict_scrutiny" rel="nofollow noreferrer">strict scrutiny</a>.  This means that it must be narrowly tailored, using the least restrictive means to advance a compelling government interest.</p>
<p>Now, it's certainly difficult to imagine a compelling interest served by banning &quot;hello world&quot; programs, but there are many other programs that could be subject to a ban, and indeed there are some kinds of programs that already are illegal (for example, it is not legal to write a program that sends daily death threats to someone).</p>

united-states constitutional-law us-constitution