Hacker News new | ask | show | jobs
by robocat 479 days ago
Your reason is unlikely to be a cause.

The _ comes from the W3C in 1995 well before JavaScript was commonly used for templating HTML.

Scripting has used $ for variables for a long time: I think the most relevant history line for $variable is PHP comes from Perl comes from shell scripts. I also remember finding $ ugly on Vax.

There were a huge variety of templating syntaxes for server side and HTML generation was virtually all server side in the 1900s.

Server side languages were very rarely JavaScript before Node in 2009.

JavaScript wasn't used much for HTML generation before Ajax. There were soon after many many client side templating syntaxes.

I'm guessing only Brendan Eich could say why $ was accepted for JavaScript variable names.

Timelines are hard because the foundations were compressed within a decade: JavaScript 1995, PHP 1996, DHTML 1997, Ajax early 2000s, jQuery 2006.

Syntaxes tend to be extremely path dependent, and every developer cribs from everything they use.

1 comments

Shell script here documents can generate HTML:

  cat <<!
  <div>
    ...
    <a href="$url" target="_blank" ...
  ...
  !
A form of CGI existed as far back as 1993 on the NCSA web server.