Replace LiveCode Script with JavaScript, forever

Something you want to see in a LiveCode product? Want a new forum set up for a specific topic? Talk about it here.

Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller, robinmiller

Post Reply
alexchandel
Posts: 1
Joined: Thu Oct 11, 2018 8:16 pm

Replace LiveCode Script with JavaScript, forever

Post by alexchandel » Thu Jan 02, 2020 9:20 am

LiveCode Script is, frankly, an abominable language. It has no ternary operators, lambda functions, callbacks, maps, iterators, generators/asynchronous functions, type classes, block-scoped variables, nested functions, array literals, object literals, destructuring assignments, parameter context matching, multiline strings, template strings, multi-character string splits, trivial functions like concat(), shift(), flat(), trim(), sorted join(), a mapped join (since there's no map), or a billion other features ubiquitous among modern languages.

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:
  1. 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.
  2. Write a PEG-js for LiveCode Script, to parse legacy LCS into JS on-the-fly.
  3. Configure LiveCode's script editor to support editing LCS or JavaScript. Bug-free JS auto-formatters are plentiful (the best is standardjs .com).
  4. Reparse LCS into JS whenever the script is saved, or the "script" property is changed. LCS continues to work, as if nothing ever changed.
Although JavaScript's builtin features replace most of the LiveCode Dictionary, step 1 still requires specifying a core JS API (likely following Apple's AS->JS translation formula). A robotic translation applies for almost every function:

Code: Select all

read from socket socketID [until string | for amount [chunkType]] [with message callbackMessage]
to

Code: Select all

readFromSocket(socketID, {until: string, for: amount, withMessage: callbackMessage})
amount = number | [number, chunkType]
Using Node-js would render most IO functions obsolete as well.

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
The equivalent JavaScript:

Code: Select all

function splitN (str, ...delims) {
  return delims .length ? str​ .​split(delims[0]).map(piece => splitN(piece, ...delims​ .​slice(1))) : str
}
That level of bloat extends to every single real-world task one attempts. LiveCode needs JavaScript.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 4726
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Replace LiveCode Script with JavaScript, forever

Post by richmond62 » Thu Jan 02, 2020 9:44 am

LiveCode Script is, frankly, an abominable language.
You are a subjective sausage. 8)

And your point is?

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 4726
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Replace LiveCode Script with JavaScript, forever

Post by richmond62 » Thu Jan 02, 2020 9:46 am

The LCS forums are littered with people struggling through problems that simply don't exist in good languages.
That's not true at all.

The LCS forums are full of messages asking for help because LiveCode, unlike a lot of other languages,
can be learnt largely by oneself (no textbooks, no nothing), but a little help does tend to accelerate things.

bogs
Posts: 4782
Joined: Sat Feb 25, 2017 10:45 pm

Re: Replace LiveCode Script with JavaScript, forever

Post by bogs » Thu Jan 02, 2020 11:13 am

It is hard to read your post, and decide whether it is basic trolling or a legitimate point of view. On the face of it, it is hard to take very seriously. After all, if you think JS is the end all be all, it isn't like there aren't enough versions of JS to satisfy you, pick one and use it.

It also isn't like you can't use JS from inside Lc. I'm not even sure that your description of Lc's shortcomings is accurate (I'm pretty sure it isn't), but all that aside, and since I have a few minutes available this morning to do not much else, I'll bite :twisted:

Is this sour grapes ?
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.
You claim to have worked with Lc for 5 years, and yet this is your first ever forum post? That is simply amazing, however it argues your very first problem with the language, that people are struggling with it to the degree that the forums are littered with posts concerning problems no one asks elsewhere. If that were the case, I would think you might have a higher post count yourself, having had to wade through these unsolvable dilemmas yourself at some point.

Further, I've used several languages myself over the decades, and have been on BBS boards and forums related to those languages. I see no difference in the general flavor of the questions asked here as opposed to there. Our points of view appear to differ right out of the gate.

