Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.programming > #4682

Re: From pseudo to spaghetti

From Kaz Kylheku <kaz@kylheku.com>
Newsgroups comp.programming
Subject Re: From pseudo to spaghetti
Date 2014-08-04 04:51 +0000
Organization Aioe.org NNTP Server
Message-ID <20140803212651.194@kylheku.com> (permalink)
References <5f9394fd-4fb5-4360-bc27-658f1954ad07@googlegroups.com>

Show all headers | View raw


On 2014-08-04, b <mike7411@gmail.com> wrote:
> What are some of the main reasons that code gets ugly when it goes from
> pseudocode into the real world?

One reason may be that the pseudo-code is not perfect, and so it it requires
debugging. It's the same reason that any code gets ugly when it is debugged:
you write some ideal piece of bullshit that looks nice, but it doesn't
actually specify the necessary computation. The program that does specify
the correct computation properly is more ugly. It is more ugly because it
has to handle more cases that were missing.

But let's say you have some polished piece of pseudo-code from the 15th edition
of some textbook that has been proof read up and down and sideways, so it is
safe to assume there is nothing wrong with the pseudo-code.

That can still get ugly when it goes into the real world, and the main
reason for that is that it is written in an ideal language, and the real
language that it is translated into is not up to the task of expressing
that approach directly. For instance, the pseudo-code may be assuming that some
garbage collector cleans up, but the actual language doesn't have one,
and so the code becomes riddled with ugly manual memory management.
Or the pseudo-code may be assuming you have first-class functions, with lexical
capture, but you don't. Or maybe the pseudo-code assumes you have
first class continuations, but the real language you're using has
only closures. Or maybe the pseudo-code assumes you have a certain
kind of pattern matching or type inference, and all you have is some clumsy
library to emulate them. Maybe the pseudo-code assumes you have an
object-oriented system, but you don't. Maybe it is dynamically typed,
and you have a static language.

In other words, there can be various kinds of semantic gaps between the
ideal language of the pseudo-code and the actual language which is chosen.

Back to comp.programming | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

From pseudo to spaghetti b <mike7411@gmail.com> - 2014-08-03 19:43 -0700
  Re: From pseudo to spaghetti Kaz Kylheku <kaz@kylheku.com> - 2014-08-04 04:51 +0000
  Re: From pseudo to spaghetti Öö Tiib <ootiib@hot.ee> - 2014-08-04 09:11 -0700

csiph-web