Article: Why Const Sucks

aberba karabutaworld at gmail.com
Tue Mar 6 09:39:07 UTC 2018


On Monday, 5 March 2018 at 10:57:35 UTC, Jonathan M Davis wrote:
> Here's something I wrote up on const:
>
> http://jmdavisprog.com/articles/why-const-sucks.html
>
> I suppose that it's not exactly the most positive article, but 
> I feel that it's accurate.
>
> - Jonathan M Davis

Its amazing how typed languages, in this case const, forces you 
to think in mutation but with an exception. I wonder the real 
world SOLE benefit of using const compared to mutable-immutable 
style. Its either mutable or immutable. Exception could only 
available by casting immutable to mutable.

I feels this const thing is a theoretical problem. One can 
overcome practically with code style discipline. At a point, 
const becomes just a decoration; something people use prematurely 
(YAGNI).

It must feel like sleeping on your bed with sharp knives hanging 
at the top such that they can fall on you anything: when 
comparing code in a typed language to an untyped one. That's a 
potential cause of premature use of certain type attributes.


By the way, Jonathan, you should really consider writing a book 
with such deep insights your have. Especially the way you explain 
things.


More information about the Digitalmars-d-announce mailing list