Eric Raymond Challenges You to Ask Smart Questions

09 Sep 2021

On “How to Avoid Hostility in Forums and Get the Help You Need”

Eric Raymond is one of the strongest proponents for open-source software and is highly respected within the programming community. In his guidelines on How to ask questions the smart way, Raymond suggests that to be successful in learning from forums, we need to practice proper decorum in asking our questions. For example, on StackOverflow, some users of the site, Raymond explains, expect answers to homework questions and for others to solve their research projects for them. Due to this “inappropriate behavior”, it has resulted in growing distaste among StackOverflow’s contributors towards the “naïve” or “elementary” programmer. Thus, for the less experienced programmer, they should adhere to certain guidelines to get their questions answered successfully. In this essay, I will give an example of a poorly phrased question as well as two well-worded questions.

A Poor Question

A poorly worded post started with, “How do I remove objects from a JavaScript associative array?” link to a poor, albeit popular StackOverflow thread. The reason why this post is poor is because the example in the question was about an object rather than an array. See his example here:

var myArray = new Object();
myArray["firstname"] = "Bob";
myArray["lastname"] = "Smith";
myArray["age"] = 25;

In fact, it seems the user has mistaken arrays for objects as his object is named myArray. It is clear that the user has not done his homework and his lack of understanding the fundamentals, has resulted in a question that is difficult to answer. There are attempts to answer his question in both ways: some on objects, some on arrays. Other viewers pointed out that removing properties from an object is not the same as removing elements from an array.

A Good Question

A good question is, “What is the JavaScript version of sleep()?” link to a Happy Camper’s StackOverflow thread. The user (actually a community of 10 people) gives an example along with their question and clarifies that though their example method works, they want a better solution. See their example here:

function pausecomp(millis)
{
    var date = new Date();
    var curDate = null;
    do { curDate = new Date(); }
    while(curDate-date < millis);
}

In addition, the user cites another question and shows that their question is not a duplicate. So, the user has asked a specific question and has done their homework.

This is not a duplicate of Sleep in JavaScript - delay between actions.; I want a real sleep in the middle of a function, and >not a delay before a piece of code >executes.

By phrasing the question in terms of the sleep() function (a commonly used function in multi-threaded languages such as Java), this helps people answering the question to understand the context in which the question is being asked. It shows that the person asking the question understands that JavaScript, being single-threaded, does not behave the same way as Java. But that they are looking for a solution that is similar enough so that they can use JavaScript in this fashion. Although this question was asked 11 years ago, it drew enough interest so that is has been updated to reflect more recent changes in the JavaScript languages (that is, Promises and await.)

Another Good Question

While working on a networking assignment, I came across the following question Is it good practice to try-with-resource a file writer. This is an example of a good question because the person asking the question gave a clear example of code that could cause an error. In addition, the question asked has to do with try-with-resources in Java – the more modern and recommended way of creating resources such as I/O streams. The try-with-resources is supposed to guarantee that any resources successfully created will automatically be destroyed when the try block finishes executing (without the need for a finally block). In more detail, the question gave an example of creating a resource using an object that is constructed with an object that must also must be constructed. Therefore, the code has anonymous objects. If something occurs where there is an abnormal termination, will this cause problems because there doesn’t seem to be a way to destroy the anonymous object (as there is no reference to it)?



The response is a very good answer as it uses the example in the original question and clarifies that yes –creating the resources without anonymous objects is a better way to implement a try-with-resources block.

Conclusion

In conclusion, Raymond’s suggestions, although direct, are in response to his real-life experiences with both good and bad questions on forums. We can see how true his recommendations hold in the questions shared above. Before we ask a question, Raymond suggests that we try to see if someone has answered a similar question. We might need to go back to the basics (like the group of people asking the poorly worded question). But we should take our time because good programming habits are not developed overnight and we are fortunate to receive help for free via the forums. Raymond stresses that forums are a great way to bounce off ideas. But participating in forums also means that we must learn to distinguish between valid and invalid responses, as anyone can respond to our questions. So, ask not for an answer. But ask and then try to understand so your future questions are better.