Re: Are programs/OSes written in D more secure than programs written in C/C++?

2012-06-07 Thread Nick Sabalausky
"J.Varghese" wrote in message news:vcmamxcuyhiqigjrq...@forum.dlang.org... > > If I was comparing a C/C++ OS versus an identical OS written in D, do you > have estimates for many fewer bugs the D OS will have? 20% fewer minor > bugs? 50% fewer critical bugs? Is that even the right question to a

Re: Are programs/OSes written in D more secure than programs written in C/C++?

2012-06-07 Thread Walter Bright
On 6/6/2012 3:04 PM, J.Varghese wrote: I'm not a programmer, so can someone explain this to me: Will programs and operating systems written in D be safer (I speak of both memory safety and security bugs) than existing operating systems written in C and C++? D offers a number of features design

Re: align number

2012-06-07 Thread Katayama Hirofumi MZ
On Friday, 8 June 2012 at 04:16:18 UTC, Denis Shelomovskij wrote: It's D and there is no C preprocessor: --- version(Win64) { align(8): ... aligned 8 ... } else { align(4): ... aligned 4 ... } ... default aligned ... --- The code overlaps and it is not much smart.

Re: align number

2012-06-07 Thread Denis Shelomovskij
08.06.2012 7:31, Andrej Mitrovic написал: On 6/8/12, Bernard Helyer wrote: Well that doesn't seem to work. Try this: version(Win64) { align(8): } else { align(4): } This will not work as you expect. Just like --- version(v1) { class } else { struct } S { int i; } --- will not compile. It's

Re: valid uses of shared

2012-06-07 Thread Steven Schveighoffer
On Thu, 07 Jun 2012 20:58:13 -0400, Artur Skawina wrote: On 06/08/12 01:51, Steven Schveighoffer wrote: The following would be illegal: struct X { shared int x; // illegal shared(int)* y; // legal shared(X) *next; // legal } Note that the type of 'x' in shared struct S {

Re: valid uses of shared

2012-06-07 Thread Steven Schveighoffer
On Thu, 07 Jun 2012 22:16:21 -0400, Robert DaSilva wrote: You're forgetting about Global data. I wasn't so much forgetting it as I was ignoring it :) My thought on that is that the shared keyword in that case is truly a storage class. It's the one place where having a value-type based

Re: align number

2012-06-07 Thread Andrej Mitrovic
On 6/8/12, Bernard Helyer wrote: > Well that doesn't seem to work. Try this: version(Win64) { align(8): } else { align(4): }

Re: align number

2012-06-07 Thread Bernard Helyer
On Friday, 8 June 2012 at 02:51:57 UTC, Bernard Helyer wrote: On Friday, 8 June 2012 at 01:46:15 UTC, Katayama Hirofumi MZ wrote: version(Win64) { const int align_number = 8; } else { const int align_number = 4; } align(align_number): ...long code... align(size_t.sizeof); ? Well that doesn

Re: align number

2012-06-07 Thread Bernard Helyer
On Friday, 8 June 2012 at 01:46:15 UTC, Katayama Hirofumi MZ wrote: version(Win64) { const int align_number = 8; } else { const int align_number = 4; } align(align_number): ...long code... align(size_t.sizeof); ?

Re: valid uses of shared

2012-06-07 Thread Robert DaSilva
On Thursday, 7 June 2012 at 23:51:27 UTC, Steven Schveighoffer wrote: I am having a quite interesting debate on pure and shared with Artur Skawina in another thread, and I thought about how horrible a state shared is in. It's not implemented as designed, and the design really leaves more quest

Re: Should range foreach be iterating over an implicit copy?

2012-06-07 Thread Ken
On Friday, 18 May 2012 at 06:17:13 UTC, Lars T. Kyllingstad wrote: On Thursday, 17 May 2012 at 14:18:55 UTC, Steven Schveighoffer wrote: [...] I believe someone has created a byRef struct that wraps a range and iterates it byRef (maybe dsimcha?) Nope, me. :) https://github.com/kyllingstad/lt

