Up to Main Index Up to Journal for July, 2024 JOURNAL FOR WEDNESDAY 31ST JULY, 2024 ______________________________________________________________________________ SUBJECT: What I’ve been doing for the last few months… DATE: Wed 31 Jul 20:40:46 BST 2024 The UK is currently in the middle of a mini heatwave. Most of the afternoon my study has been hitting 28°C. I don’t like it when it gets above 24°C, I start to feel very dopey and tired. If you don’t want to read about Mere and it’s successor “Mote”, please stop reading now. Don’t flame me for not working on WolfMUD. Just move along… Mere, my programming language, has been scrapped and thrown away — sort of. I’d spent a long time creating the language and it worked well enough — for my needs at least. However, performance was becoming an issue as was maintenance. There were also the complaints that I wasn’t work on WolfMUD enough. One of the reason why I stopped writing… If Linus can take a break to write Git and Knuth to create TeX and Metafont I don’t see why I can’t take a break to create Mere :P There were some issues in Mere I couldn’t fix and some features people asked for that I just couldn’t implement. This was a problem. People wanted to use Mere in ways I hadn’t thought of[1]. Mere IS good enough that I use it daily for automation scripts, command line tools and experimenting with algorithms. At its heart Mere is a very basic, small, safe programming language. Scripts can run on the command line, in the browser (using WASM) and embedded in larger Go programs, servers and services. You can take someone’s script and run it, knowing it cannot cause any harm. By itself, Mere has no I/O capabilities — except being able to read from standard input and write to standard output. There is no other file handling or network access. Even reading Stdin and writing Stdout can be selectively disabled. The expectation is that Mere is passed data you want it to consume and then you receive back only the data you want from what is produced. Responsibility for providing and consuming data lies with the CLI wrapper, WASM wrapper or embedding Go program, server or service. If data is not given to Mere then a script cannot go out and get it for itself. Input and output can be redirected to read or write files. However, it is at the caller’s discretion — not the script being run. It is also at the caller’s discretion how many instructions can be executed and how deep function calls can go. I limit scripts to 50,000,000 instructions and a call depth of 1,000 when running in a web browser and both limits are unlimited for CLI scripts. I don’t want the web browser locking up if I do something daft, on the command line I can just hit Control-C. As a result, there has been some interest in my little language for writing servers and services based around Mere. I think, with the rise in security breaches and the huge amount of data being exfiltrated, Mere may have found a niche for itself by accident. Hence performance, maintainability and extensibility becoming a bigger issue. This is why for the last few months I’ve been quiet. I’ve scrapped Mere and written its replacement “Mote” — just a project name, it will be Mere 2.0 Mote nearly has the full functionality of Mere, and can do some things Mere cannot. There is still work to do. For example I need to implement uint and float data types and their arrays and maps. Mote is only lightly optimized at the moment, but already 40% faster than Mere. There are some language differences between the two, for the most part Mote can run Mere scripts with minor changes. The biggest difference is that Mote has gone back to dynamic typing, at least for now. An example, a simple recursive factorial implementation: Mere Factorial Mote Factorial ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ for x := 1; x <= 20; x++ | for x = 1; x <= 20; x++ printf "%2d! = %d\n", | printf "%2d! = %d\n", x, call factorial x | x, call factorial x next | next | factorial: func N:int | func factorial N is N == 0; return 1 | is N == 0; return 1 return N * call factorial N-1 | return N * call factorial N-1 endfunc | end They say “plan to throw one away” and that’s exactly what I’ve done with Mere. I plan on writing more about Mote, in the future. I’ve missed writing a lot :( Please, if you don’t like this type of content then don’t read it. Simple. At the moment the annex is still running Mere. I’ve some work to do before I can update the annex to Mote, then anybody can have a play. -- Diddymus [1] A good example is making remote calls to a service where the body of the request is a Mere script the service runs. Depending on the end-point used different data is presented to the script. Who would have thought…? Up to Main Index Up to Journal for July, 2024