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.

Hackaday Comment Policy; We’re Cleaning Up.

Sit down for a moment commenters, we need to talk.
Yes, you all knew this post was coming one day. We’ve talked about this topic at length internally, and we have decided that we’re going to clean up our act. For some time, Hack a Day has been growing a reputation as the prime source of extremely negative, vulgar, rude, sexist, and inflammatory comments in the hacking community. We’ve had complaints from readers (yes there are readers that aren’t commenters, thousands of them) and fellow members of the hacking community about this problem for a long time. [Eliot] even mentioned it back in 2009 when a job applicant expressed concern. We’ve nicely tried to steer things to the positive in a variety of ways, from suggesting commenters to be more supportive, jokingly making a troll detector, and simply stating that the comments need to stay “on topic and nice”.

When we see things like these  tweets by [Jeri Ellsworth], we hang our heads in shame.

She’s not the only one. We actually get this quite regularly. As our readership grows, we see it more and more often. We get emails explaining that people have done a hack but don’t really want to post it because the commenters will just tear it apart in an unnecessarily aggressive and negative way. We have actually had people ask us to remove their projects and comments due to uncivil behavior. Constructive criticism is good, but insulting and angry deconstruction isn’t helpful to anyone.

We’re better than that aren’t we? We are fast, agile and fairly unrestricted in our content. We should be at the center of this community, not on the outer edges, reviled by many for the behavior of a few. Hackaday should be the teacher at the front of the classroom, not the kid in the back throwing wadded up paper at the kids in the front.

What we’re doing:
First off, as far as we can foresee, we will never close the comments section of our web site down. Hackaday should be a home for the entire hacking community and as such, you will always be able to settle in and have a reasonable discussion. We do not want to implement any sort of G+ integration or similar, nor do we want to require registration to leave a comment. We will if we absolutely have to, but lets try to avoid that.

Comment sections and forums have often been a place where negative comments can get out of hand. There are many theories for why this happens, but the result is usually the same: rules and moderation. Many sites have already laid down the law and are adhering to their goals of keeping things civil. We realize that we are to blame if our image is this poor, so we are doing something about it.

From this point moving forward, Hackaday comments will be civil. If you are posting an empty in-joke (“where’s the Arduino?”), a declaration of “not a hack”, a racist, sexist, completely off topic, platform-hating, or personally insulting comment, your post will be deleted. This will be at the discretion of whichever Hackaday staff member happens to see your comment first.

Can you criticize Hackaday?
You can’t walk into a business and start screaming about how much they suck without being escorted out immediately.  Same thing applies here.

We are always hard at work trying to find interesting hacks, makes, repairs, tweaks, videos, etc. that appeal to a wide spectrum of readers. We put this web site together for you, as well as 200,000 other individuals.  Not everything will appeal to everybody. That would be impossible. However, if you don’t like a post or project, just skip it – we’ll have another one ready in short order. We will feature projects that appeal to the seasoned EE as well as the complete beginner. We were all beginners at one time, and it would have been great to have something like Hack a Day around back then to show us hacks ranging from simple to advanced.

From time to time however, Hack a Day can be a less than desirable place to hang out, especially for those who are coming here for the first time. We don’t want to chase off young, creative minds. As a community, we should be helping those that are just starting to venture into hacking electronics.

If you have a problem, email us. You’ll probably actually get a response that way too.  My email is Caleb@ and you’re always welcome to email me personally. Again, please be civil (yep, I’ve had my share of death threats).

Grammar/spelling corrections and dead links:
No need to comment, just email us. A message to team@ will suffice, but you will probably get a quicker response by emailing the author directly. We know we have issues – we’re often so excited about a hack that some little goof slips by. Email us and we’ll fix it. Don’t write a 3 paragraph comment about how important the oxford comma is, or how we’re obviously incapable of functioning because we accidentally flubbed a word. We promise we will never intentionally screw up some grammar, spelling, or punctuation.

What you can will do to help:
Be constructive.

Every project here probably has an area that could be improved, or a part that was done inefficiently. Support your fellow hackers by offering your expertise. Explain why something isn’t working, or how you would improve it. Don’t slam them for their shortcomings. Also keep in mind that different people go about things different ways. Poster X didn’t build something the way you did?  Offer an alternative without being insulting. If someone chooses to use their brand new Core i7 monster system to drive a few LEDs, that’s their prerogative. Inside, we all know that it is not the most efficient use of money or technology, there’s no reason to beat that dead horse in public.

You know what else encourages hackers to do more projects? A pat on the back. I talk to people all the time who say that they just don’t have any constructive criticism for the projects, so they don’t comment. Well, that and they know they’ll bring the ire of the worst commenters if they happen to ask a silly question. Drop in and say what you like about a project. Those positive posts might just be enough to encourage that hacker to take it a step further. How many projects have you seen dropped simply because people thought there wasn’t any interest? Tons. If you like a project, let them know.

To encourage this, the writers are going to be keeping an eye on the comments. Randomly, when we see someone being exceptionally helpful, we’ll contact them and send them a prize. This will most likely be in the form of a hackaday sticker, but we’ll see if we can’t find some other fun things as well.

Help us make Hack a Day great. Please.

[Update: we’re working on a comment flagging system currently]

[Update: threading and comment reporting have been added]