The dilemma of Conditional Compilation
LoopyByteloose
Posts: 12,537
It really doesn't matter if it is the BasicStamp or the SX series, I find the conditional compilation often a distraction to learning.
Learning is about noticing revealent details in an appropriate order.·
At some point the use of conditional compilation distracts and overwhelms the learner.
Usually because it necessarily positions itself at the beginning of a file and introduces topics unknown in a complex manner.
While it has not be much of a burdern for me with the BasicStamp, sorting through pages of preliminary conditionals to get to the gist of an SX program in SASM is daunting to me.
Am I the only one, or is this scaring away learners?
Seems like there should be two presentations which depend on who is trying to learn what.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"When all think alike, no one is thinking very much.' - Walter Lippmann (1889-1974)
······································································ Warm regards,····· G. Herzog [noparse][[/noparse]·黃鶴 ]·in Taiwan
Learning is about noticing revealent details in an appropriate order.·
At some point the use of conditional compilation distracts and overwhelms the learner.
Usually because it necessarily positions itself at the beginning of a file and introduces topics unknown in a complex manner.
While it has not be much of a burdern for me with the BasicStamp, sorting through pages of preliminary conditionals to get to the gist of an SX program in SASM is daunting to me.
Am I the only one, or is this scaring away learners?
Seems like there should be two presentations which depend on who is trying to learn what.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"When all think alike, no one is thinking very much.' - Walter Lippmann (1889-1974)
······································································ Warm regards,····· G. Herzog [noparse][[/noparse]·黃鶴 ]·in Taiwan
Comments
(Or worst case, I switch to another product entirely)
Because any introductory book that introduces conditionals early on is clearly written by someone who is out to prove that they can everything about that processor/machine/whatever instead of trying to teach the fundamentals.
In the case of the SX chip, yes I know that there are a whole range of them, with differing capabilities, but that still doesn't require conditionals. (You only need conditionals if the same source is to be used on different models)
The correct place to put it is somewhere in the last part of the book, preferably in the 'Advanced topics' section.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Don't visit my new website...
I agree to a point conditional compiling is a good thing, but some of the VP code from ubicom is ridiculous. Try looking at the code for the SX48/52 timers. Funny thing is that the SX28 doesn't have the timers, yet there is pages and pages of conditional code to support both cores. Then a couple dozen lines to work with the timers.
There are only two versions of the SX core (AC and BD), I would much rather just see two different versions of a program.
To a lesser extent this is the same reason I don't use macros. They "hide" the true workings of the chip, well the reason I'm writing assembly code is because I WANT to know the true workings of the chip. Again to a point, macros are a good thing.
Let's be clear, I am NOT anti-conditional compiling or anti-macros. Both have their place, but like government, a little goes a long way.
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"SX-Video·Module" Now available from Parallax for only $28.95
http://www.parallax.com/detail.asp?product_id=30012
"SX-Video OSD module" Now available from Parallax for only·$49.95
http://www.parallax.com/detail.asp?product_id=30015
Product web site: www.sxvm.com
"Wise men know when they're right. The wisest also·know when they're wrong."
·
I didn't know about the Ubicom Timer examples. Someone got silly. It is nice to know it just isn't me. I would like to think that Parallax wants to re-evaluate such presentations in a more learner friendly way. I do understand that they have a very full agenda right now too.
Since the SXes really have only two flavors, Ubicom may have really made a signnificant marketing mistake by putting all their programs in the conditional format. It would have been simplier to just offer A and B. The conditional could have sat around as a 2nd option.
And yet Conditional Compilation can be quite handy with the BasicStamps as providing a 'test bed program' for a new product that will run on a diverse array of BasicStamps. So there are pros and cons.
But for the learner, I still think it has too much down side and should be 'a side dish' to the 'main course'.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"When all think alike, no one is thinking very much.' - Walter Lippmann (1889-1974)
······································································ Warm regards,····· G. Herzog [noparse][[/noparse]·黃鶴 ]·in Taiwan
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
John R.
8 + 8 = 10
I certainly do acknowledge what you are saying. When I buy a new add-on from Parallax or whom-ever, I want to verify that it is working and a conditinal compilation allows me the immediate verification. It is very important to preserve in that context.
After all, it is just human nature to think something is defective or a piece of junk if you cannot get it to run right away. We just don't want to face our own learning curve.
But, the learner needs something quite different in a 'tutorial sense'. Ubicom fell short in providing that.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"When all think alike, no one is thinking very much.' - Walter Lippmann (1889-1974)
······································································ Warm regards,····· G. Herzog [noparse][[/noparse]·黃鶴 ]·in Taiwan
I'd also add that at some point, it is important to understand what is happening with the conditional compiles,·in terms of what "Conditional Compiling" does,·why different types of chips require different options, and what those options are for the various chips.
There is a fine line between putting something in place to prevent problems and getting in the way of learning.· You certainly don't want to "overload" a new user.· Let them start easy and basic, and go from there.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
John R.
8 + 8 = 10
Post Edited (John R.) : 3/9/2006 5:56:27 PM GMT
As in the case of the baud parameter among different versions of stamp, it is nessesary to provide the correct parameter regardless of the particular processor (stamp) used. Keeping a single file helps keep the programmer sane, since any modifications to the code only needs to be done once instead of individually changing X different versions. This follows the same theory of using a symbolic constant instead of the numeric constant scattered through your code (try getting Jon to look over your code if you publish code without symbolic constants). If a seperate program were required for every version of stamp, there would be a ton of users asking why such and such a program doesn't work, to which we would have to say: "You downloaded the wrong version". As far as the SX is concerned, conditional compilation is absolutely required when writing code to be run on either the·SX28·or SX52 because the way the memory map works between the SX28 and SX52 is drastically different.
Second it is often desirable to provide the end user with a host of various features, conditional compilation makes it possible to provide the end user with various features that are or aren't compiled, again only using a single file. The reason this is important is that sometimes you want to possibly have a feature (perhaps boundry checking for arrays), but that feature consumes both memory and processing cycles.
To provide an example, I am working on assembly versions of SPI routines (SHIFTIN/SHIFTOUT) for the propeller. I switched to assembly to get faster throughput when interfacing with fast serial peripherals. But I want to be able to interface at the fastest possible rate AND also support serial devices that cannot support the the fastest rate. The second version requires waiting a fixed time period to proceed (this means the two routines are identical except the second version has two extra commands in the routine), but there is such an overhead to do this that the fastest the second version can run is only 1/3 the speed of the full speed version. And the Propeller IDE does not as of yet support conditional compilation. So I had to write two routines, two initialization routines and a monitor to choose which of the two routines to run based on which initialization routine was run. The result is the object takes up twice the memory in the central memory, takes up twice the space in the cog memory, and can lead to confusion as to which intialization routine to run. Another object for the propeller I am working on is a diagnostic tool, and the user may want one type of analysis on a particular project and another type for another project, in all I am having to write THREE different routines, even though the user will only likely use one of them for any given project. Again resulting in certain sections requiring triple the resources, leaving less for the user's actual program they are trying to diagnose.
As far as program readability, I could give a rat's you know what to whether some novice programmer can read the code or not. Don't get me wrong, I comment every line of code I write, but that is for me to remember what I did·and other·experienced programmers to understand what I did. I dont write distributable code as a learning exercise for the end user, I do it to provide a useful tool for them to accomplish something they don't have the experience to do for themselves. I know this viewpoint is crass, but Im not going to hobble myself or make my efforts more cumbersome to accomodate those who don't understand conditional compilation, chances are they aren't going to understand other programatically efficient means (tricks of the trade) I use as well. Should I instead use 3 lines of code to accomplish·what can be done in a single line·so someone can follow in a more linear mathmatical model? I think not.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·1+1=10
Post Edited (Paul Baker) : 3/9/2006 7:30:21 PM GMT
I've tossed away lots of books and introductory texts because the author is more interested in showing off what he can make the tools do, instead of teaching the reader the fundamentals.
And yes, for the experienced programmer, conditional compilation and macros are great tools.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Don't visit my new website...
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·1+1=10
In teaching English, I find pleasure in studying a meaty book on Lingusitics or Semantics. But when I teach a class, it is my duty to get down to the student's level and help them move up.
I think that it is pretty much the same here.
I do understand that expertise is most often earned by working though rough terrain and undocumented territories. I think this is why Asian cultures have a traditional respect for the teacher. It takes a certain willness to share knowledge in order to be a good teacher.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"When all think alike, no one is thinking very much.' - Walter Lippmann (1889-1974)
······································································ Warm regards,····· G. Herzog [noparse][[/noparse]·黃鶴 ]·in Taiwan