The Best ?
alexchandel wrote:
Thu Jan 02, 2020 9:20 am
JavaScript is the most popular language on the planet, for 7 years running.
Um, says who? Really, that isn't a troll. Tiobe, probably the best known of the programming language indexing places, doesn't seem to think so.
wrote: According to the latest Tiobe Index, Java just edges out C as the most popular programming language in the world.
Tiobe also said it will announce its programming language of 2019 in January 2020.
“There are 4 candidates for this title: Java (+1.3%), C (+1.8%), Python (+1.9%) and C# (+1.4%),” said Tiobe.
So you are probably not using the Tiobe index, however, I did see that Redmonk *does* think so -
Redmonk
Frequency: Semi-annually.
Methodology: Based on raw lines of code in GitHub repositories and StackOverflow language tags.
Rankings:
1. JavaScript
2. Java
3. PHP
4. Python
Saying something is the "BEST" anything is often a subjective pissing contest, but aside from that, what do you do next year when you find out "Language X" is now the best language ?

If you took and averaged out all the ranking sites (should be easy in Lc for someone of your experience, probably in one handler of less than 5 lines), you'd find that JS comes out roughly in the top 5, with some variant of C often coming in higher. Using your logic, we should change JS over to C!

Of course, since C already exists, I would still ask why.

Is it really that bad?
I think not. You post one function as if it is the end all be all. There are many examples showing the reverse. I also think your example code is bloated, but since I didn't go through it yet, I'll hold judgement.

However, this statement -
That level of bloat extends to every single real-world task one attempts.
is just pure hyperbole. If that were the case, you wouldn't be posting to argue this desperately needed change, because the language wouldn't be here to begin with. It would have died out long long ago all on its own.

To sum up, your post appears to be trollish in nature. Most of your arguments are not based in facts, many are not even well formed. The basic premise of your post makes no sense in any real world applicable way, i.e. this language should be that language instead.

My couple of minutes is up. Phwew, I feel better ! :D
Image

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 4726
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Replace LiveCode Script with JavaScript, forever

Post by richmond62 » Thu Jan 02, 2020 11:41 am

My couple of minutes is up. Phwew, I feel better !

Well said, that man!


And a very well spent couple of minutes. 8)

Legitimate points of view can be expressed using temperate language.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 4726
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Replace LiveCode Script with JavaScript, forever

Post by richmond62 » Thu Jan 02, 2020 12:11 pm

I've used LiveCode for >5 years, on hundreds of projects

Why don't I believe that?


If LiveCode were as awful as this person seems to think I would have chucked it
well before "hundreds of projects."

This person either is a sort of masochist, or they were being paid buckets of money for
these "hundreds of projects" [And now the money has dried up . . . ], or they are just . . . erm . . . rubbish.

kaveh1000
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 435
Joined: Sun Dec 18, 2011 7:23 pm
Location: London
Contact:

Re: Replace LiveCode Script with JavaScript, forever

Post by kaveh1000 » Thu Jan 02, 2020 12:16 pm

End of discussion. :-)
If LiveCode were as awful as this person seems to think I would have chucked it
well before "hundreds of projects."
Kaveh

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2262
Joined: Thu Feb 28, 2013 11:52 pm
Location: Göttingen, DE

Re: Replace LiveCode Script with JavaScript, forever

Post by [-hh] » Thu Jan 02, 2020 3:23 pm

alexchandel wrote:LiveCode needs JavaScript.
Yes, we wait since years for general do as "javascript", not only for HTML5 standalones.
That would expand the possibilities of LiveCode significantly.

But I say also:
JavaScript needs LiveCode.
That would expand the possibilities of JavaScript significantly.

Instead of silly comparisons we simply should take the best of both languages.
Last edited by [-hh] on Thu Jan 02, 2020 6:46 pm, edited 1 time in total.
shiftLock happens

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 6811
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Replace LiveCode Script with JavaScript, forever

Post by dunbarx » Thu Jan 02, 2020 3:24 pm

All.

There is no question at all that LC is not an abominable language. Too much is possible with it, usually with very short handlers. Further, it is far too easy for new users to get running, and with with reasonable competency, to think that LC is anything but nearly miraculous.

But perhaps the OP, who spent a lot of time on his post, is talking about much higher programming capabilities? I use almost no "external" gadgetry in any of my own projects, no JSON, sockets, databases, whatever, so I do not know how LC measures up when those are required.

