What language could this be?
DavidZemon
Posts: 2,973
Has anyone seen a language similar to the psuedo code at the top of this wiki page? It's very intriguing and I've never seen one like it.
http://en.wikipedia.org/wiki/State_pattern
http://en.wikipedia.org/wiki/State_pattern
class AbstractTool is function moveTo(point) is input: the location point the mouse moved to (this function must be implemented by subclasses) function mouseDown(point) is input: the location point the mouse is at (this function must be implemented by subclasses) function mouseUp(point) is input: the location point the mouse is at (this function must be implemented by subclasses)
Comments
http://en.wikipedia.org/wiki/State_pattern
Pseudocode
Take, for example, a drawing program. The program has a mouse cursor, which at any point in time can act as one of several tools. Instead of switching between multiple cursor objects, the cursor maintains an internal state representing the tool currently in use. When a tool-dependent method is called (say, as a result of a mouse click), the method call is passed on to the cursor's state.
Each tool corresponds to a state. The shared abstract state class is AbstractTool:
class AbstractTool is
function moveTo(point) is
input: the location point the mouse moved to
(this function must be implemented by subclasses)
function mouseDown(point) is
input: the location point the mouse is at
(this function must be implemented by subclasses)
function mouseUp(point) is
input: the location point the mouse is at
(this function must be implemented by subclasses)
Looking at that code and the comments within it one can easily see how this might be written in an actual language like C++, Java, C#, JavaScript, Python, etc etc etc.
Aside, back in the day we used to write out the algorithms we wanted in pseudo code and then manually "compile" or translate that to assembler. That made the high level operation of the code easier to think about and discuss before getting down to the details of actual machine instructions. It also provided documentation on how that assembler code was suppose to work. Our pseudo code was an actual high level language "ALGOL". We had no ALGOL compiler so we could be a bit sloppy in the use of this pseudo code syntax.
I don't see it in this case. Maybe someone does.
The idea is to avoid all the syntactic junk of the mechanics of making a real language work. Like types, declarations, whatever, and just use what is necessary to illustrate the idea.
assigment -> :=
equality -> =
It's hand formatted if you look at the input to the wiki article. It's not like the Java code (ahhhh, my eyes!!!!) which wiki was told about and recognized.
I think it may just be pseudo-code that someone came up with. It is certainly more formal than mine!
(yes, my pseudo-code has a garbage collector too!!! )
Other than that, that is some of the cleanest declarations I've seen.
My guess is that the author ordinarily uses some sort of tool that auto-documents projects by lifting definitions and comment blocks out of the source files, and therefore uses a very strict coding regime.
Problems arrise when one tries to get a definition of pseudocode... just because it is a quick exemplar sketch, not a formal computer language of any sort.
Trying to assign pseduocode to a particular language is dubious -- sometimes it is obvious, other times it is not.
Pseudocode is for people to review; other code is for the machine to compile or interpret. The idea is to avoid a presentation to people without a concern for bugs and nuances that distract from grasping the concept and the goals that one desires to present.
A. There is no pseudocode specifcation that is universally accepted in any formal sense.
B. Different authors of pseudocode will 'sketch' differently due to differences in knowledge, personal preferences, and education.
C. A formalization of pseudocode into a standard would like require as much effort to maintain as a true computer language -- a duplication of effort for very dubious reasons.
http://en.wikipedia.org/wiki/Pseudocode
But the simple reality is pseudocode is teaching tool. Would you use the same pseudocode for introductory programing and advanced algorhytms. The beginners wouldn't appreciate a lot of formality, the advanced students would appreciate it.
The confusion may lie in the fact that some authors formalize a pseudocode style, just for the book they author and for the level audience it is expected to reach. Other authors might try to adopt a popular style and make their psuedo code look similar to C or something else.
And of course, the real problem is when you use a search engine and you get all sorts of pseudocode for all sorts of audiences and levels.
On the other hand when Donald Knuth started his life times work "The Art of Computer Programming" he realized he needed a rigorous language with which to discuss algorithms. So he defined the MIX pseudocode very precisely. (I'm not sure if he ever referred to it as pseudo code though).
MIX is so well defined that readers of his books have built MIX virtual machines to run MIX code. I think even real hardware MIX machines have been built.
Which, by the way Loopy, again reminds me why programming languages are "real" languages. They are created by humans and used by humans to communicate with each other. Even if there is no computer that can make use of them!
Gawd, Heater. Computer languages (aka, programing languages) are primarily for machines to interpret or compile. Pseudocode is for humans to primarily communicate programing concepts with each other. Just because two people may discuss a program (in their native 'real' language perhaps), doesn't make the topic of their discussion a real language in any sense. At best, you are referring to a programming language being a semiotic system.
I don't see how you can assert that a language that directs a computer to operate in a certain manner is a 'real' language. Try some formal study in linguistics. It is all about human-to-human communication. Semiotic is all about symbolic representations.