8 ms·
Wren is a small, fast, class-based concurrent scripting language
- vaibhavthevedi 6y agoLooks nice. It reminds very much of C and C++ programming. What are some of its use cases?
- Avshalom 6y agoI think it got it's start as part of https://luxeengine.com/ https://luxeengine.com/ which transitioned away from Haxe
- skybrian 6y agoWren was originally written by Bob Nystrom, author of Crafting Interpreters. He recently handed it off to another maintainer.
- dejv 6y agoI am building tool for generating PDFs (https://docula.app https://docula.app) and I am using Wren to allow user scripts: things like show/hide label on some value or maybe display number in red when the value is > 0 and green otherwise. I was thinking about using Lua, but Wren seems more approachable to me.
- vaibhavthevedi 6y agoI like your product. Do you find Wren reliable when implementing features, like did it ever broke?
- dejv 6y agoWell, it seems to be working very well, but I am still in development mode with one customer and very little scripting going on. I will know more after general public is going to use it and will try to use things I haven't think about. I am not that concerned of Wren failing as a language, but I looking for a ways to prevent users write code that doesn't work without having to know what is going on, which is something Lua is excellent in (typo in variable name in if statement? Valid code for sure)
- skybrian 6y agoIf you're writing an application in C or C++ and want to embed a scripting language, and you think Lua is kinda weird and would prefer a more straightforwardly object-oriented language, then Wren may be worth trying. But I think there is only one active maintainer so you should be prepared to write your own patches if you need to fix something.
- _bxg1 6y ago> The VM implementation is under 4,000 semicolons. > Lightweight fibers are core to the execution model and let you organize your program into a flock of communicating coroutines. > Wren is intended for embedding in applications. It has no dependencies, a small standard library, and an easy-to-use C API.
- da39a3ee 6y ago> Wren is a scripting language. As far as I know "scripting language" doesn't have a widely-agreed upon definition and we should all stop using it. If anyone were to ask me, I'd say that a "script" is a program that contains a sequence of commands. It executes transiently for some side effect, as opposed to creating a persistent process responding to events. So for example, bash is clearly a scripting language, and if one is being rude about the appropriate uses for perl, then perl would be too. Python can be use for "scripting" but certainly isn't in general a scripting language by this definition. And I don't really think "scripting language" is a helpful term for Javascript, since it's most important role by far is in as an event-driven persistent process. However, some people (especially old-school C-programmer types) use "scripting language" to mean an interpreted language, I think. I think for Wren, maybe it's referring to a usage of "scripting" that C programmers associate with Lua?? None of the things it mentions are things that I personally associate with the word "scripting": > Wren is intended for embedding in applications. It has no dependencies, a small standard library, and an easy-to-use C API. It compiles cleanly as C99, C++98 or anything later. Or is the idea that both Lua (and thus Wren) and Javascript are "scripting" languages in the sense that they augment an executable written in a "proper" language with additional run-time functionality? If so, then that's interesting but I don't think many people get it (it only occurred to me while writing this) and we should clarify the terminology.
- andrewflnr 6y agoI understand about avoiding unclear terms, but I think "scripting language" actually does serve a useful purpose as an umbrella term for all those kinds of languages. It's not technically precise, but if you describe a language as "a scripting language", it does clear away a large part of the design space (not Haskell, C, Forth, or J) and tells you that this is meant to be user-friendly as opposed to performant, terse, high-assurance, etc. That's worth something. Of course if someone is still interested, then you want to get more precise pretty quickly. I think Wren does well enough at that on its landing page.
- da39a3ee 6y ago> user-friendly as opposed to performant, terse, high-assurance, etc. Strange, I really don't see that as an axis worth recognizing with that, or any, terminology (but whenever I bring this up I get voted down, so I guess more people agree with you.) I think the core of my disagreement is that, just because a language is user-friendly, that does not mean that it is not a "professional" or "high-assurance" language. I'm not saying that you are using it in this fashion, but I believe that with the terminological strategy you are suggesting, the term becomes a pejorative, wielded by those who use (C/C++/Rust/Java/Haskell/etc) as a subtle put-down to people who are using more user-friendly languages. Related, I think it's a rather confusing axis that doesn't fit the space of programming languages well: Go is user-friendly (I gather) and verbose, but performant and high-assurance. Python is user-friendly and terse, but non-performant and low-assurance (I'm a python programmer, but the run-time bugs put it in that category if we're comparing to statically typed languages). A lot of website HTTP handlers are written in Python, so "scripting" language seems like a very poor description for what it's doing there. IMO reasonable axes that are worth recognizing with terminology include interpreted vs compiled, statically vs dynamically typed, weakly vs strongly typed, but do not include {user-friendly} vs {performant, terse, high-assurance}.
- dang 6y agoIf curious see also 2018 https://news.ycombinator.com/item?id=16945227 https://news.ycombinator.com/item?id=16945227 2016 https://news.ycombinator.com/item?id=11611661 https://news.ycombinator.com/item?id=11611661 2015 https://news.ycombinator.com/item?id=8826060 https://news.ycombinator.com/item?id=8826060
- MR4D 6y agoLooks like what JavaScript would be like without all the baggage from the ‘90’s.
- jbverschoor 6y agoLooks like ruby with {}. Performs like ruby
- xscott 6y agoWren seems like a really clean alternative to a language like Python, but it makes one mistake that really drives me nuts. In order to provide binary operators, you must implement a method on the left object. From the documentation [0]: > The left operand is the receiver, and the right operand gets passed to it. So a + b is semantically interpreted as “invoke the +(_) method on a, passing it b“. This means that if you want to implement complex numbers, or matrices, or a bunch of other useful stuff, you'd have to be able to extend the type on the left (which you didn't write). You really want to be able to do things like: var z = Complex.new(1.0, 2.0) var result = 3.0 - z var A = Matrix.ident(3, 3) var scaled = 4.0*A Python hacks around this by having "right' versions of these methods too. It's kind of ugly - if the left object fails to support the operator method (__sub__ or __mul__) with the right type, the interpreter looks for a __rsub__ or __rmul__ operator on the right object to try. Ugly, but it works. C++ works around this a much better way: You can either have the operator method on the left object, or have an overloaded operator function that isn't tied to either object. Rust puts the operators on the left object too, but in some cases you can add methods/trait specializations to left classes. Unfortunately, Rust doesn't let you do this with generics, but that's a longer more complicated topic. Maybe there's some way Wren lets you tack on additional methods to the builtin Num class (monkey patching), but I couldn't find it. I would love an elegant alternative to Python, but this is enough of an issue that it keeps me from using Wren. [0] - https://wren.io/method-calls.html#operators https://wren.io/method-calls.html#operators
- fiddlerwoaroof 6y agoI think the most elegant solution is to break the subordination of methods to classes by having structs (possibly with inheritance) and multimethods.
- fiddlerwoaroof 6y agoSoo: class complex(real, imag); function add(number a, complex b) {} function add(complex a, complex b) {}
- jhvkjhk 6y ago
- darksaints 6y agoI believe this language was originally the creation of the guy who wrote the crafting interpreters book, but it definitely looks like it has grown well beyond his influence.
- tloru 6y agoFrom what I understand, this language was indeed developed by Bob Nystrom. AFAICT, He's passed the torch to the team behind the Luxe game engine, which uses wren as an embedded scripting language for game programming.
- nerdponx 6y agoI'd be interested in if this is comparable to Gleam, a BEAM-based scripting language, that I discovered through HN.
- wespiser_2018 6y agoWow, this would be ideal for me to write loadtests in! In broad strokes, I just want to spin up N threads making request after request, in an event loop with basic tracking. Is there a JSON or Network library available yet?
- jay_kyburz 6y agoThere is this. https://github.com/brandly/wren-json https://github.com/brandly/wren-json
- wcarss 6y agoOne thing I love about javascript is the ability to quickly and easily assign/remove whatever fields I'd like: let a = {}; a.somename = "some val"; a.newname = "some val"; a["a computed name"] = "some other val"; delete a.somename; if (a.neverseenthisbefore) { log("just doesn't log!"); } Python dictionaries requiring the ["fieldname"] syntax or .get to avoid KeyErrors on undefined keys has always pained me when whipping something short together. Similarly, here in Wren it seems like Maps require substantial and strict syntax, and Classes are not meant to allow definition of arbitrary Fields at runtime. That one small thing is a key piece of flexibility I want when experimenting. I shouldn't need to write a getter and a setter down in a distant file on the correct place in a class hierarchy just because I chose to latch a bit of temporary state onto an object while I do a bit of work. In serious code for serious business, that kind of freedom and nonchalance can be quite dangerous. But when I'm having fun and just trying something, which is the only context where I'm really trying new languages out for the moment, the guard rails chafe! (still, this looks like a pretty neat little language)
- shezi 6y agoSide note: You can use python classes for that. It's a common pattern for me to have something like this in my projects class Holder: pass Simply add any attributes at runtime. It's essentially a different interface for the built-in dict of the instances. Add a bit of getattr magic and you can read undefined attributes, too.
- hota_mazi 6y ago> Wren is fast. A fast single-pass compiler to tight bytecode Bit of equivocation here. Wren is dynamically typed. It will never be fast. At best, it will probably be one tenth as fast as the slowest statically typed language. Maybe it's fast to compile, but it will never run fast.
- smlckz 6y agohttps://wren.io/performance.html#why-is-wren-fast https://wren.io/performance.html#why-is-wren-fast
- liigo 6y agoI've an issue on Wren's FFI: binding foreign methods is slow. https://github.com/wren-lang/wren/issues/648 https://github.com/wren-lang/wren/issues/648
- molsson 6y agoThe name wren is already used by: https://projectwren.com/ https://projectwren.com/
- eis 6y agoThe Wren language has been around a lot longer than the project you linked.
- jermo 6y agoWould like to start using Wren though issues like this put me off: "Stack corruption" https://github.com/wren-lang/wren/issues/761 https://github.com/wren-lang/wren/issues/761 Using older and more established languages seems less risky.
- gotzmann 6y agoThe guy behing Wren is Bob Nystrom, member of Dart language team and author of Crafting Interpreters book.