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

Topics - xytroxon

#1
Hacker News: newLISP

https://news.ycombinator.com/item?id=10279266">//https://news.ycombinator.com/item?id=10279266



newLISP doesn't use linked lists???



(I always secretly suspected Lutz was a C "source"-rer! ;O)



--xytroxon



Update: The "leg lifting" was continued by reddit HackerNews topic thieves.

https://www.reddit.com/r/programming/comments/3mczb5/newlisp/">//https://www.reddit.com/r/programming/comments/3mczb5/newlisp/
#2
The web is evolving rapidly towards using https links for their website content. e.g. github etc...



Currently, the newLISP wiki only allows for cold blooded reptilian Jurassic style [http://... ] links.



newLISP wiki needs to adapt to the new "https everywhere*" life forms or... face extinction as a viable mammalian usable wiki...



* https://www.eff.org/Https-everywhere">//https://www.eff.org/Https-everywhere



-- Charles Dar... er. xytroxon ;o)
#3
Found this interesting programming language comparison being disgusted er. "discussed" on the Lua newsgroup.



Perl, Python, Ruby, PHP, C, C++, Lua, tcl, javascript and Java comparison

http://raid6.com.au/~onlyjob/posts/arena/">//http://raid6.com.au/~onlyjob/posts/arena/



This comparison consists of three parts:

Part 1: Speed.

Part 2: Memory usage.

Part 3: Language features.



Roberto Ierusalimschy, the the co-creator of "slowpoke" Lua, was not amused by the results...


Quote
From: Roberto Ierusalimschy <roberto <at> inf.puc-rio.br>

Subject: Re: Perl, Python, Ruby, PHP, C, C++, Lua, tcl, javascript and Java comparison

Newsgroups: gmane.comp.lang.lua.general

Date: 2013-07-15 17:24:28 GMT (4 hours and 17 minutes ago)



> Maybe this should be of interest:

>

> http://raid6.com.au/~onlyjob/posts/arena/">http://raid6.com.au/~onlyjob/posts/arena/



This test is ridiculous. Whoever wrote the code does not know how

to program in Lua (or in Java or in Javascript).



-- Roberto


I would like to hear Lutz's expert opinion on the test code methods.



-- xytroxon
#4
In the spirit of rickyboy's recent interesting posts on using the problem solving capabilities of the newlisp language, I offer up this "For Fun" challenge, inspired by this old (2011) 'Attractive Chaos' blog that bubbled back up on one of my rss feeds:



'An Incomplete Review of Sudoku Solver Implementations'

http://attractivechaos.wordpress.com/2011/06/19/an-incomplete-review-of-sudoku-solver-implementations/">//http://attractivechaos.wordpress.com/2011/06/19/an-incomplete-review-of-sudoku-solver-implementations/


QuoteSudoku is probably the most popular puzzle nowadays. Lots of attempts have been made to solve Sudoku using programs. However, solving Sudoku is known to be an NP-complete problem, which means no efficient algorithm exists so far. Finding the solution largely relies on black magic. On the other hand, lacking a definite answer makes Sudoku more interesting. A variety of methods arise to solve Sudoku. Wiki gives a good brief view of the existing algorithms. I will focus more on the practical implementations.


Searching the newLISP Fan Club found 8 matches for: sudoku

http://newlispfanclub.alh.net/forum/search.php?keywords=sudoku">//http://newlispfanclub.alh.net/forum/search.php?keywords=sudoku



The sudoku.lsp code links from 2005 are now dead. So this would be a good time to revisit the topic, and help benchmark newLISP's speed* against other languages ;o)



