|
An article published in
C Vu magazine, December 2001, by Association of C & C++ Users (ACCU) |
|
Member Experiencescollated by Francis GlassborowWell actually this time all I have is one of my own. SoftIntegration kindly sent me a review copy of version 2 of their Ch Language Environment and here are my first impressions.
The Ch Language Environment Version 2.0report by Francis GlassborowThe package sent to me was much more than most would get because it included not only a 600 page loose leaf user guide but release versions of the product for Windows (95/98/Me/2000 and NT4), Linux, Solaris and HP-UX. I think that means that the only widely used desktop OS that is not covered is Apple's. Before I go any further let me point you to www.SoftIntegration.com where you will find a wealth of material. Most importantly you will find downloadable evaluation version of the enterprise edition appropriate to your platform. The reason I give you this information here is to make it easy for you to find when you have a moment to give the product a test-drive (and hopefully, add your impressions in a future edition of C Vu)
The Basics
Now move down a couple of lines and look at that function definition. Notice anything odd? Yes it allows me to specify exactly what shape array I intend to pass and what range of indexes are valid for it (in this case the array is locally indexed from 0 to upper - there is a limitation to this syntax in that the range must be given explicitly, constant expressions do not seem to work, i.e. 99 is fine, but 100-1 is not). If you look down to my main() you will see that there I have declared my array as being [1:upper]. In other words its index range runs from 1 to upper, which is not the same. When I call printout later I get a warning about this but the program continues because there is a sensible, but imperfect, option available. Arrays are range checked if the interpreter knows the range (that was the reason for making that parameter the way it was rather than making it an int*) but when there is a mismatch as there is here you can still get beyond the end problems. If you look towards the end of printout you will see a couple of lines that use primes[upper] and primes[upper+1]. The latter generates a warning and the interpreter uses the value in the last actual element of the array. However we lied about the size of the array so the former case prints garbage. The rest of the program is fairly close to Standard C, with a little C++ thrown in. It computes all the primes less than two million. It took about 15 seconds to do the computation and 20secs to display the results. Not lightening fast but pretty good. I increased the value of upper to ten million (so as to compute and display all primes less than twenty million) and it took about 150 seconds to compute them and three minutes to display them. When I get a moment I will move over to my machine that has 256 Mbytes of memory and see just when the system refuses to try through exhaustion of resources or otherwise. Note that I am already using over forty million bytes.
To pass arrays of different length and bounds to the function
printout(), it can be defined as follows:
And More
It does not do anything useful other than demonstrates that Ch supports arrays as first class objects and supports complex numbers. However for those working in some areas of numerics that is a massive gain. And here is a third sampler:
What Else? That would already be pretty attractive to many of us. However it has strings as first class objects and adds a foreach keyword that allows iteration with string data in three forms:
s = abc Ch supports a substantial range of 2D and 3D plotting facilities, tools for numerical analysis and a great deal more. For me, one of the great points in its favour is that I can start writing perfectly ordinary C as it was in the early part of the 90's. However when I want to satisfy my numerical interests I can just extend my use of Ch. I do not have to learn an entirely new language with subtly different semantics to one that I am used to.
Cost? I think that if you are interested in scientific and engineering and want/need to do some programming as part of that interest this is a product you should at least know about so that you make a firm decision to adopt it or not. Give it a run, see if it meets your needs. The time it will save in programming mathematical problems will soon justify the cost. Of course you could always buy Mathematica but you know that isn't cheap either.
(Note: Starting version 4.0, Ch Standard Edition is free for both commercial and non-commercial uses. Ch Professional Edition is free for academic use. ) |
|