Chatting in real-time invovled server-client communication. For example, PHP web is best for Create-Read-Update-Delete operation, but it is inefficient for chatting, as the client need to pool against the server for new data periodically. This would not scale for the server against the growth of user base.
This is where Node.JS/Express/MongoDB/Socket.io comes in. The tech stack allows distribute system.
While digging into these, I realized that Erlang/OTP (Open Telecom Platform) was developed for this purpose. I could say that this is a specialized programming language. It purpose is to have a hot-swappable code, it allow processes to run forever without downtime. It solves distributed system. Real-world application like WhatsApp and Facebook chat use this solution. However it is inefficient for CRUD operation (or is it?🤔)