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.
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? :)
answered Jun 25 '10 at 04:50 AM
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.
answered Jul 26 '10 at 06:29 AM
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:
(for the movie-impaired, google "A Fish Called Wanda".
Update: yet another reason against pseudocode - apparently it's the Tang of programming languages.
Excellent question, I really think pseudocode is a great way to answer most questions.
Pseudocode is better than real code because:
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.