OSNews article about C++09 degenerates into C++ vs. D discussion
Boris Kolar
boris.kolar at globera.com
Tue Nov 21 02:54:34 PST 2006
== Quote from Walter Bright (newshound at digitalmars.com)'s article
> A lot of file reads and writes can be done atomically with the functions
> in std.file, without need for RAII.
I know, but I rarely use standard libraries directly. One of the first I
do when I start programming in a new language is abstracting most of std
libraries.
For most programmers, file is something on your disk. For me, file is an
abstract concept: it may be something on a network, it may be something
calculated on demand,... Some "files" need opening/closing, some don't.
I usually even go as far as defining a temlate File(T) (a file of elements
of type T). Anyway, File is not the only example, there are also locks,
widgets, sockets,.... All of them just as abstract if not more :)
Sometimes I need RIAA, sometimes I don't. Because of my programming style
I very freequently encounter a situation when I need very small classes, like
selection ((from, to) pair), parser event ((event, selection) pair) - these
classes are just abstract enought they can't be structs and simple enough
they shouldn't trigger GC pauses. A vast majority of such classes is immutable,
(some having copy-on-write semantics) and are often returned from functions.
One very recent specific example: I created socket class and 3 implementations
(socket over TCP, socket over Netbios, socket over buffer). The last one
(socket over buffer) doesn't need to open/close connections, but the other two
do. In my scenario, a real sockets reads encrypted data, write decrypted data
to buffer, and a "fake" socket reads buffer as if it was an unencrypted
connection.
Anyway, my almost 20 years of programming experience has tought me enough that
I can tell when some missing feature is making my life harder. And I'm not a
feature freak - I wouldn't miss goto or even array slicing (you guessed it,
I abstract arrays as well ;), but I do miss a decent RIAA and deterministic
object destruction.
More information about the Digitalmars-d
mailing list