Page 5 of 6

Re: Experience of Learning Lisp

Posted: Mon Jul 20, 2009 4:36 pm
by tayssir
But he is making of this more of an issue than it really is, this is really no big deal, because every mature programmer knows about that and that is easily avoidable.
Maybe. I'm surely putting Lisp under a microscope. You may see more bizarre things if you do this with an organism rather than a brick. And that's the point.

"Pascal is for building pyramids — imposing, breathtaking structures built by armies pushing heavy blocks into place. Lisp is for building organisms..." ― Alan Perlis

Currently, I use lisp to generate code in other languages, avoiding horrendous errors like SQL injection attacks. When I took a hacking course (yes, such things exist), they demonstrated that PHP coders are supposed to do a lot of tedious text escaping. Clearly, Lisp users avoid such problems because they're probably using some easy-to-use tool which Just Takes Care of It. I spent part of a weekend writing a little lisp tool which generated PHP/SQL automatically, with appropriate input validation and type inferencing. The code which came out of it was solid.

(Maybe I should slap a LispWorks GUI on it and make it available as a public service.)

Nowadays, I see so much public-facing code with SQL injection vulnerabilities that I don't bother to fix them. I simply point it out to whomever has decisionmaking ability, with the knowledge that it won't be fixed, and move on to the next zillion tasks. (But I don't "get used to it," like I don't get used to quoted literals' undefinedness, or how you have to remember to set *READ-EVAL*. Something in the back of my mind still voices annoyance at statistically trading correctness for.. whatever benefit which could be obtained in a better way anyway.. and I'm reminded that I still look at programming as an outsider.)

So, that is how I might put other languages in perspective, unmagnified. I use Lisp to correct deficiencies of other languages.

(But that said, I've seen terribly undebuggable Real World ™ code in Lisp. In certain dimensions, it may be the worst code I've ever read. Ultimately, the good thing about CL — it's a Big Ball of Mud — can also be the downfall of some poor codemonkey blinking at perverse uses of DECLARE SPECIAL. ;) )

Re: Experience of Learning Lisp

Posted: Mon Jul 20, 2009 8:07 pm
by Paul
Unne wrote:
Paul Donnelly wrote:So you just have to remember to use a question mark to denote statements of fact. :? And have to disambiguate it when speaking, unless you consider spoken Lisp to be a tonal language.

Sorry, that naming convention just drives me batty. IMO, marking predicates with a “p” makes a heck of a lot more sense.
I don't really see them as statements of fact, I see them as questions. "Is this a hash table?" is the question, and the answer is true or false. But I don't know, which is better, "hash hyphen table hyphen pee" or "hash hyphen table question mark"? They're both pretty terrible to say aloud. You could say "hash table predicate" and everyone would just know there's a question mark on the end,
I read it as "hash table pee"; I don't pronounce punctuation; "hash-table?" is just pronounced "hash table" with rising intonation, and wants a pause after it; it's quite difficult to read - or understand - things like "(hash-table? x)" because that's two sentences, not one.
Tonal languages are fun though. Japanese Lispers would be happy. :D
But Japanese isn't a tonal language...pitch accent is not the same thing.

Re: Experience of Learning Lisp

Posted: Mon Jul 20, 2009 8:15 pm
by Paul Donnelly
Unne wrote:I don't really see them as statements of fact, I see them as questions. "Is this a hash table?" is the question, and the answer is true or false.
But that's exactly the problem. “Is this a hash table,” is a question, and can't possiblly be true or false. To be true or false, you have to be making an assertion. If it returned #y or #n, I'd have no objection. You wouldn't give points for a yes/no answer on a true/false test, would you?
findinglisp wrote:I haven't said much and don't care much on the general conversation, but I have to disagree with you on this one. When I first saw that convention in Scheme, it made instant sense to me. The "-p" convention only makes sense once you figure out that it stands for "predicate," and you happen to know what a predicate is, which many programmers won't.
Programmers with no exposure to logic! :shock: Then let's teach them logic. :ugeek:
findinglisp wrote:Ditto with using a prefix "n" for non-consing mutable routines. It took me a couple months of working with CL before I found a reference that described that. I still think Scheme's "!" notation makes more sense.
I agree. And at least “!” can be pronounced “bang”, which is no worse to say than “n”.

Re: Experience of Learning Lisp

Posted: Mon Jul 20, 2009 11:31 pm
by Unne
Paul wrote:But Japanese isn't a tonal language...pitch accent is not the same thing.
Sorry, you're right, I wasn't familiar with what "tonal language" meant. Informal Japanese uses intonation to denote whether something is a question or a statement, which is why I thought of it here.

Re: Experience of Learning Lisp

Posted: Tue Jul 21, 2009 4:06 am
by duncan
mrove wrote: How long did it take you to get started?
Dunno quite what you mean by that. In my second semester of Uni I took a class taught in scheme. I learned about as much scheme as I had to to do well in the class. The next semester I took an AI class taught in CL ( yes, I am an old man- that class is almost certainly taught in Java now), so I had to learn enough CL to nail the programming assignments. My basic strategy as an undergrad was to ignore everything other than the programming assignments and the exams, and figure the curve would fix things for me. That worked pretty well as long as I really did well on those. So I learned enough CL to do well on them.

I think that having pretty tough assignments can be helpful. Pretty close to the first thing I ever wrote in scheme was a reasonably general implementation of Dijkstra's painting algorithm. A few weeks after that I had to write a translator from a subset of Pascal to Scheme. I'd say that that was where I first started to get it- we were provided with a framework that made it clear that we had to make specific parsers by returning parsing functions from functions that made parsers based on their parameters. Very few people in that class actually understood the assignment.

For a couple of years after I left school I programmed in a variety of languages that could be best characterized by saying that none were actually Lisp. I did a fair bit of web programming in languages like Perl and Python. I also wound up getting sucked into a number of disastrous projects written in C, mainly because I was a pretty good C programmer at the time. I also got sucked into a few really disastrous projects written in C++, mainly because I was a pretty good C programmer- well, I eventually learned a bit of C++, but I also learned that being a good C programmer has almost nothing to do with being a good C++ programmer.

To tell you the truth I was about ready to stop programming just a few years after having spent four years and a lot of money studying CS at Uni. It seemed like every project I worked on was doomed to fail. But I started thinking about why the projects I was hired to work on were doomed to fail, and.. well choice of programming language was not the main factor. But- it was a factor. I kept thinking about what was wrong with the projects, and I kept remembering CL. Every time I had to go to lunch in order to let the project compile, I started thinking about Lisp.

So I guess that by the time I started programming mainly in CL I had already got it- that is, I knew what I wanted from it. On the other hand I feel like I am still getting it. I'm not a bad CL programmer, but there are a lot of really good CL programmers out there. I mean- the best CL programmers are pretty decent programmers by any measure. So I feel like I am still getting it... then again I feel the same way about Java. I think Java is vastly ionferior to CL, but I have to program in it to make a living. I learn a lot from great Java programmers, even if I think Java is basically flawed.

Anyway, you'll get started on the day that you write something in CL, as long as you write more the next day. The only way I can think of to not get started is to not write code. Of course you coulf ask: "When did you really get it?" But that might not be that useful, tbh.

Re: Experience of Learning Lisp

Posted: Tue Jul 21, 2009 6:13 am
by skypher
Paul,

I still don't get why (defvar *list* '(1 2 3)) at the REPL could not in any way be stuffed into read-only space by the implementation...