align number

2012-06-07 Thread Katayama Hirofumi MZ
version(Win64) { const int align_number = 8; } else { const int align_number = 4; } align(align_number): ...long code...

Re: C++Now! 2012 slides

2012-06-07 Thread Jonathan M Davis
On Friday, June 08, 2012 00:30:06 Dmitry Olshansky wrote: > On 07.06.2012 22:34, Peter Alexander wrote: > > Don't get me started on std.algorithm.find... > > Why not ? It's perfect example of goodness of generic programing, > flexibility (for free) + speciality (when you need) for the win. > If yo

Re: C++Now! 2012 slides

2012-06-07 Thread Jonathan M Davis
On Friday, June 08, 2012 00:47:06 Peter Alexander wrote: > On Thursday, 7 June 2012 at 22:08:10 UTC, Andrei Alexandrescu > > wrote: > > On 6/7/12 3:04 PM, Timon Gehr wrote: > >> 'min' is not complicated. > > > > I agree. > > Then how come it has a bug where it doesn't work with > user-defined ty

Re: should pure functions accept/deal with shared data?

2012-06-07 Thread Jonathan M Davis
On Thursday, June 07, 2012 10:43:04 Steven Schveighoffer wrote: > On Wed, 06 Jun 2012 19:01:59 -0400, Alex Rønne Petersen > > wrote: > > Steven, in your particular case, I don't agree entirely. The operation > > can be atomic quite trivially by implementing inc() like so (for the > > shared int c

Re: valid uses of shared

2012-06-07 Thread Artur Skawina
On 06/08/12 01:51, Steven Schveighoffer wrote: > I am having a quite interesting debate on pure and shared with Artur Skawina > in another thread, and I thought about how horrible a state shared is in. > It's not implemented as designed, and the design really leaves more questions > than it has

Re: should pure functions accept/deal with shared data?

2012-06-07 Thread Artur Skawina
On 06/08/12 00:42, Steven Schveighoffer wrote: > On Thu, 07 Jun 2012 17:36:45 -0400, Artur Skawina wrote: > >> On 06/07/12 21:55, Steven Schveighoffer wrote: >>> On Thu, 07 Jun 2012 15:16:20 -0400, Artur Skawina >>> wrote: >>> On 06/07/12 20:29, Steven Schveighoffer wrote: >>> > I'm no

Re: C++Now! 2012 slides

2012-06-07 Thread Peter Alexander
On Thursday, 7 June 2012 at 22:29:09 UTC, Andrei Alexandrescu wrote: Great points, example could be a lot better. Maybe it's time you do get started on find(). Destroy or be destroyed. Ok... This overload: R find(alias pred = "a == b", R, E)(R haystack, E needle) if (isInputRange!R &&

valid uses of shared

2012-06-07 Thread Steven Schveighoffer
I am having a quite interesting debate on pure and shared with Artur Skawina in another thread, and I thought about how horrible a state shared is in. It's not implemented as designed, and the design really leaves more questions than it has answers. In addition, it has not real connection

Re: C++Now! 2012 slides

2012-06-07 Thread Andrei Alexandrescu
On 6/7/12 5:47 PM, Peter Alexander wrote: On Thursday, 7 June 2012 at 22:08:10 UTC, Andrei Alexandrescu wrote: On 6/7/12 3:04 PM, Timon Gehr wrote: 'min' is not complicated. I agree. Then how come it has a bug where it doesn't work with user-defined types? I just disagree. It's not compli

Re: wxD bindings

2012-06-07 Thread Andrej Mitrovic
On 6/7/12, Gour wrote: > Will it be usable for C libs as well? I'll see about that. I'm not sure if doxygen works on C libraries, if it does then it's doable. Since now I support POD types there's nothing from stopping the generator to work on C libraries. gccxml works for C++ libraries *or* as

Re: C++Now! 2012 slides

