new to newLISP

For the Compleat Fan
Locked
Ormente
Posts: 23
Joined: Tue Aug 31, 2010 1:54 pm
Location: Near Mâcon, France

new to newLISP

Post by Ormente »

Hi everybody !

I'm a new newLISPer from France, and very happy to have found this pragmatic LISP.

I use(d) to code in PHP, a few Lua, and had a look at Python, Ruby and Clojure. I like Clojure very much, but for scripting purpose it's not my prefered weapon... you know, Java is so slow to start !

As i do mainly web scripting, newLISP apear to be the best mix for me : a real lispish flavor, plenty of features built in, quick and lightweight. I'm seriously trying to use it in real (personal) projects, to see if it can realy fit my needs. So far, so good. It's not LISP as purists want it, but i think i can wrap my mind arround the implementation choices, and so far i have to say i like it a lot. So... thanks a lot Lutz, and keep improving the beast !

I'm currently working on 2 projects with newLISP : 1) a "website compiler", wich is intended to produce a complete static (or not) website from text sources, chunks/templates and "recipes"; 2 ) a micro web framework for dynamic web sites/apps.

Last week i made the website compiler with Lua, and now i'm making a newLISP version, to learn the language. For now, the "Moulinette" script weight 2.5 Ko and have 75% of it's features done.

I hope to see some activity here, because there's not much on the net about newLISP if we filter the bad words of regular LISPers. At least, Lutz publish regular updates, so newLISP seems alive, but i'm wondering how much people use it, and what they build in the real world with it.

Thanks for reading...

m i c h a e l
Posts: 394
Joined: Wed Apr 26, 2006 3:37 am
Location: Oregon, USA
Contact:

Re: new to newLISP

Post by m i c h a e l »

Ormente wrote:. . . but i'm wondering how much people use it, and what they build in the real world with it.
Hi Ormente! Welcome. I hope you find newLISP as rewarding and productive as I have. I'm not a real programmer (I don't even play one on TV), but I've been using newLISP exclusively for four years now, and I haven't felt the need for another programming language since. I spent a ridiculous amount of time going through every programming language I could find, but newLISP's Zen-like quality is what finally won me over. As I said, though, I'm no programmer. More of a programming language enthusiast :-)

m i c h a e l

itistoday
Posts: 429
Joined: Sun Dec 02, 2007 5:10 pm
Contact:

Re: new to newLISP

Post by itistoday »

Welcome Ormente!

If you haven't seen it already, you might be interested in the newLISP Dragonfly Web Framework.
Get your Objective newLISP groove on.

Ormente
Posts: 23
Joined: Tue Aug 31, 2010 1:54 pm
Location: Near Mâcon, France

Re: new to newLISP

Post by Ormente »

@itistoday : thanks :-) I know about Dragonfly. I tried it and it's an amazing piece of work. I have to work on my own framework for two reasons : 1 ) to learn newLISP and see how it goes for doing things the way i used to do them with PHP (wich is not "PHPesque"), and 2 ) i realy need something both more minimalist and more abstract, like Ramaze or Sinatra.

Basicaly my framework will do... nearly nothing. It's just a conceptual thing : allowing to specify a chain of handlers thru wich the engine walks. It starts with the request and an empty headers+output, then each handler decide if it have to do something, eventualy do it, eventualy change the chain (adding or skipping/removing handlers), then returns... and the process goes on to the end of the chain.

In most cases, the chain will begin with a handler to extract GET/POST/COOKIES, and end with another one to output headers+content to the brower, but inbetween anything can happend.

For exemple :
- a handler can use the domain parts of the URL to load a different "stack" of handlers for different site.
- once a site is done in one language, i can add a handler to recognise language code in the url (like starting with /fr/ or /en/) : il will strip it from the request elements (so as the rest of the chain works like before) and add a handler near the end of the chain to translate the output and process the urls (inject the /lang/ where apropriate).
- a handler can decide, if in /blog, to extract the needed contents, and an other one to extract something else if in /wiki... then a later handler will build up the page with availlable content and the main site template.
- in the last exemple different handlers could render the page diffenrently according to the end of the URL (.html, .txt, .json...)
- if the url ends with .htm an early handler can decide not to load the session manager, as the site is staticaly displayed... but with a .dyn ending decide to load it for the later admin handler wich have to know if the user is logged in order to display admin tools to work on the site/page. It could even inject the admin handler only if the url end with .dyn Or it could detect if the request contains post datas, and then load the session manager even if the url still end in .htm since the "form handler" could need it.
- a system can be added to a web app to add caching capabilities afterward... and so on, you get the idea ;-)

Ormente
Posts: 23
Joined: Tue Aug 31, 2010 1:54 pm
Location: Near Mâcon, France

Re: new to newLISP

Post by Ormente »

