Jump to page: 1 2 3
Thread overview
C/C++ style Crashes?
Jan 08, 2007
Jon Grant
Jan 08, 2007
Alexander Panek
Jan 08, 2007
Steve Horne
Jan 08, 2007
Alexander Panek
Jan 08, 2007
Steve Horne
Jan 09, 2007
Alexander Panek
Jan 09, 2007
Steve Horne
Jan 12, 2007
Sebastian Biallas
Jan 12, 2007
Alexander Panek
Jan 15, 2007
Steve Horne
Jan 15, 2007
Sebastian Biallas
Jan 16, 2007
Steve Horne
Jan 08, 2007
Hasan Aljudy
Jan 08, 2007
Lutger
Jan 12, 2007
Sebastian Biallas
Jan 12, 2007
Alexander Panek
Jan 12, 2007
Sebastian Biallas
Jan 12, 2007
Alexander Panek
Jan 12, 2007
Sebastian Biallas
Jan 13, 2007
Alexander Panek
Jan 15, 2007
Steve Horne
January 08, 2007
Hi
Just having a look at the D language.
Does D still let the programmer allocate memory, cast addresses and read/write
direct address space as we can from C/C++?

I'd like to know if it solves this problem, Java and C# don't allow such access.
Cheers
Jon
--
Weblog: http://jguk.org/
January 08, 2007
Jon Grant wrote:
> Hi
> Just having a look at the D language.
> Does D still let the programmer allocate memory, cast addresses and read/write
> direct address space as we can from C/C++?

You can use malloc & friends if you feel like, of course.

> I'd like to know if it solves this problem, Java and C# don't allow such access.

Sure.

> Cheers
> Jon
> --
> Weblog: http://jguk.org/
January 08, 2007

Jon Grant wrote:
> Hi
> Just having a look at the D language.
> Does D still let the programmer allocate memory, cast addresses and read/write
> direct address space as we can from C/C++?
> 
> I'd like to know if it solves this problem, Java and C# don't allow such access.
> Cheers
> Jon
> --
> Weblog: http://jguk.org/

You can play with pointers anyway you want, it's designed to be a systems language; if you can do it in C you can do it in D.
In fact, D even lets you write assembly.
January 08, 2007
Hasan Aljudy wrote:
> 
> 
> Jon Grant wrote:
>> Hi
>> Just having a look at the D language.
>> Does D still let the programmer allocate memory, cast addresses and read/write
>> direct address space as we can from C/C++?
>>
>> I'd like to know if it solves this problem, Java and C# don't allow such access.
>> Cheers
>> Jon
>> -- 
>> Weblog: http://jguk.org/
> 
> You can play with pointers anyway you want, it's designed to be a systems language; if you can do it in C you can do it in D.
> In fact, D even lets you write assembly.

In addition to that: you can do it, but you don't need to as in C/C++. You can program entirely without pointers.

So does D solves this problem? I'd say yes if the problem is that in C/C++ it is too easy to crash an application.

I very rarely have bugs in my little programs that make for a crash. More importantly, if I do have a crash it is obvious that I have messed up bigtime and can repair the bug quickly. (within minutes, without a debugger).
January 08, 2007
On Mon, 08 Jan 2007 02:15:09 +0100, Alexander Panek <a.panek@brainsware.org> wrote:

>> I'd like to know if it solves this problem, Java and C# don't allow such access.
>
>Sure.

No, D does not solve this problem. You can cast pointers and do pointer arithmetic in D if you want to.

This is important. Java is a limited languages because it makes code 'more reliable' by eliminating needed features. In reality, this doesn't make things more reliable since you then have to work around the limitations or simply accept that there are things that you can't do.

In a systems language, pointer arithmetic is a necessity. There are things you simply cannot do without it - data structures that require it, for instance. It's all very well saying that you have lists and hashes built in, but while these are very powerful and can do a lot, they are not sufficient for handling every requirement especially when efficiency (both speed and memory) is a major concern.

A reasonable analogy would be that it's like trying to improve road safety by banning cars. Cars are dangerous so surely banning them would improve safety, after all? Well, maybe, but only by making many journeys impossible and by wasting a great deal of time on many others. And its worth bearing in mind that there are far more dangerous ways to travel than in a car.