The OP also seems to know HC, and therefore has to be considered a long time xTalk user. I would not dismiss his points as trolling. He is not, unless he has changed his name, Amthony Black, and though forceful in tone, not a troll.

So that leaves us with determining the value of the points he makes. Is LC lacking in any of the arenas he mentions? Is LC too slow? I recall an early demonstration where pulling the contents of a webpage in LC took one line (it still does), and doing so in C++ took half a page. Has this situation reversed in some areas?

I doubt it, but do not want the replies to his post to appear to come from a group of "fanboys", as Amthony once accused us of being. HIs post is far too serious to dismiss that way.

Craig

mrcoollion
Posts: 563
Joined: Thu Sep 11, 2014 1:49 pm
Location: The Netherlands

Re: Replace LiveCode Script with JavaScript, forever

Post by mrcoollion » Thu Jan 02, 2020 3:36 pm

I am really glad LiveCode exists.
I have been out of the application development game for quite a while and wanted to start again (used to develop ERP Business Process Support Solutions). So after a lot of investigations I came to the conclusion that LiveCode is best fitting app development language based upon the following criteria:
  • It needs to be affordable with a free way to start without many restrictions
  • It needs to support object orientated development.
  • It needs to be able to port my applications at least to Windows, Mac OS Android, and IOS and if possible also to Linux.
  • It needs to be easy to understand and without all kinds of brackets, accents and other characters that make a language for me difficult to work with. And that makes java, in my opinion, a difficult to learn development language (And yes I have tried Java and I am able to read it but fast application development, no way).
  • It needs to be easy to deploy and test
  • It needs to have good community support.
So this was quite a list and the solution that ticked most of the boxes (in this case all) was LiveCode.

And yes LC is not perfect but it improved quite a lot in the last few years and I personally think that if you do have Java Skills the last LC versions combine perfectly with Java if you need to do something special.

From an increasingly more happy LC user.

Klaus
Posts: 11875
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Replace LiveCode Script with JavaScript, forever

Post by Klaus » Thu Jan 02, 2020 5:05 pm

Hi Alex,

welcome to the forum!
alexchandel wrote:
Thu Jan 02, 2020 9:20 am
...I'd link explanations, but this forum paradoxically blocks developer-mozilla-org).
Due to high spamming here on the forum, new users need to have at least 10 postings before they can post URLs etc. at all, that's why.

I think Craig made a good point here, I confess I have not the slightest idea what most these mentioned JS features actually mean! :oops:


Best

Klaus

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 4726
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Replace LiveCode Script with JavaScript, forever

Post by richmond62 » Thu Jan 02, 2020 6:01 pm

There is no such thing as "the ideal programming language" any more than there is an ideal human language,
and it is disingenuous to think that.

But there are things that one can put better in Scots than in English, and the other way round (or so they tell me 8) ).

And as my Granny said, "It's all in the mouth." Well, what she really said was, "It's aa in the gab." 8)

But, a rather nasty Jesuitical Latin Master that I was subjected to for a year a while back, used to beat the boys
in his charge round the back of the head with a book for "tone of voice" and "tone of look," I should like to point out
that the way the OP delivered his thing was a bit "aff" in its tone.

Not that I approve of beating anyone round the back of the head with a book;

much more effective round the front. :twisted:

AND, whatever the programming language someone favours I do have to say that I have had pretty good uptake
and retention in both Primary school children and old age pensioners who learn LiveCode with me.

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7850
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Replace LiveCode Script with JavaScript, forever

Post by FourthWorld » Thu Jan 02, 2020 6:21 pm

alexchandel wrote:
Thu Jan 02, 2020 9:20 am
JavaScript is the most popular language on the planet, for 7 years running.
By what measure? Much of the industry relies on the TIOBE Index for that metric, where Java has been #1 for a great many years, and JavaScript is #7 (after - in order - C, Python, C++, C#, and VB.net):
https://www.tiobe.com/tiobe-index/

JS is indeed the most popular language in browsers, but that's sort of an easy win since browsers only natively support one scripting language. But even with that unique advantage, its ranking on the December index shows a .97% drop; minor of course, but not upward, while the leader has a bump of 1.32% - "Long live Java!" <g>.

There are many hundreds of programming languages, with new ones made every year. No one would be making them - or using them - if each didn't bring something unique to the table.

