Browse in : |
All
> Journal Columns
> Francis' Scribbles
All > Journals > CVu > 161 Any of these categories - All of these categories |
Note: when you create a new publication type, the articles module will automatically use the templates user-display-[publicationtype].xt and user-summary-[publicationtype].xt. If those templates do not exist when you try to preview or display a new article, you'll get this warning :-) Please place your own templates in themes/yourtheme/modules/articles . The templates will get the extension .xt there.
Title: Francis’ Scribbles
Author: Site Administrator
Date: 07 March 2004 19:37:18 +00:00 or Sun, 07 March 2004 19:37:18 +00:00
Summary:
Repository of Projects
We need to program in order to develop our programming skills. Anything more than the most trivial program takes time and effort. Most students (in the broadest sense of someone who is studying) find it hard to motivate themselves with projects whose end product is of little use or interest to them. It is much easier to put in the hours doing a job properly if the result is something we have a personal interest in.
Body:
However even the most capable teacher has a limited range of interests and domains of expertise. Those indulging in self-development are unlikely to even have the advantage of a teacher, let alone one who can suggest fulfilling activities that will both develop their skills and produce a useful end product.
Students often have difficulty with selecting an achievable objective from their own areas of interest because they simply do not know what programming can achieve. For example in my days as a teacher I often had pupils who wanted to write a program to play chess. They had little idea about how difficult it is to write such a program. However there are many potential programs round the topic of playing chess. Such simple ones as creating an electronic board can develop into tools of value. For example once you have an electronic chessboard you can feed it a file of a games you are studying, create alternative branches (getting some ideas about version control on the way) and easily backtrack to earlier moves.
I am in the process of creating a repository of potential programming projects (www.spellen.org/youcandoit/projects) as a resource for anyone studying programming in any language of their choice. By the time this is published enough should be in existence so that a visit will give you the idea of what is wanted for further development.
I am limited in the range of my interests and so need contributions from as far afield as possible. My hope is that everyone who reads this or who visits the site will contribute just one project suggestion. Contributors will be acknowledged.
This repository is a form of open source project without any source. It will only work if many people contribute a little to it. It helps if you have some idea about how hard the problem is and how demanding it will be of a program language. It also helps if you can identify one or more suitable places on the Web where relevant domain knowledge is available.
Let me be blunt, failure to contribute at least one project simply labels you as lazy because you cannot be a programmer without having some idea of at least one way that programming can be applied to a subject of interest to you. If you are only interested in programming (an unlikely event) there are a myriad ways that programming can be used to develop tools for programming.
Please note that I do not intend to publish source code for solutions on the site as that would degrade its value as a teaching resource. However I think that some way that instructors could obtain good source code in one or more languages might be useful. Anyone have any ideas as to how we could achieve that objective without spoiling projects for students?
If you teach programming, even on an informal basis, I hope you will find the repository useful for enthusing your students, useful enough that you will provide a link to it from any relevant pages that you manage.
This is a book (0-471-45879-1) about the various US government reactions to 9/11 (I still wonder if that date was chosen deliberately; 911 is the US emergency phone number.) It is well worth reading both because of the author’s understanding of the US and because of his lack of understanding of the rest of the world and factual inaccuracies with regard to things external to the US (he thinks the Basque terrorists are French.)
If intelligent, well-educated US citizens who are willing to spend time researching on the Internet remain so profoundly US-centric we continue to have serious problems for which I can see little hope for solutions.
About eighteen months ago my wife and I had a problem when visiting the US. The cause of the problem was that they had no record of my wife having left after a previous visit so she was listed as having outstayed her six months on the visa-waiver program. Fortunately the date they had for her prior entry to the US was 1909 (yes, really). Worse, she had a new passport and so the old documentation was gone. It was so manifestly an error that it only took us half an hour to sort it out. But how does such a ludicrous error get into the system?
Part of the problem was highlighted on our most recent visit where no one collected the exit part of our visa-waiver, well, not until I drew their attention to this as we were about to board for the final leg of our return journey. Is it any wonder the best estimate for illegal immigrants in the US is in the millions?
Actually the whole green card visa-waiver procedure was (I do not know what it will be like the next time I visit in the Autumn this year) ludicrous in an electronic age. Clearly they should have been completed before embarkation and many of the details could be pre-entered by the airline (flight number, date, and points of departure and arrival). Indeed, with electronically readable passports the passport number should also be inserted automatically. Such pre-processing would be in everyone’s interests. What airline wants to find that one of their passengers cannot enter the country of destination only after they have flown them there?
The processing of immigrants and visitors to the US is inconsistent with their belief that they are the most advanced technological society in the world. Requiring biometric passports is fine, but only if you have the infra-structure in place to manage data correctly and consistently. Those on the ground trying to manage the problems are generally courteous and thoughtful and can see what a mess is provided by inappropriate or incorrect use of technology. Those responsible for the systems are, at best, out of their depth.
Anyway, read the book but do not get too irate by the author’s lack of understanding of how the rest of the world views US interventions.
CLI stands for ‘Common Language Interface’ (I think) and is basically the .NET mechanism whereby processes written in different languages can interoperate.
Several years ago Microsoft produced something called ‘Managed C++’ which even their own C++ experts admitted was pretty awful. Recently Microsoft proposed that there should be a set of standard bindings from C++ to CLI. At one level this makes perfectly good sense. The trouble starts when new keywords and structures are necessary for C++ to support the CLI object model. In an ideal world we would modify CLI to better match major features of C++ (such as the concept of const qualified objects). However we do not live in an ideal world. We also have the problem that CLI is already a Standard (via ECMA) and is currently going through a revision. Obviously we want to have a major influence on that so that there is a better match with C++.
This leads to the problem that the ‘correct route’ to such a C++/CLI binding via a Technical Report from WG21 is too slow to have any chance of influencing CLI.
The ‘solution’ is to use ECMA as a fast mechanism, fast enough that we have some remote chance of getting some changes to CLI along the way. However the trouble with fast processes is the potential for mistakes along the way. This is quite worrying, not least because despite the successful efforts of Herb Sutter and Tom Plum to get the ECMA participation/liaison rules modified (or at least interpreted) so that National Body experts can have oversight of the proposals and input to them (even though without a vote) only the UK (plus France through a single expert) appears to have taken up the opportunities.
It is interesting to note that just about all the participants in TG5 (the ECMA group dealing with this) are actually also members of WG21. The real problem is getting TG3 (responsible for CLI) to listen and respond. This is another problem related to the fast timetable that ECMA groups tend to set. Even when you are using electronic communications getting consensus is time-consuming.
My biggest concern is that we know from bitter experience that getting things right takes time, and even when we think we have managed it we are too often mistaken. The experts reading this might like to think about the problems with ADL (argument dependent lookup, sometimes called Koenig Lookup) and the problems that both C++ and Java have had with exception specifications (even though they tried different approaches).
For example, in my opinion, even when we want to provide something such as ‘interface classes’ in the C++/CLI binding and use a keyword for the purpose we should stick to the underlying C++ syntax (properly declared pure virtual functions) and just use the keyword to instruct the compiler to diagnose breaches of the CLI requirements (i.e. in this case, only public members, no data etc.) The result of omitting ‘interface’ should mean as near as possible the same thing in pure C++.
I am sure that the result of the UK participation through the BSI will be that the work being done to support CLI in C++ will be much better. It is only a pity that there are not more people involved in the effort. Despite what I read in one book recently, Standards are not dead and work on them does improve the ordinary user’s lot.
I will be in Australia for the last two weeks of March and for the first week of April. I will start in Melbourne and attend the ECMA TG5 (C++/CLI) meeting there before moving over to Sydney for the WG21 (C++) meeting followed by WG14 (C) which is the reverse order to the normal one.
It is disappointing that after many of us have made a special effort to go to Australia, it seems that few if any Australian experts will make the effort to attend the meetings. Worse, the Australian National Body is no longer even an O (for observer) member of SC22 which is the parent committee of WG21 and WG14. I can think of some other places I would like to visit if local interest in Standards is not required.
The other issue is that those dates are exactly the time when I would normally be working on my contributions to the next issue of C Vu. Please make a special effort to get your contributions in early because I would like to get as much as possible done before I leave for Australia. I know I can do much of the work on a laptop but I am happier working with my reference books close to hand.
It went to reprinting five weeks after its release in the UK. US book chains have been upping their orders even before it goes to distribution there (on February 9th). As the first reprint was before a single review had been published, clearly many of you have been doing your bit to tell others about it. Please keep up the good work.
Look at the following C code. Why does qsort() fail? Please note that the compare() function does rank any two objects of type X.
struct X{ int i; int j; int k; }; int compare(void * p1, void * p2){ struct X * x = p1; struct X * y = p2; if(x.i > y.i) return 1; if(x.j > y.j) return 1; if(x.k > y.k) return 1; return x.i + x.j + x.k – y.i – y.j – y.k; } int main(){ struct X array[10]; /* code initialising array */ qsort(array, sixeof(X), 10, compare); /* etc. */ return 0; }
Please look at the following two functions that are intended to save and restore the red, green and blue intensities of a palette of 256 24-bit colours. Actually you do not need to know the gory details, all you need to know is that the first function writes some data to a file and the second is supposed to restore it. What is wrong?
void save_palette(playpen const& canvas, string filename) { ofstream out; open_ofstream(out, filename); if(out.fail()) throw problem("Could not open file"); for(int i(0); i != 256; ++i) { HueRGB const mix(canvas.get_entry(i)); out << int(mix.r) << " " << int(mix.g) << " " << int(mix.b) << '\n'; } } void restore_palette(playpen & canvas, string filename) { ifstream in; open_ifstream(in, filename); if(in.fail()) throw problem("Could not open file"); for(int i(0); i != 256; ++i) { canvas.set_entry(i, HueRGB(read<int>(in), read<int>(in), read<int>(in))); } }
I wonder how long you stared at that code before the penny dropped? Even given the advantage of seeing that the result was of writing out a palette and then reading it back resulted in a completely different palette it took me an embarrassing time to realise what the problem was. In a way I was lucky that the error was so visible and that it happened immediately with the compiler I was using.
The problem is that the HueRGB constructor takes three arguments. The fact that they are all identical is not important except that it guarantees that nothing has a chance to detect the error other than the human eye.
Remember that the order of evaluation of sub-expressions is unspecified. The arguments of a function call can be evaluated in any order. The compiler I was using (the MinGW version GCC) evaluates arguments right to left. The data was written to the file left to right. The result was that red and blue values were exchanged by the process.
Elegant though the canvas.set_entry might seem to some, it is fatally flawed by trying to do too much in one gulp and must be replaced by something such as:
int const r(read<int>(in)); int const g(read<int>(in)); int const b(read<int>(in)); HueRGB const p(HueRGB(r, g, b)); Canvas.set_entry(i, p);
It is generally better to evaluate the arguments of a function call like this as it avoids the possibility that an order of evaluation will arise. Making all the intermediate values const variables allows the compiler to optimise but keeps control of the order of evaluation.
Last time I set you the following little problem concerning ‘Greek’ style clues. Unfortunately I miscounted on my fingers and gave you the wrong number (I meant to give you 271, that is covered by ‘apt’, ‘tap’ and ‘pat’). 261 only provides ‘oat’ and ‘Tao’. Perhaps this error confused you into thinking you did not understand the problem. I hope that was the reason that I have not had any responses because otherwise it says little for the creativity of my readers. Anyway here are a couple of possible clues for 261:
The result if Tao were valued in Greece. Counting wild oats in a singularly Greek fashion.
And for the intended value (271):
A Greek tap is particularly apt in a numerical way. A Greek tap is numerically indistinguishable from a pat on the head.
[Based on: A-J representing 1 to 10, J-S representing 10 to 100, S-Z representing 100 to 800.]
So far I have had two entries but the actual selection of prize winners will have to wait till the deadline (either the production editor will manage to sneak it in at the last minute or the announcement will be in the next issue.
I have this from John Kewley:
Txt me “happy” one Christmas!
’ll try and think of something less seasonal for 3 * 3 * 17 * 27960259
[Try: The text of Happy Xmas. Francis]
And Richard Blundell sent me this:
OK, how about this for a clue for your number:
“Bubbly hooligans phone to wish seasonal greetings (10 digits)”
The “seasonal greetings” bit is obviously the phrase you were encoding, namely “Happy Xmas”. But an alternative answer (at least on my phone) is also “Gassy Yobs”, hence the first part of my clue.
And that really gets into cryptic clues by giving the answer two ways.
Thanks to both for making the effort to come up with good clues and remembering to brighten my day by sending them in.
Another form of numerical clue is to use the time or date of some event that is well known to the readership. Clues actually using a time tend to be very much local to groups but dates can be more general:
When next Julian has one that Gregory skips. (4 digits)
Notes:
More fields may be available via dynamicdata ..