|
![](/i/fill.gif) |
Mike Raiford wrote:
> I am interested in seeing what your Haskell implementation will be like.
OK, so I just finished the 6th complete rewrite of the LogicWorks
simulation core. And it seems to be working, as best as I can tell.
I spent a long time trying to hyper-compartmentalise the thing so that
every tiny aspect of its operation was a seperate source file, with a
tightly-controlled interface to it. The trouble is, everything depends
on everything else, so you end up going mad trying to avoid circular
module dependencies. Eventually I just put everything related to
simulation into one utterly giant module. Circular dependencies within
the same module don't matter. ;-)
Secondly, I spent ages trying to design the circuit as a dozen seperate
data structures, each representing different facets of its operation,
and several different modes of operation depending on what you want to
alter. And then I realised that in the real application, you only want
one mode: the mode where you can modify the live circuit as you simulate
it, and everything needed to do the simulation is one data object. So
instead of having dozens of datatypes, I put everything into one big
record and wrote all my functions to work on that.
The net result is what I'd consider to be utterly huge, although other
people's opinions may differ. It's a single source file, 660 lines long
(including comments) and 20 KB in size. When you compile it, it
generates a 38 KB interface file plus a 182 KB object file.
(For reference, I usually structure my programs so that each module is
about 150 lines or so.)
It's about now that an IDE starts to sound attractive. It would be nice
to be able to glance at a panel and see the sames and types of all the
functions I've written, and be able to quickly navigate to them.
Actually, hell, just some syntax hilighting would be nice! Oh well...
Anyway, I could show you the code if you _want_, but... it's kinda
large. (And most of it is just searching for or storing data, which
isn't tremendously interesting.)
Post a reply to this message
|
![](/i/fill.gif) |