Has it ever been done ? If not why so ?

Coders forum. Discuss techniques, swap code snippets, ask for help etc. relating to all forms of software development.
User avatar
gilesgoat
Sheepie Whore
Sheepie Whore
Posts: 27258
Joined: Wed Sep 03, 2003 7:54 am 0
Location: Monfalcone, Italy
Contact:

Has it ever been done ? If not why so ?

Post by gilesgoat »

So .. "nocturnal lectures" with books gotten "at random" I tried to re-read again a book about "SCHEME" .. and ... I really CANNOT digest it .. "my brain just shuts down VERY soon about it" ..

I still cannot really understand if "it's really a language for everything" or "if it's more suited for a certain class of problems than others" ..

I always heard that LISP was "sold" as "the language for AI" .. with all the neural networking of today .. is still relevant ?

And then made me think "has ANY video game EVER entierly been coded in Scheme/Lisp ?" .. "Could you make a PONG in Lisp/Scheme" ?

Fibonacci numbers and Pascal Triangles and crossing trees of list or such "can fuck off" .. "show me something else maybe more mundane but more at-the-ground" .. and I have NEVER seen it in such languages.

Of course I can WELL undersand if you tell me "you don't make a videogame using Matlab/SageMath script" .. but that is a language with a SPECIFIC purpose in mind that is NOT about games.

So "who uses those kind of things and what for really" ?

I don't think I ever seen ANY job offer sating "looking for a Lisp/Scheme expert" ... or maybe I never looked in the "correct" places for ..

So "what the lore/opinion" about those languages ?
Giles the billy goat
"Baa"
User avatar
pyroxian
Baaaaa!
Baaaaa!
Posts: 1308
Joined: Sat Nov 06, 2004 2:05 pm 0
Location: OX-ford

Re: Has it ever been done ? If not why so ?

Post by pyroxian »

Some of these languages are more academical than others... There's languages I learned at Uni that I've never used in the real world.

As tog ames - it's a matter of using the right tool for the right job. You _could_ use a hammer to put a screw in, but it's not going to be as good a job as using a drill and a screwdriver...
User avatar
Little stoned kiwi
Baaaaaa!
Baaaaaa!
Posts: 4597
Joined: Mon Oct 27, 2003 6:05 am 0
Location: Christchurch

Re: Has it ever been done ? If not why so ?

Post by Little stoned kiwi »

If they think you're crude, go technical; if they think you're technical, go crude. I'm a very technical boy.
User avatar
Little stoned kiwi
Baaaaaa!
Baaaaaa!
Posts: 4597
Joined: Mon Oct 27, 2003 6:05 am 0
Location: Christchurch

Re: Has it ever been done ? If not why so ?

Post by Little stoned kiwi »

In the interest of stimulating conversation I should tack on some thoughts.
That video really caught my attention with the circuit of a simple class A amplifier circuit. Modelling the circuit in Lisp and then plugging in some known values (such as the transistor being biased by 0.7v) it began calculating other values.
It also pressed home the emphasis on compile time calculation instead of runtime. Which is only going to lead to a more efficient runtime. It helped me understand template programming in C++ as that also pushes problem solving to the compiler side. Lisp does it better though, C++ is as ugly as sin.
AutoCAD uses Lisp for modules. I'm not very clued up on the how and why, but can imagine it makes a lot of sense as they would deal heavily with proportions rather than values. As a project to cut my teeth on I plan to make a terrain generator.
An old game called Abuse uses Lisp for its AI. There's a number of small example games and the like floating about You obviously won't be using it to make the next big thing in Unity/Unreal. But you might include Lisp in it.
If they think you're crude, go technical; if they think you're technical, go crude. I'm a very technical boy.
User avatar
Little stoned kiwi
Baaaaaa!
Baaaaaa!
Posts: 4597
Joined: Mon Oct 27, 2003 6:05 am 0
Location: Christchurch

Re: Has it ever been done ? If not why so ?

Post by Little stoned kiwi »

I was impressed by an example of a ray-tracer; function definitions and then this:

Code: Select all

(require :asdf)
(require :ray-tracer)

(in-package :ray-tracer)

