What is CPL?

Three-letter acronyms collect many meanings. CPL has dozens, for instance several City Public Libraries, a few Cricket Premier Leagues, a Commercial Pilot License, a Microsoft Windows Control PaneL file, and a handful of programming languages among which a historical ancestor of BCPL and C. Intended here is a fivefold expansion:

  • Concealed Pointer Lookup
  • Coactive Parameter Lists
  • Consistent Procedure Linkage
  • Compiler and Programming Language
  • Conceived by Paolo Luchini

This CPL, unrelated to the Cambridge or Combined Programming Language, is a general-purpose programming language akin to FORTRAN or C (∗∗p).col=j; p=&(∗∗p).next; ⇓ ⇓ ⇓ p.col=j p=p.next (but in fact even more similar to the once popular Pascal and Modula-2, for those who remember them), with some unique features. It was born out of the effort to provide the pointer flexibility of C without the user's bookkeeping of ∗'s and &'s, the function overloading of C++ without the superstructure of classes, and the cross-file prototype checking of Modula-2 (and most modern languages) without the need for dedicated header or interface files.

Is CPL easy to use?

CPL aims for the ease of use of interpreted languages like MATLAB or Python, without giving up the error-catching benefits of mandatorily declared variables and the sheer speed of compiled execution. CPL was thought out as an easy-to-use, fast compiled language from the very beginning; in computationally intensive tasks, it inherits the speed of compiled C. > cpl make Helloworld > ./Helloworld Hello world! In fact, its compiler is implemented as a nimble and fast source-to-source translator which then invokes the system C compiler; this action, as well as the re-making of any modified modules, occurs behind the scenes at a single cpl make command. Even this command can be spared, if desired, by embedding cpl run in the program itself for immediate execution. For additional flexibility the interactive cpl interpreter is provided, with the ability to run a combination of interpreted and compiled CPL modules, as well as any function provided by an existing CPL or C library, directly from its console.

Are CPL arrays versatile and bounds checked?

CPL ARRAYs STRUCTURE(REAL a,b,c) s(-2..8) REAL v(-9..15,1..7) s(-1..5).a=2∗v(-2..4,6) var=SUM [v(i,j)-m]^2 FOR ALL i,j allow variable lower and upper bounds of each index, and are (on demand) fully bounds-checked. An ample set of subarray selections, commuting with structure fields, is efficiently supported.
A gamut of loop shortcuts is enabled by the implicit handling of array bounds.

Can the language syntax be extended with external libraries?

The CPL compiler's most distinctive feature is its incremental extensibility. The included libraries thus provide matrix operations, gnuplot graphics, and symbolic manipulation, USE lapack-eigenvalues A=[(1.,2.),(3.,4.)] WRITE eigenvalues(A) just to name three examples, all blended into the language syntax. Additionally, any function provided by an external C or FORTRAN library can be seamlessly called in a CPL program (or from the cpl i command prompt), giving access to a large number of public and proprietary libraries alike. And to encapsulate a (e.g. LAPACK) call in a CPL wrapper, as exemplified in this lapack Tutorial, simplifies syntax and exacts no performance penalty.

Does CPL use brackets intuitively?

A hallmark aesthetic touch of CPL is the availability of all three kinds of round, square, and curly brackets for grouping arithmetic (or other) expressions, p(i)=EXP(-{[x(i)-mu]/sigma}^2/2) just as you were taught in school. While to alternate parentheses, brackets and braces is optional and might be unessential to some users, to do so eases the human eye's reading and proofreading nested formulas; and it enhances automatic error catching too. The provided text editor can automatically alternate bracket styles and match bracket pairs for you.

For more information see the full Documentation and the Frequently Asked Questions.

Or, just download CPL and try! It's free.