In Search Of The First Comment

Are you writing your code for humans or computers? I wasn’t there, but my guess is that at the dawn of computing, people thought that they were writing for the machines. After all, they were writing in machine language, and whatever bits they flipped into the electronic brain stayed in the electronic brain, unless punched out on paper tape. And the commands made the machine do things, not other people. Code was written strictly for computers.

Modern programming practice, on the other hand, is aimed firmly at people. Variable and function names are chosen to be long and to describe what they contain or do. “Readability” of code is a prized attribute. Indeed, sometimes the fact that it does the right thing at all almost seems to be an afterthought. (I kid!)

Somewhere along this path, there was an important evolutionary step, like the first fish using its flippers to walk on land. Comments were integrated into programming languages, formalizing the notes that coders of old surely wrote by hand in the margins of the paper first-drafts before keying it in. So I went looking for the missing link: the first computer language, and ideally the first program, with comments. I came up empty handed.

Or rather full handed. Every computer language that I could find had comments from the beginning. FORTRAN had comments, marked by a “C” as the first character in a line. APL had comments, marked by the bizarro rune ⍝. Even the custom language written for the Apollo 11 guidance computers had comments — the now-commonplace “#”. I couldn’t find an early programming language without comments.

My guess is that the first language with a comment must have been an assembly language, because I don’t know of any machines with a native comment instruction. (How cool and frivolous would that be?)

Assemblers simply translate mnemonic names to their machine instruction counterparts, but this gives them the important freedom to ignore anything starting with, traditionally, a semicolon. Even though you’re just transferring the contents of register X to the memory location pointed to in register Y, you can write that you’re “storing the height above ground (meters)” in the comments.

The crucial evolutionary step, though, is saving the comments along with the code. Simply ignoring everything that comes after the semicolon and throwing it away doesn’t count. Does anyone know? What was the first code to include comments as part of the code itself, and not simply as marginalia?

Naming Names

We have all heard that good variable names are important for creating readable programs — advice that will serve you well when you come back to your code two years later, or even twenty. Sometimes, when you are so deep in the zone and begin to question a variable name that you made three levels up the calling hierarchy, it can be helpful to take a step back and review your variable naming conventions. The wikipedia article on computer program naming conventions is a good starting point, where you can dig into the nitty gritty of Hungarian notation like bFlag, case separated names like camelCase, and so on. But sometimes you have to go meta, and need names to describe the names themselves.

For example, in everyday usage the terms parameter and argument are often used interchangeably. But strictly speaking, a parameter is a placeholder, the variables in a function declaration for example (see image above). An argument is the actual value itself, say the number 50.334 in the example.

We recommend that units of measure should always be clearly specified in your comments, perhaps even in the variable names if you’re mixing different systems in the same program. At Hackaday we prefer to use SI units, check out NIST SP 330 if you’re interested. But invariably, there are going to be exceptions for years to come. We like to deal with those at the edges during I/O if possible, thus keeping a consistent set of units in the core of the program.

What about the terms number and value? We like to think of a number as being a kind of value. For example, a function’s return value could be a number, say a velocity. Or it could return an enumeration or a boolean. Sometimes the perfect meta-name for something will collide with a reserved keyword in your programming language, names like string or data for example. In these cases you have to be creative and find suitable synonyms, perhaps text and payload.

Using consistent and precise language can be tedious, but it can be just as helpful as good commenting and variable naming practices. Do you have any examples where precise terminology such as this has been been helpful or perhaps tripped you up? If so, share in the comments section below.

 

 

Hackaday Passes 1,000,000 Comments

For just over sixteen years we’ve been publishing fresh hacks every day. We’ve just passed another milestone: the one millionth Hackaday comment was made just a few minutes ago.

A million of anything is impressive, but it’s not the sheer volume that’s on my mind today, but how time and again I’m gobsmacked by the insightful comments I find on these pages, and the people who put them there. We find leads for futures stories, answers to unknowns voiced in the articles, and have conversations with thousands of people whose paths we never would have crossed otherwise.

Not a week goes by that I don’t lose myself in a comment thread, usually taking me down the rabbit hole of exploring a bit of technology previously hidden to me but revealed by a few words. How many Hackaday articles were spawned by someone posting just the right link in the comment section?

Too often the people who moved the world with interesting technologies move through their careers and beyond without anyone to really tell their stories to, and those are some of the best stories from the people working with the tech on a daily basis for decades. But then we publish an article that puts a spotlight on their corner of knowledge and we get to hear how it was from their perspective. It’s so gratifying to get these moments of insight on who and what have kept humanity’s relay-race of science forward.

So thank you! Keep those comments and those stories coming!

Continue reading “Hackaday Passes 1,000,000 Comments”

This Machine Learning Algorithm Is Meta

