On 05/03/2025 02:20, Lawrence D'Oliveiro wrote:
On Wed, 5 Mar 2025 01:20:07 +0000, bart wrote:
I maintain my own scripting language. Building it from source - on
Windows - takes 70ms:
How wonderful. Does it offer Python-style features?
No, it offers my-style features, that is, things I find useful:
* Named constants (known at compile-time so exprs with them can be reduced)
* Compile-time enumerations, and parallel tables of enums and data
* Jump-table-based 'switch' (this requires those named consts or enums)
* Built-in Support for C-style data types, including C-style structs and homogeneous array types
* Built-in FFI for C-style APIs
* Character constants: 'A' and 'ABCDEFGH' (Python needs 'ord("A")')
* Built-in record types with named, mutable members
* Pascal-style bit-sets: ['A'..'Z', '0'..'9']
* Bit (u1/u2/u4) arrays
* 'goto'
* Static local variables within functions
* References and pointers
* Pass-by-reference
* ++ and -- (in Python, ++A is valid but it means +(+A))
* Expression-based syntax (exprs/stmts are interchangeable)
* Well-behaved function default parameters (Python's are iffy)
* main() functions; if one exists, it is called automatically for top level module
* Multi-level loop redo, continue and break
* Dedicated endless loops and repeat-N-times loops
* Built-in Print and Read /statements/
* 'Swap' operator
* Built-in maths functions and constants like 'pi'
* Allows any text/binary file to be embedded as a string
* Scope control allows selectively exported entities from a module
* Expression-based macros
* Fast 1.5Mlps bytecode compiler with a built-in feature to create single source file amalgamations of projects
* Compact single-file implementation. (This means distributing an app involves two files: the interpreter, and the amalgamated source, and those could be combined. There is also zero start-up delay, compared to find in bundled Python apps)
* Fast, brisk contributor that is generally faster than CPython
* Shares the same syntax as its implementation language
So lots of features I consider fundamental. Python has lots of advanced features but is lacking in the basics like this:
print "Enter 2 values: "
readln a, b
fprintln "# + # is #", a, b, a+b
Meanwhile, in Python you can create a class with x, y members, but you can do this:
p.x = 100
p.z = 200
You've inadvertently created a new member 'z' (it will be an attribute) on-the-fly. Or this:
math.pi = "pie"
Or this:
def F():
....
F = 42
It is ridiculously and dangerously dynamic.