One of the unexpected speed demons presented in the article is Lua, while Python and Java methods can be extremely slow, to say the least... (I suspect the Lua version was run using Mike Pall's excellent luajit.)



Sudoku is relatively unknown to me, and I suffer greatly to solve them, (some of our fine newLISP members no doubt can solve these puzzles in their sleep ;o), so this is a challenge to new and old newLISPer's that have a few odd moments to invest.



While this maybe "child's play", the long-term challenge is to use newLISP to evolve the NP-complete problem solving challenge that Sudoku presents...

http://en.wikipedia.org/wiki/Sudoku_algorithms">//http://en.wikipedia.org/wiki/Sudoku_algorithms



-- xytroxon



* And maybe we can break, um... "make more bulletproof" Lutz's newLISP code in the process ;o)
#5
From Hacker News:

http://alan.dipert.org/post/153430634/the-march-of-progress">//http://alan.dipert.org/post/153430634/the-march-of-progress



Comments:

http://news.ycombinator.com/item?id=3963541">//http://news.ycombinator.com/item?id=3963541



--------------------



The March of Progress



*   1980: C



printf("%10.2f", x);



*  1988: C++



cout << setw(10) << setprecision(2) << showpoint << x;



*   1996: Java



java.text.NumberFormat formatter = java.text.NumberFormat.getNumberInstance(); formatter.setMinimumFractionDigits(2); formatter.setMaximumFractionDigits(2); String s = formatter.format(x); for (int i = s.length(); i < 10; i++) System.out.print(' '); System.out.print(s);



*   2004: Java



System.out.printf("%10.2f", x);



*   2008: Scala and Groovy



printf("%10.2f", x)



------------------



-- xytroxon  ;o)
#6
http://en.wikipedia.org/wiki/John_McCarthy_%28computer_scientist%29">//http://en.wikipedia.org/wiki/John_McCarthy_(computer_scientist)
#7
Whither newLISP? / newlisp on hacker news
August 23, 2011, 01:09:03 AM
Found this on my rss hackneyed er. "hacker" news feed from the weekend...



http://news.ycombinator.com/item?id=2909490">http://news.ycombinator.com/item?id=2909490



Looks like I missed all the fun! ;)



-- xytroxon
#8
http://www.drmaciver.com/2011/06/the-programming-language-hat/">//http://www.drmaciver.com/2011/06/the-programming-language-hat/
#9
Carl Sassenrath, CTO of REBOL Technologies has posted this long, complicated blog article on the Definition of Simple...

http://www.rebol.com/article/0509.html">http://www.rebol.com/article/0509.html



Simple is:

   1. Clear abstraction: smart, well-drawn layers of "knowledge focus" that allow hiding of details.

   2. Clean expression: meaningful, concise but not cryptic, representation and communication of concepts.



... Yet, when I browse these massive code-bases what I clearly see is a complete naivety of the engineers and/or programmers who wrote it. I'm not talking about their understanding of the knowledge domain, I'm talking about how they've mostly ignored tapping into the realm of expression as part of their solution.



Some designers recognize deep down that something is wrong, and to help solve their problems, they often invent yet another language as a layer within their system. Modern Linux is completely littered with such languages, and it's a huge mess that spans everything from how you configure and build the kernel down to how you write little script jobs.



The problem here is that there's no unity of language design, and in fact since most domain-smart programmers don't know much about language construction, you get something really quite ugly and nasty. Sure, people will force themselves to learn it, but only because they want the final solution... the circuit design, chip layout, kernel build, highway structure, nuclear reactor simulation, ...



But something important is lost in that approach. Simplicity is sacrificed. ....



=============================



"Simply" switch to newLISP Carl... "Simply" switch to newLISP....



-- xytroxon



P.S. Check out the comments section for this blog article... (ouch!) Rebel er. "Rebol" programmers are getting a little tired of waiting for Rebol 3 to be completed... I feel their language pain... Up(de)grading my Python 2.x scripts to Python 3.x is driving me nuts... It's simple to convert code with their conversion script, but all the batteries (Python 3 third party modules) I need are not yet included (converted and or properly debugged) :(



(Of course waiting for them gives me time to rewrite my old snake skin programs in newLISP :)
#10
Hi Lutz!



