Anyone else find pseudocode weird, counterintuitive, etc.?

Page 1 of 2 [ 24 posts ]  Go to page 1, 2  Next

FrodoHackins
Butterfly
Butterfly

User avatar

Joined: 26 Jul 2013
Age: 42
Gender: Male
Posts: 9

05 Nov 2013, 5:58 pm

As I have studied programming and computer science over the past few years, I have repeatedly read (and been told) that I should try to write out a problem in pseudocode before coding it in a specific programming language. I have attempted it, but I often end up doing it in an actual programming language, anyway.

To me, the idea of pseudocode is kind of weird. The whole idea of "general, abstract, language-independent" just doesn't make much sense to me, except at the level of specific algorithms (sorts, searches, etc.). I find it counterintuitive to think about the problem independently of language-specific features:
-Object-oriented, procedural, functional, etc.
-Compiled or interpreted
-Libraries (of functions, objects, interfaces, etc.)
-Form of persistent data (SQL, XML, JSON, etc.)

At the end of the day, either the language allows a line such as "objectName.methodName();" or it doesn't (and you, therefore, have to accomplish the same thing in a more roundabout way).

Anyone else feel this way about pseudocode?



Kurgan
Veteran
Veteran

User avatar

Joined: 6 Apr 2012
Age: 36
Gender: Male
Posts: 4,132
Location: Scandinavia

05 Nov 2013, 6:07 pm

It depends on how the pseudocode is written. In most cases, it's fairly easy to translate pseudocode into Java or C#.



Shatbat
Veteran
Veteran

User avatar

Joined: 19 Feb 2012
Age: 32
Gender: Male
Posts: 5,791
Location: Where two great rivers meet

05 Nov 2013, 6:20 pm

I'd say pseudocode is meant to serve the programmer instead of constraining him. When I need to write something I end up doing it in Java because it's the language I am more familiar with, while taking liberties on the syntax as long as what is going on is still understandable. Especially if it is not meant to be shared as in your example; why make an effort to write in "pseudocode" if it won't give me any special insights and writing in proper code is much easier anyway?

In the algorithm design class I must use GCL all the time. It can be annoying,


_________________
To build may have to be the slow and laborious task of years. To destroy can be the thoughtless act of a single day. - Winston Churchill


Sharkbait
Velociraptor
Velociraptor

User avatar

Joined: 17 Oct 2013
Age: 57
Gender: Male
Posts: 478
Location: Seattle, Washington, USA

05 Nov 2013, 11:06 pm

FrodoHackins wrote:
At the end of the day, either the language allows a line such as "objectName.methodName();" or it doesn't

If your pseudo-code requires specifics, it's not pseudo-code. It's more abstract than that, and as Shatbat points out, it's meant to serve the coders & designers as an abstraction.

Oddly, they teach pseudo-coding at the collegiate level, but I personally found it very hard to do properly until I had experience and proficiency with several languages. The more languages & technical constructs I knew, the more easily I could recognize p-code that was too specific.



Meistersinger
Veteran
Veteran

User avatar

Joined: 10 May 2012
Gender: Male
Posts: 3,700
Location: Beautiful(?) West Manchester Township PA

05 Nov 2013, 11:55 pm

I always thought pseudo code was used only by UCSD p-system (shows you my age!), let alone Java.

