Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Should we stop teaching undergraduates loops?  RSS feed

 
Campbell Ritchie
Sheriff
Posts: 53720
127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Should we stop teaching undergraduates to use loops? They can always use Streams instead
 
Richard Warburton
Author
Greenhorn
Posts: 22
7
  • Likes 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:Should we stop teaching undergraduates to use loops? They can always use Streams instead


Hi Campbell,

Its a nice idea to say that we can do away with loops, but in reality whatever software you develop needs to run on the hardware at some level. I believe that universities should be teaching students a comprehensive Computer Science education. Part of what this means is the idea that people should have at least a vague understanding of what happens at each level of the stack. So you should get that:

1. At your Java application code level you're executing a pipeline of operations on a stream.
2. Inside the streams library there's a loop that is being executed.
3. At the Java bytecode level and machine code level this loop is converted into a goto statement.

I do think, however, that we should teach undergrads functional programming concepts & streams before they get to loops. So they get to go down from the higher level of abstraction right down to the machine code.

regards,

Richard
 
Campbell Ritchie
Sheriff
Posts: 53720
127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you

I never thought of teaching streams before loops.
 
Jeanne Boyarsky
author & internet detective
Sheriff
Posts: 36396
453
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I like the idea of teaching streams before loops. It is easier to change your thinking to lower level from higher level than vice versa. It also makes loops feel "clunky" so they aren't the default solution to every problem.
 
Paul Clapham
Sheriff
Posts: 22185
38
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There's a huge dead weight of tradition out there. In the Beginning Java forum here you'll see all kinds of people posting beginner code containing things like



for processing the elements of an array (also an archaic concept by the way), as if Java 5 had never been released 10 years ago giving us a better for loop. It seems to me that it takes a decade to wean people off the old ways of doing things.>
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65824
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul Clapham wrote:It seems to me that it takes a decade to wean people off the old ways of doing things.>

Or more! (cough -- scriptlets -- cough)
 
Campbell Ritchie
Sheriff
Posts: 53720
127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I suspect a lot of people who teach programming are very much out of date. But I can't prove it.
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Slightly removed from this, I think developers who don't understand what's happening on a low level (and by "low" I mean as low as it gets - the CPU) are disadvantaged.
 
Rico Felix
Ranch Hand
Posts: 411
5
IntelliJ IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ulf Dittmer wrote:Slightly removed from this, I think developers who don't understand what's happening on a low level (and by "low" I mean as low as it gets - the CPU) are disadvantaged.


I agree here... From my current experiences, being a new comer to computer science I recently wondered off on my own into learning assembly language (advanced reading) and I can say that it opened my mind to what is really going on and how high-level languages abstracts low-level details...

With this knowledge the abstraction:


automatically translates in my head into


At the moment I don't know if this knowledge can help me write more efficient code in the future but it sure at least feels good to know such details (I can show off on my classmates )
 
Tim Holloway
Bartender
Posts: 18531
61
Android Eclipse IDE Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Which proves:

1. I am a major geek. I wrote that in my head without reference to any documents.
2. I am a dinosaur geek. That's IBM System/360 machine language.

For those who don't have their "green cards" (not the immigration ones, the IBM reference cards!):



Using General Register 12 as the base register for the data store.

Or, going 1 level further up:


Unfortunately, it has been many years since people would push lots of money my way for knowing that.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!