Besides, the damage done to the economy would mean that less money is available, which means that you can't afford health care, police, fire and rescue services, etc etc. Whoops - not so great after all.

Sometimes, the lack of the ability to do pointer arithmetic is very much like that. You end up having to do a lot of work to work around the limitation. You don't get the gains that doing pointer arithmetic can provide, and the knock-on issues in terms of development time and code efficiency make the whole project far more difficult. And the loss of those code efficiency gains mean you have to look elsewhere for efficiency gains to compensate, causing further development time issues.

Funny thing. My father is a builder. He handles dangerous tools every day. Hundreds of them. We programmers like to consider ourselves more intelligent than builders, and yet we are like toddlers who need safety gates on the stairs - god help the person who suggests that we should know how and when to climb the stairs safely.

It should be pretty obvious by now that this kind of stuff really pisses me off. Its pathetic. Before long, Eclipse is probably going to have a 'safety feature' that refuses to let you write any code until you strap yourself safely into your chair. And ten minutes after you start, it'll offer to change your nappy. In the past, you used to get fired for wanting to go home at 7PM. Give it a year or two and by 7PM your IDE will be tucking you into bed and reading you fairy stories.

-- 
Remove 'wants' and 'nospam' from e-mail.
January 08, 2007
And what exactly is it that makes D not solving this problem?
January 08, 2007
On Mon, 08 Jan 2007 19:30:12 +0100, Alexander Panek <a.panek@brainsware.org> wrote:

>And what exactly is it that makes D not solving this problem?

My reading of Jon Grants post...

: Does D still let the programmer allocate memory, cast addresses and read/write
: direct address space as we can from C/C++?
:
: I'd like to know if it solves this problem, Java and C# don't allow such access.

Is that the 'problem' is crashes due to pointer handling in C/C++. This 'problem' is 'solved' in Java and some other languages by basically banning pointer arithmetic.

Since D allows any pointer manipulation as C/C++, it can suffer the same crashes and therefore has the same 'problem'.

And my point is that the true problem is bad programmers who don't take responsibility for their code and don't know how to program. You can't fix that by banning language features.

So D has the same 'problem' that C and C++ have in relation to pointer handling, I just don't believe its a real problem.

-- 
Remove 'wants' and 'nospam' from e-mail.
January 09, 2007
Steve Horne wrote:
> On Mon, 08 Jan 2007 19:30:12 +0100, Alexander Panek
> <a.panek@brainsware.org> wrote:
> 
>> And what exactly is it that makes D not solving this problem?
> 
> My reading of Jon Grants post...
> 
> : Does D still let the programmer allocate memory, cast addresses and read/write
> : direct address space as we can from C/C++?
> : : I'd like to know if it solves this problem, Java and C# don't allow such access.
> 
> Is that the 'problem' is crashes due to pointer handling in C/C++.
> This 'problem' is 'solved' in Java and some other languages by
> basically banning pointer arithmetic.

Ok, I might have misunderstood something there. I thought the 'problem' would be that there's no language that allows both, high and low level access to memory.

> 
> Since D allows any pointer manipulation as C/C++, it can suffer the
> same crashes and therefore has the same 'problem'.
> 
> And my point is that the true problem is bad programmers who don't
> take responsibility for their code and don't know how to program. You
> can't fix that by banning language features.

This is very true.

> 
> So D has the same 'problem' that C and C++ have in relation to pointer
> handling, I just don't believe its a real problem.

Me neither, as you might have guessed already. ;)
January 09, 2007
On Tue, 09 Jan 2007 07:41:35 +0100, Alexander Panek <a.panek@brainsware.org> wrote:

>Ok, I might have misunderstood something there. I thought the 'problem' would be that there's no language that allows both, high and low level access to memory.

No worries. It was me who was getting all stressy after all, and the original post could be read several different ways on reflection.

-- 
Remove 'wants' and 'nospam' from e-mail.
January 12, 2007
Steve Horne wrote:
> In a systems language, pointer arithmetic is a necessity. There are things you simply cannot do without it - data structures that require it, for instance.

Can you give an example?
« First   ‹ Prev
1 2 3