digitalFAQ.com Forums [Archives]

digitalFAQ.com Forums [Archives] (http://www.digitalfaq.com/archives/)
-   Avisynth Scripting (http://www.digitalfaq.com/archives/avisynth/)
-   -   Programming: Lua Extensible Scripting Language (http://www.digitalfaq.com/archives/avisynth/2658-programming-lua-extensible.html)

kwag 02-17-2003 01:30 AM

Lua Extensible Scripting Language
 
A wonderful scripting language from Brasil :D
A couple of years ago, I wrote an E-Mail parser to SMS (Short Message Cellular Systems) program with this scripting language. It's probably one of the fastest interpreters around. It blows away Perl, Python, Rebol, etc. So anyone interested in scripting, even embedding in Apache web servers as I believe there is now a MOD_LUA available, take a look here: www.lua.org
There are also GTK bindings and even some commercial games have been written with this. It runs on just about every platform :wink:

Here's some of the stuff available: http://lua-users.org/wiki/LuaAddons

-kwag

SansGrip 02-25-2003 05:26 PM

You'll have to rip perl out of my cold, dead fingers :P :mrgreen:.

kwag 02-25-2003 05:38 PM

Perl 8O "The language that includes the kitchen sink" :mrgreen:
I never did get in too deep into Perl. It seems like the syntax is so terse, that if I came back to some of my own code a month later, I would probably need to decipher it :lol:
It's weird, because C is just as bad, but I guess it just rubbs in after using it for a long time. I must be brain damaged now, because I see some simpler languages around, and I can't seem to grasp some of the rules 8O. So I guess I'll stick to C ( when necessary ) and Python for everything else 8)

-kwag

SansGrip 02-26-2003 04:53 PM

Quote:

Originally Posted by kwag
It seems like the syntax is so terse, that if I came back to some of my own code a month later, I would probably need to decipher it :lol:

That is the main problem with Perl. Because it's so idiomatic it does encourage clever shortcuts that don't seem so clever when you're trying to work out what your code does six months later. Another way of saying it is that it looks somewhat like line noise ;). But then, what other language can do something like this in one line:

Code:

print "'" . $_ . "' is a low-fat sausage.\n" foreach sort grep { /(lite|light)/ } @all_sausages;
That's either a good thing or a bad thing depending on your perspective :mrgreen:.

rendalunit 02-26-2003 05:01 PM

Quote:

Originally Posted by SansGrip
That's either a good thing or a bad thing depending on your perspective

i don't know what that line was intended to do but it made me hungry- I'm gonna go make a sausage sandwich :lol:

SansGrip 02-26-2003 05:22 PM

:mrgreen:

kwag 02-26-2003 05:37 PM

Quote:

Originally Posted by SansGrip
But then, what other language can do something like this in one line:

Code:

print "'" . $_ . "' is a low-fat sausage.\n" foreach sort grep { $_ =~ /(lite|light)/ } @all_sausages;
That's either a good thing or a bad thing depending on your perspective :mrgreen:.

Python :wink:

Code:

sausages=["lite", "light"]; sausages.sort()
for x in sausages:
  print x, "is a low-fat sausage"

and faster too :wink:

-kwag

SansGrip 02-26-2003 05:59 PM

[quote="kwag"]
Code:

sausages=["lite", "light"]; sausages.sort()
for x in sausages:
  print x, "is a low-fat sausage"

This isn't quite the same. Given a list of sausages such as:

my @all_sausages = (
"Bob's High-Fat Meat Tubes",
"Sausage-tastic",
"Sausage-tastic Lite",
"Cholesterol Delights"
);

that Perl code will first search the list for all entries matching the regular expression /(lite|light)/ and produce the following temporary list:

("Sausage-tastic Lite", "Cholesterol Delights")

It'll then sort the list and print the message for each entry in that new list.

Try that in one line with Python ;).

As for any speed difference, I've not seen any benchmarks of Perl vs. Python. The latter is a nice language (e.g. object-oriented by design) but I'd miss Perl's seamless handling of regexes if I were forced to swap :).

kwag 02-26-2003 07:46 PM

Now you see, I got hungry and had to go get something to eat :mrgreen:
Ok, I didn't pay attencion to the RegEx matching part /(lite|light)/.
It's very similar in python, but a little more readable in Python. I guess RegEx is not too readable, no matter what language it's used on :lol:
Anyway, here's a one liner, which is not mine. I got it off Python's site, related to what can actually be accomplished in one line. Copy and paste to a file, run it on a U*ix console and look at the output :wink:

Code:

# Mandelbrot set
        print (lambda Ru,Ro,Iu,Io,IM,Sx,Sy:reduce(lambda x,y:x+y,map(lambda y,
        Iu=Iu,Io=Io,Ru=Ru,Ro=Ro,Sy=Sy,L=lambda yc,Iu=Iu,Io=Io,Ru=Ru,Ro=Ro,i=IM,
        Sx=Sx,Sy=Sy:reduce(lambda x,y:x+y,map(lambda x,xc=Ru,yc=yc,Ru=Ru,Ro=Ro,
        i=i,Sx=Sx,F=lambda xc,yc,x,y,k,f=lambda xc,yc,x,y,k,f:(k<=0)or (x*x+y*y
        >=4.0) or 1+f(xc,yc,x*x-y*y+xc,2.0*x*y+yc,k-1,f):f(xc,yc,x,y,k,f):chr(
        64+F(Ru+x*(Ro-Ru)/Sx,yc,0,0,i)),range(Sx))):L(Iu+y*(Io-Iu)/Sy),range(Sy
        ))))(-2.1, 0.7, -1.2, 1.2, 30, 80, 24)

Yes, it is one line, and it does run 8O

If you really love Perl, then I think you'll fall in love with Ruby :wink:
http://www.ruby-lang.org/en/
I've been reading about it lately.

-kwag

SansGrip 02-27-2003 08:22 AM

Quote:

Originally Posted by kwag
Code:

# Mandelbrot set
        print (lambda Ru,Ro,Iu,Io,IM,Sx,Sy:reduce(lambda x,y:x+y,map(lambda y,
        Iu=Iu,Io=Io,Ru=Ru,Ro=Ro,Sy=Sy,L=lambda yc,Iu=Iu,Io=Io,Ru=Ru,Ro=Ro,i=IM,
        Sx=Sx,Sy=Sy:reduce(lambda x,y:x+y,map(lambda x,xc=Ru,yc=yc,Ru=Ru,Ro=Ro,
        i=i,Sx=Sx,F=lambda xc,yc,x,y,k,f=lambda xc,yc,x,y,k,f:(k<=0)or (x*x+y*y
        >=4.0) or 1+f(xc,yc,x*x-y*y+xc,2.0*x*y+yc,k-1,f):f(xc,yc,x,y,k,f):chr(
        64+F(Ru+x*(Ro-Ru)/Sx,yc,0,0,i)),range(Sx))):L(Iu+y*(Io-Iu)/Sy),range(Sy
        ))))(-2.1, 0.7, -1.2, 1.2, 30, 80, 24)


Just goes to show you can write unreadable code in any language if you're really determined ;).

Quote:

If you really love Perl, then I think you'll fall in love with Ruby :wink:
I've never looked at Ruby. One day when my todo list clears a little I'll get a book on it :).

GFR 02-27-2003 12:11 PM

Have you ever seen the "most obfuscated C code contest" page ?

:)

