OMG, another programming language? Whyyy??
- Do you unapologetically enjoy low-level systems programming in C, but just wish it had a few modern "creature comforts" and safety checks?
Do you like the Rust and Ada brochures, but when you get down to writing programs in them,
just do not experience the joy of programming and creation?
(They are however good for programming spaceships)
- Want to easily create, use, and extend modules (packages)?
- Strict type checking including for value type aliases (e.g. if typedefs of ints in C were new strictly checked type names)
- Subtyping and discriminated union types for polymorphism without inheritance, and covariant return types
- Data and functions are freely associated; no classes
- Data structures have no visibility modifiers (no data hiding)
- No inheritance
Better Array Types
- Strings and arrays have known, fixed lengths and may be queried with the built-in function
- Strings and arrays are not "just pointers" and may be value compared using the standard
- Code may be freely associated with a module, by name, by placing a module declaration in the file
- Modules create python-style namespaces, so the function fun in the io
module may be called with
io.fun()in other modules
- Directory structure and filenames do not dictate the module namespaces (unlike in python).
Crescent is for C-like imperative programming but with modernized syntax and program organization.
Development Maturity Level: Pet Project
But, there’s a website? This website, like the language, is a work-in-progress. This site shares the current thinking about various language constructs and philosophies. It’s a way to keep track of things. It just happens to be in the open.
Basic Main Function
Here’s a bit more than just printing “Hello, World!”
This simple program demonstrates several language attributes:
- The prototype for the
main()function for any program (entry).
- Constant and variable global declarations.
- Type names for intrinsic types like integers, booleans, and strings.
- Variadic function arguments. E.g.
- String value comparison using
- Simple iteration over arrays using
foreach (element in array)
These types are pre-defined by Crescent but are also declared in the
_lang module for
documentation purposes (at least for the moment). If you are familiar with C or Rust the names will be
familiar, if not:
- Numeric types have a prefix and the number of bits in the representation:
- The u prefix indicates an unsigned integer
- The i prefix indicates a signed integer
- The f prefix indicates a floating point number
unitis a unit type (used like
anyis a variant that includes all defined types (including user-defined); it can be approximately thought of as
void*in C but with the corresponding type information intact.
stris the built-in string type.
You can declare a variant type in Crescent with
type type_name; These ones just happen to
have compiler-provided constructors. For instance,
bool is a variant type (tagged union) of
two unit types,
The source code in every file is associated with some module. The module association may be
module module_name;. There are two
specially handled modules:
- Globals and functions defined in
_langare always in scope, and are referenced without the
_langprefix. And yes, this means you can add to the language (or global scope, if you will) this way, but discretion is advised.
- Files without a module declaration are implicitly associated with the
Modules do not have data-hiding features and cannot be "sealed". Crescent does however have annotations and an annotation may be used to declare globals and function names as "private" but this merely keeps the corresponding code from being included in generated user (API) documentation. It also serves as an indicator to those modifying or extending a module to tread carefully.
- Assignment operator overloading. "Move" and "forward" semantics.