Page 5 of 7

Re: Replace LiveCode Script with JavaScript, forever

Posted: Tue Jul 14, 2020 8:18 am
by Thierry
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

Re: Replace LiveCode Script with JavaScript, forever

Posted: Tue Jul 14, 2020 4:23 pm
by mwieder
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.

Re: Replace LiveCode Script with JavaScript, forever

Posted: Tue Jul 14, 2020 9:38 pm
by richmond62
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".

Re: Replace LiveCode Script with JavaScript, forever

Posted: Tue Jul 14, 2020 11:20 pm
by mwieder
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.

Re: Replace LiveCode Script with JavaScript, forever

Posted: Wed Jul 29, 2020 9:52 am
by stam
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...

Re: Replace LiveCode Script with JavaScript, forever

Posted: Wed Jul 29, 2020 5:49 pm
by aetaylorBUSBnWt
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.

Re: Replace LiveCode Script with JavaScript, forever

Posted: Wed Jul 29, 2020 7:13 pm
by FourthWorld
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

Re: Replace LiveCode Script with JavaScript, forever

Posted: Fri Aug 07, 2020 11:45 pm
by FourthWorld
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

Re: Replace LiveCode Script with JavaScript, forever

Posted: Mon Aug 10, 2020 6:07 pm
by saw
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!)

Re: Replace LiveCode Script with JavaScript, forever

Posted: Mon Aug 10, 2020 6:24 pm
by SparkOut
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.

Re: Replace LiveCode Script with JavaScript, forever

Posted: Mon Aug 10, 2020 8:44 pm
by bogs
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:

Re: Replace LiveCode Script with JavaScript, forever

Posted: Mon Aug 10, 2020 10:38 pm
by SparkOut
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.

Re: Replace LiveCode Script with JavaScript, forever

Posted: Tue Aug 11, 2020 7:46 am
by richmond62
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)

Re: Replace LiveCode Script with JavaScript, forever

Posted: Tue Aug 11, 2020 8:14 am
by FourthWorld

Re: Replace LiveCode Script with JavaScript, forever

Posted: Tue Aug 11, 2020 9:44 am
by richmond62
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.