kwag 02-27-2003 12:34 PM

Quote:

Originally Posted by GFR
Have you ever seen the "most obfuscated C code contest" page ?

:)

Oh yeah, it's a real brain twister :lol:
But if you want to see the most pathetic one in the world, you have to see this:

Code:

022p25*":ereh drow ruoy retnE">,# :# _>~:25*-#v_v>22g1+:98+-#v_v
                                      ^p3g22              p22<
  0                                          >  ^
***************** v                            <              <
    0            >22g1+22p>22g1-:22p#v_25*,@
    0
                          ^              p 3g55"*",<
                                      v                <
                                        >:55p3g:"*"-#^_^

                                      v ^  <
                              >94+  #    ^
                              v      <    ^
                              #  >5*    > ^
                                  2      6 ^
                              v?vv?v# ?#v?7^
                              999999  # 58 ^
                              76532  >1  ^
                              +++++  v?v  ^
                                    234  ^
                              >>>>>>>>>>>>>^

SICK :mgreen: SICK :mrgreen:, but it's actually a programming language 8O : Sample here: http://www.catseye.mb.ca/esoteric/be...src/anagram.bf
Page here: http://www.catseye.mb.ca/esoteric/befunge/

The designer of this "thing" must have been smoking weed ( one in each nostril ), and an opium pipe up his :!:

Hey SansGrip, how about a new pixel anti "moire" pattern filter with this. :mrgreen:

-kwag

muaddib 02-27-2003 12:48 PM

Oh man... I just can't believe it!
No way it's a programming language. 8O
Please, tell me that's just a bunch of garbage/noise!!

I have to look that link...
But I think I'll not be convinced anyway :mrgreen:

rendalunit 02-27-2003 12:58 PM

look at this program :lol:
Code:

92+9*                          :. v  <
>v"bottles of beer on the wall"+910<
,:
^_ $                            :.v
            >v"bottles of beer"+910<
            ,:
            ^_ $                    v
>v"Take one down, pass it around"+910<
,:
^_ $                          1-v
                                :
        >v"bottles of beer"+910.:_          v
        ,:
        ^_ $                          ^
                    >v" no more beer..."+910<
                    ,:
                    ^_ $$ @

and my favorite quote:
"Maybe the language isn't that useful, but it's nifty and fun."
-- Matthew Moss

kwag 02-27-2003 01:44 PM

Quote:

Originally Posted by rendalunit
look at this program :lol:
Code:

92+9*                          :. v  <
>v"bottles of beer on the wall"+910<
,:
^_ $                            :.v
            >v"bottles of beer"+910<
            ,:
            ^_ $                    v
>v"Take one down, pass it around"+910<
,:
^_ $                          1-v
                                :
        >v"bottles of beer"+910.:_          v
        ,:
        ^_ $                          ^
                    >v" no more beer..."+910<
                    ,:
                    ^_ $$ @

and my favorite quote:
"Maybe the language isn't that useful, but it's nifty and fun."
-- Matthew Moss

8O Nifty and fun "My A* :mrgreen:

I might as well use an abacus :lol:

-kwag

kwag 02-27-2003 01:52 PM

LMAOROTF :mrgreen:
Some people are sick :mrgreen: look at this one: http://www.winterbergs.de/software/zte.htm
And with a quote like this: "The ZT programming language is quite romantic" HAHAHA

-kwag


All times are GMT -5. The time now is 07:17 AM  —  vBulletin © Jelsoft Enterprises Ltd

Site design, images and content © 2002-2024 The Digital FAQ, www.digitalFAQ.com
Forum Software by vBulletin · Copyright © 2024 Jelsoft Enterprises Ltd.