top | item 42554398

(no title)

theoa | 1 year ago

Not short but almost understandable. Given a text editor, save the following text as drawline.html:

  <canvas id="myCanvas" width="500" height="300"></canvas>

  <script>

  const ctx = myCanvas.getContext( "2d" );
  // Draw the line
  ctx.beginPath();
  ctx.moveTo( 50, 50 ); // Starting point
  ctx.lineTo( 200, 150 ); // Ending point
  ctx.stroke();

  document.write( "Hello World" );

  </script>
JavaScript is quite forgiving. No need for the HTML preambles. "document.getElementById" is a nicety that can also be ignored.

Nonetheless, I (born 1947) too miss the simplicity of BASIC, the plethora of magazines for beginners, the many shelves of "for dummies books". And, especially, that we were all beginners.

These days, full stack developers and AI are priestly classes that that, currently, do not facilitate the investigation by newbs of the black boxes they create.

Nonetheless, I look forward to AI being able to read aloud Python, Rust, Cobal, Euler notation, Greek or whatever in ways that I may understand.

discuss

order

vekatimest|1 year ago

I had no idea named elements just become globals like that. Seems kind of ridiculous

theoa|1 year ago

I discovered this perhaps ten or more years ago. I have used IDs a global in hundreds (thousand?) of efforts with no issues. Ever.

Of course, I am but a single stack developer, so your experience may vary

blacksmith_tb|1 year ago

id-s do, which is handy here, but sometimes exciting if you aren't expecting it.

ben_w|1 year ago

> "document.getElementById" is a nicety that can also be ignored.

Huh, I did not know that. This makes it a lot nicer for micro-projects.