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 - lithper

#1
Thanks, that was interesting to read.



I found newLisp very recently, but cannot remember where. I was going through a number of implementations, and when found newLisp, was really struck by how well thought-out the package was, that I could do scripting immediately, that documentation is informal, modern (full of examples and cookbook recipies, rathern than the insane formality from 1970s with "big" lisps).

All APIs were there, the tiny standalone executable could be started in tens of copies or used to distribute scripts between machines - I was fascinated by how well thought-out it was, as I already said. A true hacker's tool in the original sense of this word.



ow to make it more popular?

I try to mention newLisp where I can, but  cannot say I succeeded much so far.



One way could be to write (why do not we pool our efforts together here?) some article under a good catchy title and publish it in some Linux on-line magazine, the Perl Journal or similar (under the guise of comparison with the perl approach or sth) , push NewLisp as "perl 6 that is already here" ( that is the way I think of NewLisp myself, in my head - this is much of what I would dream perl6 to be - but for the problem that perl6 is NOT except as a fantasy, and it's completely unknown when it could get born into the world )



I'd try to find a well-known sysadmin, linux and/or scripting language on-line publication and try to write a series or a column there.



..maybe also write some "newLisp poetry" - like that Perl "poetry", when the text of the program that parses OK reads like a poem ;))
#2
newLISP newS /
May 20, 2008, 12:30:04 PM
Lutz, looks OK on that demo screen



..but there's one small typo - "щелкнуть дважды" (not "щекнуть", L letter is missing, i.e. the cyrillic "л ллллллллллл")
#3
newLISP newS /
May 20, 2008, 08:26:47 AM
"slider, progress-bar and scroll-pane" -- движок, индикатор загрузки, ??? (I have no idea what a scroll pane is)
#4
newLISP newS / Re: Translation help needed
May 20, 2008, 08:23:59 AM
Quote from: "Lutz"
Strings to translate:



"Widgets Demo" демо ГУИ-элементов

"buttons" кнопки

"button" кнопка

"radio button" выбрать

"check box" отметить

"press" нажать

"combox-box and list-box" комбо и списки

"one" один

"two" два

"three" три

"first entry" первое

"second entry" второе

"third entry" третье

"fourth entry" четвертое

"fifth entry" пятое

"sixth entry"  шестое

"seventh entry" седьмое

"eight entry" восьмое

"double-click me" щелкнуть дважды -- /typo corrected here/

"text-field and text-area" текстовое поле и текстовый ввод

"get text field" поле "получить текст"

"get text area" "получить текст"

"slider, progress-bar and scroll-pane"

"horizontal" горизонтальный

"A Dialog Window" окно-диалог

"Choose a color"  выберите цвет

"A Message" сообщение

"Enjoy GUI server" приятного пользования ГУИ-сервером

"yes" да

"no" нет



Lutz


..however one needs to know the context in which these labels are going to be used (I myself never tried the GUI server), as translation critically depends on it.



For example, instead of "check box" (a noun) I gave you "check it" , a verb phrase - which is appropriate on a web form near the element, but is wrong in a description text where the name of the element (rather than instruction to the user) is needed
#5
Anything else we might add? / Hmm..
May 17, 2008, 12:26:18 PM
.. and I think (sorry for being abrupt in such a non-american way) that Paul Graham is parasiting on his popularity while keeping on explaining how great Arc will be the moment it is.

Instead of adding their efforts to an existing open project  he and his hot-air brigade just blabber endlessly over this seeming kludge.



I know at least 3 micro-lisp implementations, newlisp including, if one ignores countless other micro-scheme's.



Graham does not even come close to a one-piece 300-kb executable, with all modern APIs built-in, which by virtue of its compactness and lack of need to do a "system install" can offer pioneering, distributed models of architecting an app.



He does not give us a modern simple and high-level set of operators, etc. etc. etc.



They are talkers, while others simply quietly DO things.

All "Arc" purports to become IS ALREADY AVAILABLE, in several implementations. Two obvious examples are newlisp - and more cryptic, but still quite powerful, at a first glance, picoLisp.
#6
Get the short in-line help.lsp from here:



