• Create Account

## pseudocode!

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

9 replies to this topic

### #1Benderwiz  Members

Posted 24 February 2013 - 07:06 PM

Pseudocode is writing steps in English? I'm kinda mixed up by some of this. I found an example that confuses me:

Pseudocode to me would be just write simple steps in English. Like for example:

wake up,
get a shower,
get dressed,
have something to eat,
etc, etc.

### #2Hodgman  Moderators

Posted 24 February 2013 - 07:19 PM

POPULAR

Yep.

Pseudo-code is any kind of informal description, which looks somewhat like code, enough that a programmer could translate it into real code.

That example is a little bit silly, because it seems to be defining a strict/formal syntax for pseudo-code, when the point is that it doesn't have to follow any strict syntax (pseudo == false/fake/pretend, so it's fake-code, pretend-code).

Edited by Hodgman, 24 February 2013 - 07:21 PM.

### #3BGB  Members

Posted 24 February 2013 - 07:42 PM

POPULAR

Yep.
Pseudo-code is any kind of informal description, which looks somewhat like code, enough that a programmer could translate it into real code.

That example is a little bit silly, because it seems to be defining a strict/formal syntax for pseudo-code, when the point is that it doesn't have to follow any strict syntax (pseudo == false/fake/pretend, so it's fake-code, pretend-code).

yeah, kind of backwards is that a lot of people get fussy and demand that pseudocode have some specific syntax, generally resembling either a BASIC or Pascal variant, and have ended up complaining because I often tend to write pseudocode which resembles C-family languages (generally ranging from C-like to C++-like to JS-like).

but, as I see it, the point is mostly to express ideas, while being able to hand-wave details (like making the code actually work, or entirely nailing it down to a particular language, ...), and people insisting that it have a particular narrowly-defined syntax kind of misses the point IMO.

then again, some people have also complained because my scripting language uses a vaguely C-like syntax as well, but I personally prefer C-like syntax, and also expect this is what most people are most familiar with.

### #4epicpunnum  Members

Posted 24 February 2013 - 08:09 PM

As this is filed under C++, I'd assume for this case a C-like syntax would be ideal. Personally, like cr88192, I prefer such a syntax as well, especially as C-based laguages have a lot of ground in today's world, encompassing C, C++, C# and Java (not to mention that there are a few other languages that have somewhat similar structures and syntax).

Just for a general idea, psuedocode can have any loosely defined structure. If you wish to adhere more to the language you're using, it could show up as

void performMorningRoutine(){
wakeUp()
shower()
getDressed()
eat(breakfast)
}


In many cases of psuedocode, the actual implementation is ignored, and instead just has a loose design, opting for comments in some places

void eat( food ){
if ( hasFood )
while (hungy){
//decide how to eat your food and eat it.

}
}


In most cases, it's just to give you an idea of the structure you need to follow for an algorithm.
Honestly though, as long as your structure follows some sort of structure that programmers can get, you should be fine. If there's one language you're using specifically, using it's syntax loosely is probably preferred as long as it promotes readability.

### #5alnite  Members

Posted 25 February 2013 - 02:45 AM

I find it strange that some people would write their pseudocode almost like they are writing actual code.  IMO, if you have to worry about syntax, then might as well write the code. My pseudo-code is usually just plain english mixed with coding symbols, which gets translated into comments, and removed once the code is tested and finalized.

For example,

if player's hit points > 0

player runs around

else

player stays, barks, and twirls

Edited by alnite, 25 February 2013 - 03:08 AM.

### #6CC Ricers  Members

Posted 25 February 2013 - 08:44 AM

I find it strange that some people would write their pseudocode almost like they are writing actual code.  IMO, if you have to worry about syntax, then might as well write the code.

I sometimes find writing pseudocode helpful that way in that it then becomes the first step of a TDD cycle. I'm not heavy on TDD but it has gotten me to write some of my functions quicker.

New game in progress: Project SeedWorld

My development blog: Electronic Meteor

### #7swiftcoder  Senior Moderators

Posted 25 February 2013 - 10:55 AM

The first time you try and write 30 curly braces on a whiteboard during an exam/interview, you'll be cured of adding excessive syntax to your pseudocode.

I tend to stick with a very minimalist style (somewhat pythonic, I guess): indentation indicates scope, statements are plain english plus various mathematical operators.

main:
for each line in input file
calculate running average of columns 2,3
output final averages

Tristam MacDonald - Software Engineer @ Amazon - [swiftcoding] [GitHub]

### #8spiralseven  Members

Posted 25 February 2013 - 02:00 PM

I use the #typedef function to create psuedo-code prototypes....

### #9spiralseven  Members

Posted 25 February 2013 - 02:02 PM

youre practically giving a label to a complicated set of instruction that would make it appear as if it were english

### #10Benderwiz  Members

Posted 25 February 2013 - 07:57 PM

Thanks for the feedback. Seems there are many ways to use Pseudocode and I understand it now.

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.