Difference between revisions of "Programming in D for Python Programmers"

From D Wiki
Jump to: navigation, search
Line 52: Line 52:
 
Web development, concurrency and JSON/BSON/XML
 
Web development, concurrency and JSON/BSON/XML
 
----------------------------------------------
 
----------------------------------------------
Phobos includes bindings to the widely-used external curl library within Phobos (std.net.curl) and does include provision within std.csv, std.json and std.xml for processing structured data.  The JSON and XML implementations in Phobos could be better, and many people choose to use an external library.  The most popular solution for this is [http://vibed.org Vibe D], and this comes with a useful framework for web development, networking, fiber-based concurrency, JSON and BSON.  One can write fiber-oriented code without having to deal with callbacks.  (See CyberShadow's presentation at a recent Dconf for an excellent review of the differences).  Officially vibed is in beta, but the author seems to have high standards, and for many purposes you may find that this is good enough to be production-ready.  (Of course, caveat emptor, it goes without saying).
+
Phobos includes bindings to the widely-used external curl library within Phobos (std.net.curl) and does include provision within std.csv, std.json and std.xml for processing structured data.  The JSON and XML implementations in Phobos could be better, and many people choose to use an external library.  The most popular solution for this is [http://vibed.org Vibe D], and this comes with a useful framework for web development, networking, fiber-based concurrency, JSON and BSON.  One can write fiber-oriented code without having to deal with callbacks.  (See [https://www.youtube.com/watch?v=Zs8O7MVmlfw CyberShadow's presentation] at Dconf 2013 for an excellent review of the differences).  Officially vibed is in beta, but the author seems to have high standards, and for many purposes you may find that this is good enough to be production-ready.  (Of course, caveat emptor, it goes without saying).
  
 
Other general solutions include those available in [https://github.com/adamdruppe/arsd Adam Ruppe's ARSD] micro-framework, and CyberShadow's [https://github.com/CyberShadow/ae AE] library.  See the forums for some further possibilities on the JSON and XML front.  D's slices facilitate fast and efficient parsing, and as of some time back, the XML parser in the Tango library was possibly the fastest in the world.
 
Other general solutions include those available in [https://github.com/adamdruppe/arsd Adam Ruppe's ARSD] micro-framework, and CyberShadow's [https://github.com/CyberShadow/ae AE] library.  See the forums for some further possibilities on the JSON and XML front.  D's slices facilitate fast and efficient parsing, and as of some time back, the XML parser in the Tango library was possibly the fastest in the world.
Line 65: Line 65:
 
-------------------
 
-------------------
 
A work in progress - see SciD.
 
A work in progress - see SciD.
 +
  
 
Libraries - what is the D equivalent of pypi and pip?
 
Libraries - what is the D equivalent of pypi and pip?
 
------------------------------------------------------
 
------------------------------------------------------
 
See [http://code.dlang.org code.dlang.org] and the DUB package manager.
 
See [http://code.dlang.org code.dlang.org] and the DUB package manager.
 +
 +
 +
Next Steps
 +
----------
 +
* Download and install D for your platform
 +
* Consider purchasing Dr Andrei Alexandrescu's [http://www.amazon.com/D-Programming-Language-Andrei-Alexandrescu/dp/0321635361 The D Programming Language], [http://www.amazon.com/dp/1783287217/?tag=packtpubli-20 Adam Ruppe's D Cookbook], and reading the free book [http://ddili.org/ders/d.en/index.html 'Programming in D' by Ali Çehreli]
 +
* Read the D solutions to [http://rosettacode.org/wiki/Category:D Rosetta Code] problems
 +
* Take a look at the [http://wiki.dlang.org/Videos D language videos]
 +
* Subscribe to [http://arsdnet.net/this-week-in-d/ This Week in D]
 +
* Attend a meeting of a [http://wiki.dlang.org/D_User_Groups D User Group] near you
 +
* Follow D on [http://www.linkedin.com/groups/D-Developer-Network-3923820 LinkedIn], [https://plus.google.com/communities/100033468228217743303 Google+], [https://www.facebook.com/dlang.org Facebook], [https://www.xing.com/net/dlang Xing], [http://www.reddit.com/r/d_language/ Reddit], [https://www.quora.com/D-programming-language Quora]
 +
* Follow some [http://planet.dsource.org/ D blogs]

Revision as of 22:51, 29 March 2015

This section is under development, but in the meantime this link presents an independent perspective on D from the perspective of a python programmer:


D is Like Native Python



AdRoll is known for their use of Python elsewhere, but their data scientists use D. According to Andrew Pascoe, senior data scientist at AdRoll, "One of the clearest advantages of using D compared to other typical data science workflows is that it compiles down into machine code. Without an interpreter or virtual machine layer, we can rip through data significantly faster than other tools like a Java hadoop framework, R, or python would allow. But D’s compiler is fast enough that in many cases it can be run as if it were a scripting language....The key thing here that separates D from other efficient languages like the oft-suggested C or C++ is that D frees you to program in the style you feel most comfortable with at the given time". He says that they have found that they "can rapidly prototype new infrastructure and analysis tasks, and when efficiency becomes a core concern, we have the ability to refactor that same code base to squeeze as much performance out as possible".


Generators and List Comprehensions


Python's generators and list comprehensions have been thought to be two of the most difficult concepts to replicate in other languages. For the D solution to the problem solved by Python generators, see D Ranges and lazy evaluation. For list comprehensions, see UFCS.


Parallel Programming


Parallel programming has become increasingly in focus as we approach the beginning of the end of the free lunch from Moore's Law. D makes multiprocessing and threading as simple as possible, but not simpler:


Interfacing D with an existing codebase



Web development, concurrency and JSON/BSON/XML


Phobos includes bindings to the widely-used external curl library within Phobos (std.net.curl) and does include provision within std.csv, std.json and std.xml for processing structured data. The JSON and XML implementations in Phobos could be better, and many people choose to use an external library. The most popular solution for this is Vibe D, and this comes with a useful framework for web development, networking, fiber-based concurrency, JSON and BSON. One can write fiber-oriented code without having to deal with callbacks. (See CyberShadow's presentation at Dconf 2013 for an excellent review of the differences). Officially vibed is in beta, but the author seems to have high standards, and for many purposes you may find that this is good enough to be production-ready. (Of course, caveat emptor, it goes without saying).

Other general solutions include those available in Adam Ruppe's ARSD micro-framework, and CyberShadow's AE library. See the forums for some further possibilities on the JSON and XML front. D's slices facilitate fast and efficient parsing, and as of some time back, the XML parser in the Tango library was possibly the fastest in the world.


Email


Some options in ARSD and AE Utils. No IMAP as yet, but bindings are under development.


Numerical computing


A work in progress - see SciD.


Libraries - what is the D equivalent of pypi and pip?


See code.dlang.org and the DUB package manager.


Next Steps