2012-06-07 Thread Dmitry Olshansky
On 08.06.2012 0:46, Dmitry Olshansky wrote: On 07.06.2012 20:04, bearophile wrote: The slide packs of the conference C++Now! 2012 are available: https://github.com/boostcon/cppnow_presentations_2012 Thanks, nice stuff for my brain to chew on. Continuing observing pages, noting apparent C++

Re: C++Now! 2012 slides

2012-06-07 Thread Peter Alexander
On Thursday, 7 June 2012 at 22:08:10 UTC, Andrei Alexandrescu wrote: On 6/7/12 3:04 PM, Timon Gehr wrote: 'min' is not complicated. I agree. Then how come it has a bug where it doesn't work with user-defined types? Maybe it isn't complicated per your definition, but it's complicated enou

Re: should pure functions accept/deal with shared data?

2012-06-07 Thread Steven Schveighoffer
On Thu, 07 Jun 2012 17:36:45 -0400, Artur Skawina wrote: On 06/07/12 21:55, Steven Schveighoffer wrote: On Thu, 07 Jun 2012 15:16:20 -0400, Artur Skawina wrote: On 06/07/12 20:29, Steven Schveighoffer wrote: I'm not proposing disallowing mutable references, just shared references.

Re: C++Now! 2012 slides

2012-06-07 Thread Andrei Alexandrescu
On 6/7/12 5:19 PM, Peter Alexander wrote: On Thursday, 7 June 2012 at 21:22:57 UTC, Timon Gehr wrote: There is not much there to clutter in this case. Therefore cluttering does not have a significant drawback. Is it just about aesthetics? Aesthetics is part of it, but it's more than that. It

Re: C++Now! 2012 slides

2012-06-07 Thread Peter Alexander
On Thursday, 7 June 2012 at 21:22:57 UTC, Timon Gehr wrote: There is not much there to clutter in this case. Therefore cluttering does not have a significant drawback. Is it just about aesthetics? Aesthetics is part of it, but it's more than that. It makes the code more difficult to read. I w

Re: C++Now! 2012 slides

2012-06-07 Thread Andrei Alexandrescu
On 6/7/12 3:04 PM, Timon Gehr wrote: On 06/07/2012 08:34 PM, Peter Alexander wrote: I find this very ugly. To be honest, I would be much happier without all that mostNegative and common type stuff. If I want to get the min between a short and an int I'll just cast them appropriately. The most

Re: C++Now! 2012 slides

2012-06-07 Thread Artur Skawina
On 06/07/12 22:46, Dmitry Olshansky wrote: > 2) Immutable strings have performance cost ... like tracking ownership and > reference counting - unless you have GC by your side, in which case it's > cheap and legal :) Until you have enough of them and your program starts to spend most of its time

Re: should pure functions accept/deal with shared data?

2012-06-07 Thread Artur Skawina
On 06/07/12 21:55, Steven Schveighoffer wrote: > On Thu, 07 Jun 2012 15:16:20 -0400, Artur Skawina wrote: > >> On 06/07/12 20:29, Steven Schveighoffer wrote: > >>> I'm not proposing disallowing mutable references, just shared references. >> >> I know, but if a D function marked as "pure" takes a

Re: Should range foreach be iterating over an implicit copy?

2012-06-07 Thread Ken
On Wednesday, 16 May 2012 at 21:40:39 UTC, Andrei Alexandrescu wrote: On 5/16/12 4:37 PM, Nick Sabalausky wrote: One counter-argument that was raised is that TDPL has an example on page 381 that indicates foreach iterates over an implicit copy. I don't have a copy handy ATM, so I can't look at

Re: C++Now! 2012 slides

2012-06-07 Thread Timon Gehr
On 06/07/2012 10:53 PM, Peter Alexander wrote: On Thursday, 7 June 2012 at 20:04:56 UTC, Timon Gehr wrote: On 06/07/2012 08:34 PM, Peter Alexander wrote: I find this very ugly. To be honest, I would be much happier without all that mostNegative and common type stuff. If I want to get the min b

