Re: moving from c++ to D is easy?

2015-03-12 Thread ketmar via Digitalmars-d-learn
On Thu, 12 Mar 2015 13:01:29 +, ayush wrote:

 Is D a lot like c++ ? I am currently midway through learning c++ and I
 also want to learn D . So should i focus on one or learn both together?
 Will I find learning D easy if I already know c++ ?

D is like C++, but made by human beings for human beings. and C++ is made 
by martians for monkeys.

signature.asc
Description: PGP signature


Re: moving from c++ to D is easy?

2015-03-12 Thread Dennis Ritchie via Digitalmars-d-learn

On Thursday, 12 March 2015 at 13:01:31 UTC, ayush wrote:

Is D a lot like c++?


Enough.


So should i focus on one or learn both together?


You can study both together, although it is better to focus on 
one.



Will I find learning D easy if I already know c++?


Yes.


Re: moving from c++ to D is easy?

2015-03-12 Thread Daniel Kozák via Digitalmars-d-learn

On Thu, 12 Mar 2015 13:35:18 +
ayush via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote:

 On Thursday, 12 March 2015 at 13:13:40 UTC, Dennis Ritchie wrote:
  On Thursday, 12 March 2015 at 13:01:31 UTC, ayush wrote:
  Is D a lot like c++?
 
  Enough.
 
  So should i focus on one or learn both together?
 
  You can study both together, although it is better to focus on 
  one.
 
  Will I find learning D easy if I already know c++?
 
  Yes.
 
 So on which language should I focus(learn) first

D is much easier to learn so I will start with it. And then you can
try learn C++ if you still want and need it.


Re: moving from c++ to D is easy?

2015-03-12 Thread ayush via Digitalmars-d-learn

On Thursday, 12 March 2015 at 13:13:40 UTC, Dennis Ritchie wrote:

On Thursday, 12 March 2015 at 13:01:31 UTC, ayush wrote:

Is D a lot like c++?


Enough.


So should i focus on one or learn both together?


You can study both together, although it is better to focus on 
one.



Will I find learning D easy if I already know c++?


Yes.


So on which language should I focus(learn) first


Re: moving from c++ to D is easy?

2015-03-12 Thread weaselcat via Digitalmars-d-learn

On Thursday, 12 March 2015 at 13:01:31 UTC, ayush wrote:
Is D a lot like c++ ? I am currently midway through learning 
c++ and I also want to learn D . So should i focus on one or 
learn both together? Will I find learning D easy if I already 
know c++ ?


D is very much like C++, but the biggest issue I found moving 
from C++ to D was trying to apply C++ idioms that only existed to 
work around ugly C++ warts(i.e, CRTP)


Re: moving from c++ to D is easy?

2015-03-12 Thread Dennis Ritchie via Digitalmars-d-learn

On Thursday, 12 March 2015 at 13:44:50 UTC, Daniel Kozák wrote:
D is much easier to learn so I will start with it. And then you 
can

try learn C++ if you still want and need it.


Yes, but in D for beginners little literature, so I would 
recommend starting with C++.


Re: moving from c++ to D is easy?

2015-03-12 Thread ketmar via Digitalmars-d-learn
On Thu, 12 Mar 2015 13:56:28 +, Dennis Ritchie wrote:

 On Thursday, 12 March 2015 at 13:44:50 UTC, Daniel Kozák wrote:
 D is much easier to learn so I will start with it. And then you can try
 learn C++ if you still want and need it.
 
 Yes, but in D for beginners little literature, so I would recommend
 starting with C++.

there are alot of books on C++ 'cause C++ is insanely complicated and 
inconsistend. D design is *MUCH* better, so D doesn't need so many books 
teaching arcane art of programming.

signature.asc
Description: PGP signature


Re: moving from c++ to D is easy?

2015-03-12 Thread via Digitalmars-d-learn

On Thursday, 12 March 2015 at 13:56:29 UTC, Dennis Ritchie wrote:

On Thursday, 12 March 2015 at 13:44:50 UTC, Daniel Kozák wrote:
D is much easier to learn so I will start with it. And then 
you can

try learn C++ if you still want and need it.


Yes, but in D for beginners little literature, so I would 
recommend starting with C++.



There is no need for dozens of books.
I would even go as far as to say that the existing ones are more 
than enough.


http://wiki.dlang.org/Books


Re: moving from c++ to D is easy?

2015-03-12 Thread Dennis Ritchie via Digitalmars-d-learn

On Thursday, 12 March 2015 at 14:47:22 UTC, ketmar wrote:
there are alot of books on C++ 'cause C++ is insanely 
complicated and
inconsistend. D design is *MUCH* better, so D doesn't need so 
many books

