Hacker News new | past | comments | ask | show | jobs | submit login

Why is "final" an unsafe feature?



Hi, I'm one of the authors.

"Unsafe" has a very specific meaning in our book -- it doesn't refer to security or to the fact to a feature is inherently bad.

It means that the cost/reward ratio of teaching a certain feature and using it in a large codebase to which multiple engineers contribute to tends to be negative.

There's nothing inherently bad about 'final', but it's easy to overuse it for no real benefit, and it can cause reusability issues in larger companies where inter-team refactorings cannot be done automatically. That's pretty much it. There are also some excellent use cases for 'final' described in the book, but they are very niche.

Hence the "unsafe" categorization, i.e. I wouldn't teach this feature to a new hire :)


The other features labeled "unsafe" also are not. And, the ones labeled "conditionally safe" are just safe.

1300 pages, and nothing useful to say in them.


If you had spent a few minutes reading the meaning of "unsafe" in the book's first chapter (freely available), you would know exactly what we mean by "unsafe", which is far from the misinformation you're spreading.

I don't know if you have been fired from Bloomberg or failed to pass an interview there, but there seems to be vitriol and anger behind your posts.

I think that people would take your "criticism" more seriously if you backed it up with facts and examples instead of repeatedly begging readers to not buy the book :)


It is not.

But virtual functions have strictly limited usefulness. If your go-to organizational feature is class hierarchies, you are probably not programming well.


'final' only partly relates to virtual functions, you are forgetting or ignoring the use of 'final' on classes.

Also, 'virtual' functions are extremely useful to define interfaces that separate teams can implement and consume independently.

Variants and algebraic data types are not the answer to anything, and it is not "outdated" to use 'virtual' where appropriate, despite what your other comments might imply.


There is nothing unsafe about final classes, either. Non-final classes could be risky, but not enough to worry over.

Virtual functions are a mechanism that has legitimate uses but makes a poor organizational basis for a program.


> There is nothing unsafe about final classes

The book agrees with that statement. If only you had taken 5 minutes to read a few pages before starting to beg strangers on the internet to not buy something that could improve their career just because one of the authors hurt your feelings sometime in the past...

> Virtual functions are a mechanism that has legitimate uses but makes a poor organizational basis for a program.

This is what I would consider "filler", much like the rest of your posts. Opinions presented as facts, without any sort of source, example, nuance, or elaboration.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: