A revelation

Miscellaneous Forums/General Discussion/A revelation

Just been reading over all those WIN VS LINUX VS MAC posts...

This may get some backs up and im sorry if it does (and ive had a beer or 2 so bear with me).

All this forum war making on 'which os' has got me thinking.

All these people who dis everything but windows etc. without actually trying anyrhing else* are.. to put a finer point on it... scared.
*(i mean really trying, not getting put off if their palmtop doesnt work first time or soundcard isnt working without nudging..)

Scared because they know nothing else and all other OSes are alien ground. How do i know? because i was the same, i grew up on a diet of dos/windows for my pc and knew nothing else. I was happy in my little world of "i know something about windows you dont"

My point: buy a second harddisk / machine and play around with an alternative!

However...

At the end of the day, its what does the job for you:
If you like your p&p, easy 2 use, sniffing dogs, DX, 33MB in Ram worth of clock and calendar(vista sidebar) then choose windows,
If you want a very powerful, secure, expandable but horribly complicated os choose linux,
If you want the best of both, choose the new macOS(the one with the UNIX based kernel).

But dont dis until you have fully tried all.
Thats it, argument over!

awaiting bashing....

There was an OS war on this forum?

Yep:
http://www.blitzbasic.com/Community/posts.php?topic=67486#754056
http://www.blitzbasic.com/Community/posts.php?topic=66978#752370
http://www.blitzbasic.com/Community/posts.php?topic=67061#751823
http://www.blitzbasic.com/Community/posts.php?topic=67146#750487
just a few

Well, you get fan-boys for all OSs. Just pick the one you like and be happy. :)

agreed

Well that was all very civil.

Everytime a new OS out, such topic pops...

That's good at least it shows the cross-platform ability of BMax.

Well, you get fan-boys for all OSs.
Who'd be a fanboy for an OS? I mean there must be cooler things to be fanatical about? That's like being a WordPad or Mine Sweeper fanatic. "Man you don't know jack. Mine Sweeper is way better than Spider Solitaire!". In fact I don't think I know anybody who is an OS fanboy. Where do you meet these crazy weirdos?

That's like being a WordPad or Mine Sweeper fanatic.

If you don't prefer Vista's Mine Sweeper over XP's Mine Sweeper you're an ass!

Good post Dan, and I agree. That same argument can be made for programming languages, too, and it's why I think everyone should learn Lisp. The language is truly the most powerful language I've ever seen. The expressive power of the language is not burdened by being overly verbose, either.

For instance, how would you write a function in any other language that takes a function as an argument, and returns a function that is identical to the function passed except that this new function is memoized (i.e. the new function that stores the results for previous lookups so when it is passed the same arguments it gets the results from a lookup table instead of computing them all over. Useful for functions that spend a long time computing their results)

