extern(C) with function returning user type

Kyoji Klyden via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Aug 1 12:59:17 PDT 2015


On Saturday, 1 August 2015 at 04:11:02 UTC, Laeeth Isharc wrote:
> 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?

Oddly enough, before D I was a python guy. I took up C about year 
after starting D. So I definitely see the python influence in my 
coding style, in both C and D. I keep everything very minimal and 
tidy, so my code is always really readable; but at the same time 
it has made me slightly hesitant to take up some of D's more 
unique features, so there's definitely still alot of areas with D 
I know I could improve in. However, there's points with D that I 
know the work around to certain problems is to use some other 
language, because D's design for better or worse won't let me 
solve the problem in a effective or sane method.
I agree with you completely about how easy D makes certain 
things. It's just that the bigger or more complex a project 
becomes, I find that it doesn't matter how the language works, 
things are just gonna get messy.

For libraries, most of them have some type of D binding available 
(of varying quality). Csound doesn't have a D binding, I don't 
think there's a Bullet3 binding, the alembic library(which is on 
my todo to use) doesn't have D binding, and the WinAPI is very 
weird to use from D. Also software APIs such as Softimage or 
Houdini's API don't have one. There's a bunch of others too. I 
think alot of this comes from game/interactive application 
programmers being in the minority in the D community.
I generally don't like the whole binding scenario anyways, 
because there's always a bit of delay between updates in the 
library and the binding, and I'm unfortunately very reliant on 
other people's libraries at the moment :\

Also one of my hobbies that I've gotten into in the last few 
months is writing code for weird processors types (i.e. the MOS 
6502, or the SX processor). There's always atleast a C compiler 
available (either official or community made). So even wishing 
for a D compiler for all those uncommon architectures is foolish.

Being that I have a decent idea of what I'm doing these days, 
it's not to hard to jump languages; but since knowing how to use 
a language and how to actually excel at a language is two very 
different things, I've chosen to get as good as possible at C, 
since there will be a much much larger payoff right now.  :]


More information about the Digitalmars-d-learn mailing list