extern(C) with function returning user type
Laeeth Isharc via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Fri Jul 31 21:11:00 PDT 2015
On Friday, 31 July 2015 at 21:35:30 UTC, Kyoji Klyden wrote:
> On Friday, 31 July 2015 at 19:13:18 UTC, Laeeth Isharc wrote:
>> On Friday, 31 July 2015 at 17:14:29 UTC, Kyoji Klyden wrote:
>>> On Friday, 31 July 2015 at 16:09:23 UTC, bachmeier wrote:
>>>> On Friday, 31 July 2015 at 03:30:20 UTC, Kyoji Klyden wrote:
>>>>> So idk, it feels silly and counterproductive to have D not
>>>>> able to natively use C libraries. Are we just gonna have to
>>>>> write D bindings to every notable library out there? Also I
>>>>> don't see how it'd be problematic, if you don't want a C
>>>>> preprocessor kicking in, then just don't import any C
>>>>> source, and then the compiler will just skip that step. :P
>>>>
>>>> That's how you end up with C++. The solution there is to use
>>>> only a subset of the language, but since everyone has her
>>>> own subset, you can either learn the whole language or not
>>>> interact with anyone else's code. A tool-based solution is
>>>> much better.
>>>
>>> It's a fair argument. Regardless though, I feel like D has
>>> lost it practicality for me for the time being. I might come
>>> back to it in half a year and see if anything changes, but
>>> unfortunately I don't see myself using D for any of my
>>> projects I got lined up.
>>
>> You have to make the right decision for you.
>>
>> But from what you say, I am not sure if you are making it on
>> the basis of proper information about the tradeoffs involved.
>> It shouldn't be a difficult thing to port the headers for most
>> C libraries. Use dstep to do the work, and a bit of tidying
>> up after (which gets easier each time). Less time involved
>> than that involved in trying to fix just one nasty memory leak
>> or pointer problem in C code.
>>
>> Sometimes though, cashflow dominates return on investment. If
>> one cannot spare the time then, ROI on learning something new
>> is irrelevant. One can't do much about that in the short term.
>
> I definitely agree with you there. I'm sure dstep could work
> quite well, but at the same time, for what I'm doing, there's
> nothing in D I couldn't do in C, and C's the one with the
> libraries + the endless supply of documentation. There really
> isn't any reward for that extra percent of time/effort spent
> when using D right now.
> I still think D is rad, and will probably use it again sometime
> :)
Walter observes that if you are a Java programmer and start
writing D, you will write D like you write Java. And so I
suppose one will see what one doesn't have in Java, but not so
much the benefits of D. That's true of other languages too.
When one learns something new, one is often initially worse off
as a result, because it destabilises ones habits before one sees
how to apply ones new knowledge. So those benefits only come
with persistence and the passage of time.
Language familiarity can also be deceptive - "D adds nothing
really new" say the Reddit guys. But as a C guy who never got
into C++, it makes a huge difference. Just not obviously so in
the beginning. One thing that's great is to be able to come back
to my own code after a break when it was written in a hurry and
without too many comments and tie be able to understand it
immediately. That wasn't my experience with C, but I suppose it
depends how much discipline you have. (Also, once it compiles,
the bugs are usually obvious enough and simple to fix - stronger
typing has benefits).
The main advantage I have found is that one can deploy limited
energy to achieve more, because one doesn't get as bogged down,
and because the work is more pleasant and satisfying.
Which libraries do you miss, out of interest?
More information about the Digitalmars-d-learn
mailing list