teaching arcane art of programming.


Well, in principle, can be started with a D, but personally, I 
started actually with ANSI C.


Re: moving from c++ to D is easy?

2015-03-12 Thread Namespace via Digitalmars-d-learn

On Thursday, 12 March 2015 at 18:57:51 UTC, Ali Çehreli wrote:

On 03/12/2015 06:01 AM, ayush wrote:

 Is D a lot like c++ ?

I came to D from C++. I remember the following being notable 
differences:


- In D, classes have reference semantics. I quickly realized 
that this is not an issue because so many of my C++ types were 
hand-reference-typified :p by this idiom, almost everywhere:


class C { /* ... */ };
typedef boost::shared_ptrC CPtr;
void foo(CPtr c);


This is a common mistake. In 99 percent of cases you want to use 
a std::unique_ptr. std::shared_ptr is rarely common and often an 
indication of an error in design. In general, there is exactly 
one owner only.

But I think you know that already. :)


Re: moving from c++ to D is easy?

2015-03-12 Thread Dennis Ritchie via Digitalmars-d-learn

On Thursday, 12 March 2015 at 18:57:51 UTC, Ali Çehreli wrote:
If you are a mortal like myself, you may find out years later 
that you are still at the midway point. Happened to me several 
times when I was learning C++. :)


О, yeah.


Re: moving from c++ to D is easy?

2015-03-12 Thread Ali Çehreli via Digitalmars-d-learn

On 03/12/2015 06:01 AM, ayush wrote:

 Is D a lot like c++ ?

I came to D from C++. I remember the following being notable differences:

- In D, classes have reference semantics. I quickly realized that this 
is not an issue because so many of my C++ types were 
hand-reference-typified :p by this idiom, almost everywhere:


class C { /* ... */ };
typedef boost::shared_ptrC CPtr;
void foo(CPtr c);

- Garbage collector took longer to get used to. There are some issues 
with the spec or implementation that some objects may never be 
destructed (or is it finalized?).


Other than issues like that, everything in D feels like a fresh air.

 I am currently midway through learning c++

If you are a mortal like myself, you may find out years later that you 
are still at the midway point. Happened to me several times when I was 
learning C++. :)


 and I also want to learn D . So should i focus on one or learn
 both together?

Economically, C++ may make more sense. But if you are learning just for 
yourself, perhaps for fun, then I recommend D.


 Will I find learning D easy if I already know c++ ?

I think so.

Ali



moving from c++ to D is easy?

2015-03-12 Thread ayush via Digitalmars-d-learn
Is D a lot like c++ ? I am currently midway through learning c++ 
and I also want to learn D . So should i focus on one or learn 
both together? Will I find learning D easy if I already know c++ ?


Re: moving from c++ to D is easy?

2015-03-12 Thread Ali Çehreli via Digitalmars-d-learn

On 03/12/2015 01:19 PM, Namespace wrote:

 On Thursday, 12 March 2015 at 18:57:51 UTC, Ali Çehreli wrote:
 On 03/12/2015 06:01 AM, ayush wrote:

  Is D a lot like c++ ?

 I came to D from C++. I remember the following being notable 
differences:


 - In D, classes have reference semantics. I quickly realized that this
 is not an issue because so many of my C++ types were
 hand-reference-typified :p by this idiom, almost everywhere:

 class C { /* ... */ };
 typedef boost::shared_ptrC CPtr;
 void foo(CPtr c);

 This is a common mistake. In 99 percent of cases you want to use a
 std::unique_ptr.

Agreed. Here is an excerpt from a comment from one of our header files:

We could not use boost::unique_ptr because the version of the Boost 
library that we currently use does not include it.


 std::shared_ptr is rarely common and often an indication of an
 error in design. In general, there is exactly one owner only.

Of course. We had definitions like the following as well, where the C 
objects are stored in:


typedef vectorCPtr MyCs;

 But I think you know that already. :)

I think so. :) Maybe we should pass weak_ptrs around instead of 
shared_ptr. Anyway... That's old code and this is a D newsgroup.


Ali



Re: moving from c++ to D is easy?

2015-03-12 Thread Namespace via Digitalmars-d-learn

On Thursday, 12 March 2015 at 21:41:07 UTC, Ali Çehreli wrote:

On 03/12/2015 01:19 PM, Namespace wrote:

 On Thursday, 12 March 2015 at 18:57:51 UTC, Ali Çehreli wrote:
 On 03/12/2015 06:01 AM, ayush wrote:

  Is D a lot like c++ ?

 I came to D from C++. I remember the following being notable
differences:

 - In D, classes have reference semantics. I quickly realized