http://www.newlisp-on-noodles.org/wiki/index.php/NewLISP_Ideas#Included_Help">http://www.newlisp-on-noodles.org/wiki/ ... luded_Help">http://www.newlisp-on-noodles.org/wiki/index.php/NewLISP_Ideas#Included_Help



I (as I explained earlier)

(1) re-wrote some, not yet all, of the brief definitions to BE LIKE VERB PHRASES of a HUMAN LANGUAGE, and



(2) added help on the categories



So now the provided function looks like this:

(define (hh (target 'help) , command_lst syntax)

(set 'command_lst '(
  ("help" "syntax: (hh command) or (hh top)")
  ("zero?" "syntax: (zero? expr) -- check if expr evaluates to 0")
  ("xml-type-tags" "syntax: (xml-type-tags [expr-text-tag expr-cdata-tag expr-comment-tag expr-element-tags]) --> suppress or replace tags in output o
f following xml-parse")
  ("xml-parse" "syntax: (xml-parse which_string-xml [int-options into_target_sym-ontext [with_func-callback]]) --> ret. parsed Ss-expr list")
  ("xml-error" "syntax: (xml-error) --> list of err from last xml-parse")

..............
..............
..............

  ("lists" "syntax: (+, -, *, /,%, <, >, =, <=, >=, !=, :, and, append, apply, args, assoc, assoc-set, begin, bind, case, catch, chop, clean, cond, co
ns, constant, count, curry, define, define-macro, def-new, difference, doargs, dolist, dostring, dotimes, dotree, do-until, do-while, dup, ends-with,
exists, eval, expand, first, filter, find, find-all, flat, fn, for, for-all, if, index, intersect, lambda, lambda-macro, last, length, let, letex, let
n, list, local, lookup, map, match, member, not, nth, nth-set, or, pop, pop-assoc, push, quote, ref, ref-all, ref-set, rest, replace, replace-assoc, r
everse, rotate, select, set, setq, set-assoc, set-nth, set-ref, set-ref-all, silent, slice, sort, starts-with, swap, unify, unique, unless, until, whe
n, while)" )
  ("strings" "syntax: (.. address, append, char, chop, dup, ends-with, encrypt, eval-string, explode, find, first, float, format, get-char, get-float,
 get-int, get-long, get-string, int, join, last, lower-case, member, name, nth, nth-set, pack, parse, pop, push, regex, replace, rest, reverse, rotate
, select, set-nth, slice, source, starts-with, string, sym, title-case, trim, unicode, unpack, upper-case, utf8, utf8len..)")
  ("math" "syntax: (.. abs, acos, acosh, add, asin, asinh, atan, atanh, atan2, beta, betai, binomial, ceil, cos, cosh, crc32, crit-chi2, crit-z, dec,
div, erf, exp, factor, fft, floor, flt, gammai, atan, gcd, ifft, inc, log, min, max, mod, mul, pow, round, sequence, series, sgn, sin, sinh, sqrt, sub
, tan, tanh..)")
  ("matrix" "syntax: (.. det, invert, mat, multiply, transpose..)")
  ("array" "syntax: (.. append, array, array-list, array?, det, first, invert, last, mat, multiply, nth, nth-set, rest, set-nth, transpose..)")
  ("bit" "syntax: (.. <<, >>, &, |, ^, ~..)")
  ("predicates" "syntax: (.. array?, atom?, context?, directory?, empty?, file?, float?, global?, integer?, lambda?, legal?, list?, macro?, NaN?, nil?
, null?, number?, primitive?, protected?, quote?, string?, symbol?, true?, zero?..)")
  ("time-date" "syntax: (.. date, date-value, parse-date, now, time, time-of-day..)")
  ("stats" "syntax: (.. amb, bayes-query, bayes-train, normal, prob-chi2, prob-z, rand, random, randomize, seed..)")
  ("patterns" "syntax: (.. ends-with, find, find-all, match, parse, regex, replace, search, starts-with, unify..)")
  ("financial" "syntax: (.. fv, irr, nper, npv, pv, pmt..)")
  ("io" "syntax: (.. append-file, close, command-line, copy-file, device, exec, load, open, peek, print, println, read-buffer, read-char, read-file, r
ead-key, read-line, save, search, seek, write-buffer, write-char, write-file, write-line..)")
  ("unix" "syntax: (.. !, destroy, exec, fork, pipe, process, semaphore, share, wait-pid..)")
  ("file" "syntax: (.. change-dir, copy-file, delete-file, directory, file-info, make-dir, real-path, remove-dir, rename-file..)")
  ("http" "syntax: (.. base64-enc, base64-dec, delete-url, get-url, put-url, post-url, xml-error, xml-parse, xml-type-tags..)")
  ("sockets" "syntax: (.. net-accept, net-close, net-connect, net-error, net-eval, net-listen, net-local, net-lookup, net-peer, net-peek, net-ping, ne
t-receive, net-receive-from, net-receive-udp, net-select, net-send, net-send-to, net-send-udp, net-service, net-sessions..)")
  ("lisp-system" "syntax: (.. $, callback, catch, context, debug, default, delete, env, error-event, error-number, exit, global, import, main-args, ne
w, ostype, pretty-print, reset, set-locale, signal, sleep, sym, symbols, sys-error, sys-info, timer, throw, throw-error, trace, trace-highlight..)")
  ("libraries" "syntax: (.. address, flt, float, get-char, get-float, get-int, get-long, get-string, import, int, pack, unpack..)")
  ("lisp-internals" "syntax: (.. cpymem, dump..)")
  ("top" "syntax: (lists strings math matrix array bit predicates time-date stats patterns financial io unix file http sockets lisp-system libraries l
isp-internals)")



(set 'syntax (map last (filter (fn (z) (= (z 0) (string target))) command_lst)))
(if syntax
  (println (join syntax "n"))
  (println "No help for that command")
)
(string target)
)


/ignore the line breaks done by the phpbb forum software/



After the file is loaded the usage is:

:- (hh)
syntax: (hh command) or (hh top)
"help"

:-  (hh "top")
syntax: (lists strings math matrix array bit predicates time-date stats patterns financial io unix file http sockets lisp-system libraries lisp-internals)
"top"

:- (hh "bit")
syntax: (.. <<, >>, &, |, ^, ~..)
"bit"

[i]..and so on. For each particular function help looks like this:[/i]

:-  (hh "trim")
syntax: (trim which_str [ str-left-onechar_to_trim] [ str-right-onechar_to_trim ]) --> ret. string_trimmed
syntax: (trim which_str [ str-onechar_to_trim ]) --> ret. string_trimmed
"trim"
:-


It does not wrap in the normal xterm window, of course, and so looks neat and readable, too
#7
Yes, there are 2 ways to use help from inside the interpreter that I use.



[1] One is offered by Lutz M., the creator of the language, in his default init.lsp file:
(define-macro (help func)
   (if (primitive? (eval func))
       (let (func-name (name func))
            (if (ends-with func-name "?") (replace "?" func-name "p"))
       (!  (format "w3m file:/usr/share/newlisp/doc/newlisp_manual.html#%s" func-name)))
        ;(format "%s is not a built-in function" (name func))
        (!  "w3m file:/usr/share/newlisp/doc/newlisp_manual.html#functions"))
   )

(I edited the macro to use "w3m", the best command-line www browser, but you may also put there any other like "links", "lynx" etc.



This help simply reads the manual file and shows it at the requested function.



[2] There is also a file with short, skeleton help lines in the form of
Quote("slice" "syntax: (slice str int-index [int-length])")

written by one of the more popular forum participants - I picked it up from his web site with newlisp scripts and add-ons. Will try to find out which site it was and add the URL here

In a similar way, this quick short help must be loaded, possibly from "init.lsp" (and its name may be changed to something like "hh" not to conflict with the full detailed help based on the manual)



[3] Generally speaking, computer documentation is very irritating. It's written, as a rule with surprisingly few exceptions, by abominably stupid people.

The main problem is that documentation demands that you always did internat translations into and from a new, intermediary language, before you can understand and use the info.



This is the same problem that humanity has with old-fashioned dictionaries in the tradition of 19th century:
QuoteBREAK

1 a: to separate into parts with suddenness or violence b: fracture break an arm  

(this will be the only example in the subentry)

When computers became available for linguistic research in the 1980s, Collins publishers and Birmingham University made a pioneering study and published a first dictionary in which entries used a radically different principle in explanations:
QuoteBREAK

1. When an object breaks or when you break it, it suddenly separates into 2 or more pieces......(etc.)

He fell through the window breaking the glass...the plate broke...(etc)

The definition EMBEDS PATTERNS OF USAGE (not speaking of the examples which in this COUBILD project all come from the real usage as collected and revealed by their computers)



The "traditional" (i.e. stupid) formal way of description presupposes someone who ALREADY KNOWS how to use the word, and needs only a small passive reminder. The second, intelligent explanation, provides immediate info, disposes of the need to restore or reformulate or regroup the information in your head - or, even worse, a need to go and look sth else somewhere else - before you can actually use it.


Quoteinsane ways of documenting language functions



[1] /some PHP doc/

object imap_bodystruct(int stream_id, int msg_no [,  int options]);



[2] /GNU Prolog/

open/4, open/3

Templates:

    open(+source_sink, +io_mode, -stream, +stream_option_list)

    open(+source_sink, +io_mode, -stream)

Description

open(SourceSink, Mode, Stream, Options) opens the source/sink SourceSink for input or output as indicated by Mode and the list of stream-options

Options and unifies Stream with the stream-term which is associated with this stream. See absolute_file_name/2 for information about the syntax of

SourceSink (section 7.26.1).



..and not a single example in sight! - one has to grep for the function among the testsuite files or in the examples directory, if it exists


This insanity murders first-class ideas and languages, such as Common Lisp, as one example, or Prolog.


QuoteInstead of:

("write-buffer" "syntax: (write-buffer str-device str-buffer [int-size])")



...Problems on the first reading are: am I writing a given buffer or into a buffer? What is the meaning of the operator? So str-buffer is my output, or do I get the stuff from it? I can figure out that str-device may be sth like stdin - or is it stdout, the output device??




In other words, before using such help one needs either to go and read in full the detailed explanation in the manual, or to KNOW all this stuff already!! ..and then it still requires reformulation of the stuff internally before one can use it.



Because NATURALLY in my head I keep a different formula - computer operators are naturally remembered AS VERBS OF A HUMAN LANGUAGE:
Quote..write this

 ("write-buffer" "syntax: (write-buffer into_which_str_or_device which_str_or_buffer [int-size])")



Internally I always think of it as "write-buffer into.. from.."

The definition MUST be like a sentence in a human language. This is the way our brains work, so use it instead of fighting it


I re-wrote half of the short definitions in my copy of the short help file to insert meaningful usage patterns, so that no reformulation or need to check another doc would ever happen, even if you do not know the operator or have not used it before.



Fake formality in definitions was invented by idiots, and unfortunately, in spite of the newer ways, popularized by the Internet wave and open programming (all those cookbooks, great snippets in each case etc.), the same old fake formality still rules making even great languages and ideas fail or require inordiate amounts of time before a newcomer is actually able to begin to use them
#8
Anything else we might add? /
April 15, 2008, 10:51:09 PM
.. one thing I always do is peek into Perl documentation. Sometimes snippets and more or less appropriate explanations can be dug out in the Camel, sometimes in the Perl Cookbook. Scripts quality may vary, as well as that of the commentaries, but I found something coherent about pre-forking servers, as one example.



The Camel has a section with example code on the use of semaphores. As most of it is in the on-line perl documentation, that is the third place I'd check.



Thanks for an interesting snippet to play with ;))
#9
newLISP newS / read from /proc
April 15, 2008, 10:46:20 PM
Quote from: "cormullion"... how does newLISP - or even me - know how many cpus there are? ...


The place with LOTS of system information (all of it, or almost) is the "/proc" filesystem.

I'm not sure of its implementation on BSD/Mac, and I remember that on Solaris it's not ASCII, so some utilities must be used from command line to read it (or APIs from a C library), but on Linux it was a specific decision to make it ASCII.



So, to find out virtually all about your machine, it's sufficient to read (read-only) the appropriate file there, and minimally match/parse it.



So something like "cat /proc/cpuinfo" could do it in a Linux box  from shell - or an obvious equivalent from newlisp.

Same technique will do with network interfaces and parameters, memory etc.



If you have enough privileges, it's possible on Linux to set some of the parameters through /proc, too
#10
heh..

newLisp is very appropriate in many interesting places. For example, there are quite a few "tiny linux" distributions, some fit on 1 diskette, others take, say, 8 MB and require something like 4 MB minimum memory.

Many of them are built with the "busybox" tool, an excellent bundle of all major unix utilities into one small executable (from 40kb to 1.xx Mb, depending on what you include).



NewLisp is a natural fit on such minimal and rescue disks. "Standalone perl" still takes over 1 MB and has limitations. NewLisp is a very versatile scripting language that can talk to C libraries etc. etc. - and I think, it should be number one consideration for such bundles and assemblies (and can actually obviate several other utilities, as a matter of fact)
#11
newLISP newS / "format" function
April 02, 2008, 04:41:38 PM
the standard way to do variable interpolation inside a given string, as far as I understand, is by using the "format" function.


(write-line (format "blablabla %s blabla %d" string_var decimal_num_var))
#12
newLISP newS /
April 01, 2008, 02:23:17 PM
Few software projects could boast such speed in their report-fix cycles ;))

Thank you
#13
Lutz - yes, thank you.'



cormullion - well, it just boils down to remembering what "development" version is. Changes in any sufficiently complex system can cause non-obvious consequences.



On the other hand, the whole point of open software development is that even if users do not contribute directly, you can always view their experiences as free testing, a fair exchange in some respects. We should not cry and complain, we are part of the process ;)



Regarding newLisp security.. Yes, I'd prefer to have a tool that can do everything, like a knife blade, rather than be "protected" from yourself, like with those plastic-embedded tiny strips of metal they call "safety razors".



But I'd use even small things to increase security of design. For example, I'd not put bare newLisp scripts into a web server cgi directory configuring it to execute newLisp directly.

I'd package the script+200kB into that fake executable, and drop the package into the web server.

It seems (seems, I'd need to check it better), that a packaged newLisp script+binary executes only the included script and does not react to any other command-line options, environment variables, or scripts altogether.

While dropping a bare script might open the setup to a variety of abuses along these lines.



And, secondly, I'd be very restrictive about the input values - no symbols besides alphanumeric etc - and about their pathways inside the program - will some input characters be treated as strings? symbols? form lists?



Same about the variables/symbols introduced inside the prog itself. Can I in some error conditions (e.g. a file missing etc.) create a situation when things will go wrong - or have I caught it early as exceptions?



These are generally known principles, of course, the difficulty is in seeing how this actually operates in the program.



Some langs tried to automate the process ("taint" input in Perl - generally systems of constraints in languages and how they propagate), but..

And some people tried to write automated checking programs, and it might be they wrote them also in Lisp ;))
#14
Quote from: "newdep"although it is not seen as a bug...

Ouuuffff...



[start of rant]

If an application crashes - for example, when you use the interface for talking to libraries in C and use incorrect variable type - it is a security hole, it is something one should guard against in his code, but it is _marginally_ acceptable -- crashing your OS can not be construed as normal behaviour in any circumstances.



Please, take your head off the shelf, dust, and screw it back onto your neck, and say you have just made a bad joke. First of April, haha. Ha.



Newlisp is a security admin's worst nightmare - packing into one 200kB executable all tools a cracker dreamt of packing for a decade or three. Trivial to open sockets, execute whatever one wishes on the target by just starting t with a command-line switch, get raw access to memory, and crash it to get cores at your will.

It as if was specifically written to get reviewed in 2600, tongue-in-cheek, as a "nifty little language", wink-wink. Not a behemoth requiring effort to do an installation right, just one tiny file to drop some place on a machine

If someone makes a prog widely acceptable (say, as a web/CGI application), and ensures quietly that there's a backdoor in the executable, or ability to trigger one of its special behaviours...



I am ready to say, nL gives full freedom to hack, and therefore limits severely security in this inevitable balance - so one has to program with specific considerations and care - just because it's better to live in freedom and take responsibility rather than sit in one cage or another (they actually prefer you not to think of imprisonment, so they use imagery of infantility and talk about "sandboxes" instead), constructed by some inane "security specialist" (on the pay from NSA anyway, "cooperating" with Microsoft, Sun, or one more of the countless Linux distros they produce to achieve the corporate takeover of the thing, like Ubuntu  or RedHat (can you believe that thier previous CEO had the last name of Жулик (Matthew Szulik)?!! - check a Polish/Russian-English dictionary on that).

But I am not prepared to make such pronouncements as yours, I am sorry to say, even on the first of April..

[end of rant]
#15
[1] accidentally came across a sequence that immediately, explosively eats up all memory and CPU and creates effectively a DoS condition, killing the OS.



> (symbols Aa)
(Aa:Aa)
> (Aa p (d))
()
> (Aa "p" (d))

invalid function : (d)

//CRASH!!//
Terminated
 ->

In fact, this incorrect attempt at putting something as value in hash will murder your machine in 3-5 seconds:

0  0 164184 225932   6932  49968    0    0     0     0 1014   162  0  1 99  0
 0  0 164184 225932   6932  49968    0    0     0     0 1011   159  0  0 100  0
 1  0 164184 205068   6932  49968    0    0     0     0 1010   162  6 12 82  0
 1  0 164184  80972   6932  49968    0    0     0     0 1002   125 35 65  0  0
 1  0 122820   3568   6932  49968    0    0     0     0 1003   203 34 66  0  0
 2  1 187264   2392    968   6936    0 70800     8 70800 1294   454 24 76  0  0
procs -----------memory---------- ---swap-- -----io---- --system-- ----cpu----
 r  b   swpd   free   buff  cache   si   so    bi    bo   in    cs us sy id wa
 4  4 236640   3372    980   6804   20 49376   108 49376 1298   528  5 50  0 45
 2  0 250240   2472    980   6804  220 13608   220 13608 1112   629  9 34  0 57
 0  1 267212   2384    980   6244    0 17160     0 17160 1029   283  7 43  0 50
 0  3 267784   1560    996   6304    0  896    72   896 1035   242  5 10  0 85
 0  3 267780   1292   1068   7700   96    0  1560     0 1128   293  0  3  0 97


CPU usage will jump to almost 100%, all memory will be eaten up, the machine will thrash the disk (swapping memory out), it will freeze



[2] A similar crash OR segmentation fault happens if after an incorrect operation a bracket is omitted (usually  a benign error condition)

-> newlisp
newLISP v.9.3.5 on Linux IPv4 UTF-8, execute 'newlisp -h' for more info.

> (define Aa:Aa)
nil
> (Aa "f" (list p))
(nil)
> (symbols Aa

missing parenthesis : "...(symbols Aa                         "
Terminated
//CRASH!!//


Sometimes in these cases newlisp generated simple segmentation faults.



I do realize the shown usage is incorrect - only if your script generates it in some unexpected case, or if your program can be manipulated into doing something similar, a very serious condition can happen.



[3] It seems that new usage -- (define Aa:Aa), then (Aa "f" "asdf") or (Aa "f" 345) -- is narrower than the one before?

It seemed that with older usage I could avoid restriction on hash key as STRING ONLY, and on data as only STRING or NUMBER ?? Or am  I mistaken and this limitation existed all the time ? (seems, not, as one of my older scripts refused to work with new notation without a typecast).