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
parent 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 = dict() # or map = {}
Apr 26 2012
prev sibling next 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
prev sibling next sibling parent "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 = dict() # or 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
prev sibling next sibling 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:
--f46d040169abf7632b04be98754c
Content-Type: text/plain; charset=ISO-8859-1

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;

of D's string[string]. Regards, Brad Anderson --f46d040169abf7632b04be98754c Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable <div class=3D"gmail_extra">On Wed, Apr 25, 2012 at 11:55 PM, Era Scarecrow = <span dir=3D"ltr">&lt;<a href=3D"mailto:rtcvb32 yahoo.com" target=3D"_blank= ">rtcvb32 yahoo.com</a>&gt;</span> wrote:<br><div class=3D"gmail_quote"><bl= ockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #= ccc solid;padding-left:1ex"> <div class=3D"HOEnZb"><div class=3D"h5">On Wednesday, 25 April 2012 at 17:5= 2:36 UTC, bioinfornatics wrote:<br> <blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p= x #ccc solid;padding-left:1ex"> i search some example of something easy (more easy) =A0to do in D an not<br=

- D - C++<br> - D - Haskell<br> - D - Java<br> - D - python<br> <br> thanks a lot<br> </blockquote> <br></div></div> =A0Associative arrays?<br> <br> C++:<br> #include &lt;map&gt;<br> #include &lt;string&gt;<br> <br> map&lt;string, string&gt; m;<br> <br></blockquote><div><br></div><div>You actually want unordered_map&lt;str= ing, string&gt; if you want the equivalent of D&#39;s string[string].</div>= <div><br></div><div>Regards,</div><div>Brad Anderson</div></div></div> --f46d040169abf7632b04be98754c--
Apr 26 2012