← Back to context

Comment by artpar

1 day ago

I made a language for using in another project, so I'll answer your questions

https://www.npmjs.com/package/wang-lang

- this new language looks and behaves exactly like javascript, except it doesnt have "eval" and "new Function", so it is CSP safe. That's the only difference. I wanted to execute dynamically generated code in chrome extension

- llm did most of the work of creating a nearley grammar and associated interpreter (whole thing is bundled, nearley is not a final dependency), elaborate tests make this quite sane to handle

- took me about total of 1 weeks for the initial mvp to try out, and then have been fixing bugs and inconsistencies with javascript behavior, about 1 day a month of effort

- mostly 0

The only reason to create was I couldnt find something similar and it was low effort thanks to llm

I also created another even smaller DSL you can say

https://www.npmjs.com/package/free-text-json-parser

It parses json embedded in plain text

I once made a hacked version of javascript for work, starting with rhino. I adjusted it to make `.` and `[]` on null/undefined return undefined. Kind of like the `?.` in modern javascript, but it didn't exist back then. I was inspired by ObjectiveC's message send behavior.

The language was for some configuration in a reporting system. The scripts were written by non-engineers, and the changes made the language more user friendly for them. I started from javascript because I expected it would be easier for them to find documentation.

Nice. I built something basically just like this for work for the same reason last year. It only look a few hours though, cause I just used Acorn [0] to parse my JS, then directly evaluated the AST. It also had an iteration limit and other configurable limits so I can eval stuff in the browser without crashing the tab. I did not use an LLM.

[0]: https://github.com/acornjs/acorn

  • This is exactly what I wanted and couldn't find. Ended up creating along with an interpreter (so slightly easier then walk and execute)

> safe

> llm did most of the work

> it was low effort

I really wouldn’t trust its supposed safety.

  • csp safe has a particular meaning associated it with. its not a "safe" language whatever that is. chrome webstore team is okay with it and serves my purpose. if you have submitted extensions to google chrome then you would know that any sign of "eval" or new Function in the code will lead to rejection.