www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Power of D

reply bioinfornatics <bioinfornatics fedoraproject.org> writes:
i search some example of something easy (more easy)  to do in D an not
in another language if possible
- D - C++
- D - Haskell
- D - Java
- D - python

thanks a lot
Apr 25 2012
next sibling parent Ary Manzana <ary esperanto.org.ar> writes:
On 4/26/12 1:51 AM, bioinfornatics wrote:
 i search some example of something easy (more easy)  to do in D an not
 in another language if possible
 - D - C++
...
 - D - Haskell
 - D - Java
 - D - python
A segmentation fault is really easy to do in D but hard in those languages. :-P
Apr 25 2012
prev sibling next sibling parent reply "Era Scarecrow" <rtcvb32 yahoo.com> writes:
On Wednesday, 25 April 2012 at 17:52:36 UTC, bioinfornatics wrote:
 i search some example of something easy (more easy)  to do in D 
 an not
 in another language if possible
 - D - C++
 - D - Haskell
 - D - Java
 - D - python

 thanks a lot
Associative arrays? C++: #include <map> #include <string> map<string, string> m; Java: import java.util.*; Map<String, String> map = new HashMap<String, String>(); D: string[string] map (Don't know the other two... sorry) -- Source/syntax parsing (compared to C++ involving templates/generics). Let's see, what else. Utility functions as pseudo members? Since in other language you'd have to include all utility functions in with the class, and try to give it all functionality right away. Anything your missing you may have to inherit from another class (with those functions) or call as regular functions.
Apr 25 2012
next sibling parent reply David <d dav1d.de> writes:
Am 26.04.2012 07:55, schrieb Era Scarecrow:
 Associative arrays?

 C++:
 #include <map>
 #include <string>

 map<string, string> m;

 Java:
 import java.util.*;


 Map<String, String> map = new HashMap<String, String>();

 D:
 string[string] map

 (Don't know the other two... sorry)
 --
Python: map = {}
Apr 26 2012
parent reply "Nicolas Sicard" <dransic gmail.com> writes:
On Thursday, 26 April 2012 at 10:50:49 UTC, David wrote:
 Am 26.04.2012 07:55, schrieb Era Scarecrow:
 Associative arrays?

 C++:
 #include <map>
 #include <string>

 map<string, string> m;

 Java:
 import java.util.*;


 Map<String, String> map = new HashMap<String, String>();

 D:
 string[string] map

 (Don't know the other two... sorry)
 --
Python: map = {}
I think that many D powerful features are also easily done in Python or have easy to use equivalents, thanks to built-in dictionaries, list comprehensions, eval, etc. and so many available libraries. Albeit at the price of a sloooow execution comparing to D (unless you can utilize native extensions).
Apr 26 2012
parent "Era Scarecrow" <rtcvb32 yahoo.com> writes:
On Thursday, 26 April 2012 at 12:30:02 UTC, Nicolas Sicard wrote:
 I think that many D powerful features are also easily done in 
 Python or have easy to use equivalents, thanks to built-in 
 dictionaries, list comprehensions, eval, etc. and so many 
 available libraries. Albeit at the price of a sloooow execution 
 comparing to D (unless you can utilize native extensions).
Heavily used features on a certain scale or larger _should_ be built into the language. C++ added new/delete for memory management, but didn't give you any good containers; Although the STL is there (Honestly without watching a good explanation of how the STL is suppose to work, I got totally lost, and nothing made sense). Honestly dealing with the issues of C++ templates, syntax and macros makes me feel like I'm driving with square wheels (It's a bumpy ride). To quote Adam Savage (Mythbusters) "Square wheels are stupid". Unfortunately something in my brain makes learning unfamiliar languages that don't follow the structured syntax similar to C/Java/C++/D. I get utterly lost and my head as feels like it's dividing by zero.
Apr 26 2012
prev sibling parent Brad Anderson <eco gnuk.net> writes:
On Wed, Apr 25, 2012 at 11:55 PM, Era Scarecrow <rtcvb32 yahoo.com> wrote:

 On Wednesday, 25 April 2012 at 17:52:36 UTC, bioinfornatics wrote:

 i search some example of something easy (more easy)  to do in D an not
 in another language if possible
 - D - C++
 - D - Haskell
 - D - Java
 - D - python

 thanks a lot
Associative arrays? C++: #include <map> #include <string> map<string, string> m;
You actually want unordered_map<string, string> if you want the equivalent of D's string[string]. Regards, Brad Anderson
Apr 26 2012
prev sibling parent Jonathan M Davis <jmdavisProg gmx.com> writes:
On Wednesday, April 25, 2012 19:51:18 bioinfornatics wrote:
 i search some example of something easy (more easy)  to do in D an not
 in another language if possible
 - D - C++
 - D - Haskell
 - D - Java
 - D - python
 
 thanks a lot
Pretty much everything that Andrei talks about in this recent presentation: http://channel9.msdn.com/Events/Lang-NEXT/Lang-NEXT-2012/Three-Unlikely- Successful-Features-of-D?format=html5 The starkest example is compile-time stuff - CTFE, string mixins, and some of the templated stuff. But even something as simple as scope statements are a pretty massive improvement which is impossible in any other language that I've ever used. You can use try-catch-finally blocks (which is what scope statements lower to anyway), but the code is _way_ messier and more error-prone that way. - Jonathan M Davis
Apr 25 2012