RiscLua 7
GavinWraith (26) 1563 posts |
Lua version 5.4 is work in progress toward a faster interpreter. RiscLua 7 is based on Lua 5.4.0(w2). Unlike RiscLua 6, it is a statically linked standalone version, with the riscos and lpeg libraries built in. It has no facilities for dynamic linking of C libraries, and it uses 32-bit VFP arithmetic in hardware; so will not work on older platforms. It has only been tested on an Rpi3. I would be grateful to hear if it works on other platforms. Unlike RiscLua 6 the application !rlua7 does not put an icon on the iconbar. When filer_run it just sets up the Lua filetype and command. It also sets up the system variable LUA_INIT_5_4 so that format strings can be used as functions, making redundant the function string.format . Otherwise RiscLua 7 is syntactically the same as versions 5 and 6. Versions 6 and 7 of RiscLua use the GCC compiler, not Norcroft. Unfortunately this makes for larger binaries, but the gain is that floating point arithmetic is implemented in hardware. For version 6 the binaries were in ELF format. For version 7 they are in AIF format. Although it is a step back not having dynamic linking, I hope it will prove to be more accessible. Any feedback on benchmark comparisons with earlier versions would be gratefully appreciated. |
Fred Graute (114) 645 posts |
Thanks for the new version! The download link doesn’t work, the https: needs to be http:.
There does seem to be some difference though as AppLua works fine on RiscLua 5 and 6 but it fails on version 7 (segmentation fault; stack frame out of bounds). I’ll do some more digging later on. |
GavinWraith (26) 1563 posts |
Whoops. Sorry about that. It should indeed be http://www.wra1th.plus.com/zip/rlua7.zip Anyway, good luck with the digging. The one-dimensional version-numbering system should really be replaced by something more tree-like to indicate the wide variety of possibilities. I am curious to know how Applua is progressing :). |
nemo (145) 2529 posts |
“…doubles for reals”, otherwise it’s confusing. |
GavinWraith (26) 1563 posts |
Up until Lua 5.3 it was Lua’s policy to have simply numbers as a type, and to try to hide from the user, by means of coercions, all that confusing business of distinguishing between different sorts of number. But over the years pressure mounted to distinguish integers from the rest, at least internally, since some platforms, e.g. RISC OS, were not well suited to a policy which could be seen as condescending to the innumerate. At the same time bitwise operations on integers were provided. Who knows, in a few years Lua might have a stronger type system and give up its coercions. |
Rick Murray (539) 13806 posts |
I view dynamically typed variables as a gift from Cthulhu. Consider: “string” == TRUE … is true. Give me a language where types are clearly defined. It may require some extra typing, but at least casts are intentional, and not “what the programmer thinks should be happening”, which we all know, is not necessarily what the language agrees should be happening… |
Clive Semmens (2335) 3276 posts |
This, exactly. What a bl**dy pain it is. BBC BASIC is bad enough, but at least once you know how it works, it’s consistent. php probably is too, but I’m not at all sure I know how it works in all cases yet. No, that’s wrong. I’m damn sure I don’t. But surely the gift is not from Cthulhu, but from the Flying Spaghetti Monster? |
Rick Murray (539) 13806 posts |
And this is why I lay blame on Cthulhu. Dynamic typing is a cursed gift… This may help… Your brain explode. https://habnab.it/php-table.html |
Clive Semmens (2335) 3276 posts |
I suspect Cthulhu and the Flying Spaghetti Monster may be closely related…possibly even different manifestations of the same entity? Oops. Not Aldershot… I like that table. At least it has a sensible symmetry about the identity diagonal. I especially like the False on the identity line, reasonably enough for NAN != NAN. |
nemo (145) 2529 posts |
I like dynamic typing. <sulks> |
Clive Semmens (2335) 3276 posts |
Really? I had you down for one of the few really sensible, like-to-do-it-right ones – not a fuck-it-it-works, now-let’s-tackle-the-next-thing type. I like demonic touch typing, but that’s not quite the same thing as dynamic typing… |
GavinWraith (26) 1563 posts |
When ML hit the computing scene, with its strong polymorphic typing, it used to be claimed that its type-checking caught 90% of all known programming errors, leaving your program sparkling clean, just like some household product. Types are useful for injecting meaning into programs, but sometimes you need types that depend on values and for such systems type-checking tends to be uncomputable – difficult to check the type of an expression until the values it depends on have been evaluated. Dynamic typing is a fudge that gets round that, but you lose the advantages of knowing that your program is type-safe before it runs. In Haskell values have types, and types can have type-classes. For example you may want to distinguish those types for which equality is definable, and give rules so that when you have a type-constructor (a function from types to types), say foo, given a notion of equality for things of type x you automatically know what equality means for things of type foo(x). This can save a lot of wearisome programming. Functors, monads, anyone? |
nemo (145) 2529 posts |
Professional C programmer. Postscript guru. Javascript advocate. ARM specialist. Put that in whatever pigeonhole you feel appropriate.
Hmm. I prefer APIs to be concise and semantically designed, so polymorphism is GOOD. Static typing simply forces a horde of cut-and-paste interfaces (do this with this, do this with that, do this with one of those) or syntactic sugar to do the equivalent (templates). As for whether we build architectural marvels that will endure for centuries or hacked-together garden sheds that will be discarded in months… well it depends on the requirement, doesn’t it? The only people who can afford to be perfectionist with everything are hobbyists. And finally, Greenspun’s Tenth Rule does suggest that if you don’t have dynamic typing immediately available, you will end up implementing equivalent functionality. PS. It’s just occurred to me that dynamic typing is central to the way the Filer works… I wonder if anyone’s noticed? |
Glen Walker (2585) 469 posts |
I wish someone would tell my soon-to-be-ex supervisor that. I’m also tempted to get “Perfect is the enemy of good” printed on a t-shirt for when I start my next job…does that constitute getting off on the wrong foot I wonder—also do you require royalties? ;—)
Nope. But then I spent 10 minutes looking for my watch the other day until I realized I had it on my wrist. Back on topic though—what is Lua and why should I be using it on RISC OS and what for? (I know I could search for Lua on the Internet—and just did in fact—but was after a RISC OS user perspective, i.e., how does it add to/superseed/compliment C and BASIC for us?) |
Steffen Huber (91) 1949 posts |
The “right” balance between static and dynamic typing is difficult to find. Static typing will save your ass and get in your way. Dynamic typing will speed you up and ruin your architecture. If you are doing “everything right and in a professional, well-thought-out manner”, it does not matter (much) which tools you use. However, in the real world the perfect software developer does not exist, things will go wrong and you need to decide which tools you use to reduce the error rate. Static typing is one such tool. Sometimes, a capable IDE can help to avoid the pitfalls of your target language. Sometimes, capable analyzation tools can highlight pitfalls of your target language. It really depends. Personally, I always found that Ada (starting with Ada 95)hat the right balance between static typing to save your ass and enough expressive power to do what I wanted. Still, it sometimes got in my way. Sometimes, because what I wanted to do was “the wrong thing”. |
Clive Semmens (2335) 3276 posts |
I certainly wasn’t intending to imply perfectionism by suggesting you were a like-to-do-it-right type. Perfectionism isn’t doing it right, far from it. If I was a perfectionist, there wouldn’t be an ARM Assembler Guide yet, never mind any ARM ARM past V6.
See Steffen’s comment, which fleshes out what I didn’t write, admirably. |
GavinWraith (26) 1563 posts |
My cue for a spiel, I think! Welcome aboard, Glen. Back in the last century I ported awk, in fact several awks, to RISC OS and found it very useful. It could do very simply stuff that would have been a pain with BASIC or C. I also ported a little OOP language called Bob, with modifications for calling SWIs. I called the result ArmBob. It was a sort of modern BASIC with OOP extras; as easy to use as BASIC but more expressive. I do not think many people used it, but that did not stop me from looking for other languages to port to RISC OS. Excellent though BBC BASIC is among BASICs it lacks a long list of what are now considered essential features among scripting languages. My ambition was to provide something that could replace BASIC in most respects, and yet be more modern (automatic garbage collected memory management, lexical scoping, functions as first-class citizens, name-space control, coroutines, pattern-matching, a fast virtual machine, …). The chief difficulty I found was that open source software is written almost entirely for the Unix or Microsoft worlds. Porting such software for RISC OS was an impossible labour. Then I came across Lua, and that answered my prayers. Lua was designed to be portable to any platform with an ANSI C compiler. It was originally commissioned for Petrobras, the Brazilian state oil company, whose employees had heterogeneous computing equipment. That meant it was relatively easy to compile on RISC OS. It was also relatively easy to extend with SYS commands and to provide memory access operators reminiscent of BASIC (guess what So I push RiscLua whenever I can, and even wear a Lua T-shirt:). Over the years I have written heaps of articles, trying to answer just your question. Ask Rick Murray. He kindly published a piece by me in his Frobnicate magazine back in 2004. Others will doubtless give you a more objective assessment :). |
Rick Murray (539) 13806 posts |
The old Frobnicate part of my site was created by an automated tool that made horrific markup…1 The PDF version: http://www.heyrick.co.uk/frobnicate/download.php?file=frob22.pdf It’s on page 4, so you can skip the blurb and my intro rubbish and get straight to it. ;-) 1 Seriously, don’t read it… |
Steffen Huber (91) 1949 posts |
I immediately stumbled over the following inside the article:
It would be a first in IT technology if something like performance results could be agreed on! |
Glen Walker (2585) 469 posts |
Well I’m newish around these parts and hopefully not dwindling any time soon… From what you say and from the Frobnicate article I would say it is definitely worthy of some of my time—even if its just to play around and explore its capabilities! |
Stephan Kleinert (2271) 70 posts |
Gavin, you’ve done a really wonderful job bringing this language to RISC OS: I find it tremendously(!!!) useful… and I have done quite a number of little projects in RiscLua which would have taken me aeons to implement in BBC BASIC. There are a roguelike RPG, a card game, an artificial life simulator and a classic RPG waiting to get finished.. but the problem with me is (as is so often): Once I’ve done 90% of the code, I begin to lose interest, and nothing ever gets published; I write stuff for RISC OS on a purely recreational basis, to forget the dread that software development is nowadays (I’m a mobile software developer by trade). But that’s not a problem of RiscLua ;-) But what could be a problem of RiscLua is a certain lack of documentation and/or exhaustive libraries for Toolbox/Wimp programming. For me, learning RiscLua was mainly done by looking at example code, and sometimes I found myself wishing for more detailed/user-friendly documentation and/or libraries or even one or two tutorials which make the job a little easier. p.s: I fully understand the amount of time involved in improving those things… as you might remember, I once tried to write a object-oriented lua library for the toolbox, but that project was far too ambitious and eventually got bogged down… |
Glen Walker (2585) 469 posts |
Hmm…sounds like me with my fiction, programming, DIY, coffee….pretty much everything! I vote we call 90% the new 100% and be happy.
Sounds like you need the services of a good Technical Writer! Now…where is Clive when you need him…? (oh and I’m only pimping out other people because my time is already taken up 120%…or is that the new 100%). edit: eh? I don’t think I got enough sleep last night… |
nemo (145) 2529 posts |
Lua is widely used in the entertainment software industry. |
GavinWraith (26) 1563 posts |
I was just reporting on what I read at the time, 14 years ago. Since then LuaJIT came on the scene, which appears to be really fast. Unfortunately it looks doubtful whether there will ever be a RISC OS version. Also, it seems to have forked off from standard Lua, sticking with Lua 5.1. I note that Raspbian comes both with LuaJIT and more recent versions of Lua. I must flag up my gratitude to Lee Noar, because without his help I would never have managed using GCC to compile Lua how I wanted. Up till 2016 I just used Norcroft, which provided much more compact binaries. Continuing to use Norcroft would have meant being unable to exploit the arithmetic hardware now to be found in Arm CPUs. How I wish we could have an updated SharedCLibrary module that did not tie us to soft floats! A year or so ago I realized that most of my website, dating from 1995, was not checking out with the WWW validator so I cleaned much of it out, including lots of overlapping tutorial material about RiscLua, its use for scripting with StrongED, parser expression grammars, and sundry scraps of software. In view of the comments above perhaps I was too hasty; I will try to put back some reorganized tutorial material. It is a shame that Netscape lacks the CSS facilities necessary for pop-up hints in web-pages, because one can use those to hide explanations that are useful for the beginner but are tiresome distractions for the more advanced reader. Python and Lua have much in common, but where Python comes with batteries included Lua takes a minimalist approach. I have tried to follow the same principles with providing libraries for RiscLua. There are so many choices for designing RiscLua libraries for wimp programming, or for using the toolbox modules; I did not want to rush things or set anything in concrete. I am getting a bit old, and I should not be prescribing ways of doing things, but leaving some fun for others. There is masses to be done. Rick ascribes dynamic typing to Cthulhu. But I challenge him to dream up a datatype in C that cannot be expressed using tables in Lua, and furthermore in a way that makes no reference to particular addresses in memory . When C was born computer architecture was much simpler. It is pointer-arithmetic that I would ascribe to Cthulhu.
|
nemo (145) 2529 posts |
Python is a 20MB library with a small programming language attached.
“Dynamic typing is bad! I never use it! I shall write about it on this forum, and then do some Amazon shopping, and then pay my mobile phone bill, and then do some online banking, and then buy that thing off Ebay using PayPal…” |