Re: wxD bindings

2012-06-07 Thread Gour
On Mon, 28 May 2012 19:55:09 +0200 Andrej Mitrovic wrote: Dear Andrej, thank you very much for your response... > I was busy doing another rewrite of my codebase since it was getting > rather large and too specific for wxwidgets (lots and lots of doxygen > workarounds). Doxygen files for handw

Re: C++Now! 2012 slides

2012-06-07 Thread Peter Alexander
On Thursday, 7 June 2012 at 20:04:56 UTC, Timon Gehr wrote: On 06/07/2012 08:34 PM, Peter Alexander wrote: I find this very ugly. To be honest, I would be much happier without all that mostNegative and common type stuff. If I want to get the min between a short and an int I'll just cast them

Re: C++Now! 2012 slides

2012-06-07 Thread Froglegs
For some reason I found these docs really dull, to much rehashing of C++ 11 which is old hat now. The template stuff might be interesting if not for the knowledge that it will take absolutely forever to compile--

Re: C++Now! 2012 slides

2012-06-07 Thread Dmitry Olshansky
On 07.06.2012 20:04, bearophile wrote: The slide packs of the conference C++Now! 2012 are available: https://github.com/boostcon/cppnow_presentations_2012 Thanks, nice stuff for my brain to chew on. For one thing the ustring caught my eye. It goes in the right direction ... for C++. My fir

Re: C++Now! 2012 slides

2012-06-07 Thread Dmitry Olshansky
On 07.06.2012 22:34, Peter Alexander wrote: On Thursday, 7 June 2012 at 16:05:00 UTC, bearophile wrote: "Now What?" by Sean Parent (Adobe). I very much liked that presentation. It's nice to see someone looking at C++ in the big picture. I also liked his comment on the "beauty" of std::pair

Re: C++Now! 2012 slides

2012-06-07 Thread Timon Gehr
On 06/07/2012 08:34 PM, Peter Alexander wrote: I find this very ugly. To be honest, I would be much happier without all that mostNegative and common type stuff. If I want to get the min between a short and an int I'll just cast them appropriately. The mostNegative and common type stuff is ther

Re: should pure functions accept/deal with shared data?

2012-06-07 Thread Steven Schveighoffer
On Thu, 07 Jun 2012 15:16:20 -0400, Artur Skawina wrote: On 06/07/12 20:29, Steven Schveighoffer wrote: I'm not proposing disallowing mutable references, just shared references. I know, but if a D function marked as "pure" takes a mutable ref (which a shared one has to be assumed to b

Re: should pure functions accept/deal with shared data?

2012-06-07 Thread Artur Skawina
On 06/07/12 20:29, Steven Schveighoffer wrote: > On Thu, 07 Jun 2012 13:46:43 -0400, Artur Skawina wrote: > >> On 06/07/12 18:45, Steven Schveighoffer wrote: >>> On Thu, 07 Jun 2012 11:55:32 -0400, Artur Skawina >>> wrote: >>> On 06/07/12 16:43, Steven Schveighoffer wrote: > I understa

Re: C++Now! 2012 slides

2012-06-07 Thread Artur Skawina
On 06/07/12 20:19, Francois chabot wrote: > On Thursday, 7 June 2012 at 17:17:07 UTC, Artur Skawina wrote: >> On 06/07/12 18:04, bearophile wrote: >>> Page 46: #pragma no_alias Are we going to need something like that (or >>> "restrict") in D too? >> >> "restrict" functionality - yes, but it's pro

Re: C++Now! 2012 slides

2012-06-07 Thread Peter Alexander
On Thursday, 7 June 2012 at 16:05:00 UTC, bearophile wrote: "Now What?" by Sean Parent (Adobe). I very much liked that presentation. It's nice to see someone looking at C++ in the big picture. I also liked his comment on the "beauty" of std::pair "Complete std::pair 372 Lines" D suffers fr

Re: should pure functions accept/deal with shared data?