I'm having problems / confusion when using dotree in a database program.



dotree either doesn't work or is of little or no value. The simplified working program below creates, lists, and deletes database tree items using dotree.



(new Tree 'pet-db)

(pet-db "dog" "King")
(pet-db "cat" "Fluffy")
(pet-db "hamster" "Sam")
(pet-db "fish" "Goldy")

(println "---> show the database")
(println (pet-db))

(println "--> list items")
; (dotree (pet pet-db) (println pet " -> " (pet) )) ; 1. Error?
; (dotree (pet pet-db true) (println pet " -> " (eval pet) )) ; 2, Hang and crash!
(dotree (pet pet-db) (println pet " -> " (eval pet) ))

(println "---> delete ttems")
; (dotree (pet pet-db) (println pet " -> " (pet nil) )) ; 1. Error?
; (dotree (pet pet-db true) (println pet " -> " ((prefix pet) (1 (string (term pet))) nil) )) ; 2. Hang and crash!
(dotree (pet pet-db) (println pet " -> " ((prefix pet) (1 (string (term pet))) nil) ))

(println "--> show database")
(println (pet-db))

(exit)


The commented out error(s) of concern:



1. Using the what I expected (pet) or (pet nil) tree access forms cause an invalid function error. After much experimentation, using (eval pet) and my patent pending "messy code" ((prefix pet) (1 (string (term pet))) nil) works, but then...



2 . When trying to only list the tree items using dotree with the true flag, it somehow causes a hang and crash on Win 7. This is like a run away system memory crash of the interpreter, and not an error condition.



What is the proper way to scan through all the items in a database tree when simply trying to update and or delete itens?



dotree, or not to dotree that is the (my) question... ;>)



-- xytroxon
#11
You may have seen this humorous Common Lisp programmer view of users of other programming languages photo collage from the link to the Kvardek Du blog on reddit, if not then: http://kvardek-du.kerno.org/2010/01/how-common-lisp-programmer-views-users.html">Click Here!



What would a newLISPer look like?



-- xytroxon
#12
"Simplicity, for the sake of simplicity, is the hallmark of simple mindedness... Or of a Scheme programmer... But, I repeat myself..."

 -- xytroxon's 1st ASC (Asymptotic Space Complexity) corollary.



Schemers often decry the lack of TCO (Tail Call Optimization) in newLISP... Here is a great blog building on the author of Python shunning TCO in his language design... The blog looks at the history of TCO, and then addresses some of the finer points of Scheme's TCO programming "heresy"...



Abstract Heresies Blog:

http://funcall.blogspot.com/2009/04/you-knew-id-say-something.html">//http://funcall.blogspot.com/2009/04/you-knew-id-say-something.html



http://www.reddit.com/r/programming/comments/8fj0p/some_misconceptions_on_tail_recursion/">Link to reddit discussion


QuoteTo summarize, this point of view about tail recursion is based on these ideas:



    * It's purpose is to avoid writing looping constructs, which are somehow considered 'bad' by 'purists'. These weirdos 'think' in loops, then transform the code to be 'recursive with tail calls' when they write it, and then expect the compiler transform it back. This is academic mental gymnastics with no practical purpose.



    * People who like tail recursion are purposefully burdening their code in the name of 'mathematical' or 'theoretical' purity, but they expect the language implementor to bear the weight.



    * Any code that depends on tail recursion can easily be rewritten to use a looping construct instead. Such a rewrite is a trivial local transformation.



    * Inter-procedural tail recursion may have some performance benefit, but such benefit is very small at best, and the tradeoff is the loss of valuable debugging information.


At the conclusion of this "blog in progress", the author exposes the problem with TCO's Bubble Sort like "asymptotic space complexity" that "acts upon the entire program"...



Of course! Why didn't I think of that! ;)



-- xytroxon
#13
To get crypto.lsp to work with Windows, go to GnuWin32:

