Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

javascript vs lua

Name: Anonymous 2012-01-24 20:47

let's say i might be working on something ``secret'' and i want to embed a scripting language that isn't too off the wall for end users. i hear luajit is kinda fast and v8 is really fast and speed would be quite nice since user scripts might be called hundreds of thousands of times in short timeframes

i've heard javascript has better semantics and is generally more pleasant to use, but i want /prog/'s opinion so i don't fuck up and regret it later

Name: Anonymous 2012-01-29 20:14

>>80
Thanks. That's kind of stupid, though.

Name: Anonymous 2012-01-30 15:41

>>80
> = "1" == 1
false

wat

Name: Anonymous 2012-01-30 17:37

>>82
Nothing wrong with that. It's far better than coercion that fails to do what you want roughly half of the time.

Name: Anonymous 2012-01-30 22:40

>>82
creten

Name: Anonymous 2012-01-31 0:08

>>82
You're not very good at any of this programming stuff are you?

Name: Anonymous 2012-01-31 2:14

>>83-85
we'll see who's laughing when browsers take over

Name: Anonymous 2012-01-31 2:27

>>86
Please elaborate on what the fuck you just said so the rest of us can start laughing now.

Name: Anonymous 2012-01-31 5:29

I prefer Javascript as it's Scheme with C style syntax.

Name: Anonymous 2012-01-31 14:00

>>86
as in, 2-3 years from now, there will be no more "native" programs apart from browsers themselves

and browsers === javascript! you'll enjoy it, trust me.

Name: Anonymous 2012-01-31 14:08

>>87
I think homegirl is talking about a loss of precision in numbers when a value undergoes an integral promotion. Oh wait, never mind. I don't think this foolholio has an ounce of programmer blood in it!

Name: Anonymous 2012-01-31 14:59

>>90
you're just mad javascript is more popular than your toy lisp

deal with it

Name: Anonymous 2012-01-31 15:02

>>89
Obviously not going to happen. Even ChomeOS is just Google Linux.

Supposing it did happen, there are languages that compile to JS, many of which are pretty damn strict about semantics. Plus you'd be out of a job. You don't even seem to know JS very well.

Name: Anonymous 2012-01-31 15:03

>>91
Javascript is toy Lisp! How is that not obvious‽

Name: Anonymous 2012-01-31 15:26

>>93
i'd like to see your lisp being used for real software

Name: >>93 2012-01-31 15:56

>>94
I wouldn't.

Name: Anonymous 2012-01-31 19:25

>>95
i wouldn't either! javascript all the way!

Name: Anonymous 2012-01-31 22:50

>>94

it was once.

Name: Anonymous 2012-01-31 22:58

>>96 see >>93

Name: Anonymous 2012-02-01 0:24

>>98
more like: lisp is toy javascript

Name: Anonymous 2012-02-01 0:46

motherfucker

Name: Anonymous 2012-02-01 16:33

I like how Lua isn't even considered OO yet it handles method calls better than Javascript

Name: Anonymous 2012-02-10 17:59

Name: Anonymous 2012-02-10 18:11

>>102
Except that both Lua and LuaJIT are less than a megabyte.

Name: Anonymous 2012-02-10 18:13

And have a great interface to C.

Name: Anonymous 2012-02-10 18:17

>>103
except they aren't javascript

Name: Anonymous 2012-02-10 18:55

>>105
And that's good!

Name: Anonymous 2012-02-10 19:12

>>106
did you even read that page, or the wiki it linked to? lua doesn't have any of that

it's obsolete

Name: Anonymous 2012-02-10 19:21

Lua is good. Just don't use vanilla Lua.

Use LuaJIT, it's what all of the professional game developers use, it has way better performance and way better C/C++ bindings.

http://luajit.org/

Name: Anonymous 2012-02-10 21:01

>>108
still doesnt add all those awesome features

Name: Anonymous 2012-02-10 21:24

>>111
sweet trips bro

Name: Anonymous 2012-02-10 21:25

>>110
Thanks homey.

Name: Anonymous 2012-02-10 21:26

>>111
anytime broski

we true tomodachi

Name: Anonymous 2012-02-11 18:19

>>102
i like the weak maps bit:
- they're exclusively weak-keyed
- they aren't enumerable, because the gc collecting fields would fuck up the iteration

in contrast to lua's weak tables (a paper on which is even mentioned in the wiki entry):
- they can be set to be weak-keyed only, weak-valued only, or both
- they can be enumerated, because next/pairs will not get confused if fields suddenly go missing

so that's at least one javascriptified feature

Name: Anonymous 2012-02-11 19:52

>>107
I laught at your .............

Name: Anonymous 2012-02-14 18:55

>>9

Right... and:

$ cat > time.lua
function analyze(s)
    local start = os.clock()
    local f = loadstring(s)
    for i = 1, 100000 do
        f()
    end
    print(os.clock() - start, "s")
end
for expr in io.lines() do
    analyze(expr)
end

$ luajit2 time.lua
math.sqrt(math.random(1000))
0    s

Multiplying loop counter by 1000 (for i = 1, 100000000 do)

$ luajit2 time.lua
math.sqrt(math.random(1000))
0.57    s

Seems like the Lua version runs in just 0.00057s...

The benchmark is pretty meaningless. It's mostly stressing parser and math.random implementation.

For math.random(), LuaJIT uses Tausworthe PRNG with period of 2^223.

V8 uses much lower quality PRNG; two 16-bit MWCs combined together. this should yield period of about 2^61, give or take.

Name: Anonymous 2012-02-14 22:30

>>115
>mfw loadstring lets you reuse what you just compiled
head full of fuck

loadstring considered unharmful

Name: Anonymous 2012-02-15 0:11

>>116
damn straight. It's like the only intelligent eval out there.

Name: Anonymous 2012-02-15 4:38

write it in python/ruby and then redo the innerloop in c

Name: Anonymous 2012-02-15 9:29

>>102

1) Lexical scoping.
Fixes Javascript specific scoping issues. About time!

2) Collections.
All you need is a Lua table, seriously. You get arrays and maps in one data type. LuaJIT gives you C-structs, with C-like memory consumption as well.

3) Weak maps.
As mentioned before, great addition. Lua has the same feature as well.

4) Proxies.
Analogous to Lua metamethods. Although Lua implementation will be more verbose, because you might need to keep one hidden 'backing' table.

Name: Anonymous 2012-02-15 12:58

>>119
Why can't ECMA or W3C just create a new language or choose a more fully-featured existing language for HTML scripting rather than bolt more hacks onto JavaScript and turn it into Frankenstein's monster? The script tag has a lang attribute for a reason.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List