CScript The Hybrid Programming Language
A modern programming language that combines the best features of JavaScript, TypeScript, C++, and C# with powerful additions like pipeline operators, match expressions, LINQ queries, and operator overloading.
// CScript - Clean, powerful, intuitive
const numbers = [1, 2, 3, 4, 5];
// Pipeline operators for clean data flow
const result = numbers
|> filter(x => x % 2 === 0)
|> map(x => x * 2)
|> reduce((a, b) => a + b);
// Match expressions for better control flow
const response = status match {
200 => "Success",
404 => "Not Found",
500 => "Server Error",
_ => "Unknown"
};
console.log(`Result: ${result}, Status: ${response}`);
Powerful Features
Pipeline Operators
Chain operations naturally with the |> operator for readable data transformations.
Match Expressions
Pattern matching that's more powerful and expressive than traditional switch statements.
LINQ Queries
SQL-like query syntax for working with arrays and collections intuitively.
Enhanced Operators
Custom operators and operator overloading for domain-specific operations.
Hybrid Syntax
Choose between C-style braces or Python-style indentation as you prefer.
Smart Functions
Function overloading, default parameters, and arrow functions with enhanced capabilities.
Get CScript
NPM Package
Install the CScript transpiler and CLI tools
npm install -g cscript-language
VS Code Extension
Full language support with syntax highlighting and IntelliSense
ext install VIBECO.cscript-language-support
Quick Start
Install CScript
npm install -g cscript-language
Create a file
touch hello.csc
Transpile & Run
cscript hello.csc
CScript vs JavaScript
See how CScript makes common JavaScript patterns cleaner and more expressive
JavaScript
// Nested function calls - hard to read
const result = data
.filter(item => item.active)
.map(item => item.value * 2)
.reduce((sum, val) => sum + val, 0);
// Or with intermediate variables
const activeItems = data.filter(item => item.active);
const doubledValues = activeItems.map(item => item.value * 2);
const result = doubledValues.reduce((sum, val) => sum + val, 0);
CScript
// Clean pipeline flow - easy to read
const result = data
|> filter(item => item.active)
|> map(item => item.value * 2)
|> reduce((sum, val) => sum + val, 0);
// Natural left-to-right data flow
const processed = rawData
|> parseJSON
|> validateSchema
|> transformData
|> saveToDatabase;
JavaScript
// Verbose switch statements
function getStatusMessage(code) {
switch (code) {
case 200:
return "Success";
case 404:
return "Not Found";
case 500:
return "Internal Server Error";
default:
return "Unknown Status";
}
}
// Complex conditional logic
let message;
if (user.role === 'admin' && user.active) {
message = 'Full Access';
} else if (user.role === 'user' && user.active) {
message = 'Limited Access';
} else {
message = 'No Access';
}
CScript
// Concise match expressions
const message = code match {
200 => "Success",
404 => "Not Found",
500 => "Internal Server Error",
_ => "Unknown Status"
};
// Pattern matching with conditions
const access = (user.role, user.active) match {
('admin', true) => 'Full Access',
('user', true) => 'Limited Access',
_ => 'No Access'
};
// Guard patterns
const category = value match {
x when x < 0 => 'Negative',
x when x === 0 => 'Zero',
x when x > 100 => 'Large',
_ => 'Normal'
};
JavaScript
// Complex array operations
const result = users
.filter(user => user.age >= 18)
.filter(user => user.department === 'Engineering')
.map(user => ({
name: user.name,
email: user.email,
salary: user.salary
}))
.sort((a, b) => b.salary - a.salary)
.slice(0, 10);
// Group by operations require reduce
const groupedByDept = users.reduce((acc, user) => {
if (!acc[user.department]) {
acc[user.department] = [];
}
acc[user.department].push(user);
return acc;
}, {});
CScript
// SQL-like query syntax
const result = from user in users
where user.age >= 18 && user.department === 'Engineering'
select {
name: user.name,
email: user.email,
salary: user.salary
}
orderby user.salary descending
take 10;
// Built-in grouping operations
const byDepartment = from user in users
group user by user.department into dept
select {
department: dept.key,
count: dept.length,
avgSalary: dept.average(u => u.salary)
};
// Join operations
const userProjects = from user in users
join project in projects on user.id equals project.userId
select { user.name, project.title };
JavaScript
// No function overloading - need different names
function processString(str) {
return str.toLowerCase();
}
function processNumber(num) {
return num * 2;
}
function processArray(arr) {
return arr.map(item => item.toString());
}
// Default parameters
function createUser(name, age = 18, role = 'user') {
return { name, age, role };
}
// No operator overloading
class Vector {
constructor(x, y) {
this.x = x;
this.y = y;
}
add(other) {
return new Vector(this.x + other.x, this.y + other.y);
}
}
CScript
// Function overloading by type
function process(value: string): string {
return value.toLowerCase();
}
function process(value: number): number {
return value * 2;
}
function process(value: Array): Array {
return value.map(item => item.toString());
}
// Enhanced default parameters with expressions
function createUser(name: string, age = getCurrentYear() - 2005, role = getUserRole()) {
return { name, age, role };
}
// Operator overloading
class Vector {
constructor(x: number, y: number) {
this.x = x;
this.y = y;
}
operator +(other: Vector): Vector {
return new Vector(this.x + other.x, this.y + other.y);
}
}
const v3 = v1 + v2; // Natural syntax!
Documentation
📖 Complete Guide
Comprehensive documentation covering all CScript features, syntax, and best practices.
View Documentation💡 Examples
Real-world examples and code samples to help you learn CScript effectively.
View ExamplesCode Examples
Data Processing Pipeline
// Process user data with pipelines
const activeUsers = userData
|> filter(user => user.isActive)
|> map(user => ({ ...user, fullName: `${user.first} ${user.last}` }))
|> sortBy(user => user.lastLogin)
|> take(50);
console.log(`Found ${activeUsers.length} active users`);
HTTP Response Handling
// Clean response handling with match
const handleResponse = (response) => {
return response.status match {
200 => { success: true, data: response.data },
404 => { success: false, error: "Resource not found" },
500 => { success: false, error: "Server error" },
_ => { success: false, error: `Unexpected status: ${response.status}` }
};
};
Complex Queries
// SQL-like data queries
const topSellers = from product in products
join sale in sales on product.id equals sale.productId
where sale.date >= startDate && sale.date <= endDate
group sale by product.category into categoryGroup
select {
category: categoryGroup.key,
totalSales: categoryGroup.sum(s => s.amount),
count: categoryGroup.length
}
orderby totalSales descending
take 5;
Operator Overloading
// Custom mathematical operations
class Matrix {
constructor(data) { this.data = data; }
operator +(other) {
return new Matrix(this.data.map((row, i) =>
row.map((val, j) => val + other.data[i][j])
));
}
operator *(scalar) {
return new Matrix(this.data.map(row =>
row.map(val => val * scalar)
));
}
}
const result = matrix1 + matrix2 * 3;