www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Looking for a language to hang my hat on.

reply Dan <20cc5a7b opayq.com> writes:
I am a very new c++ programmer, having just learned the language 
this year.

A few months ago I completed a course on Coursera that dealt with 
the security aspect of c (which I don't know, but it is similar 
enough):

https://class.coursera.org/softwaresec-008

The course highlighted just how dangerous c/c++ can be. My 
reaction to the course has been an increased use of shared/weak 
pointers over standard pointers, more judicious use of "assert" 
and increased use of destructors, where class pointers are 
destroyed via the destructor so I don't need to worry about 
memory leaks as much (all of my non-vector arrays are 
created/destroyed via a class w/ template).

Some of this slows programs down, but in reality it does not have 
much of an impact. But doubt will always linger that I caught 
every vulnerability. Therefore I am shopping for a language that 
codes like c++ but is safer.  It sounds like D may fit that 
requirement.

My platform of choice is 64-bit Fedora using Code::Blocks (yes, I 
use an IDE as a crutch). It seems that D supports this combo.

I have been lurking on this site over the past few weeks trying 
to decide when (and if) to make the transition. Can anyone here 
who has already made that transition tell me how smoothly it 
went? Any major unexpected problems? Advice?

thanks!
Dan
Nov 16 2015
next sibling parent reply lobo <swamplobo gmail.com> writes:
On Monday, 16 November 2015 at 22:39:17 UTC, Dan wrote:
 I am a very new c++ programmer, having just learned the 
 language this year.

 A few months ago I completed a course on Coursera that dealt 
 with the security aspect of c (which I don't know, but it is 
 similar enough):

 https://class.coursera.org/softwaresec-008

 The course highlighted just how dangerous c/c++ can be. My 
 reaction to the course has been an increased use of shared/weak 
 pointers over standard pointers, more judicious use of "assert" 
 and increased use of destructors, where class pointers are 
 destroyed via the destructor so I don't need to worry about 
 memory leaks as much (all of my non-vector arrays are 
 created/destroyed via a class w/ template).

 Some of this slows programs down, but in reality it does not 
 have much of an impact. But doubt will always linger that I 
 caught every vulnerability. Therefore I am shopping for a 
 language that codes like c++ but is safer.  It sounds like D 
 may fit that requirement.

 My platform of choice is 64-bit Fedora using Code::Blocks (yes, 
 I use an IDE as a crutch). It seems that D supports this combo.

 I have been lurking on this site over the past few weeks trying 
 to decide when (and if) to make the transition. Can anyone here 
 who has already made that transition tell me how smoothly it 
 went? Any major unexpected problems? Advice?

 thanks!
 Dan
Start using D now. It's not all or nothing so you don't have to give up on C++. I have several projects that contain both C++ and D intermixed. D will make you a better C++ programmer, but especially C++ template programming. D metaprogramming is so easy to read, write and understand compared to C++ and many of the patterns still apply when you're standing knee deep in C++it. I also find the D standard library, Phobos, is a great codebase to learn from. Compared to the STL (except perhaps the original [1]) it's a great example of how performant D code can still be readable and maintainable. bye, lobo [1] http://www.stepanovpapers.com/butler.hpl.hp/stl/stl.zip
Nov 16 2015
parent reply Dan <20cc5a7b opayq.com> writes:
Thanks everyone for taking the time to respond!

 Lobo,
 Start using D now. It's not all or nothing so you don't have to 
 give up on C++. I have several projects that contain both C++ 
 and D intermixed.
Using both does seem like a good way to transition. I could combine the strengths of D with the strengths of c++. I have never mixed two programming languages in one project, all have contained one language exclusively. This is another bridge to cross.
 D will make you a better C++ programmer, but especially C++ 
 template programming. D metaprogramming is so easy to read, 
 write and understand compared to C++ and many of the patterns 
 still apply when you're standing knee deep in C++it.
I use c++ templates extensively, and if D offers a better solution that is fantastic. -------------------------------- Chris Wright,
Your largest problem in the short term is documentation quality.
This concerns me since it makes it very difficult for people trying to learn the language. I don't need that additional frustration.
Your largest problem in the long run will be libraries.
Also concerning, but if I can combine the two languages somehow as lobo suggested, there may be a solution (just need to figure out how and how difficult that is).
...but you'd still have to write bindings. htod doesn't exactly 
work on Linux.
I am not exactly sure what that means, which is probably not a good sign. --------------------------------------- Russel Windmer But doesn't code::blocks just interface with the compiler? I (naively?) thought I could just install the compiler and point code::blocks to that compiler. --------------------------------------- Bachmeier
What do you plan to do with D?
Good point, I did not make that clear. Right now I just want to use it for personal projects, but someday I hope to take it further.
Personally, I don't think there is a reason to transition. 
Instead, you should learn D and then use it when you are ready.
That is troubling, but reasons to transition must exist or the language would not exist, right? I find that if I "learn" a language I forget it unless I actually start using it, at least for a short while. ---------------------------------------- January 2016 is when I should have time to experiment with D. I will attempt to install the language in Linux and kick the tires for a while. If I continuously stumble into insurmountable barriers, the experiment will end.
Nov 17 2015
parent bachmeier <no spam.com> writes:
On Tuesday, 17 November 2015 at 14:21:27 UTC, Dan wrote:

Personally, I don't think there is a reason to transition. 
Instead, you should learn D and then use it when you are ready.
That is troubling, but reasons to transition must exist or the language would not exist, right? I find that if I "learn" a language I forget it unless I actually start using it, at least for a short while. ---------------------------------------- January 2016 is when I should have time to experiment with D. I will attempt to install the language in Linux and kick the tires for a while. If I continuously stumble into insurmountable barriers, the experiment will end.
I meant there is no reason to abandon C++ in favor of D. The lowest cost way to get started with D is to write some functions in D and call them from C++. I personally don't like the term "transition" because it implies significant cost.
Nov 17 2015
prev sibling next sibling parent reply Chris Wright <dhasenan gmail.com> writes:
On Monday, 16 November 2015 at 22:39:17 UTC, Dan wrote:
 I have been lurking on this site over the past few weeks trying 
 to decide when (and if) to make the transition. Can anyone here 
 who has already made that transition tell me how smoothly it 
 went? Any major unexpected problems? Advice?
Your largest problem in the short term is documentation quality. It's improving, but it has a long way to go. It doesn't help that the standard library has such gems as: auto joiner(RoR, Separator)(RoR r, Separator sep) if (isInputRange!RoR && isInputRange!(ElementType!RoR) && isForwardRange!Separator && is(ElementType!Separator : ElementType!(ElementType!RoR))); Your largest problem in the long run will be libraries. I'm guessing the .NET BCL is larger than everything in the D standard library plus everything available via DUB. If you're using the language in a professional capacity, you'll eventually want libraries to help you connect to commercial stuff like Google or AWS APIs -- yeah, you're writing those yourself. Whereas with C++, Java, Ruby, C#, what have you, you've already got corporate library support by default. Even Go has first-party library support for AWS. D? Not even a community version. This might change, but that's a gamble, and not one I'd take. For projects where you need specific libraries to exist already, D probably won't serve your needs. (It's definitely easier with C++ interop, but you'd still have to write bindings. htod doesn't exactly work on Linux.) Random example: I wanted an embedded document database. There are a few hanging around. Guess how many have D bindings. I ended up going with LevelDB, which is just a key/value store, and hoping that I didn't need any indices -- LevelDB already has D bindings, whereas I didn't find any real embedded document databases with D bindings. Similarly, there's a lot more choice in terms of libraries in other languages. So you know that, if the first library to do a thing doesn't quite meet your needs, the second might. I don't have that confidence in D. This is slowly getting better, and it's a lot easier with DUB than it was when I started using D.
Nov 16 2015
parent reply bachmeier <no spam.net> writes:
On Tuesday, 17 November 2015 at 00:33:44 UTC, Chris Wright wrote:
 This might change, but that's a gamble, and not one I'd take. 
 For projects where you need specific libraries to exist 
 already, D probably won't serve your needs. (It's definitely 
 easier with C++ interop, but you'd still have to write 
 bindings. htod doesn't exactly work on Linux.)
Does anyone still use htod? I thought dstep was the tool being used to generate bindings. It depends on what OP plans to do. C interop is generally very easy, so anything available in C is also available in D, but it depends on how much of the glue code needs to be written. It has never been a big deal for me. The bigger problem is figuring out what the C library does than how to interface with it. One additional thing I've learned is that other languages might have large numbers of libraries "available" but a lot of it is low quality, undocumented/poorly documented stuff. The ability to easily write C bindings is in many cases preferable to complicated C interop but existing libraries.
Nov 17 2015
parent Chris Wright <dhasenan gmail.com> writes:
On Tue, 17 Nov 2015 10:53:04 +0000, bachmeier wrote:

 On Tuesday, 17 November 2015 at 00:33:44 UTC, Chris Wright wrote:
 This might change, but that's a gamble, and not one I'd take.
 For projects where you need specific libraries to exist already, D
 probably won't serve your needs. (It's definitely easier with C++
 interop, but you'd still have to write bindings. htod doesn't exactly
 work on Linux.)
Does anyone still use htod? I thought dstep was the tool being used to generate bindings.
dstep doesn't work out of the box. A simple `dub run dstep` results in compilation errors.
Nov 17 2015
prev sibling next sibling parent Russel Winder via Digitalmars-d-learn <digitalmars-d-learn puremagic.com> writes:
On Mon, 2015-11-16 at 22:39 +0000, Dan via Digitalmars-d-learn wrote:
=20
[=E2=80=A6]
 My platform of choice is 64-bit Fedora using Code::Blocks (yes, I=20
 use an IDE as a crutch). It seems that D supports this combo.
Last time I looked at Code::Blocks it couldn't do a dark theme, and the D support was for an ancient form of D. It would be good if we could get Kingsley's IntelliJ IDEA D plugin into CLion. --=20 Russel. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D Dr Russel Winder t: +44 20 7585 2200 voip: sip:russel.winder ekiga.n= et 41 Buckmaster Road m: +44 7770 465 077 xmpp: russel winder.org.uk London SW11 1EN, UK w: www.russel.org.uk skype: russel_winder
Nov 17 2015
prev sibling parent bachmeier <no spam.net> writes:
On Monday, 16 November 2015 at 22:39:17 UTC, Dan wrote:
 I have been lurking on this site over the past few weeks trying 
 to decide when (and if) to make the transition. Can anyone here 
 who has already made that transition tell me how smoothly it 
 went? Any major unexpected problems? Advice?

 thanks!
 Dan
What do you plan to do with D? Learn it so you can use it for personal projects? Write large apps for a business? Use it in a job? The answer depends on how you'll use it. Personally, I don't think there is a reason to transition. Instead, you should learn D and then use it when you are ready.
Nov 17 2015