(defun test (image-width image-height &optional (bound-objects t))
  (let ((camera (look-at (vector3 2.0 2.0 20.0)
                         (vector3 0.0 0.0 0.0)
                         (vector3 0.0 1.0 0.0)
                         1.0))
        (lights (list (make-light :location (vector3 -5.0 5.0 5.0)
                                  :color (color 0.0 0.0 1.0))
                      (make-light :location (vector3 5.0 5.0 5.0)
                                  :color (color 1.0 0.0 0.0))
                      (make-light :location (vector3 0.0 5.0 -5.0)
                                  :color (color 0.0 1.0 0.0))))
        (shapes (list (make-sphere :location (vector3 -2.0 0.0 0.0) :radius 1.0)
                      (make-sphere :location (vector3 0.0 1.0 0.0) :radius 1.0)
                      (make-sphere :location (vector3 2.0 0.0 0.0) :radius 1.0)
                      (make-plane :distance-from-origin -1.0))))
    (write-targa "/Users/mika/projects/lisp/ray-tracer/test.tga"
                 (render-scene (make-scene :objects (mapcar #'(lambda (shape) (make-object :shape shape :color white)) shapes)
                                           :lights lights)
                               camera image-width image-height bound-objects))))

(defun test-2 (image-width image-height &optional (bound-objects t))
  (let ((camera (look-at (vector3 8.0 2.0 5.0)
                         (vector3 0.0 0.0 0.0)
                         (vector3 0.0 1.0 0.0)
                         1.0))
        (lights (list (make-light :location (vector3 -5.0 5.0 5.0)
                                  :color (color 0.0 0.0 1.0))
                      (make-light :location (vector3 5.0 5.0 5.0)
                                  :color (color 1.0 0.0 0.0))
                      (make-light :location (vector3 0.0 5.0 -5.0)
                                  :color (color 0.0 1.0 0.0))))
        (shapes (let ((l nil))
                  (dotimes (row 10)
                    (dotimes (col 10)
                      (setq l (cons (make-sphere :location (vector3 (+ -5.0 col) (+ -5.0 row) 0.0)
                                                 :radius 0.5)
                                    l))))
                  l)))
    (write-targa "/Users/mika/projects/lisp/ray-tracer/test.tga"
                 (render-scene (make-scene :objects (mapcar #'(lambda (shape) (make-object :shape shape :color white)) shapes)
                                           :lights lights)
                               camera image-width image-height bound-objects))))
A function calling functions and providing the data. One big function that produces a tga image as its output, the output of the compiler if you want. From a ray-tracing perspective is looks like a script you'd make for a ray-tracer...because it is and will run as a script?
If they think you're crude, go technical; if they think you're technical, go crude. I'm a very technical boy.
User avatar
tufty
Sheepie Whore
Sheepie Whore
Posts: 12523
Joined: Fri Jan 07, 2005 4:52 pm 0
Location: French Alps

Re: Has it ever been done ? If not why so ?

Post by tufty »

gilesgoat wrote:Could you make a PONG in Lisp/Scheme" ?
First programming project I did with both of my sons. It then got converted to ball-centric pong (ball stays central, playfield and players move, spinpong (same thing, but ball contacts add rotation to the playfield) and various other even harder to play versions - 3 player, 6 payer, etc.
"massive retard™", "full of shit™", "tiny bitch™", "retarted™", "a bit of a one trick pony™", "petty™", "simple minded idealistic twat™", "miserable humourless fucker™"
User avatar
tufty
Sheepie Whore
Sheepie Whore
Posts: 12523
Joined: Fri Jan 07, 2005 4:52 pm 0
Location: French Alps

Re: Has it ever been done ? If not why so ?

Post by tufty »

Pong is possibly the best first programming project for kids. It's simple conceptually and in terms of implementation, and you can use it to introduce a large number of programming concepts and constructs, from simple data structures and functions through to abstractions, functions as data, OO, implementing different types of OO, mutability and immutability, multi-threading and so on. All through pong.
"massive retard™", "full of shit™", "tiny bitch™", "retarted™", "a bit of a one trick pony™", "petty™", "simple minded idealistic twat™", "miserable humourless fucker™"
User avatar
gilesgoat
Sheepie Whore
Sheepie Whore
Posts: 27258
Joined: Wed Sep 03, 2003 7:54 am 0
Location: Monfalcone, Italy
Contact:

Re: Has it ever been done ? If not why so ?

Post by gilesgoat »

Little stoned kiwi wrote:I was impressed by an example of a ray-tracer; function definitions and then this:

Code: Select all

(require :asdf)
(require :ray-tracer)

(in-package :ray-tracer)

(defun test (image-width image-height &optional (bound-objects t))
  (let ((camera (look-at (vector3 2.0 2.0 20.0)
                         (vector3 0.0 0.0 0.0)
                         (vector3 0.0 1.0 0.0)
                         1.0))
        (lights (list (make-light :location (vector3 -5.0 5.0 5.0)
                                  :color (color 0.0 0.0 1.0))
                      (make-light :location (vector3 5.0 5.0 5.0)
                                  :color (color 1.0 0.0 0.0))
                      (make-light :location (vector3 0.0 5.0 -5.0)
                                  :color (color 0.0 1.0 0.0))))
        (shapes (list (make-sphere :location (vector3 -2.0 0.0 0.0) :radius 1.0)
                      (make-sphere :location (vector3 0.0 1.0 0.0) :radius 1.0)
                      (make-sphere :location (vector3 2.0 0.0 0.0) :radius 1.0)
                      (make-plane :distance-from-origin -1.0))))
    (write-targa "/Users/mika/projects/lisp/ray-tracer/test.tga"
                 (render-scene (make-scene :objects (mapcar #'(lambda (shape) (make-object :shape shape :color white)) shapes)
                                           :lights lights)
                               camera image-width image-height bound-objects))))

(defun test-2 (image-width image-height &optional (bound-objects t))
  (let ((camera (look-at (vector3 8.0 2.0 5.0)
                         (vector3 0.0 0.0 0.0)
                         (vector3 0.0 1.0 0.0)
                         1.0))
        (lights (list (make-light :location (vector3 -5.0 5.0 5.0)
                                  :color (color 0.0 0.0 1.0))
                      (make-light :location (vector3 5.0 5.0 5.0)
                                  :color (color 1.0 0.0 0.0))
                      (make-light :location (vector3 0.0 5.0 -5.0)
                                  :color (color 0.0 1.0 0.0))))
        (shapes (let ((l nil))
                  (dotimes (row 10)
                    (dotimes (col 10)
                      (setq l (cons (make-sphere :location (vector3 (+ -5.0 col) (+ -5.0 row) 0.0)
                                                 :radius 0.5)
                                    l))))
                  l)))
    (write-targa "/Users/mika/projects/lisp/ray-tracer/test.tga"
                 (render-scene (make-scene :objects (mapcar #'(lambda (shape) (make-object :shape shape :color white)) shapes)
                                           :lights lights)
                               camera image-width image-height bound-objects))))
A function calling functions and providing the data. One big function that produces a tga image as its output, the output of the compiler if you want. From a ray-tracing perspective is looks like a script you'd make for a ray-tracer...because it is and will run as a script?

It's NOT very impressive to me because "it's not complete" .. hell knows how long are the definitions/implementations of all those functions !

write-targa .. eh .. or render-scene .. "show me how it's made" ...

[edit] - I mean even in CPP you could write a thing like :

A = Render_Scene ( objects_list );
Write_Targa(A, "/user/myscene.tga");

Doesn't really "say much" ...
Giles the billy goat
"Baa"
User avatar
KlaxonCow
Baaaaaaa!
Baaaaaaa!
Posts: 8444
Joined: Fri Dec 13, 2002 3:46 am 0
Location: A large grassy field.

Re: Has it ever been done ? If not why so ?

Post by KlaxonCow »

I'm going to do the short answer today.

LISP is Turing complete. Therefore, the answer is "yes, it can be done".

But I offer no guarantees nor promises on whether it'd be fast or any fun to code or whether it'll have the performance to be remotely playable.

Only that tiny mathematical nugget that, by Turing completeness, it can - in theory - be done.

Yogi Berra wrote:In theory, there is no difference between practice and theory. In practice, there is.
"Words ought to be a little wild - for they are assaults of thought on the unthinking."
- John Maynard Keynes
User avatar
Little stoned kiwi
Baaaaaa!
Baaaaaa!
Posts: 4597
Joined: Mon Oct 27, 2003 6:05 am 0
Location: Christchurch

Re: Has it ever been done ? If not why so ?

Post by Little stoned kiwi »

You can lead a horse to water.
If they think you're crude, go technical; if they think you're technical, go crude. I'm a very technical boy.
User avatar
gilesgoat
Sheepie Whore
Sheepie Whore
Posts: 27258
Joined: Wed Sep 03, 2003 7:54 am 0
Location: Monfalcone, Italy
Contact:

Re: Has it ever been done ? If not why so ?

Post by gilesgoat »

KlaxonCow wrote:I'm going to do the short answer today.

LISP is Turing complete. Therefore, the answer is "yes, it can be done".

But I offer no guarantees nor promises on whether it'd be fast or any fun to code or whether it'll have the performance to be remotely playable.

Only that tiny mathematical nugget that, by Turing completeness, it can - in theory - be done.

Yogi Berra wrote:In theory, there is no difference between practice and theory. In practice, there is.
This is like to say that "in theory" you can code a raytracer using LIFE or WIRE or anything else that is turing complete.

In theory can be done, in practice it's pointless.

[edit] - at least continuing to browse a bit that Scheme book ( at late night ) for the FIRST time I saw something that made me think "MAYBE that guy ( that wrote the book ) wasn't that wrong !" ( or wasn't such a "lisp maniac" ) ..

There's the chapter about recursion ( which seems to be "the core" of lisp/scheme ) goes with a classic example of Fibonacci Numbers .. and quite soon gives you "a magnificent recursive implementation". But INCREDIBLY after some explanation does "a better analysis of what actually happens with that function" how many calls/push/how the arguments/stack go ..

And tells you "actually is a bit of a shit implementation", it's not efficient as it could.

And it was kinda of a "warning" about how recursion can be so nice to implement at first sight but not necessarely be the best possible implementation.

Then goes into explaining about "Loops" and how sometime is better to avoid recursion.

Then it even goes much further in this case by using some "mathemagical weirdness" ( but that is explained ) showing that is possible to derive an "exact formula" for the Nth Fibonacci number that would compute it "in one single go" the formula would be exact BUT it involves irrational numbers so it can only give an approximate result in practice.

I.e. someting like FIB(n) = ( weird shit with N and 1/SQRT(5) ) i.e. "golden ratio".
Giles the billy goat
"Baa"
User avatar
KlaxonCow
Baaaaaaa!
Baaaaaaa!
Posts: 8444
Joined: Fri Dec 13, 2002 3:46 am 0
Location: A large grassy field.

Re: Has it ever been done ? If not why so ?

Post by KlaxonCow »

gilesgoat wrote:Then goes into explaining about "Loops" and how sometime is better to avoid recursion.
Yeah, sometimes the clever thing is not to be too clever.

I had a binary search thing in C / C++. I did it recursively at first, because it's a naturally recursive thing.

Check the midpoint. If it's what you want, then stop, as you've found it. Split the list in two. If it's higher than what you want, then check the lower half. If it's lower, then check the higher half. Rinse and repeat, until you find it or the list becomes a single element and you've not found it, so it's just not in the list.

But the thing is, this means a subroutine that calls itself. So you've got the subroutine calling overhead - push the address, set up the stack for parameters, return at the end, etc. - and you're using the stack as well, because you've got to keep pushing and popping the return addresses (and maybe parameters, depends on calling convention).

So you're using memory - for the stack - and CPU cycles - for all the "call subroutine" overhead.

I rewrote it as a flat function. Instead of recursion, it's just a "while" loop. Does exactly the same thing, but faster and with fixed memory usage.

Sometimes, "being dumb" is the cleverest thing you can do.
"Words ought to be a little wild - for they are assaults of thought on the unthinking."
- John Maynard Keynes
User avatar
gilesgoat
Sheepie Whore
Sheepie Whore
Posts: 27258
Joined: Wed Sep 03, 2003 7:54 am 0
Location: Monfalcone, Italy
Contact:

Re: Has it ever been done ? If not why so ?

Post by gilesgoat »

Ok ... at this point "I wonder if any psychologist could explain me what's SO non-LISP into my brain" ..

I am TRYING to read this book about "Scheme" .. and it just gets always and ever to the point where "my brain REFUSES/become ANTAGONIST" about what's is written into.

If there's somoene which mind is "the ANTI-LISP" MINE IS !

It goes from "I kinda understand what they are explaining" .. to "it's not super clear what they are saying" .. to "I can't rememeber this crap it's too weird" .. to "WHY ON EARTH I AM EVEN TRYING TO UNDERSTAND ALL THIS" to finally "I DON'T WANT TO SEE THIS THING FOR THE REST OF MY LIFE !".

It gets to a point for me of "extreme repulsion" .. I DO NOT KNOW WHY .. but so it is ..

I suppose we all have "things" that "cannot enter our brains no matter what" .. this for me is LISP/SCHEME for sure.

It gets the point it really "hurts my brain and my feelings" ... I don't know WHY "I am so adverse to it" ...

My only "guess" is that "it forces a way of thinking that is not my natural way of thinking" or the heck I know what else ...

When I code "I see problems and code in a certain way" .. someway it would appear Scheme "screws all that so badly I can't see a thing any more" ..

But yeah, if there's a "definition" of "what is heaven for some is hell for another" that's LISP for me "part of my personal hell".

There's another "technical thing/issue" that gives me "a similar sort of traumatic experience" but I don't feel like talking here about it now, I am too "LISP traumatized" for that.

And a part of me still asks "why, why it's so ?" ..

But another part of me also tells me "()"£$()£*$)"£*$) LISP AND SUCH, JUST FORGET IT !" ..

Mah ...

One thing I can GUARANTEE you, if there are 2 jobs offers, one to showel manure and one about LISP coding and I'd have to absolutely pick up one of the two I am taking the first one immediately !
Giles the billy goat
"Baa"
User avatar
Dio
Sheepie Whore
Sheepie Whore
Posts: 18887
Joined: Mon May 31, 2004 1:08 pm 0
Location: Newcastle UK

Re: Has it ever been done ? If not why so ?

Post by Dio »

If you're anything like me, it's beacuse you've got an execution model for C-like imperative languages. You know that what's going on at the backend of a computer is ordered execution of instructions in machine code. You don't see how LISP maps efficiently to that implementation. Neither does it fit in well with your understanding of declarative / functional implementations (that you must have some grasp of since you can handle hardware). It's like when I first learned C, I didn't get pointers properly until I realised that *(&x) is x. As soon as I realised it was just an address it all made sense.

If I really wanted to understand LISP, I'd look at how you build a compiler for it and so learn what the implementations are for the language constructs and then I think I'd get along a lot better with it. But I've never felt the need.
User avatar
gilesgoat
Sheepie Whore
Sheepie Whore
Posts: 27258
Joined: Wed Sep 03, 2003 7:54 am 0
Location: Monfalcone, Italy
Contact:

Re: Has it ever been done ? If not why so ?

Post by gilesgoat »

Dio wrote:If you're anything like me, it's beacuse you've got an execution model for C-like imperative languages. You know that what's going on at the backend of a computer is ordered execution of instructions in machine code. You don't see how LISP maps efficiently to that implementation. Neither does it fit in well with your understanding of declarative / functional implementations (that you must have some grasp of since you can handle hardware). It's like when I first learned C, I didn't get pointers properly until I realised that *(&x) is x. As soon as I realised it was just an address it all made sense.

If I really wanted to understand LISP, I'd look at how you build a compiler for it and so learn what the implementations are for the language constructs and then I think I'd get along a lot better with it. But I've never felt the need.
Apparently there were some "LISP Machines" computers with SPECIAL HW specially designed for LISP, unfortunately it seems most of those projects were for DARPA/kinda "secret" I can't find any HW documentation/schematics of what sort of HW they used and how.

At least one used "a dedicated 32 bits CPU" and some other in reality was a C implementation however further read ( of Wikipedia ) seems to suggest that "most" were "emulations/implementations of LISP done usually in C".

So one would be tempted to assume that "actually you can't make a CPU dedicated for LISP" or it's been done very rarely, I think it may be a case of "you are trying to make a sphere where all you have is small cubes".
Giles the billy goat
"Baa"
Post Reply