Should we use Pseudocode more on UnityAnswers?

As a sort of "branch" off of this popular question, I want to talk about the use of pseudocode here at UnityAnswers, specifically, the pros and cons, and whether it's worth it to write more example code here in pseudocode. So what do you think?

If you don't know what Pseudocode is, educate yourself. :)

Generally, I've found that the majority of questions here fall into two categories: "write my code for me" people who can't be bothered to figure out how to fix simple bug in an untested script they copied and pasted (i.e. the NullReferenceException people), and those who can actually program and need a forward vector to start with some high level concept or engine feature.

I don't think pseudocode is going to help the first category, and in fact is usually inappropriate since a lot of times you usually just need to point out why their code syntax/usage is wrong.

For the second, usually it's either just a link to "hey this is how you do X in Unity", or it's a high level feature which I would be better off explaining in english instead of trying to delve even as deep as pseudocode.

I rarely find myself in the sort of middle ground in what I like to call algorithm land where pseudocode is appropriate for both the scope of the question and the experience level of the audience. Like if there was a question here that was like "how do I do collision manually in 2D" I could write some pseudocode algorithms for capsule/line segment collision or something like that (although honestly I'd probably just point them to where I found the algorithm in the first place), but those aren't the majority of the questions here by any means.


Pseudocode is, essentially, code that doesn't adhere to a specific syntax. What this means, is that we can still provide a high level of detail here on UA, but without trying to guess which syntax (JS/C#) the asker wants us to use.

Additionally, using pseudocode forces the asker to retype the code, instead of just copying and pasting it, potentially eliminating some problems there. For example, two common copy-paste complaints I read often are "I copied and pasted your code but it didn't work", or "Sorry I'm using javascript not C#". Using pseudocode would potentially eliminate these complaints, forcing the user to rewrite the code and integrate it into their existing script, instead of just copying and pasting. This would also (hopefully) force them to actually learn something, instead of just getting a "quick fix" here without actually learning what the solution to their problem was.


I feel that a lot of people here at UA are new to programming, and may be unfamiliar with the concept of pseudocode. Thus, when an answer is posted with pseudocode, the asker may not be able to rewrite/adopt this code into their existing script, with whatever language they're using.

... Actually, that's the only con I can really think of. So I open it to you, the good people of UnityAnswers... what do you think about pseudocode? :)

Personally, I'd rather get an Answer from Duck or Eric5h5 that consists of 2 lines of C# which brilliantly solves the problem (possibly with easily-fixable syntax errors) - than get a two-page Pseudo-code answer that barely addresses the problem while using several unnecessary features. But that's just me... :)

And I don't plan on using Pseudo-code - really, once you're at that point, you're almost to code, and it's not that hard to start up Visual Studio Express and get all the syntax checking.

The only advantage I would see in Pseudo-code is, as mentioned, not tying it to single language. But hey, if I post something in C#, it's an opportunity to link Differences in C# and JS, and how could I pass that up? :)

Ahem... With regard to the implication that Eric5h5 might possibly enter faulty code:

I offer a complete and utter retraction. The imputation was totally without basis in fact, and was in no way fair comment, and was motivated purely by malice, and I deeply regret any distress that my comments may have caused you, or your family, and I hereby undertake not to repeat any such slander at any time in the future.

(for the movie-impaired, google "A Fish Called Wanda".

Update: yet another reason against pseudocode - apparently it's the Tang of programming languages.

Personally I see posted code here as a learning opprtunity. While often the posted code can indeed solve the issue itself in a copy-and-paste able form it also expands the example code base available for unity. This, for me is one of the main factors I prefer unity over other engines: A well written documentation with lots of examples.

For those learning and without programming experience - while it is easy to fall into a habit of copy and paste - looking at working code, analyzing it, studying it and finding out WHY it works is the best way to learn. Especially some beginners may have so many issue with the syntax, etc. that they may not be able to implement from pseudocode at all.

I feel that UA should stay a community as open to newcomers as it has been. After all this is what gets people hooked on the engine and makes development with it so smooth. Eventually those further behind in education and experience will catch up - and hopefully teach the newcomers how they have been taught.

In the end, when it comes down to it: Nobody can have their entire games code written for them by UA. They will need to put in effort and try and translate some code they saw that works, into code that works doing something else. Without access to proper code in the correct language and syntax.. it's much much harder and also a lot easier to fall into the following trap: Mistaking a simple syntax error in working logic for a logic error. This in return can lead to hours of wasted work trying to fix the logic, when in reality the only issue was the positioning of the ;, some () or something else that really would have taken seconds to fix.

tl;dr proper code really helps a lot more.

Excellent question, I really think pseudocode is a great way to answer most questions.

Pseudocode is better than real code because:

  • it clearly explains the programming concept without cluttering it with programming syntax
  • it isn't tied to a specific language so it can help more people
  • (as said by SpikeX) it prevents the 'your code didn't compile' replies.

If someone posts real code as a reply, they should feel obligated to edit and make it work, if it is pointed out that it doesn't work. After all, a major goal of this resource is to serve as a reference.

The whole purpose of pseudocode is readability, so everyone should understand well written psuedocode, that's the point of it.

Pseudocode is better than a block of text (for simple concepts) because:

Theory generally is either too verbose in explaining every detail or is too brief, leaving the reader to supplement it with other texts. It's impossible for the writer to tailor the text to give the right amount of detail for each person, since everyone has varying amounts of knowledge. The way pseudocode examples counter this is by being easy to navigate and allowing readers pay more attention to the parts which are foriegn to them. Thereby allowing the reader to go at their own pace.

I don't think pseudocode is the way to go. It makes longer to test suggested code and may confuse new users. Like nnx said, no one can develop a game on unity with just copy and paste, they eventually would have to look on the code and try to understand at least some of it to adapt to their needs. But if they could, so what? There are free and commercial engines like RPGMaker and Mugen that provide lots of pre made functions (just like Unity) so people can focus on what's importante on a game : making it fun.

Another subject is time. Sometimes you just don't have the time to delve into pages and pages of explanation in books or browsing older questions on UA. You just want or just needs it to be done. As a dev in a small company (we have 5 members and some hired third party), I have to deal with lots of programming matters and sometimes stop writing some code to deal with other aspect of the project or a different project at all. I'd really like to know what every bit of Unity does, but it's just not possible. And that's one of the reason people buy assets at the store too, so they don't need to care with the most complicated and time consuming matters and if they choose they may try to understand it.

Personally I believe that it's a bit annoying the "NullReferenceException" folks, but we need them. Trying to brush off beginners and elitize Unity will only make it less appealing to investors, the more people we have, the better, even if they're asking the same questions you saw before (I recall reading about burned administrators in a blog somewhere...) that will get cleaned eventually if they don't add nothing but teaching the newcomer a line or two, because the noob of today may be your boss tomorrow.

For others to see, since SpikeX deleted it...

search for TAG g000-001 to see entries that cover this topic [g=group, ###-### = bucket number] DingBEN 14 mins ago

Please don't add arbitrary and random tags that a) have no descriptive meaning, and b) don't even serve a real purpose. The "Meta" tag is for discussion about the site itself, and not Unity-related things. I think people can find their way around if they want to find discussions like these without adding a random tag to everything. SpikeX 8 mins ago

How is it arbitrary and random? the TAG i added allows one to group all dups under the same search result. It is a way to group dups, an issue that has been brought up more than once. g000-001: where g=group and ###-### the sequence number of the group. I wish you would have left it as the example that it is, was, so others can weigh in, instead of just YOU.! DingBEN 0 secs ago