A few weeks ago I made a two-part video discussion about building a telnet chat server from scratch using ZX and forgot to post any prose reference to it. (Most people are following my blog RSS, not my (extremely tiny) video channels.)
The resulting project is called “Trash Talk” and it has a repo on GitLab here. The license is MIT and is quite simple to hack around on, so have fun.
The first video is a bit slower paced than the second. I cover:
- What ZX templates when you do
zx create projectand select the “Traditional Erlang Application” project option
- How everything fits together and works
- Discussion about why things are structured the way they are in OTP applications
- Demonstrate a little bit of command implementation in the telnet server (mostly to show where in the code you would do that).
This video is a lot less exciting than the second one because there aren’t a lot of jazzy features demonstrated, but it is probably the one you want to watch once now if you’re new to Erlang and a second time a few weeks later once you’ve written a few projects and stubbed your toes a few times (a second viewing brings different insights, not because the video changes but because you change through your experiences).
The second video is the more fun one because the initial explanation that covers the critical question of “Why does anything do anything?” has already been covered in the first one, and while you might find the first video interesting, it isn’t as exciting as this second one where you get to see features that do stuff that might be more relevant to problems you have in your real-world projects get implemented. In this one I cover:
- Checking the state of the running system using
- The difference between
zxhwhen running your code in development
- The “Service ⇒ Worker Pattern” (aka “SWP”) and how ZX can help you drop one in via
zx template swp
- One way to implement text commands in a structured way, with categories of commands indicated by prefixes (this seems elementary and very IRC-ish at first, but in command protocols a direct parallel of this often happens at the byte level — so think on that)
- How to separate the “clients” concept as a service from the “channels” concept as a service, and discuss how that idea extends to much more complex systems
- A bit more useful version of a “service manager” process in the form of the
- And much much more! (advertising people from the 1980’s tell me I should always say that instead of “etc.”)
These aren’t super jazzy, but they get the job done. Hopefully they give some new Erlanger out there a leg-up on the problem of going from a “Hello, World!” escript to a proper OTP application.