Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - Astrobe

#1
newLISP newS / Re: Ask info about newLISP
January 30, 2019, 09:52:02 AM
Quote from: "TedWalther"One thing on the TODO list: non-blocking sockets, which would allow internet services to be more reliable and avoid a race condition when doing things the traditional way using net-select/accept on sockets that are bound and listening for incoming connections.  Haven't had time to do it myself.


One could sneak a "non blocking mode" flag in the mode string of net-listen?



Funny thing is that my own stuff broke recently on Windows because I updated MinGW, and apparently non-blocking mode is one of the things that broke. I gave up for the time being, so that's why I'm back to Newlisp.



Aside from that if the TODO list is empty, we could ignore that Lutz's own todo list is certainly not (for newlisp or other stuff) and start to talk about v11 and its compatibility-breaking changes...
#2
Anything else we might add? / Re: Newlisp vs Lua
September 13, 2017, 02:26:01 AM
Actually to me co-routines are not a major feature in Lua. One problem is that a procedure which is not "co-routine aware" cannot be turned in to a "co-routine aware" one. If someone provides a GUI library without a single-step gui.run() function (silly example), you are screwed. So if you have a long-running "task" (GUI, servers, heavy number crunching,...) you have to plan ahead. If you look at the https://www.lua.org/pil/9.html">examples in PIL, doing that requires significant rethinking anyway. For instance, going from the "blunt" permutation generator to the coroutine-aware is not trivial. It seems to me that turning it into a context function would require the same work in Newlisp (and the syntactic equivalence of lists and lambdas in Newlisp could probably allow us to apply a dolist to it).



Since you know Forth, someone on comp.lang.forth a long time ago quoted this definition:

: CO >R >R 2>R ;

It swaps the top elements of the return stack. Since it is a regular definition, when it returns, it returns to the caller-of-the-caller. And when the caller-of-the-call returns, it returns to the call site of CO. I actually never used that myself because it hurts my brain.

A variation is to fetch the return address from the return stack and then execute that - in other words call the return address (this is totally not standard). I think it has some similarities with call/cc.

Of course, Forth is the massive two-stacks cheater it usually is here.


Quote
What Lua got right, and Tcl and Guile also are attempting, is that an application can make itself "programmable" using a standard language. This way, skills can transfer between applications. I'd like newLisp to be able to enter that space. Also, implementing coroutines would be a fun little exercise, wouldn't require any "wierd" C at all.


I don't think Lua is "more right" here. It began as a configuration language and naturally evolved into an embeddable scripting language, while others including Newlisp began as a scripting "glue" language. Lua may be better if you want to add scripting to an existing app, but if you start with that idea, both approaches seem equally viable to me. But there are significant differences.



Emacs is an interesting case in this regard. Elisp is specific to Emacs so there's no skill transfer between applications, but the cooperation between applications written in Elisp (org-mode, erc, magit,...) is more than remarkable. Emacs is not an OS for sure, but it is now a full blown application platform. To the point that one could compare it to something like Pharo Smalltalk.
#3
Anything else we might add? / Newlisp vs Lua
September 12, 2017, 12:41:31 AM
Let's Rock'n'Troll!



I've lurked on comp.lang.forth for a long time. One thing I couldn't understand is why people constantly compared Forth with C, which was pointless in my eyes because they where in whole different categories.

It became even more pointless when Lua began to gain traction, because as a lightweight interpreted language, it was a serious contender. That's even more true for Newlisp.



+ Lua and Newlisp are about the same binary size, but Newlisp packs a lot more functionality out of the box

+ Newlisp doesn't rely on garbage collection (but the pass-by-value semantics that ORO requires are sometimes difficult to deal with)

+ Newlisp has macros

+ Newlisp's documentation is better

+ Newlisp is a simpler language, so I believe that parsing speed is better than Lua.

- Lua is faster, even without JIT

- Lua has better debugging support

- Lua has coroutines (Newlisp has IPC but it's heavier and not 100% multi-platform)

- Lua has much more mind share (nothing you can do about it, except make Newlisp better)



All points are not equally important. Lacking lightweight threads isn't a big deal as long as one has non-blocking I/O. Debugging support is important because bug squashing can kill productivity - especially for late-bound dynamic languages in which a simple typo can result in a bug (that's why most such languages have a so-called "strict mode"). Being slow can be acceptable to some extend, as long as interfacing with C (or eventually with external programs but that's really a last resort) is easy.
#4
Anything else we might add? / Re: FOOP destructors?
March 19, 2017, 06:52:35 AM
FOOP. The F should be a P. Every time I try to use it for something more object-y than glorified structures, it falls flat on its face (and even as glorified structures, it's not really convenient out-of-the-box).



I'd rather use contexts for prototype-based objects.



Kind of what the /dev/urandom example actually is.



But of course, the concept of destructor doesn't make sense in this case, because the "object" lives forever. Unless... You wipe it with delete?

The only point of doing that would be to reuse the symbol (eg that object is caught in a loop). So maybe having delete to call the local definition of delete in the context being deleted (if present; otherwise do the usual thing) would make sense. Conversely new could do the same thing (aka call what would be the copy constructor).



But all this can be defined in NewLisp itself, I think. Just call them "clone" and "destroy" instead of "new" and "delete").
#5
I quite agree that Java is becoming less relevant these  days. But I disagree that the way to go is the browser. Just like Java, Javascript is cool because it's "already there" and "cross-platform", but it's still poor at making interactive apps. The CSS/HTML/Javascript was never meant to build desktop-like interactive UIs. Browser makers are trying really hard to shoe-horn this capability in the existing technology stack, but it takes a ridiculously huge amount of resources. Case in point: on tablets and mobiles, vendors prefer to offer "apps" (which, if I'm not mistaken are mainly coded in Java, ironically).



Plus, using Ajax would certainly mean code generation, which is not cool for debugging (and which is IMO already a weak point of Newlisp).



A good cross-platform GUI library seems way better to me. UIP looks interesting even though some details look a bit retarded (like passing sizes and coordinates as strings). That's why I asked for bindings a some weeks ago. I should try to find some time to make those bindings and see how it works.
#6
Maybe the OP was talking about the name of the files rather than the content?
#7
newLISP in the real world / IUP bindings
September 24, 2014, 01:02:09 AM
Hello,



Doe anyone have bindings for the IUP library?
#8
To me, the major split is between Windows and Linux platforms. That's also true for sockets. You have no choice but to write platform specific code and to hide the differences behind the a common API.

As for DSR/DTR, RS is such a mess that one can always stumble upon some hardware that do use that. For instance control lines can be used for "reversing" the line driver in the case of an RS485 bus. But I think the few guys that may be interested in this should be savvy enough to fill in the missing parts and would be happy to find a module that already does most of the job - provided it is well written etc.
#9
Anything else we might add? / Re: flat enough?
June 26, 2014, 03:19:47 PM
That's because '(1 2) is a quoted expression, not a list:


(list? (nth 0 '('(1 2) (3 4)))) ; --> nil (id est, false)
(quote? (nth 0 '('(1 2) (3 4)))) ; --> true
#10
int returnneg(void) is a valid prototype.It's actually "more correct" than int returnneg(): the former tells that the function takes no arguments, while the latter can take any number of arguments.



