Why Learning to Code is So Hard

ApacheKid

Joined Jan 12, 2015
1,762
Programming is no different than writing a detailed standard operating procedure. Ive written thousands of lines of instructions that allowed us to replace a pair long time employees who thought they were irreplaceable because of all of their "knowledge". Their threats was actually just a minor inconvenience. Their knowledge was simply my knowledge that they memorized. Once I wrote it down and taught someone the notation, anyone could do the job of the annoying employees and shutdown was averted. Even the union was pissed at these two members for threatening to shut down the plant and putting everyone out of work.
Man, sounds like you have a story to tell...
 

nsaspook

Joined Aug 27, 2009
16,325
Besides a brief introduction to computer programming with MINI, my computer foundations were built on Fortran and BASIC.

Then I discovered procedural languages such as ALGOL and Pascal and Structured Programming. That opened a totally new chapter on what is proper programming IMHO.
I really started my Structured Programming phase with Modula-2. The Pascal based languages are IMO the best for learning proper program structure that you can use later in any language. C++ (the kitchen sink of languages) is finally catching up with the addition of modules.

https://forum.allaboutcircuits.com/...mming-languages-1965-2019.172784/post-1551101
https://en.cppreference.com/w/cpp/language/modules
 

MrChips

Joined Oct 2, 2009
34,814
I really started my Structured Programming phase with Modula-2. The Pascal based languages are IMO the best for learning proper program structure that you can use later in any language. C++ (the kitchen sink of languages) is finally catching up with the addition of modules.

https://forum.allaboutcircuits.com/...mming-languages-1965-2019.172784/post-1551101
https://en.cppreference.com/w/cpp/language/modules
By conversion to ALGOL and Pascal was initiated when I was given the task to create an automated control system in a nuclear reactor. At the time management wanted the development to be done in BASIC because that was the level of their expertise. After a few failed attempts I demonstrated to them how the program structure is more easily implemented, documented, and maintainable in ALGOL which we had available on the minicomputer being used at the time.
 

ApacheKid

Joined Jan 12, 2015
1,762
By conversion to ALGOL and Pascal was initiated when I was given the task to create an automated control system in a nuclear reactor. At the time management wanted the development to be done in BASIC because that was the level of their expertise. After a few failed attempts I demonstrated to them how the program structure is more easily implemented, documented, and maintainable in ALGOL which we had available on the minicomputer being used at the time.
BASIC, really, for a nuclear reactor control system! yes, I've heard of such absurdities before, truth is far stranger than fiction sometimes!
 

MrChips

Joined Oct 2, 2009
34,814
BASIC, really, for a nuclear reactor control system! yes, I've heard of such absurdities before, truth is far stranger than fiction sometimes!
I should have elaborated. No. We were not controlling the nuclear reactor itself. We were irradiating thousands of mining samples per day (a process called neutron activation analysis) that had to be automatically sent to the reactor core for a fixed duration, relayed to a counting station and then finally disposed into a collection container.
 

SamR

Joined Mar 19, 2019
5,491
In 1969 it was an 80-character card puncher. 2-3 cards at the start of the deck to assign the account to pay for the machine time with and instruct the Xerox Sigma 7 computer to load the Fortran program. Leave the deck in the incoming feed rack on the door to the computing floor. Come back tomorrow and search for your deck with the printout wrapped around it in the finished rack and pray there were no errors in your coding and that the printout actually had a solution on it instead of getting stuck in an endless loop or otherwise crapping out. Otherwise, punch the replacement cards without making any typos or with the necessary edits and do it all over again. Then later in the early 70s hands-on with an IBM 870 that had tape drives and hard packs, plus it had a chain-drive printer that printed an entire line at a time at an amazingly fast speed. Still had card punches and no monitors and didn't have enough power to run Fortran so we had to use PL1. And, it only took up one medium-sized room instead of the entire floor of the building but we didn't have to wait until the next day to see if the program ran or crapped out! The first time I saw an Apple IIE in the 80s running VisiCalc I thought I'd died and gone to Heaven. Almost instantaneous feedback on a Monitor with a full-screen editor and a floppy drive to save your work on!
 

WBahn

Joined Mar 31, 2012
32,844
I really started my Structured Programming phase with Modula-2. The Pascal based languages are IMO the best for learning proper program structure that you can use later in any language. C++ (the kitchen sink of languages) is finally catching up with the addition of modules.
Structured programming is largely independent of the language, which is not to say that some languages don't lend themselves better to it. Having said that, people can churn out spaghetti code in any language you like, and they can craft well-structured code in any language, too. My first programming course was BASIC in high school, but I was fortunate to have a teacher whose focus was on problem solving and not programming (not that I realized that there was a difference at the time). As a result, I was able to test out of the first semester Fortran course in college after the first two weeks because that was all that we needed to learn how to implement the comparable structures in Fortran instead of BASIC -- the problem solving was virtually identical. As I picked up additional languages over the years, whether it be Pascal, Lisp, C, VHDL, Verilog, Java, Python, or whatever, I've been able to see them not as different languages so much as different ways to achieve similar problem solving goals, which allows me to apply aspects from one language to the way I write programs in other languages pretty easily. I've seen that this seldom seems to be the case with a lot of people, who don't seem to be able to transfer anything from programming in one language to another, which puzzles me to no end.
 