http://gnuwin32.sourceforge.net/">//http://gnuwin32.sourceforge.net/
QuoteGnuWin32 provides ports of tools with a GNU or similar open source license, to MS-Windows (Microsoft Windows 95 / 98 / ME / NT / 2000 / XP / 2003 / Vista / 2008)


Download and install the OpenSSL package.

http://gnuwin32.sourceforge.net/packages.html">//http://gnuwin32.sourceforge.net/packages.html





Edit file: C:Program Filesnewlispmodulescypto.lsp

(Note: For some strange historic reason, Windows "crypto.dll" is instead called "libeay32.dll")

(context 'crypto)

; set library to path-name of the library on your platform OS
;
(set 'files '(
"C:/Program Files/gnuwin32/bin/libeay32.dll" ;<<< add this line
"/usr/lib/libcrypto.so"
"/usr/lib/libcrypto.so.0.9.8"
"/usr/lib/libcrypto.so.0.9.7"
"/usr/lib/libcrypto.so.0.9.6"
"/usr/lib/libcrypto.so.4"
"/usr/lib/libcrypto.dylib"
))


>newlisp



>(load (string (env "NEWLISPDIR") "/modules/crypto.lsp"))



;; expected result from module manual

;; (crypto:md5 "ABC") => "902fbdd2b1df0c4f70b4a5d23525e932"



> (crypto:md5 "ABC")

"902fbdd2b1df0c4f70b4a5d23525e932"

>



;; expected result from module manual

;; (crypto:sha1 "ABC") => "3c01bdbb26f358bab27f267924aa2c9a03fcfdb8"



> (crypto:sha1 "ABC")

"3c01bdbb26f358bab27f267924aa2c9a03fcfdb8"

>



-- xytroxon
#14
newLISP newS / find, starts-with, ends-with, replace
November 11, 2008, 02:48:14 PM
While reviewing the newLISP manual, I have noticed a function argument "natural order" puzzle for confusing newbies and frustrating oldies ;)



Given:
(setq in-my-text "this is useful")

Find a string in text :
(find "this" in-my-text)

Okay. But  starts-with (and ends-with) form is:
(starts-with in-my-text "this")

Shouldn't starts-with follow the find argument order?
(starts-with "this" in-my-text)

The reason I ask is that I prototype my regex's using find. And after I optimized some old code that used find to starts-with (by simply changing the find keyword to start-with) , I had a hard time finding the problem because the code still "worked" but would not match anything!



Also, when building the string to be searched in place
(starts-with (string in-my-text "xyz" (somestringfunc)) "this")

"this" gets lost in the string noise... While:
(starts-with  "this" (string in-my-text "xyz" (somestringfunc)))
Remains understandable...



And while I am "on a roll" (ranting :)



replace also suffers from "string noise" syndrome.
(replace "this" (string in-my-text "xyz" (somestringfunc)) "with that")

While this form just looks cleaner and clearer to me.
(replace "this" "with that" (string in-my-text "xyz" (somestringfunc)))

--xytroxon
#15
Anything else we might add? / weblisp
November 06, 2008, 07:10:00 AM
In the effort to design "hands on" newLISP web demonstrations, here's "WebLisp.net - An Online Interpreter for the WebLisp Programming Language"

http://weblisp.net/">//http://weblisp.net/



And for Weblisp's efforts, the requisite reddit Lisp/Scheme naysayers ;)

http://www.reddit.com/r/programming/comments/7bpbn/weblispnet_an_online_interpreter_for_the_weblisp/">//http://www.reddit.com/r/programming/comments/7bpbn/weblispnet_an_online_interpreter_for_the_weblisp/



The interesting thing with the Weblisp demo, is the "canvas" tab...



Highlight the left edit area and delete. Click the "canvas" tab, scroll down and copy the code (below e.g.) over to the left edit area and click "run program".



