Take the 2-minute tour ×

First, this is not a homework assignment, but you can treat it as such ;). I found the following question in the published paper The Camel Has Two Humps. I was not a CS major going to college (I majored in MIS/Management), but I have a job where I find myself coding quite often.

For a non-trivial programming problem, which one of the following is an appropriate language for expressing the initial stages of algorithm refinement?

(a) A high-level programming language.

(b) English.

(c) Byte code.

(d) The native machine code for the processor on which the program will run.

(e) Structured English (pseudocode).

What I do know is that you usually want to start your design implementation by writing down pseuducode and then moving/writing in the desired technology (because we all do that, right?) But I never thought about it in terms of refinement. I mean, if you were the original designer, then you might have access to the original pseudocode. But realisticly, when I have to maintain/refactor/refine somebody elses code, I just keep trucking with the language it currently resides in. Anybody have a definitive answer to this?

As a side note, I did a quick scan of the paper as I havn't read every single detail. It presents various score statistics, can't find where the answers are with the paper.

share|improve this question
I think the question is talking about the refinement the original author does. –  Karl Bielefeldt Sep 4 '12 at 22:20

3 Answers 3

up vote 2 down vote accepted

There is no definitive answer, except that very few people would choose C or D. My preference is A, but others may prefer B or E.

Modern high-level languages are expressive enough that I don't bother with pseudo-code. Instead of writing pseudo-code that says "get data; do something complicated; output something", I can just write code

def main
    def myData = getSomeDataSomehow()
    def result = myData.doSomethingComplicated()

More likely, I'll start with a test:

def testThatNoDataProducesNoOutput

Then I successively add tests and elaborate the code until I can't think of any more tests.

share|improve this answer
Agree, I find that because I constantly write various bits of algorithms etc in high level languages, it feels more natural to write algorithm stuffs in that language instead of english. I don't frequently write any logical algorithm stuffs in english except in documentation which is as non-technical as possible in most cases. –  Jimmy Hoffa Sep 5 '12 at 3:00

First of all, I hardly believe that anyone have a definitive answer.

Personally me always get annoyed by any kind of pseudocode even in good books, even in excellent ones, be it Knuth's "Bible" or Corman's "Gospel".

I'm ready to apprehend and to learn any real language, there's no problem to read the algorithm implementation written on any high level language. Moreover, I found such code snippets more useful in any sense.

As for refinement, well, my first thought was to note that actually yes, there are some options, which can be conjugated with that term. For, dealing with memory, manual allocating and deallocating, can divert us from the very essence of algorithm. For the similar reasons, dynamically typed languages are more preferable compared to static ones. Roughly, Java is better for so-called algorithm refinement than С++, and Ruby or Python are better then Java.

To say this, I repeat, was my first intention. But than I've remembered that I actually have no problems with reading code snippets in Haskell (which I know a little bit), ML (which I don't know at all) or C++, which I've never used.

So, I believe it is only matter of practice. Anyone who is reading a lot of algorithm explanations have to learn to spot quickly different peculiarities of different languages. As for me, it is way better when those languages are "real".

ps you forgot to mention flowcharts )))

share|improve this answer
You should learn C++ before giving opinions on it's expressiveness in comparison to Java. I have years of experience in both and IMO, C++ is a far more powerful language. –  kevin cline Sep 4 '12 at 21:19
@kevincline, you've got me wrong, my bad. I actually don't think that Java is more expressive than C++ (or vice versa). The only reason I've contrasted this languages is that first one have automatic garbage collection and second one does not. And this does not mean that one is better than the other. –  shabunc Sep 4 '12 at 21:25

The answer they're looking for is English. More accurately, the language used should be the one that is understood by the lowest common denominator (usually the end-users of the system and/or the person paying the bills).

The inference that the end users and other non-technical "stakeholders" are involved here makes the answer obvious; "the initial stages of algorithm refinement" is synonymous with "the gathering of requirements for the algorithm". Those requirements are not gathered in bytecode, machine code, C# or even pseudocode; they are gathered in English, and the users will evaluate the correctness of the algorithm in terms of what they said it should do, in English.

Once requirements are gathered in plain English, they are typically structured in a "Given... When... Then..." format. "Given that the user has left the User ID field blank, When the user clicks the 'Login' button, Then the program displays an error message and highlights the User ID field". These are still very understandable by end users and are not pseudocode. These can be taken, one at a time, and used to produce a pseudocode algorithm that can be reviewed before being developed in the native language. Depending on the environment, pseudocode may not be necessary (or even encouraged; TDD would typically have you start coding a test based on each Given/When/Then requirement, and then coding to pass each test in turn while keeping all previously-passing tests "green"), but pseudocode is a good way to structure the layout of a complex algorithm and have it reviewed by yourself or any other team member, regardless of the level of expertise that you or any of them may have with the programming language to be used.

share|improve this answer

Your Answer