When I was in grad school, taking a course in introduction to computers (since information science was beginning to take over from traditional library science in the 1980's), whenever an programming assignment was given, we had to flow chart the logic of that program. Once we had the logic flow charted, we then wrote the code and had to document the living daylights out of all the code written.



VIDEODROME
Veteran
Veteran

User avatar

Joined: 20 Nov 2008
Age: 48
Gender: Male
Posts: 2,691

06 Nov 2013, 12:34 am

I don't see PseudoCode as exlusively for PrePlanning.

I think it can be practical to include it while during the actual programing. Well, in my limited experience, leaving # comment lines in Bash Shell scripts.

This isn't so much for pre-planning as it is for staying organized or especially troubleshooting.

I can relate to what you're saying though because I'm trying to tackle MySQL next and the teacher's style emphasizes pre-planning and design before touching any command line. I mean c'mon, at some point I need to get into the CLI to understand the program. I see no harm in screwing up or wrecking a table and having to fix it or start over.



Sharkbait
Velociraptor
Velociraptor

User avatar

Joined: 17 Oct 2013
Age: 57
Gender: Male
Posts: 478
Location: Seattle, Washington, USA

06 Nov 2013, 1:37 am

Meistersinger wrote:
When I was in grad school, taking a course in introduction to computers (since information science was beginning to take over from traditional library science in the 1980's), whenever an programming assignment was given, we had to flow chart the logic of that program. Once we had the logic flow charted, we then wrote the code and had to document the living daylights out of all the code written.

I started at Community College in '85. The AA program was called "Data Processing," and focused on Cobol as the primary language. Pseudo-code and flow-charting was taught in the first Cobol class. I don't recall if they were interchangeable, or if the process required both. However once I got to the State-level University in '87 it was CS, and it was exclusively pseudo-code, but you were expected to know flow-charting. The languages were Assembly, C, with C++ showing-up my senior year.

videodrome wrote:
at some point I need to get into the CLI to understand the program. I see no harm in screwing up or wrecking a table and having to fix it or start over.

I certainly learn better and faster by doing rather than reading & imagining. I'll admit, though, that the planning stage tends to remove the majority of the surprises that come from rapid prototyping.

That was very problematic when mainframe time at the lower college was limited, but not so much at the Uni. level where we developed on our own PCs.



superluminary
Toucan
Toucan

User avatar

Joined: 4 Nov 2013
Age: 49
Gender: Male
Posts: 274

06 Nov 2013, 8:04 am

It's interesting that you should say that. I've never found pseudocode particularly useful either. Code for me is more like a sort of a sensation of structure. Writing it out in English feels nasty and unhelpful.

If I'm stuck I might do a little sketch, but it's typically just a few dots, circles and lines.



VIDEODROME
Veteran
Veteran

User avatar

Joined: 20 Nov 2008
Age: 48
Gender: Male
Posts: 2,691

06 Nov 2013, 8:18 am

Sharkbait wrote:

videodrome wrote:
at some point I need to get into the CLI to understand the program. I see no harm in screwing up or wrecking a table and having to fix it or start over.

I certainly learn better and faster by doing rather than reading & imagining. I'll admit, though, that the planning stage tends to remove the majority of the surprises that come from rapid prototyping.



Well.... I kind of feel like if I have a chance to bump around in Programming or Databasing, it will give me familiarity with it which I could then use in during any planning stage.

My teacher doesn't want us to do that. He wants us to Flow Chart the Database Tables first before touching SQL. I think if I played with SQL first, I'd better understand the consquences of the flow chart process and what I'm trying to plan.

I have this class again today and not looking forward to it. :p



Sharkbait
Velociraptor
Velociraptor

User avatar

Joined: 17 Oct 2013
Age: 57
Gender: Male
Posts: 478
Location: Seattle, Washington, USA

06 Nov 2013, 7:43 pm

Okay, I get it now. Time for a pro-tip: build the db, then sweep back through & document the data definitions [and logic.]

You can even use any of the open-source data visualization tools to help in the documentation process.



ruveyn
Veteran
Veteran

User avatar

Joined: 21 Sep 2008
Age: 88
Gender: Male
Posts: 31,502
Location: New Jersey

07 Nov 2013, 1:51 pm

FrodoHackins wrote:
As I have studied programming and computer science over the past few years, I have repeatedly read (and been told) that I should try to write out a problem in pseudocode before coding it in a specific programming language. I have attempted it, but I often end up doing it in an actual programming language, anyway.

To me, the idea of pseudocode is kind of weird. The whole idea of "general, abstract, language-independent" just doesn't make much sense to me, except at the level of specific algorithms (sorts, searches, etc.). I find it counterintuitive to think about the problem independently of language-specific features:
-Object-oriented, procedural, functional, etc.
-Compiled or interpreted
-Libraries (of functions, objects, interfaces, etc.)
-Form of persistent data (SQL, XML, JSON, etc.)

At the end of the day, either the language allows a line such as "objectName.methodName();" or it doesn't (and you, therefore, have to accomplish the same thing in a more roundabout way).

Anyone else feel this way about pseudocode?


Pseudo Code is an attempt to combine natural language with the structure required to do structured programming in any of the common languages such as C, C++, Java etc.

With pseudo code you can skip the syntactical peculiarities of a programming language get express your algorithm in something more like natural language. You also retain the logical structure of the algorithm You should be able to translate pseudo code readily into real code in the language of your choice.

ruveyn



Shatbat
Veteran
Veteran

User avatar

Joined: 19 Feb 2012
Age: 32
Gender: Male
Posts: 5,791
Location: Where two great rivers meet

07 Nov 2013, 3:34 pm

I remember one pseudocode example which looked suspiciously like Python :lol:

The times where I need something very abstract I end up either using GCL or a mix of Java and Python clear enough anyone should understand. Sometimes a problem is hard enough I draw graphs of what's going on, and in some cases I use mathematical notation.


_________________
To build may have to be the slow and laborious task of years. To destroy can be the thoughtless act of a single day. - Winston Churchill


FrostSA
Butterfly
Butterfly

User avatar

Joined: 9 Sep 2013
Gender: Male
Posts: 11

08 Nov 2013, 8:40 am

ruveyn wrote:
With pseudo code you can skip the syntactical peculiarities of a programming language get express your algorithm in something more like natural language.


This. I think lecturers also push it to encourage critical thinking. So many CS students rely on google or the brute force, compile-and-error approach, and then wonder why they code like s**t.



krampus
Tufted Titmouse
Tufted Titmouse

User avatar

Joined: 6 Feb 2012
Age: 49
Gender: Male
Posts: 44

09 Nov 2013, 10:16 pm

Psuedocode is a waste of time. I found an outline to be more useful.



superluminary
Toucan
Toucan

User avatar

Joined: 4 Nov 2013
Age: 49
Gender: Male
Posts: 274

10 Nov 2013, 6:24 pm

You can't convert it into the language of your choice. Try taking some non-trivial pseudocode and converting into Ruby, Erlang, Prolog, Java, Haskell, Befunge. Languages are different. A simple thing like a looping construct has no direct equivalent in Prolog. In Erlang you would solve many problems with pattern matching. In Java, you'd create a bunch of object factories. In Ruby, monkeypatching. In JavaScript you'd come up with some elegant solution involving closure.

The solution, and the pseudocode are impacted by the architecture and the environment.

Human language is elegant, but it's an ugly fit for code. No one writes pseudo-maths.



superluminary
Toucan
Toucan

User avatar

Joined: 4 Nov 2013
Age: 49
Gender: Male
Posts: 274

10 Nov 2013, 6:30 pm

Sharkbait wrote:
Okay, I get it now. Time for a pro-tip: build the db, then sweep back through & document the data definitions [and logic.]

You can even use any of the open-source data visualization tools to help in the documentation process.


Backporting the code into documentation is a great way to get good grades. Comment your code correctly and you can document an entire project. I generated most of my dissertation using JavaDoc, and scored an 82. It's how code is documented in the real world.