A D vs. Rust example

Siarhei Siamashka siarhei.siamashka at gmail.com
Sun Oct 30 00:23:29 UTC 2022


On Tuesday, 25 October 2022 at 17:47:00 UTC, Imperatorn wrote:
> On Tuesday, 25 October 2022 at 17:42:42 UTC, Siarhei Siamashka 
> wrote:
>> On Tuesday, 25 October 2022 at 17:16:58 UTC, Don Allen wrote:
>>> [...]
>>
>> When developing C++ code, I was solving this problem by just 
>> embedding a Lua interpreter (and also a much less known 
>> http://squirrel-lang.org/ because its syntax resembles C). 
>> This approach provides GC and easy programming for the parts 
>> of a program, which are not performance critical.
>>
>> Seems like Rust also can do this just fine: 
>> https://docs.rs/rlua/latest/rlua/
>
> Hey buddy, someone else on the internet that has used Squirrel. 
> I thought I was alone :D

Well, it was not too hard to find Squirrel once you decide that 
you want "something like Lua, but with C syntax" and go to the 
google search with this request :-)

Lua is great, but I wasn't completely happy about 1-based 
indexing and wanted to try something new. And nowadays I see that 
there's also mruby competing in the same niche, so there's no 
shortage of available solutions.

> I wish I could have used D instead tho

Ironically, D was also considered for this particular project, 
but got rejected because it was seen as a long term maintenance 
hazard. Thankfully my more experienced colleagues explained me 
what's wrong with D language and many years later I see that they 
were absolutely right on every account.

Lua or Squirrel interpreter is small and simple enough and can be 
just included as a part of the C++ project source tree. Even if 
the upstream developers release new incompatible versions in the 
future, nobody can force us to upgrade. Being small and simple, 
the interpreter code is also perfectly maintainable and 
customizable without depending on any third party. You know that 
you are in full control and this feels great.


More information about the Digitalmars-d mailing list