August 21, 2013
On 8/21/13 3:53 AM, Andrej Mitrovic wrote:
> On 8/21/13, Jesse Phillips <Jesse.K.Phillips+D@gmail.com> wrote:
>> I don't frown on copy-paste code because "it's the thing to do"
>> or because it causes more typing. copy-paste is bad because your
>> logic is now duplicated and requires twice (on a good day) the
>> updates.
>
> Speaking of which someone should try and make a D de-duplication
> project (perhaps using Dscanner[1]), which would print out all the
> duplicated code segments in a D codebase. I think it would be a neat
> thing to have.
>
> [1] : https://github.com/Hackerpilot/Dscanner

Awesome idea. One would run the deduper over a codebase and e.g. show the top 10 longest repeated subsequences. Those could be refactored into functions etc.

The deduper would be insensitive to alpha renaming, e.g. "int a = 10;" and "int b = 10;" would be identical.


Andrei


August 21, 2013
On Wednesday, 21 August 2013 at 16:50:38 UTC, Ramon wrote:
> I am *not* against keeping an eye on performance, by no means. Looking at Moore's law, however, and at the kind of computing power available nowadays even in smartphones, not to talk about 8 and 12 core PCs, I feel that the importance of performance is way overestimated (possibly following a formertimes justified tradition).
>

Moor's law is kaput, finish, niet, we don't know how to use the extra transistor.

> We need not look further than on our very desk. Basically all major OSes as well as all major software is riddled with bugs, problems, and considerable lack of security. - And - basically all major OSes and to a large degree software is written in - ? - languages of the C family. Coincidence?
>

A vast amount of software is written in javascript, java, C#, PHP and many "safe" languages, and still are crippled with bugs.

Some codebase are trully scary. Look at gdb's source code or gtk's.

You want no bugs ? Go for Haskell. But you'll get no convenience or performance. The good thing if that if it does compile, you are pretty sure that it does the right thing.
August 21, 2013
On Wednesday, 21 August 2013 at 17:17:52 UTC, deadalnix wrote:
> On Wednesday, 21 August 2013 at 16:50:38 UTC, Ramon wrote:
>> I am *not* against keeping an eye on performance, by no means. Looking at Moore's law, however, and at the kind of computing power available nowadays even in smartphones, not to talk about 8 and 12 core PCs, I feel that the importance of performance is way overestimated (possibly following a formertimes justified tradition).
>>
>
> Moor's law is kaput, finish, niet, we don't know how to use the extra transistor.
>
>> We need not look further than on our very desk. Basically all major OSes as well as all major software is riddled with bugs, problems, and considerable lack of security. - And - basically all major OSes and to a large degree software is written in - ? - languages of the C family. Coincidence?
>>
>
> A vast amount of software is written in javascript, java, C#, PHP and many "safe" languages, and still are crippled with bugs.
>
> Some codebase are trully scary. Look at gdb's source code or gtk's.
>
> You want no bugs ? Go for Haskell. But you'll get no convenience or performance. The good thing if that if it does compile, you are pretty sure that it does the right thing.

While I agree with you, if C hadn't become mainstream the spectrum of
bugs at the OS level would be much lower.

Given the amount of errors caused by pointer arithmetic, buffer overflows
and string manipulations. All of which are easily avoidable in systems programming languages from the early 80's.

--
Paulo

August 21, 2013
On Wednesday, 21 August 2013 at 17:17:52 UTC, deadalnix wrote:
> On Wednesday, 21 August 2013 at 16:50:38 UTC, Ramon wrote:
>> I am *not* against keeping an eye on performance, by no means. Looking at Moore's law, however, and at the kind of computing power available nowadays even in smartphones, not to talk about 8 and 12 core PCs, I feel that the importance of performance is way overestimated (possibly following a formertimes justified tradition).
>>
>
> Moor's law is kaput, finish, niet, we don't know how to use the extra transistor.

Even if that were true, we have gone quite some distance. Not even talking about Sparc T4 or 8-core X86, my smartphone is more powerful than what I had as computer 10 years or so ago.

> A vast amount of software is written in javascript, java, C#, PHP and many "safe" languages, and still are crippled with bugs.

Do I get you right considering js, java, C# and PHP being "safe" languages?

> Some codebase are trully scary. Look at gdb's source code or gtk's.

Written in C/C++ ...

> You want no bugs ? Go for Haskell. But you'll get no convenience or performance. The good thing if that if it does compile, you are pretty sure that it does the right thing.

Why should I? Isn't that what D promises, too (and probably is right)?

On another perspective: Consider this question "Would you be willing to have all your software (incl. OS) running 10% or even 20% slower but without bugs, leaks, (unintended) backdoors and the like?"

My guess: Upwards of 80% would happily chime "YES!".

August 21, 2013
On 8/21/13 5:39 AM, Joseph Rushton Wakeling wrote:
> On 20/08/13 22:43, Andrei Alexandrescu wrote:
>> It's a common omission to equate D's ranges with pipes/filters. That
>> misses the
>> range categorization, which is inspired from C++ iterators.
>>
>> A relatively accurate characterization of D ranges is a unification of
>> C++
>> iterators with pipes/filters.
>
> I'm not sure I quite follow this point.  The Clojure sequence API has
> all the stuff you'd expect from the range interface -- empty?, first
> (front), next (popFront), nnext (popFrontN), last (back), drop-last
> (popBack), ...