Re: Experience of Learning Lisp

Posted: Tue Jul 21, 2009 6:38 pm
by Paul
skypher wrote:Paul,

I still don't get why (defvar *list* '(1 2 3)) at the REPL could not in any way be stuffed into read-only space by the implementation...
At what point could it be stuffed into read-only space?

Re: Experience of Learning Lisp

Posted: Tue Jul 21, 2009 7:07 pm
by gugamilare
Paul wrote:
skypher wrote:Paul,

I still don't get why (defvar *list* '(1 2 3)) at the REPL could not in any way be stuffed into read-only space by the implementation...
At what point could it be stuffed into read-only space?
Well, this will be expanded into:

Code: Select all

(defvar *list* (quote (1 2 3)))
Then the compiler (or evaluator) read the "quote" special operator and move the list (1 2 3) to read-only space.

Re: Experience of Learning Lisp

Posted: Tue Jul 21, 2009 10:44 pm
by Paul
gugamilare wrote:
Paul wrote:
skypher wrote:Paul,

I still don't get why (defvar *list* '(1 2 3)) at the REPL could not in any way be stuffed into read-only space by the implementation...
At what point could it be stuffed into read-only space?
Well, this will be expanded into:

Code: Select all

(defvar *list* (quote (1 2 3)))
Then the compiler (or evaluator) read the "quote" special operator and move the list (1 2 3) to read-only space.
And if I type

Code: Select all

(defvar *foo* (list 1 2 3))

(defvar *list* (quote #.*foo*))
the QUOTE can't distinguish between what it sees now and what it saw in your example, so it moves my *foo* list into read-only space....and fails to comply with the standard!

Re: Experience of Learning Lisp

Posted: Wed Jul 22, 2009 6:10 am
by gugamilare
Paul wrote:And if I type

Code: Select all

(defvar *foo* (list 1 2 3))

(defvar *list* (quote #.*foo*))
the QUOTE can't distinguish between what it sees now and what it saw in your example, so it moves my *foo* list into read-only space....and fails to comply with the standard!
Yes, you are probably right that no one would do this. As a hypothetical example, though, the implementation could have added some tags to the value of *foo* when expanding #.*foo*, and quote would see that tag and wouldn't move it into read-only space.