[erlang-questions] erlang sucks

attila.rajmund.nohl@REDACTED attila.rajmund.nohl@REDACTED
Tue Mar 18 11:43:26 CET 2008

On Mon, 17 Mar 2008, Kevin Scaldeferri wrote:

> On Mar 17, 2008, at 6:31 AM, Jani Hakala wrote:
>> attila.rajmund.nohl@REDACTED writes:
>>> I don't think that immutable variables make it easier to write less
>>> buggier code. On the contrary, I often see code like this:
>>> HR1=f(HugeRecord),
>>> ...
>>> g(HR1).
>>> Then someone adds a line to modify the HugeRecord and forgets to
>>> update
>>> the call to 'g':
>>> HR1=f(HugeRecord),
>>> HR2=f2(HR1),
>>> ...
>>> g(HR1).
>>> Now we have a stupid bug.
>> The compiler would warn about that
>>    Warning: variable 'HR2' is unused
> These examples always feel like people are insisting on writing
> imperative code in a functional language.  Why not:
> HR1 = f2(f(HugeRecord)),
> ...
> g(HR1)

Because this is a mock-example, the real code looks more like

... code uses HR1
g(HR1), % forgot to update variable name
h(HR2). % didn't forget to update variable name

In this case the compiler won't save my a**. I see this kind of code
change all the time. Every week I see a checkin which only fixes a
variable name that wasn't updated, so this is not exactly a rare bug.

"Beware of bugs in the above code; I have only proved it correct, not
  tried it."

More information about the erlang-questions mailing list