- Home /
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. :)
What? You expect me read about something and educate myself ??? -50 D$$anonymous$$P! :)
What? You give people the link, ins$$anonymous$$d of expecting them to Google it??? :-P
I$$anonymous$$HO - Press the pseudocode button, this entire forum crawls to a screeching halt. Too sketchy = a narrower community base. Real code examples and associated explanations and links to the docs that cover the issue is what get people out of their current bind. 3D dev is no overnight endeavor. $$anonymous$$ost who embark on this journey want to understand everything about the tools, languages(idiosyncracies), hierarchies(objects) to gain full control of their 'baby's design. ...unless you want only super and same experts to code everyone's project out there(good luck on that).jkk
...The elite will bubble up and participate less as it is replaced by a new elite hot to help... I say keep up the good work and leave a good thing be.
search for TAG g000-001 to see entries that cover this topic [g=group, ###-### = bucket number]
Answer by Tetrad · Jun 25, 2010 at 05:11 AM
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.
Exactly why I asked the question in the first place, thanks for adding your point of view. :)
Answer by qJake · Jun 25, 2010 at 04:50 AM
Pros
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.
Cons
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? :)
I'm not entirely sure that's a con. Personally I don't want to see Unity become a program$$anonymous$$g 101 site, and if people cannot code they'll just end up co$$anonymous$$g back with more write-my-code questions after the first time they get a nice, pre-digested answer. If they're unfamiliar with the concept of pseud code, we could just post a note stating that's not C# or UnityScript, and they should adapt it themselves.
I fully agree with your Pros here regarding the positive effect on making people actually learn something for themselves. The only other Con I can think of is that having a working script to start with can be a lot less daunting for new coders, and they can get their head around the syntax more if they see it in action. That said, it depends on the asker. I'd use psuedocode on a case-by-case basis really.
Answer by nnx 2 · Jul 26, 2010 at 06:29 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.
I find myself browsing the answers to questions I do not have myself occasionally just to learn more about the code, functions I may have overlooked and different approaches to implementation. With pseudocode this just wouldn't be viable for learning.
Answer by Cyclops · Jun 25, 2010 at 02:03 PM
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.
It's far more likely that I'd post 2 lines of Javascript. ;) (And it's unlikely there will be any syntax errors...I actually run most code that I post just to be sure.)
As for your apology, I notice you haven't retracted your hateful slander about writing C#. Still, I might consider accepting it, if you were to genuflect and generally abase yourself. Offering cash bribes would also help. Also wash my car, please, there's a good chap!
@Eric5h5, I thought it was implicit that code written in C# was faulty code. No? Okay, hand me the bucket and sponge...
Hmm, well, we will accept that for now. ::benevolent gesture::
Answer by _Petroz · Jun 25, 2010 at 10:28 AM
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.
Your answer
Follow this Question
Related Questions
New Features in QATO 2 Answers
Tag-Management? Conventions for editing and re-tagging? 5 Answers
When should Questions be closed (by power-users)? 4 Answers
Are we being too generous? 9 Answers