2012-06-07 Thread Steven Schveighoffer
On Thu, 07 Jun 2012 13:46:43 -0400, Artur Skawina wrote: On 06/07/12 18:45, Steven Schveighoffer wrote: On Thu, 07 Jun 2012 11:55:32 -0400, Artur Skawina wrote: On 06/07/12 16:43, Steven Schveighoffer wrote: I understand the implementation is not correct for shared, and that actually

Re: C++Now! 2012 slides

2012-06-07 Thread Francois chabot
On Thursday, 7 June 2012 at 17:17:07 UTC, Artur Skawina wrote: On 06/07/12 18:04, bearophile wrote: Page 46: #pragma no_alias Are we going to need something like that (or "restrict") in D too? "restrict" functionality - yes, but it's probably better done the other way around - restrict as def

Rational numbers in D

2012-06-07 Thread Joseph Rushton Wakeling
Sorry for the double-post -- I already asked this in d-learn, but this may be a better place to ask. What's the current state of affairs and roadmap for inclusion of rational number support in D? I've come across David Simcha's work: http://cis.jhu.edu/~dsimcha/d/phobos/std_rational.html ...

Re: should pure functions accept/deal with shared data?

2012-06-07 Thread Artur Skawina
On 06/07/12 18:45, Steven Schveighoffer wrote: > On Thu, 07 Jun 2012 11:55:32 -0400, Artur Skawina wrote: > >> On 06/07/12 16:43, Steven Schveighoffer wrote: >>> I understand the implementation is not correct for shared, and that >>> actually is my point. The current compiler lets you do the wr

Re: C++Now! 2012 slides

2012-06-07 Thread Artur Skawina
On 06/07/12 18:04, bearophile wrote: > Page 46: #pragma no_alias Are we going to need something like that (or > "restrict") in D too? "restrict" functionality - yes, but it's probably better done the other way around - restrict as default and "alias" when necessary. Reusing the keyword could wor

Re: should pure functions accept/deal with shared data?

2012-06-07 Thread Steven Schveighoffer
On Thu, 07 Jun 2012 11:55:32 -0400, Artur Skawina wrote: On 06/07/12 16:43, Steven Schveighoffer wrote: I understand the implementation is not correct for shared, and that actually is my point. The current compiler lets you do the wrong thing without complaint. Given that the shared ver

C++Now! 2012 slides

2012-06-07 Thread bearophile
The slide packs of the conference C++Now! 2012 are available: https://github.com/boostcon/cppnow_presentations_2012 Some of those slides packs seems too much large for the GitHub blob serving interface. To solve this problem download them all from as zip here (large amount of stuff): https://g

Re: should pure functions accept/deal with shared data?

2012-06-07 Thread Artur Skawina
On 06/07/12 16:43, Steven Schveighoffer wrote: > I understand the implementation is not correct for shared, and that actually > is my point. The current compiler lets you do the wrong thing without > complaint. Given that the shared version of the function needs to be written > differently tha

Re: should pure functions accept/deal with shared data?

2012-06-07 Thread Steven Schveighoffer
On Wed, 06 Jun 2012 19:01:59 -0400, Alex Rønne Petersen wrote: Steven, in your particular case, I don't agree entirely. The operation can be atomic quite trivially by implementing inc() like so (for the shared int case): void inc(ref shared int i) pure nothrow { // just pretend the

Re: should pure functions accept/deal with shared data?

2012-06-07 Thread Andrei Alexandrescu
On 6/7/12 9:13 AM, Manu wrote: On 7 June 2012 04:55, Andrei Alexandrescu mailto:seewebsiteforem...@erdani.org>> wrote: We could define shared to refuse compilation on odd machines, and THEN provide an atomic template with the expected performance of a lock. *sigh* .. my biggest pet pee

Re: should pure functions accept/deal with shared data?

2012-06-07 Thread Manu
On 7 June 2012 04:55, Andrei Alexandrescu wrote: > We could define shared to refuse compilation on odd machines, and THEN > provide an atomic template with the expected performance of a lock. > *sigh* .. my biggest pet peeve with the D community. ARM and PPC are not 'odd', ARM is the most common