nsaspook

Joined Aug 27, 2009
16,325
Structured programming is largely independent of the language, which is not to say that some languages don't lend themselves better to it. Having said that, people can churn out spaghetti code in any language you like, and they can craft well-structured code in any language, too. My first programming course was BASIC in high school, but I was fortunate to have a teacher whose focus was on problem solving and not programming (not that I realized that there was a difference at the time). As a result, I was able to test out of the first semester Fortran course in college after the first two weeks because that was all that we needed to learn how to implement the comparable structures in Fortran instead of BASIC -- the problem solving was virtually identical. As I picked up additional languages over the years, whether it be Pascal, Lisp, C, VHDL, Verilog, Java, Python, or whatever, I've been able to see them not as different languages so much as different ways to achieve similar problem solving goals, which allows me to apply aspects from one language to the way I write programs in other languages pretty easily. I've seen that this seldom seems to be the case with a lot of people, who don't seem to be able to transfer anything from programming in one language to another, which puzzles me to no end.
This is true about structured programming is largely independent of the language but we do things by (sometimes forced) habit at a subconscious level. Languages in the Pascal tree (designed by Niklaus Wirth as a small, efficient language intended to encourage good programming) tend to put the student in a language imposed structured straitjacket (like rust vs C) that also allows the compiler to find more errors at compile time rather than run-time. The good habits of forced structured programming become natural mind-muscle memories that tend to make programmers using less strict languages better at writing structured code naturally or at least they make good structure possible with less effort.

https://www.tutorialspoint.com/pascal/pascal_overview.htm
 
Last edited:

WBahn

Joined Mar 31, 2012
32,844
This is true about structured programming is largely independent of the language but we do things by (sometimes forced) habit at a subconscious level. Languages in the Pascal tree (designed by Niklaus Wirth as a small, efficient language intended to encourage good programming) tend to put the student in a language imposed structured straitjacket (like rust vs C) that also allows the compiler to find more errors at compile time rather than run-time. The good habits of forced structured programming become natural mind-muscle memories that tend to make programmers using less strict languages better at writing structured code naturally or at least they make good structure possible with less effort.
I very much agree. I guess what I struggle with is the issue of is it better to develop good habits because your forced to, even if you don't really understand what they are or why they are good. For that matter, how well do such people that develop those habits really carry them forward once the constraints that force them to use them are removed? I don't know that I can really claim that people that learned Pascal as their first language are really that much better at writing well organized and structured programs in other languages, though I haven't studied that question specifically (and I think it would make a useful study, if it hasn't already been done). I know I see it with the use of units all the time -- people are often forced to use units more or less properly in their physics and chemistry courses and then they throw that away as soon as it's not required.

But let's, for the moment, stipulate that people that are forced to learn good programming habits because they learn using a language that imposes them do carry that practices forward regardless of whether they really understand why they are good. Is that better than deliberately teaching, and enforcing, the use of good programming practices in an environment where the language doesn't impose them. From an idealistic perspective, I think the latter is better. But perhaps the former is the better from a more practical and realistic perspective. The real test would be to see which group, say ten years down the road, produces higher quality software, both on average and at the tails of the distribution. My initial gut feel is that, on average, the former might produce somewhat better code, but that the best, and worst, code would tend to come out of the latter group.
 

nsaspook

Joined Aug 27, 2009
16,325
I very much agree. I guess what I struggle with is the issue of is it better to develop good habits because your forced to, even if you don't really understand what they are or why they are good. For that matter, how well do such people that develop those habits really carry them forward once the constraints that force them to use them are removed? I don't know that I can really claim that people that learned Pascal as their first language are really that much better at writing well organized and structured programs in other languages, though I haven't studied that question specifically (and I think it would make a useful study, if it hasn't already been done). I know I see it with the use of units all the time -- people are often forced to use units more or less properly in their physics and chemistry courses and then they throw that away as soon as it's not required.

But let's, for the moment, stipulate that people that are forced to learn good programming habits because they learn using a language that imposes them do carry that practices forward regardless of whether they really understand why they are good. Is that better than deliberately teaching, and enforcing, the use of good programming practices in an environment where the language doesn't impose them. From an idealistic perspective, I think the latter is better. But perhaps the former is the better from a more practical and realistic perspective. The real test would be to see which group, say ten years down the road, produces higher quality software, both on average and at the tails of the distribution. My initial gut feel is that, on average, the former might produce somewhat better code, but that the best, and worst, code would tend to come out of the latter group.
I still fold my clothes for travel the way I learned in boot-camp when we needed to pack all the stuff in a tiny foot-locker for ships and use the principles of attention to detail drilled into us knuckleheads on trivial things by the company commander. I don't do it today because I was told long ago to do it that way, I do it because it works. We are creatures of habit and brains. I can't claim that people that learned Pascal like languages (strictly as a learning language, for serious programming IMO C is superior) are better programmers but it's unlikely IMO they are worse for being forced (by a Language corset) to write a more structured code than their mind was thinking at the time.
 