source: http://www.drdobbs.com/c-and-c-case-studies-in-compatibility/184401562">http://www.drdobbs.com/c-and-c-case-stu ... /184401562">http://www.drdobbs.com/c-and-c-case-studies-in-compatibility/184401562
#11
I work with the manual essentially, plus the "code patterns" file. Both of them give a lot of recipes.



One thing to note about NewLisp is that its built-in functions library is very rich. And many of these functions can be used in more than one way thanks to the clever use of default parameters. As a result the manual is quite dense in the sense that it contains a lot of information. I would advice to read it start-to-end once in order to have an idea of what Newlisp can do out-of-the-box. This will certainly raise questions like "can I do this with that?"; it is a great occasion to fire up the interpreter and experiment. For instance you might notice that Newlisp doesn't have the familiar "struct" construct, so you might experiment ways to recreate similar functionality (perhaps with regular definitions, macros, letex or using the built-in OO support features). You'll probably end up building your own tool belt file in order to tailor Newlisp to your needs and programming style (maybe you'll love the "higher order functions" like map and fold).



Newlisp is quite nice. I myself work with C/C++ mainly, but have also explored other languages like Chicken Scheme, Pharo/Squeak, Forth, or Lua, but it's my go-to language when I have to make an utility program. It does have its weaknesses and pitfalls, but it's worth a good try.
#12
Maybe that work could be reused for a different thing.



I didn't really run into the issue as of yet, but a potential memory management problem may happen with external libraries that return allocated object, and you are responsible for freeing them. It seems there exist no way to "link" with Newlisp's memory management. That is, get the signal that a variable goes out of scope, so what it refers to should be deleted.



Maybe your work could find some reuse there.



If I run into that issue I would probably use some RAII and/or an idiom I saw once in some Lisp source:



(with-window (W 100 200) ; where 100 200 are dimensions of the window for instance
  (:show W))


In this example, one assumes that some GUI library provides a window creation primitive that return a pointer to a malloc'ed window object that must be freed when finished. The with-window calls this primitive, executes its body, and finally free the window object.



This protects from memory leaks, but the reference to the window object can still escape the local scope, and cause a crash if the user is reckless. While I don't imply that reckless users should be supported, supporting library authors is good for the ecosystem.
#13
Debugging and error messages are still a weak point of Newlisp for me.



I could make it slightly easier by inserting a call to getDebuggerInput() at the end of printErrorMessage(). At least one can check the value of local variables, arguments, and even those of the callers if names don't overlap.



Can it be improved?
#14
newLISP in the real world / Optimisations
March 21, 2014, 02:22:00 AM
Arrays versus Lists



The deal is that lists are good at insertion and bad at random access, while arrays suck at insertion and are good at random access (I've measured a 30% difference on random accesses).

More often than not, one does a bit of both, so the choice between lists and arrays is not obvious; and it can evolve as the application evolves. However there is one case where the choice is simple: data structures, and objects. It seems to me that objects should be implemented as arrays rather than lists, because one typically perform random accesses to properties or fields of objects, and it seems unlikely that one needs to add/remove a field.



Micro-optimisations



I've read that on current processors, one thing that matters as far as performance goes, are conditionnal jumps.

I have replaced the "if ladder" on lines 1547 and following with the switch() in function evaluateExpression(), and moved the second if statement (cell->type is symbol or context) in the switch statement below. I observed a gain of performance between 7% and 10%.



However this kind of micro-optimisation is very volatile and depends a lot on the compiler, the processor, and the context. If I replace the "if ladder" near line 1525 by a switch case on args-type, I observe a slight loss in performance. My "benchmark" is a broken implementation of the map operator with a for loop. I'm not sure if it's actually "good" way to measure performance. I think we need a set of standard benchmarks.
#15
Node.js is popular because it's javascript. It let "web" developers reuse their knowledge, server-side.



Javascript itself is one of the biggest steal in CS history IMHO. The language design is full of WTFs (kind of the opposite image of Newlisp if you ask me), but it is the language of web browsers. Web browsers won, so JS won.



Browsers themselves are a poor technology. HTML, XML, CSS and JS are "resources don't matter" languages. You realize that when you have to fit the "web stack" in an embedded platform; you need far too much resources for what you want to do (except if what you want to do is really browse the web).