@m i c h a e l : Thanks for your words. I can recognise myself in your description ! Sometimes instead of actualy working i spend days trying other languages. I like that a lot, and so had a look at things like Rebol, Factor, Forth, OCAML... there's a lot of great languages out there ! But work have to be done ;-)

So i still ends with doing my work with PHP, wich is not fully satisfying for me : not "functional" enought, and evolve (???) to an horrible OO language. Not to mention its weight and poor startup performance in CGI. The only advantages of PHP are that i'm realy used to it, and that it's availlable everywhere (in hosting world) with no ceremony.

I have to say that newLISP looks very good, for my needs as well as for my taste.

It's maybe to early to say that it totaly won me, but it seems that's on the way.

hilti
Posts: 140
Joined: Sun Apr 19, 2009 10:09 pm
Location: Hannover, Germany
Contact:

Re: new to newLISP

Post by hilti »

Welcome Ormente!

Good to see some new minds developing in newLISP.
Your projects sound interesting. I've developed the Dragonfly framework with Greg Slepak (itistoday). You may have a look at it.

Currently I'm doing some work on my micro framework or better DSL called Appigale. Some small web apps are already running it. It has a simple markup language for generating HTML.

Code: Select all

(h (type 1) (text "Hello World"))
will result in

Code: Select all

<h1>Hello World</h1>
The cool thing about it is, that I don't have to switch my mind in doing newLISP and HTML when building up a website. :-)

All the best!
Marc
--()o Dragonfly web framework for newLISP
http://dragonfly.apptruck.de

Ormente
Posts: 23
Joined: Tue Aug 31, 2010 1:54 pm
Location: Near Mâcon, France

Re: new to newLISP

Post by Ormente »

Hi hilti, nice to learn about your Appigale DSL. Would you mind giving some URLs of sites built on it ?

For the HTML generators i was considering a similat idea, but more like :

Code: Select all

(h1 "This is my text" br "And this is another one")
--> <h1>This is my text.<br />And this is another one</h1>
First argument may be a list of attributes :

Code: Select all

(h1 '(class "heading" id "title) "This is my text")
--> <h1 class="heading" id="title">This is my text.</h1>
An idea of shortcuts to simple tags (like "br" in the 1st sample):

Code: Select all

(h1 "This is my text" b_ "And this is another one" _b)
--> <h1>This is my text. <strong>And this is another one</strong></h1>
Some tag generators should know how to assemble parts, so :

Code: Select all

(uli "first" "second")     < would do the same as >      (ul (li "first") (li "second"))
I've not yet played with reader-event in newLISP, but i suspect it could be a nice way to further enhance the coolness/simplicity of the generator syntax. Maybe by allowing some zencoding like shortcuts :

Code: Select all

(div.MyClass#Truc "coucou")   > expending to >   (div '(class "MyClass" id "Truc") "coucou")
I like the idea of not switching lisp<=>html a lot ;-)
BTW, I would be very happy to learn more about your generator, and Appigale... and even to give it a try.

Thanks for sharing your idea.

EDIT : i forgot to mention that tags with no contents should be written with "flat" attributes :

Code: Select all

(img src "picture.jpg" alt "My best pic ever")
Renaud

Kazimir Majorinc
Posts: 388
Joined: Thu May 08, 2008 1:24 am
Location: Croatia
Contact:

Re: new to newLISP

Post by Kazimir Majorinc »

I have little to add, but - welcome.

m i c h a e l
Posts: 394
Joined: Wed Apr 26, 2006 3:37 am
Location: Oregon, USA
Contact:

Re: new to newLISP

Post by m i c h a e l »

Ormente wrote:It's maybe to early to say that it totaly won me, but it seems that's on the way.
It took me a while to fully appreciate newLISP, and I almost gave up twice. It's deceptively simple. Sometimes, it seems, too simple. If you've been habituated to complexity, it can take some time to see the straightforward solutions newLISP is capable of. Especially if you're well-versed in another language (I fought a terrible case of writing Ruby-like code in newLISP my first year!).

m i c h a e l

P.S. Oddly enough, PHP is one of the few languages I didn't study.

Ormente
Posts: 23
Joined: Tue Aug 31, 2010 1:54 pm
Location: Near Mâcon, France

Re: new to newLISP

Post by Ormente »

ah ! ah ! Before coding my website generator in Lua i tried to do it in newlisp... and gave up !
So, i made it with Lua, a language in wich i had no experience, and that was pretty easy.

Lua is very good, but miss a lot of the things packed in newLISP. And it's not a lisp. :-)

I gave another try, and now things goes better with newLISP.
I struggled with proper use of contexts/hashes and "association lists"... and still not sure how
to uses them well. It seems i'm missing a Dictionary type, or a way to store a context/hash
inside another one to do things like :

Code: Select all

PHP :
$my_var['first_key']['second_key']['third_key'] = $a_value;
No, please, don't laugh, it's not intended to be funny ;-)

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Re: new to newLISP