WBahn

Joined Mar 31, 2012
32,844
I still fold my clothes for travel the way I learned in boot-camp when we needed to pack all the stuff in a tiny foot-locker for ships and use the principles of attention to detail drilled into us knuckleheads on trivial things by the company commander. I don't do it today because I was told long ago to do it that way, I do it because it works. We are creatures of habit and brains. I can't claim that people that learned Pascal like languages (strictly as a learning language, for serious programming IMO C is superior) are better programmers but it's unlikely IMO they are worse for being forced (by a Language corset) to write a more structured code than their mind was thinking at the time.
But what fraction of vets fold still their clothes that way? Pretty small, because most of them only did it because they were forced to do it and, unlike you, did not see it as something that works, only something that was required at the time. And note that I've already said that I would expect, on average, for people coming up through something like Pascal to retain those habits, only that I would expect the people that are really good (and really bad) to tend to come from a less-structured background.
 

nsaspook

Joined Aug 27, 2009
16,325
But what fraction of vets fold still their clothes that way? Pretty small, because most of them only did it because they were forced to do it and, unlike you, did not see it as something that works, only something that was required at the time. And note that I've already said that I would expect, on average, for people coming up through something like Pascal to retain those habits, only that I would expect the people that are really good (and really bad) to tend to come from a less-structured background.
That fraction is larger than you might think for us older guys that spent a lot of time with our life possessions in a sea-bag.
 

BobTPH

Joined Jun 5, 2013
11,515
Never see much mention of ADA here, I never used it but read of it often over the years, nobody here ever work with that?
I have my own compiler for a language called bobl, which has pretty much Ada syntax for declarations and statements, but Java like classes replacing both packages and records.

I find it the most productive language I have ever used, though I might be a bit biased.

Ada was the epitome of the pascal descendants, though I think a few of it’s decisions, like copy in copy out were ill advised, I went with reference for out and in out parameters.

I happen to love the end if, end loop, etc. compared to {}. Never have a problem with black nesting errors.
 

KeithWalker

Joined Jul 10, 2017
3,607
I still make my bed every morning and shine my shoes after leaving the RAF 63 years ago, simply because it works for me.
Having written programs in Pascal does make it easier to learn C because the structure of Pascal was used in the development of C. It doesn't guarantee that the programmer will write well structured code. I have seen some pretty awful spaghetti code in both languages.
 

ApacheKid

Joined Jan 12, 2015
1,762
I still make my bed every morning and shine my shoes after leaving the RAF 63 years ago, simply because it works for me.
Having written programs in Pascal does make it easier to learn C because the structure of Pascal was used in the development of C. It doesn't guarantee that the programmer will write well structured code. I have seen some pretty awful spaghetti code in both languages.
Man, I respect that. Seems you left the RAF the year I was born too!
 

djsfantasi

Joined Apr 11, 2010
9,237
I happen to love the end if, end loop, etc. compared to {}. Never have a problem with black nesting errors.
I don’t have a problem with nesting errors, either (except for those pesky close braces automatically inserted by the IDE). In part because I use:
{ // begin descriptor
} // end descriptor

…when defining blocks
 

ApacheKid

Joined Jan 12, 2015
1,762
I have my own compiler for a language called bobl, which has pretty much Ada syntax for declarations and statements, but Java like classes replacing both packages and records.

I find it the most productive language I have ever used, though I might be a bit biased.

Ada was the epitome of the pascal descendants, though I think a few of it’s decisions, like copy in copy out were ill advised, I went with reference for out and in out parameters.

I happen to love the end if, end loop, etc. compared to {}. Never have a problem with black nesting errors.
I did have a very strange syntax error in PL/I many years ago. That used DO and END and CALL and so on, various keywords.

Well I had a loop like:

D0 I = 1 to 100 WHILE(A > B);
/* code */
END;

and got a very obscure syntax error because I'd written a zero after the "D" by mistake. It was so obscure that we reported the case to IBM because it deserved a special check all of its own, the token "DO" was very common in PL/I.
 

BobTPH

Joined Jun 5, 2013
11,515
Original Fortran had no reserved words and spaces are allowed between the characters of a name.

So:

DO 10 I = 1

Is an assignment statement, whereas:

DO 10 I = 1, 5

is a loop statement!
 

nsaspook

Joined Aug 27, 2009
16,325
Original Fortran had no reserved words and spaces are allowed between the characters of a name.

So:

DO 10 I = 1

Is an assignment statement, whereas:

DO 10 I = 1, 5

is a loop statement!
More proof that Fortran programming will ruin your life. :)
 
Top