Is "parameter passing" between methods/objects difficult for younger people to
bill190
Posts: 769
I'm curious about something...
I finally got some time to begin reading the documentation on the Propeller I recently bought...
I was reading chapter 5 on methods and cogs in the Propeller Education Kit Labs book, and it discusses "parameter passing" between methods and objects, etc.... I was thinking... Yea, yea, yea...
Then·I suddenly realized this·concept might be quite difficult for a younger person to grasp! Someone who grew up with just windows computers and·never used MS-DOS or UNIX command line prompts?
Then I got to thinking... Older people used these systems everyday where you had a prompt, you would type a command, then something for that command to do. Something like this...
C:\>Print mytextdocument
...would print the file mytextdocument on the printer.
So this is easy for me to understand that you have a "program" or a "method" or whatever and you give that program "instructions" as to what it is to do...
But I would think this would be quite difficult to explain to someone who grew up with windows?
Computers these days are pretty far removed from the way things work inside.
So the question is, if I were young today and not exposed to command line "arguments" (as they are called), would I be totally baffled by the concept of "passing parameters" between methods/objects?
·
I finally got some time to begin reading the documentation on the Propeller I recently bought...
I was reading chapter 5 on methods and cogs in the Propeller Education Kit Labs book, and it discusses "parameter passing" between methods and objects, etc.... I was thinking... Yea, yea, yea...
Then·I suddenly realized this·concept might be quite difficult for a younger person to grasp! Someone who grew up with just windows computers and·never used MS-DOS or UNIX command line prompts?
Then I got to thinking... Older people used these systems everyday where you had a prompt, you would type a command, then something for that command to do. Something like this...
C:\>Print mytextdocument
...would print the file mytextdocument on the printer.
So this is easy for me to understand that you have a "program" or a "method" or whatever and you give that program "instructions" as to what it is to do...
But I would think this would be quite difficult to explain to someone who grew up with windows?
Computers these days are pretty far removed from the way things work inside.
So the question is, if I were young today and not exposed to command line "arguments" (as they are called), would I be totally baffled by the concept of "passing parameters" between methods/objects?
·
Comments
When I was a teenager the were no such things as computers. At least not in the experience of the vast majority of people. As a consequence there was no idea of programming in my mind, no programs, no instructions, functions, methods, parameters or any such concepts.
However after one week in technical school we had exposure to BASIC and were quite happily writing our first programs. I don't remember anyone having any major difficulty with those basic ideas.
Fast forward to today. There is no such thing as a computer. At least not in the experience of the vast majority of people. A crazy statement you may say given that the world is swimming in PCs. I don't think so. Most of those machines have no programming facilities on them. They have WEB browsers, they have games, etc etc but for all intents and purposes, out of the box, they are not computers. Unless someone is inspired to set themselves up with some dev tools.
So youg people today seem to be in much the same situation that I was all those years ago. The ones that some how get inspired to delve into programming or otherwise exposed to the idea will get along just as well as we did.
Now specifically talking about parameter passing.
From a very tender age we were studying algebra in school. So straight away we have such things as y = x * x.
That is the idea of variables is it not. Soon we are talking about functions y = f(x) and so on. The whole idea of "algorithms" is kicked of with a basic maths education, consider generating the fibonacci sequence for example. The basic idea of "program" is there already.
So anyone with a minimal education already has concepts of variable, functions, parameters in their mind. Transferring those concepts over to programming, variables, functions, methods, parameters is not a big leap.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
For me, the past is not over yet.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
cmapspublic3.ihmc.us:80/servlet/SBReadResourceServlet?rid=1181572927203_421963583_5511&partName=htmltext
Hello Rest Of The World
Hello Debris
Install a propeller and blow them away
Here we enter a whole world of extra complication. Much of that is inherent in the ideas of spreading some algorithm over many processors. For some algorithms that is easy. For other it is not, or perhaps an entirely different approach to the problem is required for a parallel solution. There are the issues of scheduling, communicating, sharing data etc etc.
Much of the complexity though exists at the implementation level. The mechanics of passing parameters from COG to COG, especially to PASM running COGs, and then having them communicate are quite primitive, low level and complicated to do in Spin/PASM. I would not expect youngsters, or anyone, to grasp any of that with out a good grounding in single CPU programming in Spin/PASM first.
On the other hand in some languages parallelism is a lot easier to grasp at the higher level. For example, to run two functions at the same time you might simply write:
and bingo you have your device drivers all up and running.
What are all those tx, rx, ... parameters. Well they are the means by which you will communicate with the device. Predefined "channels" that can be read or written just like variables.
This kind of high level language approach to parallelism makes the whole thing much easier to deal with than the mess of shared memory and pointer passing that we go through in Spin/PASM.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
For me, the past is not over yet.
In short: You handy can run more sophisticated applications than you'd be able to program by yourself as a beginner.
If a youngster starts with programming he want's to do exactly that, not realizing that it's a long path down the road to learn all that. Many of them give up because they are dissappointe by what you can do as a beginner.
But here I think mikrocontrollers have a big advantage. You can start with a lot of little projects that are easy enough for youngsters but give you enough satisfaction straight away for going on on that long road. And you'll learn about the basic concepts that you'll later on need for bigger projects.
And the propeller is even better than all other mikrocontrollers for learners. You don't have to bother with interrupt programming - which is a PIA and is needed very soon to do something meaningfull on other uCs.
Writing these lines I think we should maybe start a "little projects"-page - maybe in the wiki? What do you think?
Post Edited (MagIO2) : 4/24/2010 12:59:12 PM GMT
On the flip side, there are the people (most of us, I assume) who get excited about successfully reading a switch status, because it means we can tick that task off in our heads as "accomplished", and move on to projects that put it to use. I've got a Ping here that I haven't touched in months, but I know I was able to get it to work, and to run that "Pingdar" program, so if I get to a point in a project at which I need to have my controller know the distance to something, I know how to do that. I built a rocket deployment controller circuit on a breadboard, and tested it, not because I'm working on something using that right now, but because I suspect I'm going to want to be able to do that sometime in the next year or so.
It's important to make the point that an interesting project is mostly a collection of boring little pieces, put together creatively. At the Carnegie Science Center in Pittsburgh earlier this week I played with one of those robots that interacts with your facial expression. It had a transparent head, and you could see how the servos moved the robot's mouth, eyes, and eyebrows. I think if I really wanted to, I could do that part of that project right now. But I know that I do not know how to get it to read a person's facial expression, so if my goal were to replicate that project, I know exactly what I'd need to learn before tackling it.
I do it this way:
The main process keeps all the variables and there is a "PCB" or Process control block for every started cog. This PCB is just an array of pointers, where the first pointer points to a command. Whenever a cog is started, he holds a local copy of the pointers and so has access to the global memory to exchange data. The command data allows synchronization, starting and stopping the processes, selecting different functions. The mechanism is the same for spin and asm processes:
Such a PCB looks like this:
The process is started:
The start routine just copies the pointers:
The pointer array of the process looks like this:
Using such a technique, the processes can communicate quite simple and as this mechanism is the only one, I use, I do not produce to much errors. And changing the number of parameters is just a modification of the table. And the data can be somewhere in memory.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
cmapspublic3.ihmc.us:80/servlet/SBReadResourceServlet?rid=1181572927203_421963583_5511&partName=htmltext
Hello Rest Of The World
Hello Debris
Install a propeller and blow them away
Each *restaurant* a "cog".
Each *worker* in a restaurant a "method".
Then you would have a worker/method who would only need to be called to do a task - like the person working at the drive thru window. A simple "ding" that a car has arrived, then the person takes the order. Just need to "call" that worker.
Then other workers like the person handling french fries. If you just "called" this worker and said french fries, the person would not know what to do! You need to·call "french fries" along with additional information. So "french_fries(2, medium)". Then the worker knows they want 2 medium french fries.
Taking this a bit further...
McDonalds corporation provides global or overall functions like the "I" part of I/O, EEPROM, and RAM. (Supplies and instruction.)
Customers being the "O" part of I/O.
I think others have touched on the more significant issue though, motivation. Most college-level programming students are thoroughly insulated from the the low level hardware. They don't understand how the hardware works, or why they should care how it works. Colleges are transitioning away from programming languages like assembly or C and into languages with more high-level abstrations and less low-level connection to the actual hardware. One of my friends, a professor, told me that he expects the future of computer programming to be more associated with assemling the right pre-written building blocks using GUI tools and much less actually writing your own code.
If you think about it the same thing probably happened with us hardware guys. There were probably transistor guys watching the development of the microprocessor, thinking about how the next generation would simply assemble microprocessors and peripherals and the construction of circuits out of transisters would be a lost art. Before them, the vacuum tube guys were thinking the same about the transistor guys. Today the phrase "build your own computer"·means ordering the right cpu, motherboard, and power supply from newegg.
I guess it's called "progress".
Fortunately there are still people like this around www.youtube.com/watch?v=GcDshWmhF4A
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
For me, the past is not over yet.
What I meant is that youngsters nowadays - if they really have the idea to build something by themselves - directly want to build an iPhone without learning the basics. They are used to consume and not used to put energy in doing - I suppose.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
cmapspublic3.ihmc.us:80/servlet/SBReadResourceServlet?rid=1181572927203_421963583_5511&partName=htmltext
Hello Rest Of The World
Hello Debris
Install a propeller and blow them away
Nice idea but I don't think so. There is no way anyone is going to start programming anything without the fundamental ideas of "instruction", "sequence", "operands", "operators", "variables", "if", "then", "else" etc etc under their belt first.
Admittedly getting into the idea of parallelism may be a tad easier on the Prop in Spin than on some systems I have seen.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
For me, the past is not over yet.
I learned electronics 30 years ago and I never learned something about tubes. Transistors are still needed, so you won't get rid of em the next decade in education.
Even if you directly want to start with parallel programming you have to know the basics of programming, datastructures, algorithms ... . And please note ... the parallel programming era has just begun. Changing the paradigms takes a while in all areas .. for professional programmers as well as for education.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Powered by enthusiasm
I personally don't like analogies and black box Smile... just show me what is actually happening and I'm good.
Ohhh and some of us still use command line, and to a much greater degree. Except for my web cruising time, I would say atleast half of my time in Linux is quick command line stuff. I do all of my file management via command line, and nothing beats awk/grep/etc for some quick down and dirty data manipulation.
The world is running in parallel. But computers were machines, depending on serial execution of instructions. Therefor computer science focus on serializing parallel things. Now, computers start to be parallel even in hardware. This process is ongoing for some time, but was not available to the public. But as an individual, the natural way of acting is serial. Therefore, we always have to take care, what the character of the problem is. Then we we have to fit the problem to the abilities or vice versa. I just want to say: we should first try the second. Changing the problem means: doing something different from what was intended first.
One of the advantages of processes like a web browser is, that they do not expect certain data, but that they are able to analyze the data stream, as this stream is self describing. And the process is flexible enough to react.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
cmapspublic3.ihmc.us:80/servlet/SBReadResourceServlet?rid=1181572927203_421963583_5511&partName=htmltext
Hello Rest Of The World
Hello Debris
Install a propeller and blow them away
Once we got the kit I was suprised that he didn't get disappointed that we didn't build the mobile chassis right away, and was amazed it could do math. He actually spent time learning, with help, how to get it to solve his math homework and for the first time ever was interested in something like this. He just 'got it', accepted lots of concepts without question and loved every moment. When something didn't work, we checked the program and fixed it, he was learning some good troubleshooting skills without realising it.
He was making servos run and got two working together by duplicating code and trial and error rather than using the book and once the bot was built (cool bit of kit by the way - well done!) he was experimenting away in no time.
He was predicting things and flowcharting ideas at school and asking me how we could get it working, but, participating and entering all the code himself.
The key thing here is that he was interested.
He guessed that lots of things 'must' be there or doable from his requuirements for them to be there and wrote a program to reverse turn depending on which whisker was triggered more or less single handed, all in his spidery hand wrriten 'flowchart psuedocode' that I helped him turn into real code - but there was nothing wrong with his concept.
He isn't a child genius and struggles at school, but he is bright and that he can now code in Pbasic is a great thing, which has had a major impact on his confidence.
I am now learning the propeller based stuff as he wants to branch out and build more complex things, and Jake is now planning some wild and dangerous robots to take over the world with this new power, while I am planning on replacing a dead controller in a robot vacuum cleaner as a first project. I'm looking forward to working on many more projects with him for years to come.
Don't limit kids imaginations by worrying how they learn, just be there to guide them and they'll do fine.
-Phil
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Check out my new website!!
Use the Propeller icon!!
Follow me on Twitter! Search "Microcontrolled"
I prefer things like "global" definitions and niceties like "struct". Indirection isn't my friend. Do I understand why ? Sure. Do I like it, no. Cogs seem to confuse the issue. Not wholly sure why, but they do.
just my opinion.