A few notes on choosing between Go and D for a quick project
Paulo Pinto via Digitalmars-d
digitalmars-d at puremagic.com
Fri Mar 20 00:42:19 PDT 2015
On Friday, 20 March 2015 at 05:17:11 UTC, Walter Bright wrote:
> On 3/19/2015 9:59 AM, "Ola Fosheim =?UTF-8?B?R3LDuHN0YWQi?=
> <ola.fosheim.grostad+dlang at gmail.com>" wrote:
>> On Thursday, 19 March 2015 at 00:42:51 UTC, weaselcat wrote:
>>> On Wednesday, 18 March 2015 at 12:59:17 UTC, bearophile wrote:
>>>> High level constructs in D are often slower than low-level
>>>> code, so in some
>>>> cases you don't want to use them.
>>> I actually found that LDC does an _amazing_ job of optimizing
>>> high level
>>> constructs and converting "low level" code to higher level
>>> functional code
>>> resulted in minor speedups in a lot of cases.
>>> (Other performance benefits include the algorithm primitives
>>> being extensively
>>> optimized in phobos.)
>> If the code/compiler generates suboptimal code in the first
>> place then
>> improvements can be somewhat random. But if you write code
>> with good cache
>> locality, filling the pipeline properly then there is no
>> alternative to going
>> low level.
>> Btw, take a look at this:
>> That's really bad marketing...
> Sigh. The Python version:
> import sys
> if __name__ == "__main__":
> if (len(sys.argv) < 2):
> infile = open(sys.argv)
> linect = 0
> for line in infile:
> linect += 1
> print "There are %d lines" % linect
> does not allocate memory. The splitLines() version:
> [...] cutted
Of course it does allocate memory.
Python's "for...in" makes use of iterators and generators,
already there you have some allocations going around.
Not only that, there is one string being allocated for each line
in the file being read, even if it isn't used.
Not counting the whole minor allocations going on.
More information about the Digitalmars-d