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

Thierry
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 791
Joined: Wed Nov 22, 2006 3:42 pm
Location: France
Contact:

Re: Replace LiveCode Script with JavaScript, forever

Post by Thierry » Tue Jul 14, 2020 8:18 am

Python is most usable in contexts where it's called from other apps.
From Python's docs:
What platform-independent GUI toolkits exist for Python?
https://docs.python.org/3/faq/gui.html#id4


And some code in Python with a Mac GUI:

Code: Select all

#!/usr/bin/env pythonw

# HelloWorld.py
# The original PyObjC interface example by Steve Majewski.

from Cocoa import NSObject, NSApplication, NSApp, NSWindow, NSButton, NSSound
from PyObjCTools import AppHelper

class AppDelegate(NSObject):
    def applicationDidFinishLaunching_(self, aNotification):
        print("Hello, World!")

    def sayHello_(self, sender):
        print("Hello again, World!")

def main():
    app = NSApplication.sharedApplication()

    # we must keep a reference to the delegate object ourselves,
    # NSApp.setDelegate_() doesn't retain it. A local variable is
    # enough here.
    delegate = AppDelegate.alloc().init()
    NSApp().setDelegate_(delegate)

    win = NSWindow.alloc()
    frame = ((200.0, 300.0), (250.0, 100.0))
    win.initWithContentRect_styleMask_backing_defer_(frame, 15, 2, 0)
    win.setTitle_("HelloWorld")
    win.setLevel_(3)  # floating window

    hel = NSButton.alloc().initWithFrame_(((10.0, 10.0), (80.0, 80.0)))
    win.contentView().addSubview_(hel)
    hel.setBezelStyle_(4)
    hel.setTitle_("Hello!")
    hel.setTarget_(app.delegate())
    hel.setAction_("sayHello:")

    beep = NSSound.alloc()
    beep.initWithContentsOfFile_byReference_("/System/Library/Sounds/Tink.Aiff", 1)
    hel.setSound_(beep)

    bye = NSButton.alloc().initWithFrame_(((100.0, 10.0), (80.0, 80.0)))
    win.contentView().addSubview_(bye)
    bye.setBezelStyle_(4)
    bye.setTarget_(app)
    bye.setAction_("stop:")
    bye.setEnabled_(1)
    bye.setTitle_("Goodbye!")

    adios = NSSound.alloc()
    adios.initWithContentsOfFile_byReference_("/System/Library/Sounds/Basso.aiff", 1)
    bye.setSound_(adios)

    win.display()
    win.orderFrontRegardless()  # but this one does

    AppHelper.runEventLoop()

if __name__ == "__main__":
    main()
Kind regards,

Thierry
Regex LiveCode sunnYrex
https://sunny-tdz.com

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3130
Joined: Mon Jan 22, 2007 7:36 am
Location: Berkeley, CA, US
Contact:

Re: Replace LiveCode Script with JavaScript, forever

Post by mwieder » Tue Jul 14, 2020 4:23 pm

So, WTFF (Why The Flying Fantoushies) is is being adopted faster than you can say 'LiveCode' in
educational establishments everywhere while LiveCode is NOT?
We used python as a backend processor for crunching lots of data quickly, handing it off to an Angular frontend for web display.
Python has the best numeric and scientific libraries of any language out there.
And it's easy to hire python programmers to work on the system.
LiveCode is basically a dead-end street if you're looking to build up hireable skills.

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

Re: Replace LiveCode Script with JavaScript, forever

Post by richmond62 » Tue Jul 14, 2020 9:38 pm

LiveCode is basically a dead-end street if you're looking to build up hireable skills.
Then it's a good thing I make my main income "elsewhere".

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3130
Joined: Mon Jan 22, 2007 7:36 am
Location: Berkeley, CA, US
Contact:

Re: Replace LiveCode Script with JavaScript, forever

Post by mwieder » Tue Jul 14, 2020 11:20 pm

Not necessarily... I mean, yes, it's a good thing... er...

You're basically a one-person operation, and LiveCode is ideal for that. I love the environment and I'm very productive with it, or I wouldn't still be here after 15-odd years. But beyond one-person shops, there are few folks who have heard of LiveCode, fewer who have development structures that LiveCode fits into, and fewer still who are looking for developers with LC skills. I long ago learned to take it off my resume so that I didn't have to spend time in interviews trying to explain what it is.

stam
Posts: 122
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Re: Replace LiveCode Script with JavaScript, forever

Post by stam » Wed Jul 29, 2020 9:52 am

mwieder wrote:
Tue Jul 14, 2020 11:20 pm
... so that I didn't have to spend time in interviews trying to explain what it is.
Yeh, not only liveCode... my main work is not within IT, but I have to contend with a huge corporate IT organisation with a strict top-down hierarchy. This huge IT organisation drinks the Microsoft koolaid like there is no tomorrow.

Anything that is not within Microsoft sphere or web development sphere is an unknown, and anything that originated on Mac is not only unknown but also vilified.

Even products like FileMaker Pro which are relatively well known in many circles, where skills can be sellable, are unknown. I can’t tell you how many hundreds of hours and resources I’ve wasted trying to get a sensible FileMaker solution established in the workplace and in then have had to work around IT with lesser stand-alone solutions because they didn’t understand what Server could do.

