Write to Byte
Editorial Calendar

Categories
Previous Editions
Columns
Features
Audio



Resources
BYTE Forums
WebTools
Java Resources
History Of Byte

BYTE Humor
Ian Shoales' Page

Print Archives
By Issue   By Topic

About Us
Byte Editorial Staff
Advertise with Byte
Privacy Policy




Search DDJ

DDJ Links

ARTICLES
SOURCE CODE
DEVSEARCHER
TECHNETCAST
BOOK REVIEWS
OP-EDS
COMMUNITY UNIVERSITY
MICROPROCESSOR RESOURCES
HISTORY OF COMPUTING
MAILINGLISTS




Print Friendly Version

Mr. Computer Language Person

BYTE Magazine > Mr. Computer Language Person > 2001 > November

The Ch Language Environment

(The Ch Language Environment:  Page 1 of 1 )

Long-time readers of this column know that I was educated as a particle physicist and eventually drifted into computer programming. Being a particle physicist gave me a lot of exposure to numerical analysis and computer graphics, which has stuck with me. In the last few years, while most of us were paying more attention to C++, Java, JavaScript, Perl, and Python, the ANSI/ISO C Standard Committee was continuing to evolve the C language. The result, C99, has a number of extensions over both K&R; C and C90 for numerical programming, including IEEE floating-point arithmetic, complex numbers, and variable-length arrays.

Ch is an interpreter and shell environment for a superset of C99, produced by SoftIntegration under the leadership of Harry Cheng, an Engineering professor at UC Davis, and a member of the ANSI/ISO C Standard Committee. (An article by Harry about C99 will appear in an upcoming issue of Dr. Dobb's Journal.) Ch pretty much implements all of C99 (or at least more than any other extant compiler or interpreter) plus C++ classes in its Standard edition, priced at $159-$399 depending on platform. In its Professional edition ($899-$1499) it goes on to include sophisticated plotting and serious numerical programming libraries. The Enterprise edition ($1699-$2495) adds CGI and multiuser capabilities. Ch is available for Windows, Linux, Solaris, and HP-UX. Academic and student licenses are priced well below the ranges mentioned above.

First Impressions and Comparisons

If you already know C/C++, you'll find Ch a congenial development environment — the fact that it's an interpreter and has a big library make a lot of things very simple. Ch also seems like it would be fabulous for beginning C/C++ programmers to use as a learning environment. As a shell-programming environment, I can see using it, with some reservations. On Windows in particular, I'm not sure whether I like Ch as well as the Hamilton C Shell or the MKS Toolkit, mostly because those packages have extensive collections of UNIX-like utilities, and more amenities in their shells than Ch currently sports.

Ch reminds me most of two other products: the old Instant-C environment, and MATLAB. Instant-C, for those of you who don't remember it, was a very slick, high-performance C programming environment that sported an incremental compiler and used one of the first DOS extenders, DOS/16M. It was a product of Rational Systems, now Tenberry Software. I often regretted having to give up Instant-C when I started doing Windows programming — it was a great development environment, especially when you were debugging. Ch isn't quite at Instant-C's level for debugging, however, at least in this release.

MATLAB, a product of The Mathworks, "integrates mathematical computing, visualization, and a powerful language to provide a flexible environment for technical computing." The Professional edition of Ch has facilities that are competitive with MATLAB's, and the Ch manual includes a table that helps translate most MATLAB functions to Ch. For example, the MATLAB function to perform a Cholesky decomposition of a matrix, A=chol(A1), can be expressed in Ch as choldecomp(A1,A).

Performance and Safety

Although you wouldn't think so, it's very hard to measure the performance of an interpreted programming environment in a meaningful way, especially when it can take advantage of compiled code when needed, as Ch can. What I can say about the performance of Ch is that it feels OK for the most part, even on my old 400-MHz Pentium II. Yes, I can certainly make Ch slow down by writing interpreted code with tight inner loops, but I can also write very fast matrix operations easily, by using the built-in numerical library functions.

A shell as powerful as Ch can be quite dangerous in malicious or inexperienced hands. This is especially true when scripts can be accessed over the network. Fortunately, Ch has a "safe" mode that restricts programs and scripts to a "sandbox," going so far as to suppress pointer arithmetic.

Advanced Features

Plotting in Ch includes fairly sophisticated 2D and 3D graphs. The emphasis in Ch's CPlot class is on scientific and engineering graphs, so you'll find that it easily does things like plotting a 3D contour surface with hidden line removal in spherical coordinates with accurate axis labels. It's not quite so strong on business presentation graphs — right now, at least, you probably couldn't use it for stacked 3D bar charts, or pictogram bar charts.

The categories of numerical analysis functions in Ch read like the chapters in a graduate-level book on numerical methods, and appear fairly complete to my eye. I thought I spotted a glaring omission, cubic spline interpolation, but I was wrong (it turned out to be included as an option in a generic interpolation function). Even some advanced procedures, like Singular Value Decomposition, are included — with complex variables, yet. I didn't find a nonlinear least squares solver, or a partial differential equation solver, but those are pretty specialized.

CGI support in Ch revolves around CResponse, CRequest, CServer, and CCookie classes. Output uses the ordinary printf() function and its relatives. In general, writing CGI scripts in Ch looks about as simple as writing them in Perl, and way simpler than writing them in bare C.

You can combine the CGI and plotting features of Ch, as is done on SoftIntegration's web site. One nice trick is that you can use the output of a plotting script as the source of an image tag. You can also use Safe Ch scripts as applets, but only on machines where Ch is already installed.

Quibbles and Futures

The weakest part of the current Ch distribution, Version 2.0, seems to be the debugger. It has no GUI, and all it can really do at this point is single-step into a line, evaluate an expression, and run the rest of the program. It can't even step over a line, so when you single-step you wind up debugging into stuff you really don't want to see, like stdio.h. I've been promised a "step over" command in the next release of Ch, and a GUI debugger for a future version.

While Ch has shell command editing using the command history and quick string substitution, in Windows 95/98/Me it can't edit the command line interactively with the arrow keys. It can do this in Windows NT/2000/XP, but only because it has inherited that capability from the system command prompt, cmd.exe. Also, Ch seems to lack a way to save and restore the command history.

Ch sets its own shell path defaults very restrictively, choosing safety over power. You can change the various paths that Ch uses by editing .chrc (or .schrc for the Safe Ch shell) in your home directory. It's a very UNIX-like setup; I can see beginners finding it awkward.

Ch has no database support now, but I'm told that an ODBC package is actually in use on SoftIntegration's web site and due to be released soon, and that an ADO package is planned for the future. In a similar vein, Ch has no GUI support now, but an interface to GTK+ is coming soon.

Overall, I think Ch is a game effort, and I wish SoftIntegration well with it. The few quibbles I've mentioned are the sorts of things that will be fixed in time. I can certainly recommend Ch to scientists and engineers and C/C++ programmers; as for using Ch as a general shell-programming environment or for CGI, it's not for everyone, although some people will probably like it a lot.


Martin Heller is a Web and Windows programming consultant, an author, and a Senior Contributing Editor at Byte.com. His most recent publicly viewable project is PC Pitstop. You can reach Martin at MrCLP@mheller.com.

 Page 1 of 1 






 

 

www1