C WIMP Tutorial?
Steve Drain (222) 1620 posts |
I am extremely impressed by the AppBasic documentation and I wish I had the time and skill to do something like it for the Basalt Toolbox apspects, which ought to be easier to use. It takes very few steps to produce more compact and much faster applications than the BASIC library method of AppBasic, but I might still recommend the latter to a beginner with no experience of the Toolbox to start with.
That is something I have had in mind for many years and I did produce a working system based on Java, but it was so complicated and slow that I never pursued it. I have attempted a ittle along that line with the Basalt LOCAL variable lists. These can be declared for just a single routine or for a library as a whole, and they can be more flexible. The next step might be local routine names. |
nemo (145) 2529 posts |
It’s difficult to get very far without promoting PROC/FNs (and code blocks!) to first class objects. Once you have that in a language, extremely cool stuff follows (especially with the kind of automatic scope capture you get in JavaScript, for example) – closures, lambdas, anonymous functions. One can get close with my OOBasic syntax: DEFFNclosure(val):LOCALclass% class%={ .val=val DEFFNresult(a)=a*.val } =class% >z=FNclosure(12) >PRINTz.result(10) 120 But that’s nothing like as neat as JavaScript: function closure(val) { return function (a) {return a*val} } var z = closure(12) ; console.log(z(10)) ; JS is much cleverer here, and if you don’t understand the language, it can look like magic – where is ‘val’ kept?! |
GavinWraith (26) 1563 posts |
. . . or RiscLua:
Having functions as first class objects makes a language vastly more expressive, so long as it is coupled with lexical scoping. I must confess to a certain amount of irritation with the syntax
instead of
because they think C programmers will be shocked at nameless functions. In Lua you can use the notation
but it is only syntactic sugar for the assignment statement
If you have got the advantage of nameless functions then flaunt it, instead of mimicking the notations of more restricted first-order languages, is what I say. |
nemo (145) 2529 posts |
I wish I got a £1 for each of these ;-) I must confess to a certain amount of irritation with the syntax Both of those are valid JavaScript syntax (though they have subtly different hoisting behaviour, as any fule kno). ES6 is also adding ‘fat arrow’ syntax, which I can’t say I’m fond of because it’s so limited: f = a => a*v ; OK I relent. The first is a function declaration, the second a function expression. However, either way you end up with the executable object f – a function. The difference between the two will catch out people who think JS works like any other language though. Rather than describe the difference here, I will direct interested readers to look up “function hoisting”. |
nemo (145) 2529 posts |
And of course you can do this, which is a bit strange: var f = function g() {...} What’s ‘g’? :-) |
GavinWraith (26) 1563 posts |
I do not want to ignite any flame wars but I do find it easier to understand what a Lua program means (and what it does when it runs) than a Javascript one. I acknowledge that Lua is used far less than Javascript, but when it comes to learning to program I think Lua is a much better bet. |
nemo (145) 2529 posts |
Horses for courses. Lua is widely used in the games industry for scripting. I slightly prefer JavaScript for its ubiquity. However, neither is my favourite interpreted language! (Uijt!jt"!){(?)dup 0 4 3 roll 1 sub put print}forall |
Steve Drain (222) 1620 posts |
Just a postscript to that: A←1 2 3 4 5 6 7 8 9 Which is one hell of a programming language. I only dabbled, I did not inhale. ;-) |