that this
 is not an issue because so many of my C++ types were
 hand-reference-typified :p by this idiom, almost everywhere:

 class C { /* ... */ };
 typedef boost::shared_ptrC CPtr;
 void foo(CPtr c);

 This is a common mistake. In 99 percent of cases you want to
use a
 std::unique_ptr.

Agreed. Here is an excerpt from a comment from one of our 
header files:


We could not use boost::unique_ptr because the version of the 
Boost library that we currently use does not include it.


 std::shared_ptr is rarely common and often an indication of an
 error in design. In general, there is exactly one owner only.

Of course. We had definitions like the following as well, where 
the C objects are stored in:


typedef vectorCPtr MyCs;

 But I think you know that already. :)

I think so. :) Maybe we should pass weak_ptrs around instead of 
shared_ptr.
You could also pass raw pointers around. Since they have no owner 
it's fine. Or references.

Anyway... That's old code and this is a D newsgroup.

Ali

Agreed.


Re: Moving from C to D

2009-01-28 Thread bob
do IN become in maybe?

BLS Wrote:

 BCS wrote:
  Reply to bob,
  
  sorry i copy wrong line. how do i do this line:
 
  int PASCAL FAR mycnt ( IN SOCKET s, IN const struct sockaddr FAR *name, 
  IN int namelen );
 
  bob Wrote:
 
  
  step 1 would be get the output from the preprocessor and take a look at 
  it. I'm guessing that PASCAL, FAR and IN are macros
  
  step 0 is try htod:   http://www.digitalmars.com/d/1.0/htod.html
  
  
 
 I think
 int PASCAL FAR mycnt()
 becomes :
 extern (Pascal) int mycnt()
 
 The FAR* thingy seems to be a 16 bit relict...
 
 Guess the IN is not nessesary in D..., not sure though
 
 Bjoern



Re: Moving from C to D

2009-01-28 Thread Daniel Keep


bob wrote:
 do IN become in maybe?
 
 BLS Wrote:
 
 BCS wrote:
 Reply to bob,

 sorry i copy wrong line. how do i do this line:

 int PASCAL FAR mycnt ( IN SOCKET s, IN const struct sockaddr FAR *name, 
 IN int namelen );
 bob Wrote:

 step 1 would be get the output from the preprocessor and take a look at 
 it. I'm guessing that PASCAL, FAR and IN are macros

 step 0 is try htod:   http://www.digitalmars.com/d/1.0/htod.html


 I think
 int PASCAL FAR mycnt()
 becomes :
 extern (Pascal) int mycnt()

 The FAR* thingy seems to be a 16 bit relict...

 Guess the IN is not nessesary in D..., not sure though

 Bjoern
 

in means pass argument by value, and is the default for arguments.

Also, I believe that PASCAL is the same as the Windows cc, so my guess
at the conversion would be:

For D 1.x:

extern(Windows) int mycnt ( SOCKET s, sockaddr* name, int namelen );

For D 2.x:

extern(Windows) int mycnt ( SOCKET s, const sockaddr* name, int namelen );

Note that you'd have to supply definitions of SOCKET and sockaddr.

  -- Daniel


Re: Moving from C to D

2009-01-28 Thread Daniel Keep


BLS wrote:
 Daniel Keep wrote:
 [snip]

 Also, I believe that PASCAL is the same as the Windows cc, so my guess
 at the conversion would be:

 For D 1.x:

 extern(Windows) int mycnt ( SOCKET s, sockaddr* name, int namelen );

 For D 2.x:

 extern(Windows) int mycnt ( SOCKET s, const sockaddr* name, int
 namelen );

 Note that you'd have to supply definitions of SOCKET and sockaddr.

   -- Daniel
 
 I am pretty sure that PASCAL means  __pascal
 
 so the D1 translation is :
 extern (Pascal) int mycnt ( SOCKET s, sockaddr* name, int namelen );
 
 See :http://www.digitalmars.com/d/1.0/htomodule.html  at the bottom
 
 Bjoern

Aah yes; I didn't realise Pascal was defined; I thought it was limited
to C, D, Windows and System for D1, adding C++ for D2.

  -- Daniel


Moving from C to D

2009-01-27 Thread bob
im trying to convert my code from c to d and i have a question, how would i 
convert this line

void notify ( struct dev_notify * );

thank you in advance


Re: Moving from C to D

2009-01-27 Thread BCS

Reply to bob,


sorry i copy wrong line. how do i do this line:

int PASCAL FAR mycnt ( IN SOCKET s, IN const struct sockaddr FAR *name, 

IN int namelen );


bob Wrote:



step 1 would be get the output from the preprocessor and take a look at it. 
I'm guessing that PASCAL, FAR and IN are macros


step 0 is try htod:   http://www.digitalmars.com/d/1.0/htod.html