Erlang jokes are too rare
May 8, 2009 Erlang, General Interest, Miscellaneous No CommentsBut this one’s funny.
But this one’s funny.
Always nice when someone lets you know, y’know?
[19:43] <apples> by the way StoneCypher, if you're curious, the level
of functionality provided by my SMTP server in C, which is
~1000 lines, i trimmed down to less than 100 in erlang :p
[19:45] <StoneCypher> lel
[19:45] <StoneCypher> and i bet it's less buggy now too
[19:45] <apples> quite
[19:46] <apples> oh, and i wrote it in an hour
[19:46] <StoneCypher> awesome
[19:46] <StoneCypher> can i post that quote on my blog?
[19:46] <apples> sure thing
Helps one remember one’s doing the right thing to push people to learn new things.
I originally found the PCM through Starling Software’s copy, but it turns out to originally be by Sijin Joseph. As both sites have lots of other interesting content, I’m linking both.
The Programmer Competency Matrix is a surprisingly realistic grid of capabilities sorted by topic, which gives an extremely rough but in my opinion basically valid idea of an engineer’s gumption. Starling republished it as part of their standard set of tools to be used during a hire.
Regardless of whether you agree with the grid or its data, it’s fun. Have a look, and try scoring yourself.
One of the most amazing things to me about the typical adware scumbag is their desperation to justify their own behavior. An interview with such a person just went onto slashdot, in which in the site afterword, he attempts to compare his choices to the Millgram Experiment.
Of course, anyone with half a clue will remember three things:
The dirtbag goes on to talk about how difficult it was to ignore a challenging occupation when one doesn’t have many other options. Thing is, I could be making tons of money as a pirate, or writing malware, and I manage to get through my day without doing it. I’m also willing to bet that Drew Peters wasn’t actually looking for other jobs at the time.
“It’s even harder if the bad starts out small and slowly gets bigger.”
Horseshit. The second you do something bad, you object, and if they try to force you, you walk away. That’s why when I found out my old boss Russell was triple- or more billing his clients in my name, I told him that he stopped tomorrow, or I walked. Did I get fired? Sure, but I told the client what happened, so so did Russell, and I ended up getting the job back with a different boss and a much larger hourly billable.
Oh, and I had my honesty and decency intact.
Go to hell, Matt Knox. It’s not that hard to not write malware. It’s just hard for people like you. I hope that eventually you find yourself the victim of the things you’ve done to others; you’ve almost certainly caused far more damage than you’ll ever understand, during a time where it was extremely easy to get other work.
Disgusting.
There is a failure in WebKit to honor overflow:hidden with clear:none on child elements. This prevents several cheesy no-table space filling strategies which have worked portably since IE3 from working in WebKit derived browsers (safari, chrome, etc.)
Test case with screen shots and examples.
I have submitted this as Bug 23221.
[digg-reddit-me]I’ve had mixed reactions to this when I’ve discussed it with people on IRC. This may be well known to oldbear Erlang programmers. I suppose it’s also possible that I’m wrong, though I’ve talked to several people I respect, and more than one of them have suggested that they were already aware of this problem. If I’m wrong, please let me know; I’m open to the possibility that there’s a better answer that I just don’t know about. I’ve never seen it discussed on the web, at least. Update: Serge Aleynikov points out that this TrapExit tutorial documents this approach.
I think this is probably real.
I believe there is a significant defect in the idiomatic listener pattern as discussed by most Erlang websites and as provided by most Erlang example code, and which is found in many Erlang applications. This defect is relatively easily repaired once noticed without significant impact on surrounding code, and I have added functionality to my ScUtil Library to handle this automatically under the name standard_listener.
The fundamental problem is essentially a form of race condition. The idiomatic listener is, roughly:
do_listen(Port, Opts, Handler) ->
case gen_tcp:listen(Port, Opts) of
{ ok, ListeningSocket } ->
listen_loop(ListeningSocket, Handler);
{ error, E } ->
{ error, E }
end.
listen_loop(ListeningSocket, Handler) ->
case gen_tcp:accept(ListeningSocket) of
{ ok, ConnectedSocket } ->
spawn(node(), Handler, [ConnectedSocket]),
listen_loop(ListeningSocket);
{ error, E } ->
{ error, E }
end.
Now consider the case of a server under very heavy load. Further, consider that the listening socket is opened either {active,true} or {active,once}, which is true in the vast bulk of Erlang network applications, meaning that packets are delivered automatically to the socket owner. The general pattern is that the listening socket accepts a connection, spawns a handling process, passes the connected socket to that handling process, and the handling process takes ownership of the socket.
The problem is that it takes time for that all to happen, and Erlang doesn’t specify or allow you to control its timeslicing behavior (as well it should not). As active sockets are managed by a standalone process, this means that if the connecting client is fast and the network is fast, the first packet (even the first several under extreme circumstances) could be delivered before the socket has been taken over by the handling PID, meaning that its contents would be dispatched to the wrong process, with no indication of where they were meant to go. This invalidates connections and fills a non-discarding mailbox, which is a potentially serious memory leak (especially given that erlang’s response to out of memory conditions is to abort an entire VM.)
Obviously, this is intolerable. There are better answers, though, than to switch to {active,false}. One suggestion I heard was to pre-spawn handlers in order to reduce the gap time, but that doesn’t solve the problem, it just makes it less likely.
The approach that I took is to lie. standard_listener takes the following steps to resolve the problem:
This neatly closes the problem. A free, MIT license implementation can be found in ScUtil beginning in version 96. A simplified, corrected example follows for immediate reference; the thing in ScUtil is more feature complete.
do_listen(Port, Opts) -> ActiveStatus = case proplists:get_value(active, SocketOptions) of undefined -> true; Other -> Other end, FixedOpts = proplists:delete(active, SocketOptions) ++ [{active, false}], case gen_tcp:listen(Port, FixedOpts) of { ok, ListeningSocket } -> listen_loop(ActiveStatus, ListeningSocket); { error, E } -> { error, E } end. listen_loop(ActiveStatus, ListeningSocket, Handler) -> case gen_tcp:accept(ListeningSocket) of { ok, ConnectedSocket } -> spawn(?MODULE, shunt, [ActiveStatus,ConnectedSocket,Handler]), listen_loop(ActiveStatus, ListeningSocket, Handler); { error, E } -> { error, E } end. shunt(ActiveStatus, ConnectedSocket, Handler) -> controlling_process(ConnectedSocket, self()), inet:setopts(ConnectedSocket, [{active, ActiveStatus}]), Handler(ConnectedSocket).
[digg-reddit-me]My erlang library ScUtil has been public at the ScUtil page for some time now. Recently, I’ve been working on documenting it. It’s about half documented in its current state.
Here’s the prototype ScUtil documentation. I’m open to commentary.
THIS IS ONLY HALF WRITTEN. I have been sitting on this post, waiting for the mood to finish it, for months; because EEP18 is now being treated as a likely implement, I am immediately publishing the half-written version, because it exposes many (though not all) of the serious, irreconcilable problems with EEP18.
On the mailing list, people are actively trying to bring Erlang up to snuff with regards to web standards. One of the more unfortunate choices being discussed is JSON as a data notation. JSON, unfortunately, does not actually map to Erlang in a useful way. Joe Armstrong has gone as far as to suggest BIFs, which are decidedly unrealistic as well as unnecessary. My goal is to create a JSON handling library. However, the mailing list is beginning to put momentum behind an alternative proposal which is currently presented in BIF form.
This post explains why my approach is different. Many of the issues herein are discussed by the tabled EEP (EEP 18, “JSON BIFs” by Rickard O’Keefe), but some are not, and some of these issues are accepted when I believe they should not be. It is my position that EEP 18 is unacceptably dangerous. I will explain why.
[digg-reddit-me]My good friend Jeff happened to mention offhand his knowledge of a document I’ve been looking for for quite some time now. I’m sharing it with my readers in case they’re looking for something similar.
Let me be forward: I cannot stand the various Objective C books I’ve tried. They all want to teach me to be a programmer. I’m already there. I just want a book like Stroustrup. The PragProg book is awful: the first several chapters are about Mac development tools, like I give a damn. Everything’s through interface wizards. It’s nauseating.
Jeff heard mein painz0rz, and turned me on to From C++ to Objective-C. It isn’t perfect: it’s not super comprehensive, and it’s translated from a different native language (French), which leaves a few passages cumbersome. However, as one can tell from reading the intro, the author of the document, much like me, found little to love in the state of Objective C documentation, and wanted to write something for people who were already well established.
Kudos to Pierre Chatelier for writing the book that Apple and Alan Kay could not.
My boss’ boss, Varun, is letting me open source some of the work I’m doing at Kayako. I’m not supposed to talk about the interesting three until they’re ready for release, but I can tell you that a JavaScript ISO8601 implementation is among them, and that they’re all going to be MIT licensed, no GPL contamination.
More news as I get my butt in gear and finish the libraries in question. But, yay Varun!