No random access. I didn't know about drop-last though - does it work in O(1)?

> Is the point here that in Clojure these are all implemented as
> pipes/filters on top of singly-linked lists, whereas in D range
> interfaces are a "first-class" part of the language that is agnostic
> about the underlying data structures?

More accurately was the point that Clojure's sequence API is (to the best of my understanding) only dealing with forward access, whereas D distinguishes between one-pass, forward, bidirectional, and random, and designs algorithms around these notions.


Andrei

August 21, 2013
On 8/21/2013 10:12 AM, Andrei Alexandrescu wrote:
> On 8/21/13 3:53 AM, Andrej Mitrovic wrote:
>> Speaking of which someone should try and make a D de-duplication
>> project (perhaps using Dscanner[1]), which would print out all the
>> duplicated code segments in a D codebase. I think it would be a neat
>> thing to have.
>>
>> [1] : https://github.com/Hackerpilot/Dscanner
>
> Awesome idea. One would run the deduper over a codebase and e.g. show the top 10
> longest repeated subsequences. Those could be refactored into functions etc.
>
> The deduper would be insensitive to alpha renaming, e.g. "int a = 10;" and "int
> b = 10;" would be identical.

I've often thought of writing a pass for dmd that would coalesce functions that are semantically identical (even though they may operate on different types).

August 22, 2013
On Wednesday, 21 August 2013 at 17:45:29 UTC, Ramon wrote:
> On Wednesday, 21 August 2013 at 17:17:52 UTC, deadalnix wrote:
>> You want no bugs ? Go for Haskell. But you'll get no convenience or performance. The good thing if that if it does compile, you are pretty sure that it does the right thing.
>
> Why should I? Isn't that what D promises, too (and probably is right)?
>
> On another perspective: Consider this question "Would you be willing to have all your software (incl. OS) running 10% or even 20% slower but without bugs, leaks, (unintended) backdoors and the like?"
>
> My guess: Upwards of 80% would happily chime "YES!".

Have you looked at Rust? It promises to solve a few of the memory-related problems mentioned:

- no null pointer exceptions
- deterministic free (with owned pointers)
- optional garbage collection

It also has generics, which are runtime generics if I'm not mistaken. It doesn't have inheritance in the traditional OO sense, so you may not like that. I really like that it's LLVM compiled, so performance and cross-compiling should be pretty much solved problems.

There are still things that keep me here with D though:

- templates instead of generics (little reason to take a performance hit)
- CTFE
- inheritance (though I hardly use classes, they're handy sometimes)
- community
- array operations (int[] a; int[]b; auto c = a * b;)
  - I don't think these are automagically SIMD'd, but there's always hope =D
- similar to C++, so it's easy to find competent developers
August 22, 2013
On Thursday, 22 August 2013 at 02:06:13 UTC, Tyler Jameson Little wrote:
> It also has generics, which are runtime generics if I'm not mistaken.

Both.
August 22, 2013
Tyler Jameson Little:

> It also has generics, which are runtime generics if I'm not mistaken.

> - templates instead of generics (little reason to take a performance hit)

As far as I know Rust uses monomorphization just like C++ and D for generics. The difference in generics between D and Rust is that Rust has them strongly typed with type classes (this means inside a function templated on an argument, you can't do on that argument operations that are not specified in its static type class). But unlike the type classes of Haskell, the Rust ones are designed to have no run-time hit (but this makes them currently less powerful. Some persons are trying to improve this in Rust). Perhaps the original poster of this thread is looking for this.

Bye,
bearophile
August 22, 2013
On Wednesday, 21 August 2013 at 17:45:29 UTC, Ramon wrote:
>> Moor's law is kaput, finish, niet, we don't know how to use the extra transistor.
>
> Even if that were true, we have gone quite some distance. Not even talking about Sparc T4 or 8-core X86, my smartphone is more powerful than what I had as computer 10 years or so ago.
>

Just read this this : ftp://ftp.cs.utexas.edu/pub/dburger/papers/ISCA11.pdf and come back informed.

>> A vast amount of software is written in javascript, java, C#, PHP and many "safe" languages, and still are crippled with bugs.
>
> Do I get you right considering js, java, C# and PHP being "safe" languages?
>

They are dramatically superior to C in term of safety.

>> Some codebase are trully scary. Look at gdb's source code or gtk's.
>
> Written in C/C++ ...
>

Well look at phpBB's source code then. Horrible codebase isn't language specific.

>> You want no bugs ? Go for Haskell. But you'll get no convenience or performance. The good thing if that if it does compile, you are pretty sure that it does the right thing.
>
> Why should I? Isn't that what D promises, too (and probably is right)?
>

D promise a pragmatic balance between safety, performance, ease of use, productivity, etc . . .

> On another perspective: Consider this question "Would you be willing to have all your software (incl. OS) running 10% or even 20% slower but without bugs, leaks, (unintended) backdoors and the like?"
>
> My guess: Upwards of 80% would happily chime "YES!".

Would you accept it if it means a 3x slowdown and no real time capabilities (no video games for instance) ?