new to newLISP

Started by Ormente, August 31, 2010, 08:14:27 AM

Previous topic - Next topic

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

#1
Quote from: "Ormente". . . 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

#2
Welcome Ormente!



If you haven't seen it already, you might be interested in the http://www.rundragonfly.com">newLISP Dragonfly Web Framework.
Get your Objective newLISP groove on.

Ormente

#3
@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

#4
@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

#5
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.


(h (type 1) (text "Hello World")) will result in <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\">http://dragonfly.apptruck.de

Ormente

#6
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 :



(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 :

(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):

(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 :

(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 :

(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 :

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


Renaud

Kazimir Majorinc

#7
I have little to add, but - welcome.
http://kazimirmajorinc.com/\">WWW site; http://kazimirmajorinc.blogspot.com\">blog.

m i c h a e l

#8
Quote from: "Ormente"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

#9
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 :
PHP :
$my_var['first_key']['second_key']['third_key'] = $a_value;


No, please, don't laugh, it's not intended to be funny ;-)

Lutz

#10
There are no nested name-spaces / context, but your could chain the keys, and have the same effect:
> (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

#11
Quote from: "Ormente"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 http://www.marchildmann.com">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\">http://dragonfly.apptruck.de

hilti

#12
Quote from: "Ormente"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.



(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\">http://dragonfly.apptruck.de

Ormente

#13
@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 :

(MyVar (string "key" "subkey" "endkey1") "value 1")
(MyVar (string "key" "subkey" "endkey2") "value 2")

I can't get both with :

(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 :

(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 :

(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

#14
@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.