-- xytroxon
#16
Anything else we might add? / In defense of newLISP
July 15, 2008, 11:26:26 AM
Jeff has written the thoughtful: "In defense of newLISP" on his Artful Code blog...

http://www.artfulcode.net/articles/in-defense-newlisp/">//http://www.artfulcode.net/articles/in-defense-newlisp/



Very well written Jeff :)



Fellow newLISPers can join the defense team on reddit...

http://www.reddit.com/r/programming/info/6rux8/comments/">//http://www.reddit.com/r/programming/info/6rux8/comments/
#17
I found this over at reddit:

http://reddit.com/r/programming/info/6jgnp/comments/">//http://reddit.com/r/programming/info/6jgnp/comments/



They are discussing this article:

"Why Arc is bad for exploratory programming" (arcfn.com)

http://arcfn.com/2008/05/why-arc-is-bad-for-exploratory.html">//http://arcfn.com/2008/05/why-arc-is-bad-for-exploratory.html


Quote...The problem, of course, is that Arc lacks libraries. Arc lacks basic functionality such as fetching a web page, parsing an XML document, or accessing a database. Arc lacks utility libraries to parse HTML pages or perform numerical analysis. Arc lacks specialized API libraries to access sites such as del.icio.us or Akismet. Arc lacks specialized numerical libraries such as a support-vector machine implementation. (In fact, Arc doesn't even have all the functionality of TRS-80 BASIC, which is a pretty low bar. Arc is inexplicably lacking trig, exp, and log, not to mention arrays and decent error reporting.)



To be sure, one could implement these libraries in Arc. The point is that implementing libraries detours you from the exploratory programming you're trying to do.



Paul Graham has commented that libraries are becoming an increasingly important component of programming languages, that huge libraries are now an expected part of a new programming language, and that libraries are an increasing important feature of programming languages. Given this understanding of the importance of libraries, it's surprising that Arc is so lacking in libraries. (It's also surprising that it lacks a module system or some other way to package libraries.) It's a commonplace complaint about Lisp that it lacks libraries compared to other languages, and Arc makes this even worse...


-----------



newLISP: The fully functional*, "Functional Language"...



* Dilithium crystals included!
#18

;(Note: This entire code section can be copied to a file for testing.)
;
; Hi Lutz!
;
; I'm having a problem with the following console code
; using newLISP v.9.3.11 on Win32 IPv4
;
(print "Press <Enter> key to input name. ")
(setq key (read-key))
(println "Key pressed: " key)
(if (= key 13)
(begin
(print "Enter name: ")
(setq line (read-line))
(println line)
)
)
;
; Program output:
; ---------------------------------------------------------
; Press <Enter> to input name. Key pressed: 13
; Enter name:
; ---------------------------------------------------------
;
; Program continues without allowing line to be input.
;
; So let's try a different key...
;
(print "Press </> key to input name. ")
(setq key (read-key))
(println "Key pressed: " key)
(if (= key 47)
(begin
(print "Enter name: ")
(setq line (read-line))
(println line)
)
)
;
; Program output:
; ---------------------------------------------------------
; Press </> to input name. Key pressed: 47
; Enter name: /
; ---------------------------------------------------------
;
; This time it allows input, but prepends "/" to the input
; prompt. Typing in the name and pressing <Enter> is now
; allowed.
;
; ---------------------------------------------------------
; Enter name: /xytroxon <Enter>
; /xytroxon
; ---------------------------------------------------------
;
; Pressing <Backspace> will erase the extra "/". So the
; problem is that the (read-key) function is not consuming
; the key press and is carried over into (read-line)...
;
; -- xytroxon
(exit)

#19
I found this humorously titled Python article:

http://wordaligned.org/articles/why-python-programmers-should-learn-python">"Why Python Programmers Should Learn Python"



Referencing this Java article:

http://www.keithbraithwaite.demon.co.uk/professional/presentations/#python">"Why Java Programmers Should Learn Python"