Suppose you ran a website releasing many articles per day about various topics, all following a general theme. And suppose that your website allowed for a comments section for discussion on those topics. Unless you are brand new to the Internet, you’ll also imagine that the comments section needs at least a little bit of moderation to filter out spam, off topic, or even toxic comments. If you don’t want to employ any people for this task, you could try this machine learning algorithm instead.

[Ladvien] goes through a general overview of how to set up a convolutional neural network (CNN) which can be programmed to do many things, but this one crawls a web page, gathers data, and also makes decisions regarding that data. In this case, the task is to identify toxic comments but the goal is not to achieve the sharpest sword in the comment moderator’s armory, but to learn more about how CNNs work.

Written in Python, the process outlines the code itself and how it behaves, setting up a small server to host the neural network, and finally creating the webservice. As with any machine learning, you need a reliable dataset to use for training and this one came from Wikipedia comments previously flagged by humans. Trolling nuance is thrown aside, as the example homes in on blatant insults and vulgarity.

While [Ladvien] notes that his guide isn’t meant to be comprehensive, but rather to fill in some gaps that he noticed within other guides like this, we find this to be an interesting read. He also mentioned that, in theory, this tool could be used to predict the number of comments following an article like this very one based on the language in the article. We’ll leave that one as an academic exercise for now, probably.

The Anxiety Of Open Source: Why We Struggle With Putting It Out There

You’ve just finished your project. Well, not finished, but it works and you’ve solved all the problems worth solving, and you have a thing that works for you. Then you think about sharing your creation with the world. “This is cool” you think. “Other people might think it’s cool, too.” So you have to take pictures and video, and you wish you had documented some more of the assembly steps, and you have to do a writeup, and comment your code, and create a repository for it, maybe think about licensing. All of a sudden, the actual project was only the beginning, and now you’re stressing out about all the other things involved in telling other people about your project, because you know from past experience that there are a lot of haters out there who are going to tear it down unless it’s perfect, or even if it is, and even if people like it they are going to ask you for help or to make one for them, and now it’s 7 years later and people are STILL asking you for the source code for some quick little thing you did and threw up on YouTube when you were just out of college, and of course it won’t work anymore because that was on Windows XP when people still used Java.

Take a deep breath. We’ve all been there. This is an article about finding a good solution to sharing your work without dealing with the hassle. If you read the previous paragraph and finished with a heart rate twice what you started, you know the problem. You just want to share something with the world, but you don’t want to support that project for the rest of your life; you want to move on to new and better and more interesting projects. Here are some tips.

Continue reading “The Anxiety Of Open Source: Why We Struggle With Putting It Out There”

Going Back To Our Old Commenting System!

On Friday, I announced we would upgrade our commenting system. It was tested over the weekend, and ultimately I have decided to go back to the wordpress system.  Here are the reasons why:

1. Our old comments never got transitioned over.

The intenseDebate system says I can just click a single button and it will import our old posts into the new system.  I did this Friday and the page never moved from 0%. I tried again Saturday night, with the 0% import still there this morning(Monday). Our old posts simply never imported. I don’t know if it was because our database of comments was so large (I doubt it) or what. I went to contact their support, but found them out for the weekend. That’s no big deal, but I wonder if the importer was a manual thing and no one was there to do it? If so, they should probably put a warning on the importer page.

2. It wasn’t failing gracefully.

I had many emails and comments saying that the comments were not showing when people were using script blockers, or certain android devices. The intenseDebate website claims that their system will show comments even if someone is using a script blocker. I did not personally test this, and frankly I don’t have to. Even if those people are mistaken or have peculiar setups, I simply can’t ignore complaints that our content isn’t even showing.

3. I couldn’t expand all replies by default, or maybe I’m an idiot.

I didn’t see an option anywhere to display all comment threads expanded by default. Maybe I just overlooked it. Maybe there’s some css trick to it. We HAVE to have our comments expanded. Often there is more useful information in the comments than the article itself. With replies nested you would have to go through and click every single thread just to see if there was anything useful. This is such an obvious feature that I’m convinced I just went stupid for a while and didn’t read the button that enabled it, surely they didn’t omit it.

For these 3 reasons, I removed it.  Just like they said it would, it came out with no issue.

Finally Upgrading Our Comment System.

intense

UPDATE: I’m working on making the visual style fit better. It really needs some work.

Yes Ladies and Gentlemen, we’re finally taking the plunge into a more robust commenting system. This one has a ton of features, but the following few have been asked for quite frequently.

  • You can now edit your comments. Yes, finally. No seriously, try it. To do this, you’ll need to log in though!
  • Subscription to a comment thread is now optional. Horay!
  • You can now “Like” or dislike comments.

IntenseDebate is converting our old comments over, so they should begin to appear soon. Please feel free to email me directly[caleb@] with any issue you encounter using the new system. I know you’ve been asking for it for a very long time, I’ll do my best to make sure that it goes as smoothly as possible.