Clay: A Generic Programming Language With an LLVM Backend
The Clay programming language is a type-safe variant of C/C++ that was developed at Tachyon technologies. It recently appeared on bitbucket's open source repository to let developers find new, innovative uses for its highly reusable and efficient code. Clay's runtime overhead and memory footprint are on the same level as C. The language is perfect for writing embedded systems, garbage collectors, database servers, games, and more.
Programmers who have written C++ templates know that the longer type names in generic code make the templates verbose, but Clay solves this issue with a whole-program type propagation. When generic programming is combined with the entire program type propagation, developers can write high-level code that is on par with scripting language conciseness.
These are a few code samples form the 'test' directory:
Factorial
Sequences - Lambda, filter
One feature of Clay that really makes it efficient is the LLVM backend. The LLVM compiler infrastructure is used to optimize the type-specialized low-level code generated during Clay's compilation. As mentioned before, this low-level code is equivalent to C in performance, according to the project's developers.

Here is a more concise list of Clay's primary features and advantages:
Clay is a fully functioning compiler available for Mac, Windows, and Linux. You can learn more about the Clay programming language here.
Programmers who have written C++ templates know that the longer type names in generic code make the templates verbose, but Clay solves this issue with a whole-program type propagation. When generic programming is combined with the entire program type propagation, developers can write high-level code that is on par with scripting language conciseness.
These are a few code samples form the 'test' directory:
Factorial
factorial1(n) {
if (n == 0)
return 1;
return n*factorial1(n-1);
}
factorial2(n) {
var p = 1;
again :
if (n == 0)
return p;
p *= n;
n -= 1;
goto again;
}
factorial3(n) {
var p = 1;
while (true) {
if (n == 0) break;
p *= n;
n -= 1;
}
return p;
}
factorial4(n) {
var p = 1;
for (i in range(n))
p *= i+1;
return p;
}
main() {
var n = 7;
n -= 1;
var f = factorial4(n);
println("factorial(", n, ") = ", f);
return 0;
}
Sequences - Lambda, filter
double(x) = 2*x;
main() {
var a = Vector([1, 2, 3, 4, 5, 6]);
var b = map(addressOf, a);
var c = map(dereference, b);
for (x in c)
x += 2;
for (x in map(double, map(double, a)))
println(x);
for (x in map(double, range(5)))
println(x);
}
One feature of Clay that really makes it efficient is the LLVM backend. The LLVM compiler infrastructure is used to optimize the type-specialized low-level code generated during Clay's compilation. As mentioned before, this low-level code is equivalent to C in performance, according to the project's developers.

Here is a more concise list of Clay's primary features and advantages:
- Machine memory model
- Value semantics
- Whole program type propagation
- Module system
- Extensible variant types
- Multiple dispatch
- Powerful compile time meta-programming
- Interoperability with C
- No garbage collection
- LLVM backend
Clay is a fully functioning compiler available for Mac, Windows, and Linux. You can learn more about the Clay programming language here.
(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)





Comments
Ks Sreeram replied on Fri, 2010/10/01 - 1:21pm
Clay, the language designed for generic programming, was not developed at Dartmouth. There does appear to be a different research language under development at Dartmouth with the same name. These two languages are completely unrelated.
The Clay that you've written about was developed at Tachyon Technologies, and it's website is at http://tachyon.in/clay .
Also the following paragraph doesn't apply to this Clay:
Regards
KS Sreeram
Developer of Clay
Ks Sreeram replied on Sun, 2010/10/03 - 11:11am
Raw ThinkTank replied on Sat, 2010/10/02 - 5:24am
Mitch Pronschinske replied on Sat, 2010/10/02 - 6:27pm