Re: toImpl deprecated, use opCast instead?

2012-06-07 Thread Jens Mueller
Manu wrote: > Seriously? > > I perceive to!T and cast(T) as fundamentally different operations. How can > opCast correctly perform the role of to! ? > cast() is a low level type cast, to! implies a conversion of some kind. If > you have a pointer type, I assume cast to operate on the pointer, and

toImpl deprecated, use opCast instead?

2012-06-07 Thread Manu
Seriously? I perceive to!T and cast(T) as fundamentally different operations. How can opCast correctly perform the role of to! ? cast() is a low level type cast, to! implies a conversion of some kind. If you have a pointer type, I assume cast to operate on the pointer, and to! to perform a convers

Re: Better casts?

2012-06-07 Thread bearophile
Mehrdad: What do people think? I think some specialized and safe casts will be good to have in Phobos: http://d.puremagic.com/issues/show_bug.cgi?id=5559 Bye, bearophile

Re: runtime hook for Crash on Error

2012-06-07 Thread Timon Gehr
On 06/07/2012 12:11 AM, Lars T. Kyllingstad wrote: On Wednesday, 6 June 2012 at 21:05:51 UTC, Jonathan M Davis wrote: ... Having a mechanism which allows you to allocate without throwing OOM is great for the cases where someone actually needs, it but I'm _completely_ against requiring it anywher

Re: Are programs/OSes written in D more secure than programs written in C/C++?

2012-06-07 Thread Kagamin
On Thursday, 7 June 2012 at 09:44:35 UTC, J.Varghese wrote: If I was comparing a C/C++ OS versus an identical OS written in D, do you have estimates for many fewer bugs the D OS will have? 20% fewer minor bugs? 50% fewer critical bugs? Is that even the right question to ask? You should tell h

Re: Are programs/OSes written in D more secure than programs written in C/C++?

2012-06-07 Thread J.Varghese
D has a few language features that help to minimize exploits: - slices - bounds checking - more restrict type checking - GC - reference parameters - proper strings - security layers among modules (system, trusted, safe) Most C and C++ security exploits are due to: - pointer arithmetic - null te

Re: Are programs/OSes written in D more secure than programs written in C/C++?

2012-06-07 Thread Regan Heath
On Thu, 07 Jun 2012 06:47:05 +0100, Mehrdad wrote: On Thursday, 7 June 2012 at 05:09:27 UTC, Alex Rønne Petersen wrote: On 07-06-2012 07:04, Mehrdad wrote: no programming language will save you from that LINQ isn't exactly susceptible to SQL injection. :P LINQ can't mutate the state of th

Re: Are programs/OSes written in D more secure than programs written in C/C++?

2012-06-07 Thread Paulo Pinto
On Wednesday, 6 June 2012 at 23:10:54 UTC, Justin Whear wrote: On Thu, 07 Jun 2012 01:01:55 +0200, Alex Rønne Petersen wrote: On 07-06-2012 00:04, J.Varghese wrote: I'm not a programmer, so can someone explain this to me: Will programs and operating systems written in D be safer (I speak of bo

Re: Are programs/OSes written in D more secure than programs written in C/C++?

2012-06-07 Thread Paulo Pinto
On Wednesday, 6 June 2012 at 22:04:27 UTC, J.Varghese wrote: I'm sure most of you have heard of the recent increase of high profile hacking and security violations. The PlayStation Network, RSA, LinkedIn, (today) and thousands of lower profile attacks. The Flame trojan also marks the rise of hi

Re: Implicit type conversions with data loss

2012-06-07 Thread renoX
On Thursday, 7 June 2012 at 03:19:18 UTC, ctrl wrote: Thanks for your answers. You want a sane language: use a different language, most C-derived language have insane semantic for integers.. Have you tried Ada? I want a language with metaprogramming and compile-time computations. A google