What Meem can and cannot do
This page comes from part one of the «direction 0.9.1 report» in the compiler repository: a real program was written for each kind of program, run, and measured on 0.9.1; what changed after it comes from docs/memory-safety.md and the release notes from 0.10.0 to 0.17.1 there. The five projects were migrated to the 0.17 forms and rerun with 0.17.1, and their output did not change; their times are from 0.9.1. It promises nothing beyond 0.17.1.
What it is good for today
Section titled “What it is good for today”| Kind | The example that was tried | Result |
|---|---|---|
| Command-line tools that process text | Most frequent words | Works; time on a par with Python (0.70 s against 0.74), with about 7 times the memory |
| Processing CSV and text files that fit in memory | Summarising a CSV file | Works; 0.64 s against 0.54 for Python |
| Algorithms and data structures | Dijkstra and a search tree | On a par with C: 0.27–0.31 s against 0.29 for gcc -O2 |
| Teaching applications in the terminal | Tic-tac-toe | Works; 0.24 s |
| Small systems programs on files | Folder line counter | Works; 0.02 s for 64 files |
| A thin wrapper around a C library | Pattern search with regcomp, and CRC-32 with zlib, through خارجي |
Works, provided its writer takes care of خطر and the bytes, and it must be built dynamically |
What makes writing easier: a small language, Arabic error messages with a stable ID and a hint, mandatory error handling with three words, a single executable of tens of kilobytes with no dependencies, a memory detector that is on by default in a direct run and names the line of creation and the line of freeing, and --debug-mem, which says which line did not free.
What became possible after 0.10.0
Section titled “What became possible after 0.10.0”| Missing in 0.9.1 and 0.10.0 | Now |
|---|---|
| Reading a file line by line or in chunks | ملفات.افتح_للقراءة (open for reading) and اقرأ_سطر (read line), and the writer افتح_للكتابة and اكتب_سطر (since 0.14.0) |
| Binary files and bytes | اقرأ_ملف_بايتات and اكتب_ملف_بايتات, and طول_بايت, جزء_بايت and بايتات_نص (since 0.14.0) |
| An optional value for anything but a string | ن؟ for any type (since 0.11.0; structs and tuples since 0.14.0) |
| Returning more than one value | Tuples and destructuring: خ, ب = قسم(17, 5) (since 0.14.0) |
| Generic types (a heap or tree for any type) | Generic functions (since 0.15.0), generic structs and enums (since 0.16.0), and traits and constraints (since 0.17.0) |
| A dictionary key made of a struct, and sets | Any type that implements قابل_للتجزئة (hashable) as a key, and the مجموعات module with a heap, a queue and a set (since 0.17.0) |
The 0.9.1 report’s measurements have not been redone with these new tools.
What it cannot do yet, and the workarounds
Section titled “What it cannot do yet, and the workarounds”Ordered by how hard it hits a real program:
| What it cannot do | A workaround today? |
|---|---|
| Networking | At a cost: sockets from libc through خارجي |
| Running commands and processes | Yes: system() from C |
| Threads and parallelism | Dangerous: pthread works for computation without allocation, and allocating from two threads is undefined |
| JSON | By hand only, and not tried |
| Regular expressions | Yes: regcomp and regexec from libc |
| A library callable from C | No, officially |
| Closures and nested functions | No: a top-level function with its state in a struct |
Variadic functions, and printf from C |
اطبع with commas, and رياضيات.نسق and نسق_عدد |
Methods (س.دالة()) and interfaces |
Functions that take the struct |
| A struct by value to or from C | A pointer to a هيكل_سي |
| Graphical interfaces | Not tried |
And what was thought to be missing but turned out to exist: مدى with a step, changing a field of a list element directly (ق[0].ك += 10), deep iteration, and خطأ.لا_ذاكرة (out of memory) from حاول_احجز.
What works but hurts
Section titled “What works but hurts”- The default static build is slower than
--dynamicby 1.2 to 1.6 times in allocation-heavy programs. - Indexing a string by character,
ن[ف], goes through the string from its start: 20 thousand indexings in 2.2 s in 0.9.1 (and 1.74 s instead of 2.56 in the 0.11.0 measurement on a 20-thousand-character string), whileلكل ح في نover the same string takes a fraction of a millisecond. Walk the string withلكلwhen you can. - Memory:
حررdoes not follow what is inside a container, growing with+=leaves old buffers behind (a bounded leak), and a built file without the detector does not catch use after free through another name. The detector that is on by default in a direct run is 0% to 32% slower. Details in memory in Meem. - An error’s context is a message, not typed data, and «نشأ في» (originated in) is not a full stack. Details in dealing with errors.
- A direct run (
meem برنامج.م) loads the whole compiler: no less than about 95 MB for any program. A built file was between 8 and 76 MB in the examples.
Where it fits today
Section titled “Where it fits today”Suitable: terminal tools on text files that fit in memory, algorithm and data-structure exercises, teaching programming and manual memory in Arabic, and a thin wrapper around a C library.
Not suitable yet: a server or a long-running program (not tried, and حرر does not follow nested structures), anything networked or parallel without C, any library called from another language, and any platform other than Linux x86_64.
See also
Section titled “See also”Meem compared with C and Zig · The five projects · Try 0.17.3 with us