57 points · by fogus · 16y ago · 23 comments
I didn't see this one in my reader, though the author is a member: http://news.ycombinator.com/user?id=KirinDave
The problem I've got with posting stuff from 'the same feeds' is that it tends to drown out the non-mainstream (and non techcrunch ;)) stuff, which is what really makes HN interesting.
Between all the spam posts and the 'feed pushers' a lot of really good content never makes it to the home page and so is lost to a great many readers.
Personally I've switched to the 'new' page as the homepage of HN long ago, but even there if you look the other way for one or two days it's hard to catch up because of all the fluff.
The scala one is a webapp that is sitting on top of a lot of specialized machinery provided by lift.
They are both short chat applications in the new cool languages on the JVM, and both are neat code samples, but other than that they don't have much in common.
Perhaps you could write a basic chat server in Scala to show us? Really, I found this exercise quite fun. The programmer's equivalent of cotton candy.
http://dhotson.tumblr.com/post/271733389/a-simple-chat-serve...
Any difference in functionality?
The data model is slightly different, too. Clojure has very powerful concurrency-safe data structures which made my data structure slightly more obvious. It's just a hash table of lists, and the lists contain tuples of [Name, StringWriter].
If you know Javascript and you don't know Clojure, it's probably natural your eyes follow that example more easily. I wouldn't say either version is particularly more convoluted than the other (although it's obvious we both made some decisions that favored brevity over readability).
Mainly just a curiosity question, I realize not many people will ever have to deal with thousands of concurrent people chatting.
I'm probably going to extend this exercise by switching from the default contrib library networking and standard java.io, and instead use netty. I'm told that can give me superior performance and scalability, and I don't think it'd take much more code. But the rest of the code should be fine. I'm quite certain, from profiling, that the core data structures can scale to thousands (and even millions) of users. Clojure's refs and agents are extremely well-implemented.
But, I'm not sure the node.js version really would scale to thousands of users. Every time someone connected hits enter the entire user set is looped over, synchronously. I suspect this latency will add up. The reason that code is so simple and direct is that everyone is just executing slices in one thread. In my version, the rooms have a thread pool (implicitly), so it really comes down to how many user threads java can allow.
The only reason I didn't was that the original node.js was usable right from netcat or telnet without prefacing anything with /say or any such command. If I had multiple rooms, a /say <targetroom> <message> would have been required and I didn't think that was very fun to type.