Newbie questions. Which Compiler to start with? Real Time behaviour? Has anyone converted CImg yet?

Craig Dillabaugh cdillaba at cg.scs.carleton.ca
Wed Sep 4 07:45:25 PDT 2013


On Monday, 2 September 2013 at 02:38:35 UTC, bearophile wrote:
> John Carter:
>
>> "How easy is it to convert both C++ programs and C++ 
>> programmers to D?"
>
> Porting C code to D is not hard, it's mostly mechanical work, 
> you just have to keep an eye on few things (like passing 
> fixed-sized arrays to functions by reference, global floating 
> point data not initialized to zero, etc).
>
> I think that for a C++ programmer it's not too much hard to 
> learn D. But converting C++ code to D could be very hard (and a 
> slow work) if the code uses lot of small things that are 
> specific of C++ and missing or different in D. If the C++ code 
> is more plain, then it's probably not hard, despite the missing 
> multiple inheritance and struct inheritance.
>
> Converting CImg to D seems a multi-years work.
>
> Bye,
> bearophile

While I just had a brief look at CImg and am thus far from an
expert I wonder if developing a similar project in D would be
quite that bad.  There seems like a lot of the code isn't core
functionality for an image processing library.

The whole header file is 40+K lines of code.

The system seems to include its own cross-platform image/graphics
rendering system. There are 1100+ loc are just static arrays
storing fonts.

Furthermore, while it does seem to include a tonne of image
processing functions, I am sure a basic library could initially
omit many of these.
For example there is a math formula parser that accounts for a
huge chunk of the library.  Certainly something you would want to
have in the long run, but might be omitted initially.

Finally, the use of templates seems fairly straightforward - at
least by my brief perusal, and the code is more C like that C++
like.  It doesn't appear to have a complex object hierarchy at
all.


So, I think this might be doable if:

1. You skipped the image display system (that shouldn't be part
of a library in my opinion anyway).

2. You identified what your priority functionality would be and
(initially at least) dropped the others [eg. the math formula
parser].

Craig


More information about the Digitalmars-d-learn mailing list