Speedie is a programming language created in 2022 by Theodore H Smith.
#1314on PLDB | 2Years Old |
"General-purpose modern and clean object-oriented programming language."
main
"Hello World!"
#require #expect #error and asm break class continue else elseif false for if is in import module or return require expect error virtual behaviour function syntax syx self true with yield while xor
Feature | Supported | Example | Token |
---|---|---|---|
hasSelfOrThisWord | โ | self.Remove .remove | |
Classes | โ | ||
Zero-based numbering | โ | printline ["a", "b", "c"][0] // prints "a" | |
Print() Debugging | โ | "error 1 here" | |
Dispose Blocks Pattern | โ | using SomeObject for 10 Someobject.dosomework if (random[]>0.5) return // someobject.SyntaxUsingComplete called here // someobject.SyntaxUsingComplete called here too | |
Strings | โ | "hello world" | |
Access Modifiers | โ | class Person |int| age setter age expect (value >= 0) ("bad age $value set!") .age = value main || p = person() p.age = -1 // calls a function rather than the property || n = p.age // reads the property directly! | |
Inheritance | โ | class Person (Animal) | |
Semantic Indentation | โ | class Person |string| name | |
Null | โ | || msg = message() while if msg != nil "msg exists" else "empty" return msg = nil | |
Unary Operators | โ | || x = !0 | |
hasUserDefinedOperators | โ | class myclass |int| Num operator add (|int| x, |myclass|) return myclass(.num + x) render fs <~ .num main || x = myclass(1) || y = myclass(2) || z = y + x printline z | |
Operator Overloading | โ | str = "a" + "b" array <~ str | |
Function Overloading | โ | function volume (|float| a, |float|) return a*a*a function volume (|float| r, |float| h, |float|) // volume of a cylinder return math.pi*r*r*h | |
Single-Type Arrays | โ | |array of string| s s <~ "abc" // ok s <~ 1 // fail | |
hasForEachLoops | โ | || items = [5,6,7,8] for i in items printline i | |
Iterators | โ | || items = [5,6,7,8] for i in items printline i | |
Constructors | โ | class Foobar |float| x |float| y constructor (|float| r=1, |float| alpha=0) .x = r * alpha.cos .y = r * alpha.sin || a = foobar() || b = foobar(3) || c = foobar(5, M_PI/4) | |
Binary Literals | โ | || num = 0b010101 | |
Floats | โ | || num = 0.0 | |
Hexadecimals | โ | || num = 0xBEEF | |
Functions | โ | function Example (|string| data) file <~ data | |
Lists | โ | myList = [1, 2, 3, 4, 5] | |
Units of Measure | โ | || time = 1day - 10s || size = 10.2MB | |
Integers | โ | pldb = 80766866 | |
Pointers | โ | || i = 0 || p = &i *p = 1 if (i == 1) "success" | |
Homoiconicity | โ | The~entire~Language is (%written in:@Jeebox) | |
Multiline Strings | โ | "hello you beauty" | |
Infix Notation | โ | seven = 3 + 4 | |
Breakpoints | โ | debugger | |
Source Maps | โ | linkage bannedclasses (file, process, shellstream, archive) // using these classes... even indirectly, will create an error // the error message will show the entire call-chain that reached these classes | |
Virtual function | โ | class abc virtual DoSomething (|string| name) behaviour DoSomething printline "hello: $name" | |
Static Methods | โ | class abc module function Print "abc" main abc.print | |
Type Parameters | โ | function ABC (|string| name) | |
hasTimestamps | โ | printline __time_id__ | |
hasMethodOverloading | โ | ||
hasVoidFunctions | โ | || x = 123 function abc x = 10 | |
hasGlobalScope | โ | || x = 123 function abc x = 10 | |
hasFnArguments | โ | function ABC (|string| name) | |
canReadCommandLineArgs | โ | printline app[0] | |
hasDynamicSizedArrays | โ | || arr = [] arr <~ "abc" | |
hasRequiredMainFunction | โ | main "hello world" | |
hasStatementTerminatorCharacter | โ | if x: x++, x*=2, return | |
hasMemberVariables | โ | class abc |int| def | |
hasStringConcatOperator | โ | || ab = "a" + "b" | |
Characters | โ | || char = 'b' if b > 32 "good" | |
hasEscapeCharacters | โ | || str = "\01\02\03" | |
hasForLoops | โ | while i in 10 "hello: $i" | |
While Loops | โ | while true "hello" | |
Assignment | โ | name = "John" | = |
File Imports | โ | import Proj | |
MultiLine Comments | โ | /* multiline comments */ | /* */ |
Comments | โ | // comment | |
Garbage Collection | โ | || msg = message() DoSomethingWith(msg) // msg now gets disposed | |
Constants | โ | constants Opened = 1 Closed = 2 | |
hasBreak | โ | for i in 10 if i > 3: exit printline i // 1,2,3 | |
hasContinue | โ | for i in 10 if i < 5: continue printline i // 6,7,8,9 | |
Conditionals | โ | ||
Booleans | โ | true false | |
Symbol Tables | โ | ||
Shebang | โ | #!/usr/local/bin/spd | |
Bitwise Operators | โ | x << y | |
Message Passing | โ | || chld = app.fork("ipc_identifier_123", app.rawargs) chld <~ "send message" printline chld.get // receive message | |
Ternary operators | โ | while printline (1,0)(random[]>0.5) | |
Case Insensitive Identifiers | โ | if "abc".LeNgTh == 3 "cool length" | |
Case Sensitivity | โ | || Same = "x" == "X" // same = false | |
Disk Output | โ | "helloworld.txt" <~ "Hello, world!\n" | |
Enums | โ | flags A B C D // A=1, B=2, C=4, D=8 constants X Y Z W // X=0, Y=1, Z=3, W=4 | |
Structs | โ | struct Fuel |int| A |byte| B | |
Type Casting | โ | || x = message() || y = x|object| // lose type info || z = y|message| // regain it | |
Module Pattern | โ | module App function Path (|string|) // return the app's path here | |
Single Dispatch | โ | || x = "str" || i = x.find("t") | |
Increment and decrement operators | โ | || x = 1 x++ x-- | |
Static Typing | โ | || x = "Hello" x = 1 // fails to compile... because x is a string | |
Type Inference | โ | || x = "Hello" || y = FunctionThatReturnsAString() // is now a string x = 1 // fails to compile y = 2 // fails to compile | |
Macros | โ | ||
Magic Getters and Setters | โ | ||
Default Parameters Pattern | โ | function Find (|string| pattern, |int| pos=0, |int|) | |
Unicode Identifers | โ | class รฉยฉยฉ constructor printline .class.name // "รฉยฉยฉ" | |
Doc comments | โ | function Find (|string| pattern, |int| pos=0, |int|) description "Returns the position of pattern in self, starting from 'pos'. If not found, we return -1." | |
Assert Statements | โ | class Person |int| age setter age // "expect" will actually add an Error to a list of errors expect (value >= 0) ("bad age $value set!") .age = value main || p = person() p.age = -10 if !stderr.ok "Oof we got some errors" | |
Polymorphism | โ | |object| x = somefunction() || y = x.render // returns a string by calling the virtual func "render" | |
Pipes | โ | ||
Maps | โ | || x = ["a":"Apple", "b":"Bird", "c":"Cat"] printline x["b"] // Bird | |
Partial Application | โ | main "hello world ${app.args[0]}" | |
hasReservedWords | X | || return = 123 || if = 456 if if == 456 return return | |
Exceptions | X | ||
Threads | X | ||
Templates | X | ||
Multiple Inheritance | X | ||
Namespaces | X | ||
Octals | X | ||
hasTryCatch | X | || data = "somefile".file.readall if !data stderr.printerrors // prints any file-system error that occurred during .readall | |
Dynamic Properties | X | ||
Regular Expression Syntax Sugar | X | ||
Duck Typing | X | ||
Manual Memory Management | X | ||
Multiple Dispatch | X |