x


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. :)

more ▼

asked Jun 25 '10 at 04:50 AM

qJake gravatar image

qJake
11.6k 43 78 161

What? You expect me read about something and educate myself ??? -50 DKP! :)

Jun 25 '10 at 01:37 PM Cyclops

What? You give people the link, instead of expecting them to Google it??? :-P

Jun 25 '10 at 02:20 PM Ricardo

IMHO - 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. Most 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

Jul 25 '10 at 03:13 AM dingben

...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.

Jul 25 '10 at 03:14 AM dingben

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

Jul 26 '10 at 05:59 AM dingben
(comments are locked)
10|3000 characters needed characters left

7 answers: sort voted first

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.

more ▼

answered Jun 25 '10 at 05:11 AM

Tetrad gravatar image

Tetrad
7.2k 27 37 89

Exactly why I asked the question in the first place, thanks for adding your point of view. :)

Jun 25 '10 at 08:32 AM qJake
(comments are locked)
10|3000 characters needed characters left

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? :)

more ▼

answered Jun 25 '10 at 04:50 AM

qJake gravatar image

qJake
11.6k 43 78 161

I'm not entirely sure that's a con. Personally I don't want to see Unity become a programming 101 site, and if people cannot code they'll just end up coming 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.

Jun 25 '10 at 07:30 AM Ricardo

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.

Jun 25 '10 at 11:21 AM Novodantis 1
(comments are locked)
10|3000 characters needed characters left

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.

more ▼

answered Jul 26 '10 at 06:29 AM

nnx 2 gravatar image

nnx 2
51 1 2

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.

Jul 26 '10 at 06:30 AM nnx 2
(comments are locked)
10|3000 characters needed characters left

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.

more ▼

answered Jun 25 '10 at 02:03 PM

Cyclops gravatar image

Cyclops
7.1k 33 63 115

@Cyclops If I could +2 I would. ;)

Jun 25 '10 at 02:13 PM e.bonneville

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.)

Jun 25 '10 at 04:14 PM Eric5h5

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!

Jun 25 '10 at 06:37 PM Eric5h5

@Eric5h5, I thought it was implicit that code written in C# was faulty code. No? Okay, hand me the bucket and sponge...

Jun 25 '10 at 07:04 PM Cyclops

Hmm, well, we will accept that for now. ::benevolent gesture::

Jun 25 '10 at 07:18 PM Eric5h5
(comments are locked)
10|3000 characters needed characters left

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.

more ▼

answered Jun 25 '10 at 10:28 AM

_Petroz gravatar image

_Petroz
3.6k 27 35 57

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x143
x9

asked: Jun 25 '10 at 04:50 AM

Seen: 1625 times

Last Updated: Jul 26 '10 at 06:05 AM