Post by Lutz »

There are no nested name-spaces / context, but your could chain the keys, and have the same effect:

Code: Select all

> (new Tree 'MyVar)
MyVar
> (MyVar (string "first-key" "second-key" "third-key") "any data/type value")
"any data/type value"
> (MyVar (string "first-key" "second-key" "third-key"))
"any data/type value"
> 
… or you could store the handle of a second dictionary tree as a value in the first one.

But tell us about the concrete problem, you want to solve? Perhaps there are other solutions.

hilti
Posts: 140
Joined: Sun Apr 19, 2009 10:09 pm
Location: Hannover, Germany
Contact:

Re: new to newLISP

Post by hilti »

Ormente wrote:Hi hilti, nice to learn about your Appigale DSL. Would you mind giving some URLs of sites built on it ?
At first there's my personal site www.marchildmann.com, which is currently a "heavy under testing" playground. My other Appigale apps are sitting on localhost and doing simple tasks e.g. like displaying random tweets for a specific keyword.

I think it's a good way to learn a lot from a language if You code real things, e.g. like a web framework although it'll only might be used by yourself.

For example I've learned a lot from the Dragonfly project and the guys in this forum.

So keep on Your work and share some code :-)

Marc
--()o Dragonfly web framework for newLISP
http://dragonfly.apptruck.de

hilti
Posts: 140
Joined: Sun Apr 19, 2009 10:09 pm
Location: Hannover, Germany
Contact:

Re: new to newLISP

Post by hilti »

Ormente wrote:BTW, I would be very happy to learn more about your generator, and Appigale... and even to give it a try.
Here comes the code for generating valid HTML headlines. If ID is nil, then it'll be auto generated. This way Appigale generates valid HTML.

Code: Select all

