syntax difference

Chris Angelico rosuav at gmail.com
Tue Jun 19 06:13:10 EDT 2018


On Tue, Jun 19, 2018 at 7:19 PM, Bart <bc at freeuk.com> wrote:
> My own dynamic language is much smaller than Python, much less dynamic, much
> less extendable, and lower level.
>
> Yet it might have a dozen highly useful features, ones I consider basic,
> that are already built-in and Just Work without having to grapple with
> innumerable, incompatible add-ons.
>
> (What, I have to list them? Let's see:
>
> * Goto (yes this /can/ be very useful)
>
> * Pointers (this allows some of the features below)
>
> * Swap(x,y) (evaluate each once unlike a,y=y,x)
>
> * Reference parameters
>
> * Mutable records
>
> * Mutable and in-place modifiable strings
>
> * Named constants
>
> * Simple enums
>
> * 'Tabledata' (too hard to explain; mix of enums and linked tables)
>
> * Integer sets (Pascal-like sets)
>
> * Bit indexing (eg. a.[i] to get the i'th bit, or a.[0..7])
>
> * Switch statement (like C)
>
> * Case statement (switch but for any types and for runtime expressions)
>
> * N-way select (n|a,b,c,...|z); only one expr evaluated, z is default)
>
> * Increment/decrement ops
>
> * C-style packed struct types
>
> * Direct access to native-code functions in external DLL/.so files
>
> * Type punning
>
> * Byte-code compiler will always compile all modules of app to single-
>   byte-code file (very fast too)
>
> * The interpreter is a single executable file. (Distribute any app as one
> exe plus one byte-code program file; or they can be trivially combined into
> one file)
>
> * Built-in read statement: readln a,b,c
>
> * Bit arrays (including 1, 2 and 4-bit elements)
>
> * Packed arrays of C-style types
>
> * View-slices
>
> * Stop or 'stop x' (not a big feature, but it's there).
>
> * 'main' function replaces all the '__main__ business; it will be called
> first if present.
>
> * Dedicated loop statements for endless loop and repeat N times
>
> Is that a dozen yet? Sorry it's about two dozen, of things which I don't
> think are in Python, or which may require add-ons.)

Great! Now, for this next test, you are also allowed to count any
standard library that is included as part of your single-file
distribution (and thus isn't an "add-on"). Do you have:

* Arbitrary-precision integers?
* Unicode strings?
* The ability to create TCP sockets, and bind, listen, and connect them?
* Ditto for UDP and Unix sockets?
* Easy ways to create servers and clients for common internet
protocols eg HTTP, SMTP, IMAP?
* Out-of-the-box handling for SSL certificates?
* An efficient way to multiplex many concurrent connections eg select()?
* Reading and writing files relative to a previously-opened directory
(openat etc)?
* Parsers for common transport formats and encodings eg JSON, MIME, etc?
* A unit test framework?
* A GUI framework?
* An interactive interpreter, with GNU readline (on supported platforms)?
* An argument parser?
* A secure and reliable way to generate random numbers?
* Any form of compression library (eg zlib, lzma)?
* Parsers for any form of compressed file (eg zip, gz)?
* Inbuilt access to at least one database (SQLite3, PostgreSQL, etc)?
* Trigonometric functions (sin/cos/tan)?
* High-resolution timers?
* Cryptographic hashing functions (eg sha256)?
* A regex engine? (Bonus points for having two or more. Maybe negative points.)
* Date/time calculations using the Gregorian calendar? (Bonus points
for supporting other calendars.)
* Dare I ask: Multiple inheritance?

ALL of these are fully supported, out-of-the-box, by both Python and
Pike, the two languages I happen to have full source and docs for at
my fingertips. I would expect that most or all of these are also
supported by most other modern languages; some won't include a GUI
framework, others don't have arbitrary-precision integers, etc, but
I'd predict scores of 75% or better across the board. What's your
language's score?

And no, these are not cherry-picked from the most obscure features I
could find. Every single one of these is of immense value to
real-world code. Even multiple inheritance, which I listed last
because it's a bit of a hairy one, and is part of the reason that very
few languages will score 100%. But can you at least score *some*?

ChrisA



More information about the Python-list mailing list