News for hackers. Stuff that matters.
Re:John Carmack working on Scheme as a VR scripting language by TazeTSchnitzel on Wednesday July 01, 2015 @05:56AM (#9810893)
Lua's a minimal and easy-to-learn language that's easy to embed. But is it a good language? I'm not sure. It's weakly-typed and dynamically-typed, for example.
Re:John Carmack working on Scheme as a VR scripting language by beagle3 on Wednesday July 01, 2015 @07:24AM (#9811138)
Lua is not weakly typed (at least not in the sense of Javascript and PHP where "3"+4 is either 7 or 34, can't remember which.

It is dynamically typed, but so is Scheme, so that's not a reason to choose Scheme over Lua.

It has the bestest JIT currently found in any dynamically typed language, and rivaling the best JITs of statically typed languages like Java.

What's your definition of a good language that accepts scheme but not Lua?

Re:John Carmack working on Scheme as a VR scripting language by TazeTSchnitzel on Wednesday July 01, 2015 @07:41AM (#9811204)
> Lua is not weakly typed (at least not in the sense of Javascript and PHP where "3"+4 is either 7 or 34, can't remember which.

In JS, "3" + 4 is "34", in PHP, it's 7. PHP separates concatenation and addition, unlike JS.

Anyway, huh? Lua has automatic type conversion. That's usually considered weak typing.

Re:John Carmack working on Scheme as a VR scripting language by ufo on Wednesday July 01, 2015 @11:41AM (#9812596)
Its just for "+" and ".." though. For other things, such as equality and table indexing numbers and strings are not interchangeable.
Re:John Carmack working on Scheme as a VR scripting language by JoshuaScholar on Wednesday July 01, 2015 @08:08AM (#9811300)
In Lua "3"+4 is an error. Concatenation is a different operator than add, specifically to avoid confusing coersions.
Re:John Carmack working on Scheme as a VR scripting language by ggilles on Wednesday July 01, 2015 @08:35AM (#9811407)
Try it:

    Lua 5.1.5  Copyright (C) 1994-2012 Lua.org, PUC-Rio
    > ="3" + 4
    7
Re:John Carmack working on Scheme as a VR scripting language by JoshuaScholar on Wednesday July 01, 2015 @08:42AM (#9811451)
Ah. Well at least there isn't a confusion between add and concat

"3"+4 is 7 4.."3" is "43"

"3hello"+4 is an error

Re:John Carmack working on Scheme as a VR scripting language by beagle3 on Wednesday July 01, 2015 @10:39AM (#9812096)
Stand corrected with the example. I forgot about the lua auto type conversion - but that, on its own does not make weak typing - Python, C and Java do that between floats and ints, would you consider them weak typed?

I'm not familiar with a rigorous definition of weak typing - but my experience is that weak typing is usually reserved for languages like TCL, Snobol, and even Perl where there's no "type" of values to speak of - everything is equivalent and decoded according to context.

Re:John Carmack working on Scheme as a VR scripting language by superfunc on Wednesday July 01, 2015 @11:45AM (#9812645)
That's the problem with those terms, both 'weak' and 'strong' typing are purely subjective.
Re:John Carmack working on Scheme as a VR scripting language by k__ on Wednesday July 01, 2015 @08:19AM (#9811339)
> bestest JIT currently found in any dynamically typed language

Aren't the best players in this field the JavaScript engines? Not because JS is the best language, but because Google, for example, hired people like Lars Bak to make them.

Re:John Carmack working on Scheme as a VR scripting language by ufo on Wednesday July 01, 2015 @08:56AM (#9811500)
Javascript engines certainly have the best marketing going for them :) But Lua is a much simpler language and its much easier to write a JIT compiler for it than Javascript.

And if it comes to quality of programmers, LuaJIT has Mike Pall which is a bit of a legend for those who heard of him.

Re:John Carmack working on Scheme as a VR scripting language by pjmlp on Wednesday July 01, 2015 @12:55PM (#9813321)
Which means LuaJIT suffers from Bus factor syndrome.
Re:John Carmack working on Scheme as a VR scripting language by sklogic on Wednesday July 01, 2015 @07:26AM (#9811149)
TypedRacket is statically typed.

Good language is a meta language. There is MetaLua, of course, which qualifies it as a "good" language, but Scheme got more bells and whistles.

Re:John Carmack working on Scheme as a VR scripting language by JoshuaScholar on Wednesday July 01, 2015 @08:14AM (#9811325)
Metalua isn't compatible with luajit. It needs the slower C based interpreter. Its problem was that it was based on a very old version of Lua and it needed things like goto that weren't in lua yet, so it goes straight to bytecodes.

I'm working on building languages on top of Lua/Luajit, since Lua has a good tracing jit, there's no reason you can't write an expanded metalanguage on it that will preprocess a bit and give you a brand new language.

By the time I'm done it will have the power of scheme (including continuations, with some functions compiled internally to use continuation passing style, since Lua guarantees tail call elimination) and macros. The main difference should be that the base type will be arrays and tables not lists, but that could be an improvement. I'll probably tack on something like s-expressions too.

Re:John Carmack working on Scheme as a VR scripting language by corysama on Wednesday July 01, 2015 @01:16PM (#9813482)
You should find this interesting http://terralang.org

Took me a couple reads to figure out what it does. Luajit is the metalanguage for Terra. But, if you want to, you can run a mixture of Lua and Terra at runtime or statically compile to a pure Terra exe or .o with no Lua runtime at all.

Re:John Carmack working on Scheme as a VR scripting language by zem on Wednesday July 01, 2015 @04:03PM (#9814758)
that reminds me a bit of lush [http://lush.sourceforge.net/], one of a small handful of languages that i really feel should have made the jump to at least haskell-level popularity.

hn actually had a lush discussion recently: https://news.ycombinator.com/item?id=9602430

Re:John Carmack working on Scheme as a VR scripting language by JoshuaScholar on Wednesday July 01, 2015 @08:48AM (#9811466)
Also, I've worked in both Lua and Racket.

Racket's garbage collector is the only one I've ever used that actually made programs unusable.

Also, Racket's macro system feels like a mistake. While it's more powerful than most others, it's still rather incomplete, feels like a bad design, and ... well just look at the code that's used to implement the (sadly slow) object system. The code makes assembly language look clear by comparison. Dig under the surface and despair.

Scheme is very powerful, but in the end Lua programs are a lot more readable.

Re:John Carmack working on Scheme as a VR scripting language by JoshuaScholar on Wednesday July 01, 2015 @08:58AM (#9811507)
[edit, I wrote this before you changed your comment so say "one-shot". In short my continuations are not one shot, they are delimited though, by necessity because I don't rewrite ALL functions into continuation passing style, and you can't recast what lua calls metafunctions.]

Continuations are not coroutines.

Continuations let you save the current position, like setjump/longjump. But unlike setjump/longjump you can continue inside a function that already returned, ie as long as there is a continuation remembering that position then the activation record can't be deleted.

That means that activation records (ie local variables) can't be just the top of the stack - it changes things deep.

Also note that continuations only save the position, they don't restore the values of variables to what they were at that position, so re-evaluating continuation more than once will break any code that wasn't expecting to re-run.

Something that snapshots some local variables as well as the position will be more useful than raw continuations for things like search, backtracking, and logical programming languages.

[edit 2, I am ALSO adding snapshot continuations for these purposes]

Running an OUTER continuation rather than an inner one looks like an exception.

Re:John Carmack working on Scheme as a VR scripting language by ufo on Wednesday July 01, 2015 @08:51AM (#9811484)
Doesn't Lua already have (one-shot) continuations, in the form of coroutines?
Re:John Carmack working on Scheme as a VR scripting language by sklogic on Wednesday July 01, 2015 @09:37AM (#9811667)
> Metalua isn't compatible with luajit.

Although there should not be any obstacles for porting (or re-implementing) MetaLua on top of the most modern luajit.

> The main difference should be that the base type will be arrays and tables not lists, but that could be an improvement.

That should only matter in compile time anyway, for your meta-language. Target may use whatever data structures you want.

> I'll probably tack on something like s-expressions too.

It's not necessary for a meta-language, as long as you have quasiquotation (that works both for constructing ASTs and for pattern-matching them). It's just the easiest way, but not the only one.

Re:John Carmack working on Scheme as a VR scripting language by polymeris on Wednesday July 01, 2015 @08:51AM (#9811482)
Lua, thanks to Metalua, works pretty well as a meta language, so you could easily add static typing, while keeping the benefits of its interpreter.

OTOH, the same is true for Scheme.