Recent from talks
Nothing was collected or created yet.
Ch (computer programming)
View on Wikipedia| CH C/C++ interpreter | |
|---|---|
| Original author | Harry H. Cheng |
| Developers | SoftIntegration, Inc. |
| Initial release | October 1, 2001 |
| Stable release | 8.0.0
/ November 19, 2017 |
| Written in | C |
| Operating system | Windows, OS X, Linux, AIX, HP-UX, Solaris (SPARC and x86), QNX, FreeBSD |
| Platform | x86, SPARC |
| Available in | English |
| Type | Integrated development environment |
| License | Proprietary software Standard edition: freeware Student edition: freeware for students Professional edition: trialware for 30 days |
| Website | www |
CH /ˌsiːˈeɪtʃ/ is a proprietary cross-platform C and C++ interpreter and scripting language environment. It was designed by Harry Cheng as a scripting language for beginners to learn mathematics, computing, numerical analysis (numeric methods), and programming in C/C++. Ch is now developed and marketed by SoftIntegration, Inc.. Free versions include the student edition, and the non-commercial Professional Edition for Raspberry Pi.
CH can be embedded in C and C++ application programs. It has numerical computing and graphical plotting features. CH is combined of both shell and IDE.[1] CH shell combines the features of common shell and C language.[2] ChIDE provides quick code navigation and symbolic debugging. It is based on embedded CH, Scite, and Scintilla.[3][4]
CH is written in C and runs on Windows, Linux, macOS, FreeBSD, AIX, Solaris, QNX, and HP-UX. It supports C90 and major C99 features, but it does not support the full set of C++ features. C99 complex number, IEEE 754 floating-point arithmetic, and variable-length array features were supported in CH before they became part of the C99 standard.[5][6][7][8] An article published by Computer Reseller News (CRN) named CH as notable among C-based virtual machines for its functionality and the availability of third-party libraries.[9]
CH has many tool kits that extend its functions. For example, the CH Mechanism Toolkit is used for design and analysis of commonly used mechanisms such as four-bar linkage, five-bar linkage, six-bar linkage, crank-slider mechanism, and cam-follower system.[10] CH Control System Toolkit is used for the design, analysis, and modelling of continuous-time or discrete-time linear time-invariant (LTI) control systems.[11] Both tool kits include the source code.
CH has been integrated into free C-STEM Studio, a platform for learning computing, science, technology, engineering, and mathematics (C-STEM) with robotics. C-STEM Studio is developed by the UC Davis Center for Integrated Computing and STEM Education, offering a curriculum for K-12 students.
CH supports LEGO Mindstorms NXT and EV3, Arduino, Linkbot, Finch Robot, RoboTalk and Raspberry Pi, Pi Zero, and ARM for robot programming and learning.[12][13][14] It can also be embedded into the LabVIEW system design platform and development environment.[15]
Features
[edit]CH supports the 1999 ISO C Standard (C99) and C++ classes. It is a superset of C with C++ classes. Several major features of C99 are supported, such as complex numbers, variable length arrays (VLAs), IEEE 754 floating-point arithmetic, and generic mathematical functions. The specification for wide characters in Addendum 1 for C90 is also supported.
C++ features available in CH include:
- Member functions
- Mixed code and declaration
- The this -> pointer
- Reference type and pass-by-reference
- Function-style type conversion
- Classes
- Private/public data and functions in classes. Ch is compatible with C++ in that by default, members of a class definition are assumed to be private until a 'public' declaration is given
- Static member of class/struct/union
- Const member functions
- The new and delete operators
- Constructors and destructors
- Polymorphic functions
- The scope resolution operator
- The I/O functions cout, cerr, and cin with endl
- Arguments for variadic functions are optional
CH supports classes in C++ with added abilities, including:
- Classes inside member functions
- Nested functions with classes
- Passing member function to argument of pointer-to-function type of functions
CH can interact with existing C/C++ libraries and call C/C++ functions from CH script.[16] As a C/C++ interpreter, CH can be used as a scripting engine and extension language for applications. Pointers to arrays or variables can be passed and shared in both C-compiled and CH scripting contexts. One example of an embedded CH scripting application is Mobile-C, which has been used for collaborative visualization of distributed mesh model.[17][18][19]
CH has a built-in string type (string_t) for automatic memory allocation and de-allocation. It supports shell aliases, history, and piping.[20][21]
CH has built-in 2D/3D graphical plotting features and computational arrays for numerical computing. A 2D linear equation of the form b = A*x can be written verbatim in Ch.[22]
See also
[edit]References
[edit]- ^ Veeraraghavan, Sriranga (2013). "An introduction to Ch: Implementing a temperature converter in Ch". ComputerWorld.
{{cite journal}}: Cite journal requires|journal=(help) - ^ Ch Shell
- ^ Ch IDE
- ^ Wang, Gary (2002). "Ch Solves Portability Headaches". IEEE Spectrum. 39 (6): 59. doi:10.1109/MSPEC.2002.1049264. S2CID 32477309.
- ^ Cheng, Harry (1993). "Handling of Complex Numbers in the Ch Programming Language". Scientific Programming: 76–106.
- ^ Cheng, Harry (1993). "Scientific Computing in the Ch Programming Language". Scientific Programming: 49–75.
{{cite journal}}: Cite journal requires|journal=(help) - ^ Cheng, Harry (1995). "Extending C and FORTRAN for Design Automation". ASME Trans., Journal of Mechanical Design: 390–395.
{{cite journal}}: Cite journal requires|journal=(help) - ^ Cheng, Harry (1995). "Extending C with arrays of variable length". Computer Standards & Interfaces. 17 (4): 375–406. doi:10.1016/0920-5489(95)00007-H.[dead link]
- ^ Morejon, Mario (2006). "Ch Language Rivals Java Functionality". CRN.
{{cite journal}}: Cite journal requires|journal=(help) - ^ Cheng, Harry (2006). "Object-Oriented Interactive Mechanism Design and Analysis". Engineering with Computers. 21 (3): 237–246. doi:10.1007/s00366-005-0008-4. S2CID 16996625.
- ^ Zhu, Yong (2003). "An Object-Based Software Package for Interactive Control System Design and Analysis". Journal of Computing and Information Science in Engineering. 3 (4): 366–367. doi:10.1115/1.1630815. S2CID 17908643.
- ^ ch robot
- ^ ch finch
- ^ ch raspberry and arm[permanent dead link]
- ^ "Embedding a C/C++ Interpreter Ch into LabVIEW for Scripting".
- ^ Wilson, Matthew (2004). "Open-RJ and Ch". Dr. Dobb's Journal.
- ^ Cheng, Harry (2009). "Speeding-Up Software Development Using Embedded Scripting". Dr. Dobb's Journal. p. 8.
- ^ Wang, Li-rong; Bo, Yo; Hagiwara, I (2009). 2009 IEEE 10th International Conference on Computer-Aided Industrial Design & Conceptual Design. Computer-Aided Industrial Design & Conceptual Design, 2009. CAID & CD 2009. IEEE 10th International Conference. pp. 1127–1132. doi:10.1109/CAIDCD.2009.5375178. ISBN 978-1-4244-5266-8. S2CID 39307433.
- ^ Wang, Li-rong; Bo, Yo; Hagiwara, Ichiro (2009). An agent based collaborative simplification of 3D mesh model. Cdve'09. CDVE'09 Proceedings of the 6th international conference on cooperative design, visualization, and engineering. pp. 325–328. ISBN 9783642042645.
- ^ Campbell, Matt (2003). "Ch, A C/C++ Interpreter – New possibilities for people who like C and Unix". MACTECH, the journal of Apple technology.
{{cite journal}}: Cite journal requires|journal=(help) - ^ Cheng, Harry (2010). The Ch Language Environment (6.3 ed.). Davis, CA: SoftIntegration, Inc.
- ^ Glassborow, Francis (2001). "The Ch Language Environment Version 2.0". C Vu Magazine: 36–37.
{{cite journal}}: Cite journal requires|journal=(help)
Further reading
[edit]- Heller, Martin (2001). "The Ch Language Environment". Byte. Archived from the original on November 16, 2001.
{{cite journal}}: Cite journal requires|journal=(help) - Cheng, Harry (2002). "C99 & Numeric Computing". Dr. Dobb's Journal. pp. 28–34.
- Cheng, Harry (2006). "Ch: A C/C++ Interpreter for Script Computing". Dr. Dobb's Journal. pp. 6–12.
- Cheng, Harry (2009). C For Engineers & Scientists, An Interpretive Approach. McGraw-Hill. ISBN 978-0-07-729046-7.
- Cheng, Harry (2011). C For Engineers & Scientists (Chinese ed.). Higher Education Press. ISBN 978-0-07-729046-7.
External links
[edit]Ch (computer programming)
View on GrokipediaIntroduction
Overview
Ch is a proprietary, cross-platform interpreter and scripting language environment for C and C++ , designed primarily for interactive computing, scripting, and numerical tasks.[5][6] Developed by SoftIntegration, Inc. and originally designed by Harry H. Cheng, it was initially released on October 1, 2001.[7][8] The primary goals of Ch include enabling beginners to learn C and C++ interactively through an accessible environment, supporting shell programming for automation and system tasks, and providing embedded scripting capabilities for integration into larger applications.[9][10][11] These objectives address the limitations of traditional compiled C/C++ workflows by allowing immediate execution and testing of code without compilation cycles.[12] A key differentiator of Ch is its integration of a shell (Ch shell), integrated development environment (ChIDE), and interpreter into a single cohesive environment, facilitating rapid prototyping and education in ways not typical for standard C/C++ tools.[13][10] It complies with the C99 standard and includes features for numerical computing, such as support for complex numbers and computational arrays.[6]History and Development
Ch, an embeddable C/C++ interpreter and scripting language, was originally designed and implemented by Dr. Harry H. Cheng, a professor in the Department of Mechanical and Aeronautical Engineering at the University of California, Davis, to facilitate teaching introductory computer programming in C to computer science and engineering students.[3] The language emerged around 2000 in response to the need for an interactive computing environment tailored to educational curricula, allowing students to execute C code incrementally without compilation, similar to interactive tools like MATLAB but grounded in C/C++ standards.[2] This academic origin addressed the limitations of traditional compiled C environments in classroom settings, where immediate feedback was essential for learning programming concepts.[3] Commercialization began with the founding of SoftIntegration, Inc. in 1999, though the company focused on distributing Ch starting with its initial release, version 1.0, on October 1, 2001.[14][7] SoftIntegration, headquartered in Davis, California, positioned Ch as a cross-platform tool for scripting, numerical computing, and embedded applications, leveraging Cheng's invention to market it to educators, engineers, and scientists.[15] Key milestones included version 3.0 in 2004, which added full support for the ISO C99 standard, enhancing features like complex numbers and variable-length arrays for advanced numerical tasks.[16] Later versions introduced C++ class support, beginning around version 2.0 and expanding in subsequent releases to include object-oriented capabilities such as nested classes and member function passing.[2] Development continued with regular updates through the 2010s and 2020s, culminating in version 8.5, released on July 14, 2024, which includes updates for Mac OS X Sonoma compatibility, new functions like REPEAT_UNTIL, and enhancements for educational tools bundled in C-STEM Studio.[17][18] As of November 2025, SoftIntegration maintains Ch for professional scripting and academic settings, with version 8.5 as the latest release. In the 2010s, Ch was integrated into C-STEM Studio, an open-source platform developed by Cheng's UC Davis C-STEM Center—founded in 2010—for K-12 STEM education, enabling block-based to text-based coding transitions with robotics hardware like Arduino.[19][20] This evolution reflects Ch's enduring role in bridging interactive computing with standard C/C++ for educational and practical applications.[21]Language Features
Core C/C++ Support
Ch provides support for most features of the ISO C99 standard, allowing interpreted execution of standard C constructs without requiring compilation. This includes key features such as complex numbers via the<complex.h> header, variable-length arrays (VLAs) for dynamic sizing, inline functions for performance optimization, and designated initializers for structured data assignment. For instance, complex numbers enable mathematical operations on real and imaginary parts, as demonstrated in the following code snippet:
#include <complex.h>
#include <stdio.h>
int main() {
double complex z1 = 1.0 + 2.0 * I;
double complex z2 = 3.0 - 4.0 * I;
double complex sum = z1 + z2;
[printf](/page/Printf)("Sum: %f + %f i\n", creal(sum), cimag(sum));
return 0;
}
#include <complex.h>
#include <stdio.h>
int main() {
double complex z1 = 1.0 + 2.0 * I;
double complex z2 = 3.0 - 4.0 * I;
double complex sum = z1 + z2;
[printf](/page/Printf)("Sum: %f + %f i\n", creal(sum), cimag(sum));
return 0;
}
long long integer types, mixing declarations with code, and type-generic functions from <tgmath.h> for polymorphic math operations across numeric types. These features ensure compatibility with modern C programming practices while maintaining an interpretive workflow that evaluates expressions line-by-line, unlike traditional compiled environments.[22][1]
In terms of C++ integration, Ch offers partial support focused on object-oriented essentials, including classes with encapsulation (public/private access), constructors and destructors, static members, the this pointer, scope resolution operator (::), and new/delete operators. Polymorphic mathematical functions and variable-argument lists are available, but general function and operator overloading are not supported. References and pass-by-reference semantics facilitate efficient parameter passing. Basic I/O streams like cout, cin, and endl from <iostream> are available for console interactions. Examples include defining a simple class:
class Point {
private:
double x, y;
public:
Point(double a = 0, double b = 0) : x(a), y(b) {} // Constructor
double distance() { return sqrt(x*x + y*y); } // Member function
};
int main() {
Point p(3.0, 4.0);
cout << "Distance: " << p.distance() << endl; // Outputs: 5
return 0;
}
class Point {
private:
double x, y;
public:
Point(double a = 0, double b = 0) : x(a), y(b) {} // Constructor
double distance() { return sqrt(x*x + y*y); } // Member function
};
int main() {
Point p(3.0, 4.0);
cout << "Distance: " << p.distance() << endl; // Outputs: 5
return 0;
}
system("ls | grep .c") to filter files), input/output redirection (e.g., printf("output") > "file.txt" or command < input.txt), and environment variable handling via getenv("PATH") for reading and putenv("VAR=value") for setting. This enables hybrid scripts, such as:
#include <stdlib.h>
int main() {
char *path = getenv("PATH");
printf("Current PATH: %s\n", path);
system("ls > files.txt"); // Redirect output to file
return 0;
}
#include <stdlib.h>
int main() {
char *path = getenv("PATH");
printf("Current PATH: %s\n", path);
system("ls > files.txt"); // Redirect output to file
return 0;
}
Extensions and Built-in Libraries
Ch extends the C/C++ language with specialized features for numerical computing, integrating libraries such as LAPACK and BLAS for linear algebra operations, including matrix inversion, decomposition (e.g., LU, QR, SVD), and solving linear systems via functions likelinsolve().[26] It also incorporates statistical functions from the GNU Scientific Library (GSL), supporting tasks like numerical integration, optimization, and signal processing with operations such as cross-correlation (xcorr()) and Fast Fourier Transform (fft()). Matrix operations handle complex arithmetic, approximating IEEE 754 standards for floating-point behavior, including support for metanumbers like Inf, NaN, and complex variants, enabling element-wise computations on arrays declared as array double A[3][3].[3][27]
For graphical plotting, Ch provides the CPlot class and high-level functions in chplot.h, enabling 2D and 3D visualizations directly within C code without external dependencies. This includes line plots via plotxy() for data like y = sin(x), surface rendering with plotxyzf() from array or file inputs, contour plots, and animations for dynamic sequences, such as real-time updates in engineering simulations. Outputs can be exported to formats like PNG, EPS, or GIF, with features like autoscaling, legends, and annotations integrated seamlessly for inline use, as in plotting a sine wave immediately after computation.[28][3]
Additional extensions enhance scripting capabilities, including improved string handling with the string_t type for automatic memory management and functions like stradd(), strjoin(), and strparse() for concatenation, tokenization, and parsing. Regular expressions are supported through POSIX regular expressions via regex.h for pattern matching, allowing operations like string validation or extraction in scripts. Dynamic linking via dlopen() and dlsym() permits loading user libraries at runtime, facilitating modular extensions without recompilation.[26][3]
Embedded mathematical functions are native to the interpreter, offering type-generic operations for trigonometric (e.g., sin(), cos()), logarithmic (e.g., log(), exp()), and statistical computations (e.g., mean(), std()) that apply polymorphically to scalars, arrays, and complex numbers. This allows quick inline evaluations, such as sqrt(complex(1,2)) or array-wide factorial(), promoting efficient prototyping. A unique aspect of these extensions is their seamless integration, where numerical computations and plotting occur without external calls—for instance, solving a linear system x = inverse(A) * b and immediately visualizing the results with plotxy(x, y).[27][3]
Implementation
Architecture and Interpreter Design
The core interpreter of Ch is implemented in portable C, enabling cross-platform compatibility across Windows, Unix, and macOS without requiring platform-specific modifications.[3] This design choice facilitates its embeddability as a C/C++ scripting engine, integrating seamlessly with existing C/C++ applications and libraries while maintaining a small footprint and avoiding intermediate or bytecode generation.[29] Ch employs a lexical analyzer for tokenization and a recursive descent parser to handle C/C++ syntax, including extensions like nested functions and variable-length arrays.[3] The interpreter parses source code into an internal abstract syntax tree, enabling just-in-time evaluation that executes statements interactively without a separate compilation step, supporting both command-line and script modes for rapid prototyping and debugging.[3] For embedding, Ch provides a C API that allows integration into host C/C++ applications, with functions such asch_eval() for executing script strings directly and streval() for runtime evaluation of expressions.[30] This mechanism supports bidirectional callbacks between the host environment and interpreted scripts, including tracing via callback functions, and enables multi-threading where a single interpreter can process multiple scripts concurrently or multiple interpreters can run in parallel.[30]
The Ch IDE (ChIDE) offers an integrated environment for editing, running, and debugging Ch scripts, supporting multi-language development with tools like syntax highlighting and breakpoint management.[3] Complementing this, the Ch shell provides an interactive C-compatible command-line interface with features such as command history, tab completion, aliasing, I/O redirection, and pipelines, mimicking Unix shells while enforcing C syntax for seamless scripting.[3]
Memory management in Ch combines automatic and manual approaches: strings and certain dynamic arrays receive automatic allocation and deallocation during interpretation, while pointers and user-defined objects use standard C functions like malloc(), free(), new, and delete for explicit control.[3] This includes automatic initialization of variables to zero, array bounds checking, and a deallocate() function to reset pointers after freeing memory, ensuring safe handling of dynamic structures without garbage collection overhead.
Ch's design philosophy centers on the "One Language for All" principle, striking a balance between C's low-level control—such as direct memory access and pointer manipulation—and the ease of scripting languages, with an emphasis on real-time interactivity for numerical computing and scientific applications.[3] By extending ISO C standards with features like nested functions and computational arrays, it promotes modularity and portability while eliminating compilation barriers to foster rapid development and educational accessibility.[3]