In an IT environment like that there is just no way to even mention things like liveCode.

I live an uneasy truce with them and have relative latitude to do what I want within very strict limits, and it’s here products like LiveCode (and other related 1-man environments) are truly helpful.
However I would shudder in even mentioning liveCode, let alone trying to explain what it is...

aetaylorBUSBnWt
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 51
Joined: Thu Sep 20, 2012 5:11 pm

Re: Replace LiveCode Script with JavaScript, forever

Post by aetaylorBUSBnWt » Wed Jul 29, 2020 5:49 pm

Hi,

Just curious, has anybody attempted to rewrite the LC code that was posted into something more efficient?

I am just starting back up with LC, so the task is beyond me for the moment, but it would seem that showing that LiveCode can do better than what was posted is the best response to the posting.

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

Re: Replace LiveCode Script with JavaScript, forever

Post by FourthWorld » Wed Jul 29, 2020 7:13 pm

aetaylorBUSBnWt wrote:
Wed Jul 29, 2020 5:49 pm
Just curious, has anybody attempted to rewrite the LC code that was posted into something more efficient?
Quite often. This is my favorite example, where the original code in the opening post took about 9 minutes to complete, and several pages of optimizations brought that time down more and more until the last page when it took only a few milliseconds, with the discussion encompassing a variety of good techniques and some useful language/version history:

https://forums.livecode.com/viewtopic.php?f=8&t=24945
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/

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

Re: Replace LiveCode Script with JavaScript, forever

Post by FourthWorld » Fri Aug 07, 2020 11:45 pm

As long as we're talking about fashion fixation in programming, hemlines are changing again as functional programming comes back into vogue:

https://towardsdatascience.com/why-deve ... a3d3bcb7d2
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/

saw
Posts: 5
Joined: Fri Jul 31, 2020 10:30 am

Re: Replace LiveCode Script with JavaScript, forever

Post by saw » Mon Aug 10, 2020 6:07 pm

capellan wrote:
Tue Jan 07, 2020 2:53 pm
If I understand correctly, the OP just wants to use JavaScript libraries along with LCS.
How could this be possible? Maybe, Compiling a JavaScript Engine as a LC external?

Al
Something like duktape[dot]org?

I've seen it used by a couple of Filemaker plugins.

(First post so I can't add urls!)

SparkOut
Posts: 2297
Joined: Sun Sep 23, 2007 4:58 pm

Re: Replace LiveCode Script with JavaScript, forever

Post by SparkOut » Mon Aug 10, 2020 6:24 pm

If I understand correctly, the OP is a possible wannabe spam-planting, one-post troll with no constructive reason to have posted at all. Certainly not interested in engaging in a discussion regarding the merit or drawback of LCS versus Javascript.
However, the rest have made a 5 page discussion around the original subject, and are prepared to engage.

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

Re: Replace LiveCode Script with JavaScript, forever

Post by bogs » Mon Aug 10, 2020 8:44 pm

SparkOut wrote:
Mon Aug 10, 2020 6:24 pm
However, the rest have made a 5 page discussion around the original subject, and are prepared to engage.
Guilty as charged, however, since there is already a language devoted and about Js, I still have to say I don't see any point to turning another language into it :P :P :P

<I do wonder if we can hit 10 pages though...> :twisted:
Image

SparkOut
Posts: 2297
Joined: Sun Sep 23, 2007 4:58 pm

Re: Replace LiveCode Script with JavaScript, forever

Post by SparkOut » Mon Aug 10, 2020 10:38 pm

There's no charge on the rap sheet that I know of. Nothing to plead guilty to. No constructive point in the OP's original post, but always welcome to have a reasoned discourse, even if the outcome is pretty clearly one-sided.

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

Re: Replace LiveCode Script with JavaScript, forever

Post by richmond62 » Tue Aug 11, 2020 7:46 am

No constructive point in the OP's original post
Recently the forums seem to be getting more and more of these rather nebulous questions posted by bots,
people who've got nothing better to do, or people who cannot work out what these forums are for . . .

Having stated that . . .

I do think a bit more documentation about how one might connect "something" written in LiveCode
with "something" written in another programming language might not be a bad thing.
Hybrid programming might prove quite useful under certain circumstances; and while that
probably sounds like rediscovering the wheel, a way to make a 'wheel' using LiveCode that was well
documented would be a good thing.
<I do wonder if we can hit 10 pages though...>
Quite possibly . . . 8)

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

Re: Replace LiveCode Script with JavaScript, forever

Post by FourthWorld » Tue Aug 11, 2020 8:14 am

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/

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

Re: Replace LiveCode Script with JavaScript, forever

Post by richmond62 » Tue Aug 11, 2020 9:44 am

FourthWorld wrote:
Tue Aug 11, 2020 8:14 am
Here's a good starting point:
https://livecode.com/resources/api/#liv ... ript/shell
Program that accepts operating-system commands. The program a user uses to interact with the operating system, move files around, lauch(sic) applications, and so on.
Well; that is not what I meant.

What I meant is, for the sake of argument, to program a front-end in LiveCode and some of the
"heavy lifting round the back" in another language and be able to "spit out" a standalone application at the end of the work.

Post Reply

Return to “Feature Proposals”