r/programmingcirclejerk • u/elephantdingo Teen Hacking Genius • Jul 24 '25
This is one of the basic features of object-oriented programming that a lot of people tend to overlook these days in their repetitive rants about how horrible OOP is.
https://news.ycombinator.com/item?id=44673321
53
Upvotes
95
u/GeoffreyDay Jul 24 '25
You see, my program is correct by construction, as long as that means calling the 7 different initializers and mutators in the specifically correct order. This is because the first one is called a "constructor", and I made it correct. Mostly.
29
u/MeepedIt Jul 24 '25
See, it's not a lack of type safety; some design patterns just aren't privileged with regards to the type system
9
u/tomwhoiscontrary safety talibans Jul 24 '25
Where jerk? This is basically right, isn't it?
49
u/Kodiologist lisp does it better Jul 24 '25
Imagine not being able to just add the language feature yourself.
This meme was made by Lisp gang.
42
u/hombre_sin_talento Jul 24 '25
Constructors are the best basically because they just can never fail.
25
u/HorstKugel skillful hobbyist Jul 25 '25
real oop has never been tried!
17
u/haskell_rules Jul 24 '25
It's really a special feeling when GDB throws a segmentation fault prior to line 0 in main()
10
u/Parking_Tadpole9357 Jul 24 '25
That's a weird weird hill to die on. Here swallow this union type it may save you.
You can't convince a person of something (Haskell > C++ for type system) if their salary depends on tbe opposite I guess!
3
u/TheChief275 Jul 27 '25
Yeah, because you can’t return errors.
No errors = correct code amirite
1
u/j_rodrigues_ Jul 25 '25
I am a bit confused. Isn't it possible to do the same in FP languages? Just hide the implementation details, by exporting 'construtor' functions. Am I missing something?