In Lisp, the code to define a function that creates memoized functions is this:
(defun memoize (fn)
   (let ((cache (make-hash-table :test #’equal)))
     #(lambda (&rest args)
       (multiple-value-bind (val win) (gethash
         (if win
             val
             (setf (gethash args cache)
                   (apply fn args)))))))


(defun memoize (fn)
(let ((cache (make-hash-table :test #’equal)))
#’(lambda (&rest args)
(multiple-value-bind (val win) (gethash
(if win
val
(setf (gethash args cache)
(apply fn args)))))))

Now I know why they started applying the word "code" to computer programming.

lol - Surely that is more understandable - or at least less intimidating - to a non-coder than the following chunk of C++ template code

template <class T, class D1, class D2>
quantity< 
    T
  , typename mpl::transform<D1,D2,plus_f>::type  // new dimensions
>
operator*(quantity<T,D1> x, quantity<T,D2> y)
{
    typedef typename mpl::transform<D1,D2,plus_f>::type dim;
    return quantity<T,dim>( x.value() * y.value() );
}


It all comes down to your frame of reference.

It all comes down to your frame of reference.

That's true, when I see C++ code, I can't help see through the syntax and only view the logic of it.

That C++ code segment however, is one exception. As with any language, it's up to the coder to keep things readable, which your C++ example is definitely not.

IMO, overused templates, variable names like T, D1, D2, and dim, and the lack of comments to name a few is what is making that example "cryptic".

But what you said is still true: it all comes down to your point of reference.

Yeah, that's not a very good C++ example. I just grabbed the first bit of cryptic looking C++ I could find on the web. Surely though, things like some function pointers and pointers to pointers can be rather difficult to read and follow even if you know C++. Well, maybe not the pointers to pointers, although they always prove to be difficult for me to read and follow - of course, I am a C++ noob.

The thing with Lisp is that, the parenthesis are the only strange part about it's "syntax." It doesn't really have much syntax because it's so extremely regular. It doesn't have special case syntax for templates or for macros or for anything else. I've found it - syntactically at least- relatively easy to pick up. Conceptually though - with the ability to utilize the full power of the language within macro's, which gives you the ability to write code that generates code - and the other features like being able to compile functions on teh fly, passing functions around as arguments, lexical closures for both variables and functions, and it's extremely flexible object orientation protocol are proving to be difficult to fully grok.

Surely though, things like some function pointers and pointers to pointers can be rather difficult to read and follow even if you know C++. Well, maybe not the pointers to pointers, although they always prove to be difficult for me to read and follow - of course, I am a C++ noob.

I agree, there are some areas of C/C++ that need improving; it's surely not a perfect language. Pointers and their relationship to arrays are probably some of the most difficult areas of C++.

Since these concepts are based on physical hardware (the fact that all memory has a numbered location), I also had difficulty understanding them at first, coming from BASIC, a language that completely abstracts these hardware concepts into a more algebraic form.

But once you understand that a pointer is simply a integer referring to a location in memory, it's not quite so hard to understand.

Languages like C# look very promising in that they can eliminate many of these complexities, while retaining the power of the C++ syntax and it's features.

Well, I understand pointers themselves. I understand that the name of an array, when passed to a function, is really just a pointer to the head of a contigous block of memory. Function pointers just get screwy because of the syntax needed:

long* (*fn_pointer)( int*, int*)

Whereas in lisp you can simply store a function in any symbol...
(setf my-symbol #'make-hash-table)

Setf sets the value of the symbol "my-symbol" to the function "make-hash-table" (every symbol can have a variable value and a functional value. To get at the functional value you use the #' syntax...so in this example my-symbol is set to the function stored under the symbol "make-hash-table".)

To call this function, just like any other function call in Lisp, all you have to do is put that symbol as the first element of a lisp form...
so

(my-symbol :size 200)

now creates a hash-table of 200 elements. It's equivalent to the call

(make-hash-table :size 200)

Both calls will, in fact, will produce the exact same machine code.

Another simple thing I love about lisp...keyword parameters. Keyword parameters are named parameters (like :size in the function call above) that may be omitted from the function call, or they can be placed *in any order*.

In most languages, you can have optional parameters, but they won't let you omit any of the parameters out of order. I.e: You could decide to provide only the 1st and 2nd param, but if you wanted to provide only the 5th you'd have to include the 4 before it. Not so with Lisp.

You can also call make-hash-table with a :rehash-size parameter, a :test parameter (which is a function which is used to compare the provided key to the stored key), etc. Any and or all parameters may be included or omitted.

But truly the most powerful part of lisp is the fact that you can use the full power of the language as a "pre-compiler" using Lisps macro system. And, given Lisps regularity of syntax, it is easy to treat code as data and manipulate it prior to compiling it. You could for instance write a Macro that allowed you to write C++ code that would then get translated to lisp. Granted, that'd be a lot of work, but it is possible. One example of a cool macro is Lisps built in LOOP macro, which defines it's own mini language and allows you to type something like this:

(defparameter *random* (loop repeat 100 collect (random 10000)))

(loop for i in *random*
counting (evenp i) into evens
counting (oddp i) into odds
summing i into total
maximizing i into max
minimizing i into min
finally (return (list min max total evens odds)))

*random* here is a variable with a list of 100 random values, 0-9999. The loop itself should be quite clear as to what it is doing. It creates local variables with the "into" keyword. Counting, summing, maximizing and minimizing are all keywords in this little mini-language, and direct the loop to do just as their name implies. Finally, the loop returns a list of the values accumulated during the loop.

The loop macro is completely non-lispy, but gets turned into lisp code before being compiled. This is because the above code gets passed to the loop macro, which then processes the code (it's basically a mini-compiler for this domain specific language) and turns it into lisp code that actually gets compiled.

This of course means that you can write your own scripting language with any syntax you desire and suffer no speed loss because it actually gets translated to lisp prior to compilation.

Anyhow, I'll quit promoting Lisp before I get *too* annoying. ;) It just pains me to see such a great language, with features that other languages are finally sort of half-arsed implemeneting, get such little love all because of it's "strange syntax." The syntax isn't what makes Lisp difficult. No, it's the freedom of expression it gives you - it's overwhelming at first having virtually no constraints put on you by the language.

Sculpture:
I thought that the first code you listed above, looked just as cryptic as the C++ code you also listed.
But that second example looked kinda cool.

But I want to know; where did you pick up Lisp? and can you recommend a site or two, which gives you a some nice tutorials?

also, are there some game development libraries for Lisp?

Hehe, yeah, I suppose it is just as undecipherable as the C++ if you don't know the functions and such - but at least on a syntactic level it's simpler (it's just parenthesis and words...not a ton of symbols and rules about where those symbols can and can't go.)

Regarding your questions: I'm far from a lisp expert. I just started learning it a couple months ago because BlitzMax wasn't the right language for my MUD server. I needed multi-threading. The fact that Lisp allows things such as a custom scripting language, remote debugging of a live application, etc, just made it all the sweeter for this particular project.

Regarding libraries, that's the weak spot with Lisp. I suppose that's the main reason I and others try and get people interested in the language - the more that hop on board the more libraries you'll find. As of right now I know there is an SDL wrapper that can be used for games, along with others that can be found here: http://lispbuilder.sourceforge.net/

There are many Lisp implementations (unlike say Python where there is the one canonical implementation of the language), and while most of them follow the Lisp language standards closely there are a lot of areas that the standard doesn't clarify how things should be done. Networking and sockets, for instance, where each implementation has it's own library. If you want to work with windows, Corman Lisp has an unlimited trial and is fairly cheap
http://www.cormanlisp.com/

The two big name Lisp implementations are Allegro Common Lisp and LispWorks. These have much more powerful IDE's and a ton of other features that can be read about on their respective websites:

http://www.franz.com/
http://www.lispworks.com/

They both offer free trial editions, and both run on Windows and Linux and I believe Mac, too.

If you want a free implementation and are using Linux, I'd look at either SBCL Common , CMU Common Lisp, Lisp, or CLISP.

While there aren't a ton of game development oriented libraries out there for lisp, you CAN interface with C/C++ code through Lisps foreign function interface. So, like BlitzMax, you could write a wrapper for most of the popular physics/3D engines if you felt up to the task.

Lastly, regarding learning the language, I'd recommend the following books in the following order. I'm sure there are others that are as good or better but these are the only ones I've managed to read (or partially read) as of yet. All of them are free, too.

Lisp - A gentle introduction (a very basic but hands on book that'll engrain the fundamentals of the language into your mind. I'd recommend doing most/all of the exercises in the book. If you've done a bit of programming before, this should be a pretty quick read)
http://www.cs.cmu.edu/afs/cs.cmu.edu/user/dst/www/LispBook/index.html

Practical Common Lisp - A good book that'll show you how to put Lisp to use in real-world programs.
http://www.gigamonkeys.com/book/

Successful Lisp - a good overview of the language. I haven't read it all but have used it as a reference and as a secondary text along with Practical Common Lisp.
http://www.psg.com/~dlamkins/Site/sl.html


On Lisp - I've started working through this but am going back to finish up Practical Common Lisp first. The techniques in this book begin to expose the power of Lisp and many techniques that just aren't feasible to attempt in other languages.
http://www.paulgraham.com/onlisptext.html

Realistically I should add that, I wouldn't use Lisp for a casual game or something where Blitz is much more suited to the job. Also, doing low level programming in Lisp is a bit trickier than it is in Blitz or C++ or something where you have easier access to the raw memory and can bit twiddle easily. It's not that it isn't possible but just that it's not idiomatic in Lisp.

If nothing else though, learning the language will really open your mind and expand your horizons, so to say. It's *really* different from C++/C#/Blitz/Java in ways that will, if nothing else, make you a better programmer when you program in those languages.

Sorry again for the hi-jack Dan. At least it's sort of on-topic ;).

Actually, this has inspired me to try out Linux (soon, once I've got some time to devote to learning it), even though I've been hesitant to do so in the past.

Thats ok, its made interesting reading :)

Its amazing the kind of thread a drunken rant can start ;)

Actually, this has inspired me to try out Linux
- i reccomend debian based (i think its the easiest) ubuntu especially. Its weird at first but persevere and you will discover a whole alternative world with helpful forums and support threads.

Hang on, this can't be right, we got civil and making sense going on in this thread. I seem to be on the wrong forum,,, no it's blitz. How very odd. Must be an anomaly. ;o)

it was rather polite wasnt it ol' chap :)