| Feature | Plastic (Current) | Rust |
|---|---|---|
| Keywords | Basic + Error Handling | Extensive |
| Data Types | Basic + List/Map/Array | Rich (u8, char, (), &str) |
| Ownership & Borrowing | 🚧 Partial (WIP) | ✅ Core Feature |
| Functions | Basic, DLL Import, Closures | Advanced (generics, lifetimes) |
| Variables | let, mut, pub |
let, mut, patterns, annotations |
| Operators | Arithmetic, Logical, Custom | Full set |
| Comments | // only |
//, /* */, doc comments |
| Structs/Traits/Enums | ✅ Supported | ✅ (struct, trait, enum) |
| Error Handling | try, catch, throw, finally |
Advanced (Result, panic!) |
| Imports/Plugins | import, reference, using, DLL |
Advanced modules, crates |
| File/Process I/O | ✅ Built-in | Via stdlib |
| HTTP/Localhost | ✅ Built-in server | Via crates |
| Concurrency | Channels, Threads | Advanced (async, threads, channels) |
Plastic now supports a broader set of keywords, including:
- Control flow:
fn,let,mut,pub,if,else,while,for,return,match - Data modeling:
struct,enum,trait,impl,interface - Error handling:
try,catch,throw,finally - Imports:
import,reference,using,dllimport - Others:
self,as,in,true,false
- Primitives:
i32,i64,f32,f64,bool,string,void - Collections:
array,list,map,List<string> - User-defined:
struct,enum,trait - Function types:
fn(...) -> ... - Special:
any
- Plastic has experimental support for ownership and borrowing checks in the type checker (WIP).
- Mutable and reference types:
mut,&,&mutin function parameters.
- Standard function declarations.
- Support for closures and function types.
- DLL import: Call native functions via
dllimport.
letfor variable binding.mutfor mutability.pubfor public visibility.
- Arithmetic:
+,-,*,/,% - Logical:
&&,||,&|(and-or) - Comparison:
==,!=,<,<=,>,>= - Assignment:
= - Custom: e.g.,
addedas an alias for+
- Single-line comments:
//
- User-defined types:
struct,enum,trait,impl - Traits and trait implementations for polymorphism.
try,catch,throw,finallyblocks for robust error management.
import,reference,usingfor code and plugin loading.dllimportfor native interop.
- Built-in functions:
readFile,writeFile,appendFile,deleteFile,exists,mkdir,rmdir,listDir,copyFile,moveFile,renameFile - Process control:
runProcess,runProcessAndWait,openFile,command
- Start a local HTTP server:
startHttpServer(port) - Access HTTP request data:
GetHttpRequestData(),GetHttpRequestMethod(),GetHttpRequestPath() - Respond to HTTP requests:
SetHttpResponse(response) - HTTP client:
curl(url, method, data, headers)
- Threading:
CreateNewThread(source, input) - Channels:
SendToChannel(value),ReceiveFromChannel(),GetChannelCount()
- String/number utilities:
len,parseInt,parseFloat,toString,toInt,toFloat,toUpper,toLower,trim,split,join,contains, etc. - Time/date:
now,timestamp,formatDate,time - Random:
random - UUID:
uuid,GenerateUUID - Environment:
env,GetEnvironmentVariable,GetCurrentDirectory,GetCurrentProcessId - Logging:
log,error,showErrorBox,showConfirmBox - JSON:
ParseJSON,SerializeJSON - Math:
abs,floor,ceil,round,sqrt,pow,max,min,clamp - Binary/Morse/Hash:
ConvertToBinary,BinaryToConvert,ConvertToMorse,MorseToConvert,Hash,VerifyHash - Garbage collection:
CollectGarbage
startHttpServer("8080");
while (true) {
let method: string = GetHttpRequestMethod();
let path: string = GetHttpRequestPath();
let data: string = GetHttpRequestData();
print("Received", method, path, data);
SetHttpResponse("Hello from Plastic!");
}
writeFile("test.txt", "Hello, file!");
let content: string = readFile("test.txt");
print(content);
SendToChannel("hello");
let msg: string = ReceiveFromChannel();
print(msg);
Note: Plastic is evolving rapidly. See the Plastic Syntax in Visual Studio Marketplace for up-to-date syntax highlighting and tooling.
Summary of Recent Additions:
- Localhost HTTP server and request/response API
- File and directory operations
- Process and command execution
- Channels and threading
- Structs, enums, traits, and implementations
- Error handling with try/catch/finally/throw
- Many new built-in functions for scripting, system, and utility tasks
Feel free to further expand or reorganize this as needed for your documentation site or repository!
