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: 768
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: 3037
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: 4680
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: 3037
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: 45
Joined: Sun Jun 04, 2006 9:39 pm

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: 14
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: 7804
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/

Post Reply

Return to “Feature Proposals”