Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I’d go as far as saying classes are never the simplest tool for the job.

But maybe the past 10 years of functional-ish programming have broken me. There are lots of problem areas where objects fit nicely. Actor based programming is very elegant with classes and objects I think.



Sadly C++/Java/C# have given classes a bad name. I think a lot of that is because in those languages classes are pretty much the only tool in the toolbox. After a while you are going to really hate that tool, no matter what it is. Also, all those languages are a pretty poor implementation of classes and OO.

Modern multi-paradigm languages are great because you can use classes when classes are the right thing, and functional programming when that's the right thing.

Classes are a great tool, but not the only tool.


> Modern multi-paradigm languages are great because you can use classes when classes are the right thing, and functional programming when that's the right thing.

There doesn't seem to be an either/or situation when using CLOS in Common Lisp.


The two biggest problems with OO as it's traditionally used are:

1. Implementation inheritance creates brittle, tightly coupled and difficult to test code.

2. Mutable classes force you to structure data updates in a particular, inflexible way. In a world where you're sharing data across multiple clients, serializing and deserializing, using things like Redux to structure updates etc this creates a huge amount of internal friction.


There are things like static classes and functions that can co-exist.


Isn’t a static class essentially just a namespace?


Static classes still have constructors that gets invoked to create the static instance. Namespaces doesn't have constructors and instead each member of the namespace gets constructed separately.


I guess it depends on the language but I've definitely had problems with codebases that depended heavily on static initializers. IMO it's usually better to explicitly bootstrap your code.


Most developers aren't fully aware of how static initialization works so putting it in your code usually isn't a good idea even if you know it, no, but it is a difference between static classes and namespaces.


I agree with that.

My class-based solutions are more prone to failure than other solutions I've used before. It always gets more complex than it should.




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

Search: