|
|
|
|
|
|
| |
| |
|
|
|
|
| |
| |
|
|
> I'm pretty sure if I tried to explain the rules of gravitation to a girl,
> I wouldn't _have_ a girlfriend for very long...
She wasn't interested in space before she met me, it's only when she saw
Saturn through the telescope that she thought it was really cool and started
to read a lot about it - she asks lots of questions. But it's a very fine
line to tread, if I try to make things too simple I get the "I'm not dumb -
god who did you date before me" line, but go too far the other way and you
get "ok i don't understand, i give up, don't bother".
> Heh, oh well. I was expecting the reply to be "I can't think of anything
> that Haskell would be useful for". ;-)
Well that too :-) I guess I just don't do much of the sort of stuff Haskell
would be really good for. OOC are there any "classic" examples of real life
stuff Haskell does better than other languages? Might give me some ideas.
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
scott wrote:
>> I'm pretty sure if I tried to explain the rules of gravitation to a
>> girl, I wouldn't _have_ a girlfriend for very long...
>
> She wasn't interested in space before she met me, it's only when she saw
> Saturn through the telescope that she thought it was really cool and
> started to read a lot about it - she asks lots of questions. But it's a
> very fine line to tread, if I try to make things too simple I get the
> "I'm not dumb - god who did you date before me" line, but go too far the
> other way and you get "ok i don't understand, i give up, don't bother".
Hmm. Apparently you have a very cool girlfriend...
[I'm not going to continue this train of thought any further. I don't
want to depress myself.]
>> Heh, oh well. I was expecting the reply to be "I can't think of
>> anything that Haskell would be useful for". ;-)
>
> Well that too :-) I guess I just don't do much of the sort of stuff
> Haskell would be really good for. OOC are there any "classic" examples
> of real life stuff Haskell does better than other languages? Might give
> me some ideas.
Parsers, compilers, interpretters, simulations, anything that does
complex algorithmic processing. (I hear it's popular for things like
financial modelling and IC design.)
Hypothetically Haskell _should_ be an excellent choice for things like
cryptography and data compression, but in practise the performance tends
to be suboptimal.
Anything where correctness is more important than performance or even
possibly development cost. (I hear Haskell is sometimes used in
safety-critical fields like avionics - although you don't actually *run*
Haskell on embedded systems, you use it to generate the code that will
be run, with strong guarantees about correctness of the generated code.)
Anything where parallel processing is useful. In theory this is the
Killer Advantage of Haskell; normal Haskell programs consist of about
98% pure code, which is inherantly thread-safe and hypothetically easy
to parallelise. Again, in practise performance is a little too variable
to claim that Haskell is the killer language for compute-bound problems.
As examples of some of the above:
- The Haskell Platform comes with Parsec, an impressive parsing library
which I'm *sure* I must have documented here at least once before.
- GHC itself is written in 98% Haskell. (Stuff like the garbage
collector and the I/O subsystem is written in C.) Think about it - what
do compilers do? They parse stuff, and they transform code trees. These
are both tasks which Haskell is excellent at.
- There's a small cottage industry for writing things like theorum
provers, constraint solvers, neural networks, genetic algorithms and the
like using Haskell. Writing these things typically isn't difficult;
making it efficient is the tricky part. ;-)
- Hell, you may even remember that I wrote a small logic equation solver
a while back. Remember? It could not only join to lists together, but
also UNjoin them in every possible way. ;-) OK, not terribly useful, but
quite satisfying to get it to work...
- I personally have also written ray tracers, fractal generators,
compression and cryptography algorithms, and all sorts of other crazy
stuff. If that's your thing, Haskell is a great way to write code
quickly. (Not necessarily code that runs quickly, sadly.)
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
> simulations,
I heard Haskell has OpenGL capability, how easy is that to get running -
then we might be talking :-)
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
scott wrote:
> I heard Haskell has OpenGL capability, how easy is that to get running -
> then we might be talking :-)
Heh, OK, it's just taken me the entire morning to figure this out.
(Documented? What do you mean documented? Why would it be documented??)
First: The Haskell Platform includes OpenGL out-of-the-box, so it should
Just Work(tm).
Second: The documentation for OpenGL is missing, which made me spend 20
minutes trying to figure out why it wasn't there. Querying the package
list confirms that OpenGL actually *is* there, it's only the
documentation that's missing. (Thanks, guys...)
Third: I compiled a simple OpenGL program, and it crashed with "cannot
find glut32.dll". I don't know if that's because I don't have a 3D card
on this machine or what. Anyway, it took a while to fix it! YMMV.
Start with this:
module Main where
import Graphics.Rendering.OpenGL
import Graphics.UI.GLUT
myPoints :: [(GLfloat,GLfloat,GLfloat)]
myPoints = map (\k -> (sin(2*pi*k/12),cos(2*pi*k/12),0.0)) [1..12]
main = do
(progname, _) <- getArgsAndInitialize
createWindow "Hello World"
displayCallback $= display
mainLoop
display = do
clear [ColorBuffer]
renderPrimitive Points $ mapM_ (\(x, y, z)->vertex$Vertex3 x y z)
myPoints
flush
Save that lot as Test.hs or something. Then execute
ghc --make Test
That should generate Test.exe. Now run it.
If it whines about not finding glut32.dll, go here:
http://www.transmissionzero.co.uk/software/freeglut-devel/
Download the "FreeGLUT MinGW" package, and unpack glut32.dll from it.
(You can ignore all the other files; you only need the DLL.) Drop the
DLL into your search path or just into the same folder as Test.exe, and
then try and run it.
If it works, you should get a black window with some white dots.
Assuming all of that works, you now just need to learn the whole Haskell
programming language, including how to do I/O, and learn the OpenGL
binding, and then you can do stuff. ;-)
And now if you'll excuse me, I'm going to go file a bunch of tickets
with the bugtracker. :-P
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Invisible <voi### [at] devnull> wrote:
> I compiled a simple OpenGL program, and it crashed with "cannot
> find glut32.dll". I don't know if that's because I don't have a 3D card
> on this machine or what. Anyway, it took a while to fix it! YMMV.
Yup, OpenGL doesn't ship with GLUT (OpenGL Utility Toolkit). You need to
download it separately.
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
> myPoints
> flush
>
> Save that lot as Test.hs or something. Then execute
>
> ghc --make Test
I get:
Test.hs:20:0: parse error (possibly incorrect indentation)
I guess something with the indentation is not correct at the end of the .hs
file? What does it need?
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
scott wrote:
>> myPoints
>> flush
>>
>> Save that lot as Test.hs or something. Then execute
>>
>> ghc --make Test
>
> I get:
>
> Test.hs:20:0: parse error (possibly incorrect indentation)
>
> I guess something with the indentation is not correct at the end of the
> .hs file? What does it need?
The "myPoints" is supposed to be at the end of the previous line.
Apparently it got wrapped...
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Cool it works! (I had to rename freeglut.dll to glut32.dll)
Now to learn Haskell...
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
scott wrote:
> Cool it works! (I had to rename freeglut.dll to glut32.dll)
Oh, yeah, I forgot to mention that part. o_O
> Now to learn Haskell...
LOL! Um, yes. ;-)
You'd probably be best learning the pure part of Haskell first, since
this is the primary objective of Haskell. The impure part of Haskell is
just like any other language - but far, far more wordy. Thing is, OpenGL
is all *about* the impure part, so...
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
scott wrote:
> You're also quite good a writing tutorials, you should definitely write
> a book. Haskell for Imperative Programmers. :-)
If I write it, will you help review it?
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
|
|