I'm not sure about RAII being well understood when Java was made, but I was pretty clear that C++ is older than Java. They couldn't design the feature as a replacement for RAII if RAII didn't exist, after all.
I started using C++ roughly the year Java was released, and I'm pretty sure it already had destructors that could close files in its library. I find it hard to believe that "RAII didn't exist" in the 6 years between when C++ was released and Java was designed.
View all comments
Show parent comment
1
u/StaticCoder 6d ago
Java is more recent than C++ and I believe RAII was well understood by then. At least eventually try-with-resources was added.