JavaScript is the most popular language on the planet, for 7 years running. JavaScript has ternaries, lambda functions, callbacks, maps, iterators, generators and async functions, classes, block-scoped variables and functions, array and object literals, destructuring assignment, parameter context matching, multiline and template strings, multi-character splits, concat(), shift(), flat(), trim(), join(), map(a => a .join()), and countless other useful features (I'd link explanations, but this forum paradoxically blocks developer-mozilla-org).
LiveCode Script needs to die.
This is not sour grapes, or some noob complaint. I've used LiveCode for >5 years, on hundreds of projects, and worked on LC native extensions. I can't count the number of utility functions I've written and rewritten to work around LCS's painful design flaws and shortcomings. The LCS forums are littered with people struggling through problems that simply don't exist in good languages.
Meanwhile, there's a near-infinite pool of JavaScript libraries, tools, and resources online, and literally millions of JS programmers who would be potential LiveCode users. Even Apple now supports JavaScript instead of AppleScript (HyperCard's other descendent).
LiveCode shouldn't be maintaining and improving a dilapidated language that falls further behind every year. LiveCode's selling point is its multifunctional GUI platform, not its HyperCard nostalgia. LiveCode should adopt JavaScript as its primary and internal scripting language.
Proposal:
- Replace LiveCode Script with JavaScript internally. Use Mozilla Firefox's SpiderMonkey engine, Google Chrome's V8 engine, or preferably Node js to execute JavaScript within LiveCode.
- Write a PEG-js for LiveCode Script, to parse legacy LCS into JS on-the-fly.
- Configure LiveCode's script editor to support editing LCS or JavaScript. Bug-free JS auto-formatters are plentiful (the best is standardjs .com).
- Reparse LCS into JS whenever the script is saved, or the "script" property is changed. LCS continues to work, as if nothing ever changed.
Code: Select all
read from socket socketID [until string | for amount [chunkType]] [with message callbackMessage]
Code: Select all
readFromSocket(socketID, {until: string, for: amount, withMessage: callbackMessage})
amount = number | [number, chunkType]
Is it really that bad?
Yes. Consider the minimum code for an "N-deep" string-splitting function, which takes splitn("1+2*3", "+", "*") and returns [[1], [2, 3]]. In LiveCode Script:
Code: Select all
function splitn str delims
if a_len(delims) > 0 then -- Signature 2, recursive case
local _result = ""
if len(delims[1]) > 1 then -- Hack to handle multichar and regex delims.
-- Hack replaces delimiter with vtab, a rare character
put replaceText(str, delims[1], numToChar(11)) into str
put numToChar(11) into delims[1]
end if
set the itemDelimiter to delims[1]
split str by itemDelimiter
put shift(delims) into delims
repeat with i=1 to a_len(str)
put splitn(str[i], delims) into _result[i]
end repeat
return _result
else
if length(delims) > 0 and (delims is not "delims") then -- Signature 1
local _delims = ""
repeat with i=2 to paramCount()
put param(i) into _delims[i-1] -- make _delims an array of params
end repeat
return splitn(str, _delims)
else -- Signature 2, trivial case
return str
end if
end if
end splitn
Code: Select all
function splitN (str, ...delims) {
return delims .length ? str .split(delims[0]).map(piece => splitN(piece, ...delims .slice(1))) : str
}