Posing this trivial programming problem:
Quote
Given the supplied library classes write some code in "quickSilver" to convert between word and decimal digits representations of positive integers less than 1001.



    e.g. "five seven three" → 573



    e.g. 672 → "six seven two"


The "Quicksilver Model Solution" presented to Java programmers was actually this (surprise!) Python code:


Quote
class WordsFromNumber:
    def __init__(self,number):
        self.representationOf = number
    def wordsOf(self):
        lsd = self.representationOf % 10
        msds = self.representationOf / 10
        if msds == 0:
            return self.wordFor(self.representationOf)
        else:
            return WordsFromNumber(msds).wordsOf() + " " +
                   self.wordFor(lsd)

def wordFor(self,numeral):
        return ["zero", "one", "two", "three", "four",
                "five", "six", "seven", "eight", "nine"][numeral]

class NumberFromWords:
    def __init__(self,words):
        self.representation = words
    def number(self):
        words =  split("\s",self.representation)
        return self.unpack(words)
    def unpack(self,words):
        if len(words) == 1:
            return self.numberFor(words[0])
        else:
            lswi = len(words) - 1
            lswi = words[lswi]
            msws = words[0:lswi]
            return self.numberFor(lsw) + 10 * self.unpack(msw)
    def numberFor(self,word):
        return {"zero" : 0, "one" : 1, "two" : 2, "three" : 3,
                "four" : 4, "five" : 5, "six" : 6, "seven" : 7,
                "eight" : 8, "nine" : 9}[word]


Which resulted in a less than stellar review by the WPythonPSLP author on the WJavaPSLP authors "Model Solution" Python implementation...



I have been amazed and awed to watch newLISP code questions being refactored on the newLISP Fan Club by it's clever members... (I SO miss lesser programmers being told to RTFM in those OTHER language groups ;) LOL



So this newLISP newbie thought it might be fun to see what you newLISP pros ;) can do to give the "newLiSP Model Solution" (or in Elica, etc.)...



-- xytroxon
#20
I saw this and thought Lutz might be interested. It is also of interest to other newLISPers who want to understand one of the core aspects of the inner working of newLISP.


QuoteFrom the newLISP FAQ:

6. Does newLISP have hash tables?

newLISP has fast and scalable symbol processing using red-black binary trees . Symbols in newLISP are used to build dictionaries for associative data access, similar to how hash tables are used in other scripting languages. See the newLISP manual for more details.


While some people scoff at the use of Red-Black Binary Trees in newLISP over hash tables. To me, they are the compelling reason I am drawn to use newLISP ;)

See: Problems with Hash Tablers:

http://enfranchisedmind.com/blog/2008/02/25/problems-with-hash-tables/">//http://enfranchisedmind.com/blog/2008/02/25/problems-with-hash-tables/



Now there appears to be a better method to impliment this data structure!



Robert Sedgewick, of the Department of Computer Science at Princeton University, recently gave a talk on an improved version of Red-Black trees called, Left-Leaning Red-Black Trees. (Sedgewick co-authored the 1978 paper that gave Red-Black Trees their name.)



In this talk, he shows how to reduce the Java code for Red-Black Trees from 400+ lines to under 80 lines. Yikes!!! (Although he doesn't show timings, the code reduction of this method should be more effiecent, hence faster.)



He also created an interesting PDF file on his talk, complete with explainations of how various Binary Tree methods work.

http://www.cs.princeton.edu/~rs/talks/LLRB/RedBlack.pdf">//http://www.cs.princeton.edu/~rs/talks/LLRB/RedBlack.pdf

(Note: 12+ megabyte Adobe PDF file.)



Dr. Robert Sedgewick is also the author of the famed "Algorithms in C/C++/Java" books.

http://www.cs.princeton.edu/~rs/">//http://www.cs.princeton.edu/~rs/



-- xytroxon