The cT Programming Language and Environment

Important announcement about Python

We have an important announcement to make about the cT programming language that we have been developing in the Center for Innovation in Learning at Carnegie Mellon University. We will continue to provide a certain level of support for cT for some time, but we are now turning our attention to developing a new programming environment, by adding 3D graphics to the Python programming language. We hope that eventually this can be a replacement for cT, but there is a lot of work required to get there.

Python is a powerful programming language invented by Guido van Rossum about ten years ago. Superficially Python resembles cT, in that there are few extraneous brackets, etc., and loops and ifs have required indenting. Here are equivalent subroutines to calculate a factorial in cT and in Python:

unit      factorial(x; product)   $$ cT
           f: x, product
calc     product := x
loop    x > 1
           calc    x := x-1
                     product := product*x
endloop

def factorial(x):   # Python; note that there is no need to define variables
        product = x
        while x > 1:
                x = x-1
                product = product*x
        return product

Python is quite different from cT in being object-oriented. As is the case with cT, it is easy to start writing simple programs in Python, and even using classes and objects involves a relatively gentle learning curve. Python is cross-platform (Windows, Mac, Linux). It is open source (and therefore free) and supported by a sizable developer community. The user community though small in comparison with the users of C is quite large compared to the cT user community. Python is a general-purpose language, though a very common use of Python is for the same kinds of application for which Perl is used, to manage servers, administer systems, etc. There is an extensive web site, https://www.python.org/. A good textbook is "Learning Python" by Mark Lutz and David Ascher, O’Reilly 1999.

Python itself does not provide graphics output, though it is possible to do 2D graphics using the Tk graphics library (this is difficult however and really intended only for expert programmers). Recently David Scherer, a sophomore in computer science at Carnegie Mellon, created a 3D graphics module for Python, called "Visual", that is exceptionally easy to use; the combination of Python with Visual is called VPython. Suppose you want to write a program that calculates and displays the Earth orbiting the Sun. You create two spheres and name them "Earth" and "Sun". Then in a loop, one instant after another, you compute the new positions of the Earth, without writing any graphics output statements. Visual, running in parallel to your program, watches the current values of your Earth object and automatically updates a 3D scene of the Earth and Sun. This allows you to focus on the computational aspects and leave completely to VPython the difficult task of making a corresponding display in three dimensions.

Moreover, with no programming effort on your part, you can use the mouse to navigate in the 3D scene, looking at the scene from different points of view while the program is running.

As an added bonus, VPython supports not only graphics objects such as spheres and boxes and arrows but also full vector arithmetic. You can add or subtract vectors, multiply them by scalars, take dot and cross products, etc. This makes it much easier (and faster) to deal with vector quantitties. Often one writes a single vector statement rather than two or three vector component statements.

Some physics students at Carnegie Mellon used cT to do computer modeling (see http://cil.andrew.cmu.edu/mi.html). Students are now using VPython  instead, because we see big advantages to being able to focus better on the physics computations (without graphics statements), with 3D visualization, and with the possibility of doing true vector rather than component calculations.

The Python language itself is cross-platform, but not with respect to graphics. VPython works on Windows, Linux, and Macintosh (though some of the nice editing features available for Windows and Linux do not yet work on the Macintosh version).

You might ask, why not build Visual on top of cT rather than on top of Python? The answer is basically that because cT is not object-oriented, it would be essentially impossible to do this. We think the advantages are so compelling that we have moved from cT to VPython.

We are also encouraged in this move by the fact that Guido van Rossum himself has become very interested in what he calls "Programming for Everybody" (see essay at www.python.org). Until recently Python was used mostly by expert professional programmers. Guido believes (correctly, in our judgement) that Python could make it possible for novice programmers to write useful programs, and he wants to address the many difficulties that novice programmers face. cT has attempted to support nonprofessional programmers, and we continue to be interested in this challenge.

The VPython group at Carnegie Mellon has consisted of computer science students David Scherer, Ari Heitner, and Ian Peters, and Center for Innovation in Learning personnel David Andersen, Ruth Chabay, and Bruce Sherwood. In addition to work on Visual itself, the group has addressed various issues to make Python easy to use by novice programmers. Significant improvements have been made in installation procedures and in "Idle," the integrated Python editing and testing environment.

At present, VPython offers 3D graphics but does not offer everything that cT offers, including buttons, sliders, and edit panels. One of the thrusts of our future work is to bring these capabilities to VPython , in an easy-to-use form, based on our experience with cT. In the long run we would hope that nonprofessional programmers will be able to create in VPython the kinds of applications for which they have used cT in the past.

As far as support for cT is concerned, we expect to maintain cT for some time, to the extent of fixing serious bugs and/or getting cT to run on new versions of operating systems, but we don’t intend to add new features to cT. At this time it is an open question whether we can provide in the VPython environment capabilities comparable to those currently available in cT. If we can do this, at some point we will stop supporting cT. If someone else would like to take over support and development of cT, we would be happy to assist in a transfer of technology and responsibility.

        David Andersen and Bruce Sherwood

Overview of cT

The cT programming language is an algorithmic language like C, Pascal, Fortran, and Basic, but greatly enhanced by multimedia capabilities, including easy-to-use support for color graphics, mouse interactions, and even movies in QuickTime or Video for Windows format.

The cT programming language offers easy

programmability of multimedia programs, with
portability across Macintosh, Windows, Linux, and Unix.

The cT programming environment offers

on-line help with executable program examples,
a graphics editor for automatic generation of graphics commands,
incremental compiling to provide rapid turn-around, and
detailed error diagnosis.

cT has been developed in the Center for Innovation in Learning at Carnegie Mellon University in Pittsburgh by David Andersen, Bruce Sherwood, Judith Sherwood, and Kevin Whitley. cT is a trademark of Carnegie Mellon University.

  1. When is cT the right tool?
  2. Major features of the cT language
  3. Major features of the cT programming environment
  4. Obtaining cT at no cost
  5. Sample Programs Included with cT
  6. cT References

When is cT the right tool?

There are many excellent applications available for creating pictures and diagrams, and for making multimedia presentations, without having to write your own computer program.

However, it is sometimes the case that doing something really new and different is hard to do with these non-programming applications, because they often don't provide enough control of interactions and enough calculational capability to do what you really want to do.

cT offers the open-ended flexibility and power associated with programming languages but eliminates many of the difficulties and complexities usually associated with using a programming language.


Major features of the cT language


Major features of the cT programming environment


Obtaining cT

Download cT 3.0 at no cost for Windows, Macintosh, or Linux: Click here to view the license agreement and download cT.

Programs written in cT run compatibly on all these machines, with no changes required. All that is needed is to transfer the file and compile it.

cT formerly was distributed by Physics Academic Software, whom we thank for their professional work on behalf of cT. Vastly expanded use of the World Wide Web has made it now appropriate to try a network distribution mechanism.

Earlier versions: If you have used an earlier version of cT, be sure to invoke the on-line help and read the section on "New Features," which describes new features and changes from earlier versions.

Unix: If you are at Carnegie Mellon, you can run an older version on Unix by typing cT on an Andrew SparcStation, DECStation, or HP workstation running X, execute cT. To run the latest version, execute xct.


Sample Programs Included with cT 3.0

Here are descriptions of the cT programs available in source form to give you  ideas for your own work:

General

Graphics

Color

Video

Games

Physics and Math

Inter-computer programs using sockets


cT References