DEV Community

Raed Yak
Raed Yak

Posted on

What was the first code you ever wrote?

I bet many of us have started with some silly codes, i just feel curious about other people's experience, so what was your first lines of code/script/application?

Top comments (4)

Collapse
 
somedood profile image
Basti Ortiz

Hehehe... I love this question. My first lines of code weren't even written by me; it was from a very clever guy from Stack Overflow who knew how to programatically play a <video> element. The code was something along the lines of:

var button = document.getElementById("playButton");
var video = document.getElementById("videoPlayer");

button.onclick = function() {
    video.play();
};

The way I used to code is a far cry from how I write code today. In the old days...

  • I used var everywhere.
  • I heavily polluted the global namespace.
  • I gave an id to every single HTML element that I needed to programmatically access with JavaScript.
  • I now prefer the addEventListener method over the "oneventname" properties to attach event listeners to DOM elements.
  • I indent with two spaces nowadays. Before, I indented with tabs (which is kind of equivalent to four spaces).
  • I prefer single-quoted strings now.

Wow, I have changed a lot since my early programming days (when I didn't even know about JS frameworks). Good times...

Collapse
 
yak0d3 profile image
Raed Yak

Well, i think you are a true coder now haha
I believe that a developer that have never wrote something he knows nothing about, is not a real developer, because he haven't made a lot of research haha

Collapse
 
somedood profile image
Basti Ortiz

Copying and pasting from Stack Overflow: the Rites of Passage for every programmer.

Collapse
 
joeberetta profile image
Joe Beretta

My one was on Turbo Pascal. It was at school. basic IO))) And of course after six years I forgot Pascal. But It was my first experience and it was cool :)