[Haskell-cafe] How to variables

yin yin at atom.sk
Mon Jul 18 18:13:20 EDT 2005


robert dockins wrote:

>>>>>> I'm doing a 3D simulation. Now I need something like variables in
>>>>>> imperative languages. My mainLoop check for new events and renders
>>>>>> scene.
>>>>>
>>>>>
>>>>> Then you want IORef.
>>>>> http://www.haskell.org/ghc/docs/latest/html/libraries/base/Data.IORef.html
>>>>>
>>>>>
>>>>
>>>> I saw it. The problem is, I need an amount of 100*X of mutable
>>>> variables
>>>> to implement the system (camera position, rotation, aceleration, ...,
>>>> position and deformetion infomations for every object, ..., renderer
>>>> situations [like temprary fading and other efects], ... and more)
>>>
>>>
>>> Then you probably want a big labeled record, 
>>
>>
>>
>> Uhm... and what if I write some runtines in plain C, then bind them to
>> Haskell and and use then as in OOP:
>
> [snip]
>
>> Is this apoarch safe enougth, what do you think?
>
>
> If you do it carefully.  But why?  It sounds like you are planning to
> write a transliteration of the code you would write in C, without
> leveraging the advantages of Haskell.  Which brings us to the critical
> question; what properties of Haskell cause you to want to develop your
> program using it?  The answer to that question should direct your
> design choices.

A 3D engine aproach is a bit problematic (I can't describe it correctly
in English... I'm a slovak...). Behind polygons, textures, HUD GUI and
efects are mathematic functions, methods to solve problems, physics,
data representations, heuristic algoritms, "unkown time living meta
data", skripting language and sometimes expert systems, like simplified
neuron networks. Behind these is memory handling, loops, heavy algorithm
optimaliations and bugs.

I need to write functions fast and efective. Math, heuristic, metadata
and expert systems are better in haskell. If I could use haskel from C,
I would do it. The problem are optimalizations, which are a critical
change in algorithm. Other (and me too) won't understand my concepts.
The speed and usability of Haskell is a good argument to use and learn it.

I made a 3D engine in C++, but it was a broken aproach. I rewrote ti in
C and it had many memory leaks and too many optimalizations. I shoudn't
implement MainLoop and rendering state in Haskell. Haskell has the same
leaks like imperative languages, but in other "programing universe". If
we combine these universes together, we become an perfect world... with
some new, but hidden problems.

I try to combine my old "Imperium" and Haskells new "Functioning". I'm
sure I get an "Functioning Imperium".

Did you understand my metaphors?... I can't describe all my problem in
english, I sad, my english is poor.

Matej 'Yin' Gagyi



More information about the Haskell-Cafe mailing list