Hacker News new | ask | show | jobs
by rkeene2 2567 days ago
I recently did something similar with Tcl (instead of Python) and Duktape (instead of V8): https://rkeene.dev/js-repl/

All the Tcl runtime is in the "runtime" object, so like "runtime.puts('Hello World')" or "runtime.expr('2128')", etc

It was a lot of fun

1 comments

Tcl is one of those languages that feel special once you get to know it. In a good way! It’s like a command prompt for actual code. I don’t know how to explain it any better.
I'm not sure I got to know Tcl properly. I needed to use it to interact with an electronics design tool in order to extract information about a design, and so most of what I learned was from the tool's documentation about how to use its API, and some random Stack Overflow for specific questions.

Anyway, Tcl felt very much like an 80's interpreted language to me. It seemed like every data structure was built on top of strings, and every statement was being run through eval().

I haven't used Tcl in years, but you are right about strings, actually the goal is that every data type is implicitly marshalled into string and vice versa.

As for the eval you need to keep discipline there is difference whether you use [] {} or "".

The magic about the language is that it has no statements, for example you are missing try/catch? You can implement it your own: http://code.activestate.com/recipes/68396-try-catch-finally/

>It seemed like every data structure was built on top of strings, and every statement was being run through eval().

That's the case, and that's the whole magic...