(define-macro (h)
	(local (type id class text)
		(bind (args) true)
		(if (nil? id)
			(set 'id (string "id" (random 0 1)))
		)
		(push (string "<h" type " id=\"" id "\" class=\"" class "\">" text "</h" type ">") RENDERBUFFER -1)
	)	
)
--()o Dragonfly web framework for newLISP
http://dragonfly.apptruck.de

Ormente
Posts: 23
Joined: Tue Aug 31, 2010 1:54 pm
Location: Near Mâcon, France

Re: new to newLISP

Post by Ormente »

@Lutz :

Thanks for this idea Lutz, but that won't do the job. I've done something similar, but with this trick i can't access "intermediate tables". If i have :

Code: Select all

(MyVar (string "key" "subkey" "endkey1") "value 1")
(MyVar (string "key" "subkey" "endkey2") "value 2")
I can't get both with :

Code: Select all

(MyVar (string "key" "subkey"))
I've no concrete example at hand, but when i find one i'll ask you.

@hilti :
Thanks, i had a look at your site. I definitely agree that one can only learn by doing real things.

As for your "h" macro, it seems overly complicated to use, for me, and i dislike the fact that unnecessary id are added as well as "nil classes".

This is an early experiment, but here's how i begin :

Code: Select all

(setf . nil)
(define (attr T A)
	(if (true? A)
		(append "<" T " " A ">")
		(append "<" T ">")
	)
)
(define (p a)
  (append (attr "p" a) (join (args)) "</p>")
)
(define (span a)
  (append (attr "span" a) (join (args)) "<span>")
)
So i can write :

Code: Select all

	(println (p . "this is a text" "and another one") )
	(println (p {id="myId" class="entry"} "that's good " (span {class="red"} "to know") " about newLISP") )
What do think about this way of doing it ?

Ormente
Posts: 23
Joined: Tue Aug 31, 2010 1:54 pm
Location: Near Mâcon, France

Re: new to newLISP

Post by Ormente »

@Lutz : For the idea of storing handles for secondary contexts/dicts, i can't see how to deal easyly with multiple contexts/dicst having the same subkeys.

Maybe i have to find a real example where i would use this in "traditional" language, and see if i can refactor it with a more newLISP idiomatic approach.

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Re: new to newLISP

Post by Lutz »

Perhaps nested association lists are better in your case:

Code: Select all

(set 'MyVar '(
		("keyA" ("subkey1" ("endkey1" "value1") ("endkey2" "value2")))
		("keyB" ("subkey1" ("endkey1" "value3") ("endkey2" "value4")))
	)
)

(assoc "keyA" MyVar) ;=> ("keyA" ("subkey1" ("endkey1" "value1") ("endkey2" "value2")))

; return both endkeys
(assoc (list "keyA" "subkey1") MyVar) ;=> ("subkey1" ("endkey1" "value1") ("endkey2" "value2"))

; return only one specific endkey
(assoc (list "keyA" "subkey1" "endkey2") MyVar) ;=> ("endkey2" "value2")
when retrieving the endkey and not a list, then lookup may be better:

Code: Select all

; return the value only
(lookup (list "keyA" "subkey1" "endkey2") MyVar) ;=> "value2"
using (list "foo" "bar") instead of '("foo" "bar") allows you to use variables for keys:

Code: Select all

(set 'k2 "endkey2")
(lookup (list "keyA" "subkey1" k2) MyVar) ;=> "value2"
Association lists are not as fast as dictionaries formed with name-space contexts, but if you only have a few hundred entries, the speed difference can be neglected.

You also could have a mixed arrangement, e.g. using "keyA", "keyB" as keys in a dictionary which stores association lists in each entry:

Code: Select all

(new Tree 'MyVar) ; or as an alternative just (define MyVar:MyVar) which does the same

(MyVar "keyA"  '("subkey1" ("endkey1" "value1") ("endkey2" "value2")))
(MyVar "keyA"  '("subkey1" ("endkey1" "value1") ("endkey2" "value2")))

(MyVar "keyA") ;=> ("subkey1" ("endkey1" "value1") ("endkey2" "value2")

(assoc "endkey2" (MyVar "keyA")) ;=> ("endkey2" "value2")

(lookup "endkey2" (MyVar "keyA")) ;=> "value"
this solution does a very fast access of the top level key (e.g. millins of records) then uses associative access inside the record itself.

you also can modify entries easily using 'setf'

Code: Select all

(setf (lookup "endkey2" (MyVar "keyA")) "newValue2")

(lookup "endkey2" (MyVar "keyA")) ;=> "newVAlue2")
This last solution, using a hash tree for the top level and using associations for the sub levels, is also the most readable and probably the best solution.

Ormente
Posts: 23
Joined: Tue Aug 31, 2010 1:54 pm
Location: Near Mâcon, France

Re: new to newLISP

Post by Ormente »

Thanks a lot Lutz. That's what i ended doing for my website generator, but i was wondering if better ways were availlable.

In this case i can have a lot of documents, each one is stored in a context as an association list of fields. This is ok, because each doc have few fileds, even if i can have a lot of docs. But i can't see this as an efficient and straitforward solution for the general case.

cormullion
Posts: 2038
Joined: Tue Nov 29, 2005 8:28 pm
Location: latiitude 50N longitude 3W
Contact:

Re: new to newLISP

Post by cormullion »

Ormente wrote:i'm wondering how much people use it, and what they build in the real world with it.
Hi! I use newLISP for various things, including web sites and text processing. Currently I'm not able to use it very much - my current work doesn't allow for any computer use and I seem to have little time outside work either. Also, my newLISP work seems to have got stuck recently - the development versions broke some of the code in my toolchain but I can't work out how or when to fix it (I seem to be stuck on v10.1).

One of the most interesting newLISP developments at the moment is kane-box over at http://lifezero.com/.

Have fun.

kanen
Posts: 145
Joined: Thu Mar 25, 2010 6:24 pm
Contact:

Re: new to newLISP

Post by kanen »

Thanks for the kind words!

It's actually http://www.Lifezero.org (or Kane-Box.com). :)
cormullion wrote:
Ormente wrote:i'm wondering how much people use it, and what they build in the real world with it.
Hi! I use newLISP for various things, including web sites and text processing. Currently I'm not able to use it very much - my current work doesn't allow for any computer use and I seem to have little time outside work either. Also, my newLISP work seems to have got stuck recently - the development versions broke some of the code in my toolchain but I can't work out how or when to fix it (I seem to be stuck on v10.1).

One of the most interesting newLISP developments at the moment is kane-box over at http://lifezero.com/.

Have fun.
. Kanen Flowers http://kanen.me .

cormullion
Posts: 2038
Joined: Tue Nov 29, 2005 8:28 pm
Location: latiitude 50N longitude 3W
Contact:

Re: new to newLISP

Post by cormullion »

Sorry, Kanen! I went there once by mistake. It's all electronics, interestingly...

newBert
Posts: 156
Joined: Fri Oct 28, 2005 5:33 pm
Location: France

Re: new to newLISP

Post by newBert »

Ormente wrote:Hi everybody !

I'm a new newLISPer from France, and very happy to have found this pragmatic LISP.
Hello Ormente,
I'm a french NewLisper too ... a kind of ghost, in french "revenant" (= who is coming back), because I had given up programing a while ago.
I'm not a pro but I like NewLisp even if I made some diversions to Rebol, Lua, Euphoria, etc.
At present I use above all FBSL, ELICA and of course NewLISP ... just for the fun, most of the time.
:-)

P.S. : I agree for Java and its slowness (and heaviness in memory), but NewLISP-GS is quite usable despite that, and in any case easy to use.
BertrandnewLISP v.10.7.6 64-bit on Linux (Linux Mint 20.1)

Locked