
Wren: a small, fast, class-based concurrent scripting language - bluesilver07
http://munificent.github.io/wren/
======
Ameo
The fibers remind me of Elixir's processes. Elixir fascinated me at first, but
I really didn't get into the groove of it after trying it out on a project.

Wren looks equally fascinating; perhaps it could warrant a trail project of
its own.

------
andrewflnr

      4000 semicolons
    

I've never seen that used as a way to measure code size, but it's perfect for
Cish code. That alone made this worth the click. And the language itself looks
like something I wish I could have designed. Good show.

~~~
emmanueloga_
Probably a homage to IO:

"features: BSD license , small vm (~10K semicolons), ..."

[https://web.archive.org/web/20150101035218/http://iolanguage...](https://web.archive.org/web/20150101035218/http://iolanguage.org/)

------
untothebreach
Wren is great, I participated in the community for a while but then got on to
different things. Glad to see it is still going strong.

------
tasty_freeze
I've looked through the wren.io website, including the module documentation.
As a scripting language, I would expect Wren to have decent regex support, but
I find nothing there. Did I overlook it?

I use perl and python for building little utilities. I like the regularity of
python over perl, but if I could get a clean syntax and it ran 4x faster with
Wren, that would be great. But if there isn't a regex facility, it is a non-
starter.

------
amflare
Looks interesting, but I can't figure out where/for what it would be used. Am
I missing something obvious?

~~~
munificent
Quoting myself from my own FAQ[1] feels a little weird, but here you go:

\---

There are a few scripting languages used for embedding in applications. Lua is
the main one. TCL used to be. There’s also Guile, increasingly JavaScript, and
some applications embed Python. I’m an ex-game developer, so when I think
“scripting”, I tend to think “game scripting”.

Lua is nice: it’s small, simple, and fast. But—and I don’t mean this as a
criticism—it’s also weird if you’re used to languages like C++ and Java. The
syntax is different. The semantics, especially the object model are unusual.
Anyone can get used to 1-based indexing, but things like metatables really
show that objects were bolted onto Lua after the fact.

I think there’s room for a language as simple as Lua, but that feels natural
to someone with an OOP background. Wren is my attempt at that.

\---

[1]: [http://wren.io/qa.html#why-did-you-create-
wren](http://wren.io/qa.html#why-did-you-create-wren)

~~~
emsy
I used to have a program with an embedded Lua interpreter where I sometimes
needed to switch back and forth between C++ and Lua. It's insane. Arrays don't
start at zero, you create blocks with keywords and then there are some minor
annoyances like != being ~= or the lack of a ternary operator. Where Lua
really shines though is the binding api. It's really easy to use when you have
to do something by hand. The documentation is great and you have a selection
of binding tools. You can even create classes with overridable virtual
methods.

Since Lua is rather tedious to use for me, I looked for alternatives with a
C-like syntax. I found Squirrel and Wren but the last time I looked they
lacked the tooling and mailing lists that Lua already has. It's a bit of a
chicken-egg problem unfortunately.

~~~
eropple
An option that might be worth looking at is AngelScript, which I think
minimizes the context switch between C++ and the scripting layer really
nicely.

~~~
emsy
I totally forgot about AngelScript. It really has the lowest context switching
overhead, but you get to keep the verbose C++ syntax in return, which is a
trade-off.

Personally I don't mind if a language differs somewhat, but with Lua I
constantly get errors because of basic things like braces, comments and
comparisons.

------
nilkn
Are Wren fibers automatically distributed across available CPU cores or is it
all single-threaded?

~~~
munificent
Single-threaded. The Wren VM itself is completely self-contained and has no
global state. So, if you wanted to, you could host multiple VMs
simultaneously, one for each thread, to get actual concurrency. You'd have to
do the marshalling to move values from one to the other to get sharing or
communication working, though.

~~~
duaneb
If the VMs are self-contained, what mechanism would they use to communicate?
id be ok to use marshaling if the marshaling itself is the dominating cost of
communication.

~~~
ori_b
> what mechanism would they use to communicate?

That's up to the program embedding them -- the idea is that you're the one
implementing the communication and synchronization in the embedding program,
rather than in Wren itself.

~~~
duaneb
I would imagine some base shared memory copy on write queue system would help
here immensely.

------
Touche
I wish languages in this space would make it easier to create statically
linked executables. With Lua you can do it yourself using squishy and a small
main.c program, but it would be nice of the compiler just did it all for you.

For small cli apps, being able to write them in a pleasant to use language
like Wren would be a big win.

------
Kelet
Hmm – I'm working on some Windows API manipulations to provide a framework to
make `macro scripts` (similar to AutHotKey or AutoIt), and in a few weeks I'll
be looking to implement a scripting language. I've checked out LuaJIT, Lua
5.3, Lua w/Terra, AngelCode, Python, et al. and they all seem to have their
faults. I actually need a language that supports both proper threading and co-
routines, to respond to user-based key hooking (and good stuff like timers).
This seems like it may be a good candidate, I don't mind contributing either.
Bookmarked.

------
rurban
Bob: so no workstealing with native threads anymore, just tiny fibers?

looking forward to your jit. have a look at potion, it's really simple and
fast.

------
nikolay
A cute little language, but without the support of existing libraries, it
can't gain mass adoption. It will take years to catch up with LuaJIT, and its
vibrant ecosystem.

~~~
ketralnis
Isn't that true of every language ever? Surely Lua was in that position when
it was young. That just doesn't sound like a reasonable objection to anything
that's young

~~~
nikolay
Of course, but how many years did it take for Lua to get there? Without
piggybacking off existing libraries, prepare for a very long journey!

In general, the language does not matter much - the ecosystem does and it
includes libraries, integrations, etc.

Duktape [0] in a similar position.

[0]: [http://duktape.org/](http://duktape.org/)

------
ww520
What is the performance like? Comparable to V8 javascript? Or maybe even
comparable to LuaJIT?

~~~
andrewflnr
Only comparable to LuaJIT with the jit off, because "Mike Pall is a robot from
the future.":
[http://munificent.github.io/wren/performance.html](http://munificent.github.io/wren/performance.html)

~~~
ww520
Wren's performance is pretty impressive!

------
realworldview
fibers? sounds like a duck named quacky.

~~~
ob
I assume they mean this:
[https://en.wikipedia.org/wiki/Fiber_(computer_science)](https://en.wikipedia.org/wiki/Fiber_\(computer_science\))

