Thread overview | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
April 24, 2014 python vs d | ||||
---|---|---|---|---|
| ||||
I am following discussions about GC and some other 'critical' improves in D language for a long time. I see a lot of arguments and heaps of code, that often hard to understand (for example Templates) even more complicated to use it. I like D, but more and more I am playing with Python, and understanding it's philosophy. And I like it because it's do not have any overhead like C++. It's clean any easy to understanding. As result it's harder to write bad code in it. Does anybody make tests of speed most common algorithm in D and Python. I am trying to understand which project better to start in Python and which in D. |
April 24, 2014 Re: python vs d | ||||
---|---|---|---|---|
| ||||
Posted in reply to Suliman | On Thursday, 24 April 2014 at 06:38:42 UTC, Suliman wrote:
> I am following discussions about GC and some other 'critical' improves in D language for a long time. I see a lot of arguments and heaps of code, that often hard to understand (for example Templates) even more complicated to use it.
>
> I like D, but more and more I am playing with Python, and understanding it's philosophy. And I like it because it's do not have any overhead like C++. It's clean any easy to understanding. As result it's harder to write bad code in it.
>
> Does anybody make tests of speed most common algorithm in D and Python. I am trying to understand which project better to start in Python and which in D.
I'm completely new to D, but have been writing in python for quite a while. Python is a very good language but it can be slow. I've noticed that anything involving bit shifting is very slow.
On one project I had a CRC algorithm in a python program that had to read a 2 megabit/sec datastream, calculate/compare CRC's and write data to disk files based on encoded times. The calculation involved bit shifting and the program couldn't keep up with the input stream at 96% CPU utilization. I implemented the CRC calculation in C (with almost no change to the algorithm), and added a python binding, leaving the rest of the python program unchanged. CPU utilization dropped to 4.5% and I was able to keep up with the input stream, no problem.
In general I guess that anytime you need native performance write the program in D. If it doesn't matter one way or the other write in D because you can deliver a binary with no dependency on an interpreter. But if you know that the python interpreter will be available on the target system, and you need to make use of the extensive python standard library, and your program isn't multi-threaded, then use Python.
|
April 24, 2014 Re: python vs d | ||||
---|---|---|---|---|
| ||||
Posted in reply to Suliman | On Thursday, 24 April 2014 at 06:38:42 UTC, Suliman wrote:
> I am following discussions about GC and some other 'critical' improves in D language for a long time. I see a lot of arguments and heaps of code, that often hard to understand (for example Templates) even more complicated to use it.
>
> I like D, but more and more I am playing with Python, and understanding it's philosophy. And I like it because it's do not have any overhead like C++. It's clean any easy to understanding. As result it's harder to write bad code in it.
>
> Does anybody make tests of speed most common algorithm in D and Python. I am trying to understand which project better to start in Python and which in D.
In my experience alot of the code you see popping up on this forum is from people who are interested in developing reusable libraries (parts of Phobos) and pushing the limits of D.
To accomplish some task in D, I would suggest that the normal D code would (could) look a lot closer to the Python code performing the same task, than much of what you see posted on here.
Most of my D code looks nothing like what you see posted on these lists. I likely don't write code in the idiomatic D way, but it still works and is a lot easier on the eyes than my C++ code.
I think improving the library documentation and some parts of the library (ie. XML, JSON a few others) would likely help close the gap with Python in terms of 'ease of use'. Of course it will likely never be as easy as Python for quick and dirty apps. However, just because you can do crazy complex stuff in D doesn't mean you have to.
|
April 24, 2014 Re: python vs d | ||||
---|---|---|---|---|
| ||||
Posted in reply to Craig Dillabaugh | > Most of my D code looks nothing like what you see posted on these lists. I likely don't write code in the idiomatic D way, but it still works and is a lot easier on the eyes than my C++ code. > > I think improving the library documentation and some parts of the library (ie. XML, JSON a few others) would likely help close the gap with Python in terms of 'ease of use'. Of course it will likely never be as easy as Python for quick and dirty apps. However, just because you can do crazy complex stuff in D doesn't mean you have to. It would be very nice to add to dlang wiki comparison woth Python, to show that D code can be easy as Python. Because some of solution here are very hard for understanding. For example topic that was few days ago about филге checking element in an array http://forum.dlang.org/thread/lbhtghccdtoojwpfyapw@forum.dlang.org Also what about web. Is I understand there is another situation, and 90% of task in middle site is SELECT operation. So where is speed of D can be used? What benefits I will get in speed and writing code instead of Python or even PHP. Both of them have good optimization for such operations... |
April 24, 2014 Re: python vs d | ||||
---|---|---|---|---|
| ||||
Posted in reply to Suliman | On Thursday, 24 April 2014 at 08:05:53 UTC, Suliman wrote: >> Most of my D code looks nothing like what you see posted on these lists. I likely don't write code in the idiomatic D way, but it still works and is a lot easier on the eyes than my C++ code. >> >> I think improving the library documentation and some parts of the library (ie. XML, JSON a few others) would likely help close the gap with Python in terms of 'ease of use'. Of course it will likely never be as easy as Python for quick and dirty apps. However, just because you can do crazy complex stuff in D doesn't mean you have to. > > It would be very nice to add to dlang wiki comparison woth Python, to show that D code can be easy as Python. Because some of solution here are very hard for understanding. For example topic that was few days ago about филге checking element in an array http://forum.dlang.org/thread/lbhtghccdtoojwpfyapw@forum.dlang.org > > Also what about web. Is I understand there is another situation, and 90% of task in middle site is SELECT operation. So where is speed of D can be used? What benefits I will get in speed and writing code instead of Python or even PHP. Both of them have good optimization for such operations... Based upon what I've tested on my machine which I might add has a problem with hard drive speed (bottleneck) Cmsed/Vibe is capable of a very large number of connections per second with quite a low memory footprint. Which does exceed any PHP web service framework currently available. I've seen around 16k possible locally with logging off, release build and keep alive. Still thats a far cry from 2.5k which is around PHP frameworks usual max. Perhaps with some form of caching for complex pages it'll stay quite high, although I haven't really looked into this. Speed isn't the only consideration with building web services however. How well does it scale? Productivity to write? Either way at this stage the bottleneck isn't the runtime performance its actually compilation. Right now with Vibe/Cmsed you cannot do reloading of templates/routes/models at runtime. This is the next step to getting D as a real substitute for e.g. Java for web development. I've been waiting up to this point for shared library support on all platforms but.. in the end I want this kinda now. Here is what I'm doing [0]. [0] http://forum.rejectedsoftware.com/groups/rejectedsoftware.dub/thread/1404/ |
April 24, 2014 Re: python vs d | ||||
---|---|---|---|---|
| ||||
Posted in reply to Suliman | Suliman:
> It would be very nice to add to dlang wiki comparison woth Python, to show that D code can be easy as Python.
In the Rosettacode site there are around one thousand Python-D comparisons.
Bye,
bearophile
|
April 24, 2014 Re: python vs d | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile | On 4/24/14, 2:20 AM, bearophile wrote:
> Suliman:
>
>> It would be very nice to add to dlang wiki comparison woth Python, to
>> show that D code can be easy as Python.
>
> In the Rosettacode site there are around one thousand Python-D comparisons.
>
> Bye,
> bearophile
Guess we could link from dlang.org to some. -- Andrei
|
April 24, 2014 Re: python vs d | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrei Alexandrescu | On Thursday, 24 April 2014 at 16:23:22 UTC, Andrei Alexandrescu wrote:
> Guess we could link from dlang.org to some. -- Andrei
It would be neat to have some of the shorter Rosetta Code examples on rotation... Do they allow the examples to be displayed outside of RC?
|
April 24, 2014 Re: python vs d | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrei Alexandrescu | On Thursday, 24 April 2014 at 16:23:22 UTC, Andrei Alexandrescu
wrote:
> Guess we could link from dlang.org to some. -- Andrei
It would be neat to have some of the shorter Rosetta Code
examples on rotation... Do they allow the examples to be
displayed outside of RC?
|
April 24, 2014 Re: python vs d | ||||
---|---|---|---|---|
| ||||
Posted in reply to Suliman | On Thursday, 24 April 2014 at 06:38:42 UTC, Suliman wrote: > I am following discussions about GC and some other 'critical' improves in D language for a long time. I see a lot of arguments and heaps of code, that often hard to understand (for example Templates) even more complicated to use it. Try this intro: http://nomad.so/2013/07/templates-in-d-explained/ Once you understand what the extra parens and exclamation marks are it all becomes clear. |
Copyright © 1999-2021 by the D Language Foundation