Re: What will be the next MAJOR programming language for commercial use?



"Walter" <walter@xxxxxxxxxxxxxxxxxxxxxxx> writes:

>> If so, what happens when an invalid pointer is dereferenced?
>
> You get a hardware generated exception.

This probably means that D is unsafe. If you are not lucky, the
pointer will access a random other object.

> I would argue that "safety" is a continuum between more safe and
> less safe, and there is no obvious dividing line between the two.

There is: either it's guaranteed that no program has undefined
behavior (when it can execute random bits of memory as code or
shoot at arbitrary data memory) or not.

There are languages which are technically unsafe but they contain a
useful safe subset which encompasses almost the whole language and
it's easy to find all uses of unsafe features.

It happens that most languages with GC are safe or almost safe. Most
languages without GC are either unsafe or have limited data structures
(all values are independent, there is no conceptual sharing of
subobjects).

There is a related notion which is not that strict: features which
under some circumstances return a result which is almost always
undesirable instead of signalling an error, for the sake of efficiency,
are similar to unsafe features but don't cause undefined behavior.
Examples:
- ignoring overflow on integer arithmetic
- messing up with a data structure on concurrent access (but without
crashing nor shooting at random other data)

The next thing also sometimes called "unsafety" is when the language
has a habit of accepting almost arbitrary input instead of signalling
that it's probably wrong when it looks wrong. Perl is the primary
example of that. It will accept "foo" as a number (treated as 0)
and an array reference as a strong (treated as something like
"ARRAY(0x804cc28)"). Usually it doesn't check for too many or too few
arguments (unless the function is statically known and declared with
a prototype). The behavior is documented but mistakes aren't treated
as errors.

But the first notion is the primary meaning of "unsafe language".

> I will also argue that D has many characteristics that make the need
> for pointers much less than in, say, C, so one rarely has to deal
> with pointers.

Can you make a tree (e.g. abstract syntax tree for the sake of
example) without pointers?

> That's exactly what a dynamic closure is. A static closure would
> "capture" the local variables so they survive the function exit.

I haven't encountered your terminology and I'm not sure whether I
understand it. Do you mean that D supports only downward closures
(which are valid only as long as the containing function is running)
and not upward closures (with indefinite lifetime, independent from
the execution of functions)?

--
__("< Marcin Kowalczyk
\__/ qrczak@xxxxxxxxxx
^^ http://qrnik.knm.org.pl/~qrczak/
.



Relevant Pages

  • Re: which object orient language is most suitable for embedded programming?
    ... It's a shame that type safe languages always lose the nice ... It's been a *long* time since I used Modula-2, ... modules or objects "unsafe", which lets you construct pointers and the ...
    (comp.arch.embedded)
  • Convert unsafe code to safe, how to convert pointers to regular GDI+ methods?
    ... Quantaizaton code from unsafe to safe, but I don't understand pointers. ... byte pSourceRow = Marshal.ReadByte(origBitmapData.Scan0, ...
    (microsoft.public.dotnet.framework.drawing)
  • Re: introspection in SML
    ... of languages provide very different levels of guarantees and safety. ... 'Safe' and 'unsafe' doesn't really capture the essence, ... latter chose to take terminology from the former out of context and ...
    (comp.lang.functional)
  • Re: Unsafe lack of pointers in C#?
    ... Pointers can be used in unsafe code blocks from C#. ... Find great Windows Forms articles in Windows Forms Tips and Tricks ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Access to driver memory using c#
    ... if you need the unmanaged data to be available as a managed type ... To do this in C# you have two options, or you can use unsafe code pointers, ...
    (microsoft.public.dotnet.languages.csharp)

Loading