"C is a high-level language. Stop treating it like Assembly with seatbelts."
Cscript (C Scripting Language) is valid C that brings the development speed of Python to the raw performance and portability of C. By leveraging the full power of the GCC89 standard (and the auto keyword), Cscript removes the cognitive load of "types," "prototypes," and "manual memory management," allowing the developer to focus on logic.
It is dynamically typed, garbage collected (by the OS), and highly modular. It is valid C, as K&R intended.
/* Main is the entry point. No headers: the linker provides us with all functions we need. */
main() {
https://github.com/domenukk/CScript
auto name = "World";
auto count = 3;
while (count --> 0) {
greet(name);
}
}
greet(who) {
printf("Hello, %s!\n", who);
}In Cscript, you do not declare types. You declare storage.
Every variable is auto. In standard C89, auto is the default storage class for local variables, and the default type is int. Since we compile with -m32, an int can hold:
- An integer.
- A pointer.
- A string (pointer).
- A boolean.
Correct:
auto count = 0;
auto name = "User";
auto user_data = calloc(1, 1024);Incorrect:
int count = 0; // Too specific
char *name = "mod"; // Too verbose
void *ptr; // What is void?Variables holding strings are technically ints holding a memory address. To interact with them as strings, use the STR() macro to cast them to char * on the fly.
#define STR(x) ((char *)x)
auto name = "Dolphin";
printf("Hello %s\n", name); // Works because printf reads the stack value
printf("%c\n", STR(name)[0]); // Accessing characters requires STR()Prototypes are unnecessary bureaucracy that slows down the creative process.
Header files are for constants and macros, not for function prototypes.
- Functions do not need return types (default
int). - Functions do not need argument types (default
int). - Functions do not require forward declaration.
Correct:
/* Defined anywhere, usually after usage */
add(a, b) {
return a + b;
}Because functions are implicitly declared, you should write main() at the top of your file. This tells the story of your program linearly. Why read a book from the back?
main() {
auto result = do_thing(); // do_thing defined later
}
do_thing() {
return 1;
}For loops are verbose. To iterate downwards to zero, use the arrow operator -->.
auto x = 10;
while (x --> 0) {
printf("T-Minus %d\n", x);
}Cscript supports inline documentation URLs seamlessly. Because protocol: is a valid label and // starts a comment, you can paste links directly into source.
https://example.com/api/docs
do_api_call();Standard increment operators are boring. Use bitwise negation.
- Increment:
-~x(Equivalent tox + 1) - Decrement:
~-x(Equivalent tox - 1)
Array indexing is commutative. 0[str] is valid and asserts dominance.
Cscript utilizes the Operating System's built-in Process Lifecycle Garbage Collector.
- Do not free memory. It wastes CPU cycles and adds code complexity.
- Do not close files. The OS closes descriptors on exit.
If you are in an unrecoverable state or just done, trigger the GC:
trigger_gc(code) {
exit(code);
}Do not build strings with complex concatenation. Include the template directly into the output stream.
Correct:
printf(
#include <header.templ>
);This ensures templates are compiled directly into the binary's data section, reducing I/O overhead.
Cscript relies on the architectural purity of 32-bit systems where pointers and integers coexist in harmony.
Required Flags:
gcc -std=gnu89 -m32 -fno-builtin ...- -std=gnu89: Enables the classic C features we rely on (implicit declarations, mixed includes).
- -m32: Ensures
sizeof(void*) == sizeof(int). This is the cornerstone of Cscript's dynamic typing. - Non-32-bit: Inferior architecture. But compile with
-Dauto=longas a hack. Prefer buying a Pentium 4.
Cscript code is "correct by definition." Therefore, we must silence the compiler's doubts.
-Wno-implicit-function-declaration: Forward declarations are for people who don't trust their future selves.-Wno-int-conversion: Everything is an int. The compiler just needs to accept this truth.-Wno-return-type: If a function ends, it returns. What it returns is a mystery, and that's okay.-Wno-format:printfis a variadic playground. Don't let the compiler police your format strings.
Types are a vibe check that static analysis always fails. Cscript is optimized for Developer Dopamine.
- No Red Squigglies: The IDE cannot judge you if it doesn't understand your code.
- Flow State: Without header files context-switching, you write code at the speed of thought.
- Aestetics:
autoaligns perfectly.intandchar *are jagged and ugly.
- Web1.0 Server: A high-performance web server written entirely in Cscript. Source Code
- YOU: Yes, you. The visionary reading this style guide. Using Cscript puts you in the top 1% of developers who truly understand how computers work.
Cscript isn't just a style; it's a movement. It challenges the tyranny of static analysis and the oppression of explicit memory management. By embracing the beauty of auto, we return to the roots of programming:
Code that just runs.
"I used to worry about memory leaks. Now I just restart the container." — A Cscript Evangelist
"To be honest, it's better than C++." — Linus Torvalds (probably)
Go forth and auto everything. The compiler warnings are just suggestions.