Syntax & Records (was: Re: COPL, the Tandem, PLITS and JAVA (WAS Re: Eppur si sugat))

Chris Pressey cpressey@REDACTED
Thu May 29 23:14:58 CEST 2003


On Thu, 29 May 2003 08:17:30 +0100
Peter-Henry Mander <erlang@REDACTED> wrote:

> Morning Chris,

Good afternoon!

> [...]
> But C++ and Java have lost these most 
> attractive aspects by attempting to be strong-typed and early-binding.

.'. statically-architected pre-planning sucks.

> > [...] in order for a replacement for records to not suck as
> > badly, some research would have to be done into what means of
> > aggregating data & code have succeeded in not sucking.  i.e. to look
> > into fields like OO and take what works and leave behind what
> > doesn't.
> 
> I find that records in themselves are syntactically ugly, but 
> semantically useful. The only thing about records I would change would
> be the syntax, and only for aesthetic reasons.

Erlang's syntax is pretty dire anyway - better than C++ or Perl, but for
every nice thing in it I bet I can find something nasty.

In that light, the record syntax doesn't seem too bad.

My problems with records are more semantic:
- they're optimized for performance - which is not always the #1 goal
- they're compile-time only - making general functions which work on
records very awkward to write
- they're not a real type - they're "repurposed" tuples
- they're not typesafe - A#b "casts" A as a b whether it is or not
- when used across modules you get header file dependency headaches,
esp. during code upgrade
- when used internal to a module, they can't be pattern-matched from
outside that module

These all more or less follow from the first.  If you're willing to take
the performance hit, dicts solve many of the problems.  But you can't
pattern-match on dict contents, which is why structs look appealing.

> [...]
> I've mostly found that ideas are freely discussed here, it's a
> pleasantly open-minded discussion group.

The fact that I haven't been ridden out of town in a rail yet speaks
volumes for the tolerance of the Erlang community :)

However, pragmatism is a fly's eyebrow away from cynicism...
One hopes the influence of the gurus' is only linearly proportional to
their focus :)

> Pete.

-Chris



More information about the erlang-questions mailing list