Out of all those many hundreds, LiveCode has been moving up, currently at #48 on the TIOBE Index, ahead of Prologue, Awk, VBScript, Clojure, Erlang, Red, and even WebAssembly and bash. It's former leading competitor, RealBASIC/Xojo, isn't on the list at all.

Modern programming is most commonly polyglot by nature. Each language offers what it specializes in, and none of them is best at everything. So we use the mix of languages and tools that best support the work we need to do. In my office I use LC for native apps, JS for web apps, and bash for system administration. Though Java is by far the world leader, I've never needed it, and I've had no reason to open a C compiler in many years.

Should the world stop using the hundreds of other language to adopt JS - or any single language - exclusively? Talk to many programmers and you'd get an earful of reasons why they'd prefer not to.

It's possible to find examples that show the benefits of any language over others. That's why each language was made. It's most useful to become at least familiar with many, and learn the ones that best support the work you need to do.

For making native apps, I haven't found a more productive solution than LC. Its breadth of platform coverage and exe packager are more satisfying than I find in most alternatives.

But then we have the language itself:

Most languages treat GUIs as an afterthought, if at all. But in LC GUI elements like buttons, fields, windows, etc. are an inherent part of the core language, integrated right alongside conditional expressions, arrays, etc. This allows a grace for delivering GUI designs that's hard to find elsewhere, radically shortening the distance between design and implementation.

And then there are chunk expressions. Much of programming involves parsing and concatenating text, where LC's chunk expressions shine. Rather than set up a series of loops with nested indexOfs to keep track of delimiters, the LC engine does that for you with statements as simple as:

Code: Select all

get character 2 of word 3 of line 4 of fld 1
How many lines of code would that be in JS, or just about anything else?

And then there's the language style itself. Some may complain because it's not like cookie-cutter languages that slavishly copy style from mindshare leaders, but that's not a bug, it's a feature. Its uncommon nature makes it uncommonly productive: it's readable enough to be almost self-documenting, and can be learned more quickly than just about anything else in its class. Indeed, it measurably requires a lower cognitive load to get from zero knowledge to competency than the most popular scripting languages, making it not only an invaluable choice for EDU, but also lowering maintenance costs for mature code bases in everything from commercial app production to enterprise tools.

LiveCode is far from perfect, as everything in our imperfect universe is. And there's a lot I'd like to see added, like having indexed arrays in LC Script as we have in LC Builder. But by and large it offers a unique mix of features that apparently well justifies its upward-moving place on the TIOBE Index.

Let a thousand flowers bloom. Use the mix of languages that works for you.

If we're going to have an advocacy flame war, I'd much rather we duke it out over the relative merits of Arch, Gentoo, and Ubuntu, like serious geeks do. :)

De gustibus non est disputandum.
Richard Gaskin
Community volunteer LiveCode Community Liaison

LiveCode development, training, and consulting services: Fourth World Systems: http://FourthWorld.com
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

dalkin
Posts: 101
Joined: Wed Jul 04, 2007 2:32 am
Location: Blackheath, Australia
Contact:

Re: Replace LiveCode Script with JavaScript, forever

Post by dalkin » Fri Jan 03, 2020 7:54 am

"The english language, use it to write code." The motive at the core of LC.

I look at other languages, including Java, as the place where dreams go to die. LC is a solid foundation in a stormy ocean of potential paths to development. I always get the feeling, when I reach out for help on the forums, that I'm amongst friends.
If you're skating on thin ice you might as well dance.

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7850
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Replace LiveCode Script with JavaScript, forever

Post by FourthWorld » Fri Jan 03, 2020 9:13 am

dalkin wrote:
Fri Jan 03, 2020 7:54 am
I look at other languages, including Java, as the place where dreams go to die. LC is a solid foundation in a stormy ocean of potential paths to development. I always get the feeling, when I reach out for help on the forums, that I'm amongst friends.
Indeed you are. Those first two sentences are so fun, you've got a beer waiting for you whenever you're passing through Los Angeles.
Richard Gaskin
Community volunteer LiveCode Community Liaison

LiveCode development, training, and consulting services: Fourth World Systems: http://FourthWorld.com
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

Post Reply

Return to “Feature Proposals”