Hacker News Comments on
Erlang: The Movie (Fixed Audio)
CH1LLW4VE
·
Youtube
·
209
HN points
·
7
HN comments
- This course is unranked · view top recommended courses
Hacker News Stories and Comments
All the comments and stories posted to Hacker News that reference this video.Sounds like live patching in Erlang. Kudos for pulling it off without support by the runtime.
This is the same "movie", but the audio has been fixed to not play out of just the left ear: https://www.youtube.com/watch?v=BXmOlCy0oBM
⬐ scnsLike on a telephone :)
This is almost certainly a reference to Erlang: The Movie [1] which is the most glorious 11 minutes of some programmers explaining how their creation works you will ever see. In the video, the three call each other to demonstrate what happens real-time in an Erlang system. For the impatient, the telephone conversation starts at about minute 3.
At least we have this "Erlang: The Movie" demo to reverse engineer some bits: https://m.youtube.com/watch?v=BXmOlCy0oBM
⬐ tonyarklesThat's awesome! Thanks!
Interestingly, if you watch the Erlang: The Movie (https://www.youtube.com/watch?v=BXmOlCy0oBM) they use the term 'declarative programming' to refer to what we would now call 'functional programming'. It's an interesting way of thinking about it - these sort of declarative interfaces are very simple in languages with first class function support.
⬐ tsimionescuC has first-class functions support, but I don't think it's very easy to define such interfaces in C. Closures and automatic memory management seem to be the "magic dust" that makes this nice to use, first-class functions are necessary but not sufficient.⬐ lmm⬐ swyxC doesn't have first-class functions, because you can't define new functions in general places (only at top level).⬐ jschwartziGCC supports this as an extension actually. I’ve never used it though.⬐ tsimionescuThe definition of first-class functions is the ability to treat functions as data, which C supports. Yes, they are cumbersome to work with, since they must always be defined at top level, but that is just missing syntax sugar. GCC even allows nested function definitions.⬐ dllthomasMy understanding agreed with your respondent. I haven't dug deeper but per wikipedia there's a split in the CS community as to whether function literals are necessary for functions to be first class. I think we all agree on the reality of the situation, whichever way we decide that ambiguity.⬐ lmm> Yes, they are cumbersome to work with, since they must always be defined at top level, but that is just missing syntax sugar.It's not just syntax sugar. Try writing a function that takes an array of integers and an integer x, and sorts the array mod x by calling qsort. In C this is not just cumbersome but impossible.
⬐ tsimionescuWe can do it with a global variable.We could even wrap qsort so that you could pass something much closer to a closure to it :static int reg; int cmp(int a, int b) { return a%reg - b%reg; } void qsortModX(int[] a, size_t len, int x) { int tmp = reg; reg = x; qsort(a, len, sizeof(*a), cmp); reg = tmp; }
With this, you can define a `struct closure` that encapsulates a function and some data and use that to pass to qsort_cls. You can even make it thread safe by using thread local variables instead of globals.static void* g_ctx; static int(*g_cmp)(void*, const void*, const void*) int compare(const void* a, const void* b) { return g_cmp(g_ctx, a, b) ; } void qsort_cls(void*[] a, size_t len, size_t elem, int(*cmp)(void*, const void*, const void*), void* ctx) { void* tmp = g_ctx; g_ctx = ctx; int(*tmp_f)(void*, const void*, const void*) = g_cmp; g_cmp = cmp; qsort(a, len, sizeof(*a), compare); g_ctx = tmp; g_cmp = tmp_f; }
Basically, if you want higher-order functions in C, you can do it, but you need to take a context pointer and a function which accepts a context pointer. The writers of qsort didn't think of that, so we had to resort to global variables to do it, but you could also re-write qsort to avoid the need for the global variable.
As I said, we're missing a lot of syntax sugar, but we can still work with functions as first class objects in pure C.
⬐ lmmWhat you're proposing requires extra work to be threadsafe, is even less typesafe than normal C functions (you've lost checking that `ctx` is actually an `int`), requires you to reimplement it for each standard function you want to use, and is significantly syntactically more cumbersome even after you've done all that. If that's "first class" then how bad would things have to get before you called them "second class"?⬐ tsimionescuI am sympathetic to what you're saying, and in the end this is just a matter of definitions.I would note though that with C's type system, you always have to choose between type safety and genericity, this is not exclusive to higher order functions. C doesn't have a notion of threads or thread safety, so talking about thread safety in pure C does not make sense. And the fact that the designers of the stdlib didn't think about supporting closures still doesn't mean that the language itself doesn't support them. Other foundational libs, like pthreads, do have support for this style of closures built in.
⬐ lmm> with C's type system, you always have to choose between type safety and genericity, this is not exclusive to higher order functions.True, but functions defined via some kind of "struct closure" scheme are non-typesafe even when monomorphic (e.g. if all the types are int).
> C doesn't have a notion of threads or thread safety, so talking about thread safety in pure C does not make sense.
I'd hold that a function that relies on a global variable is noticeably second-class in a number of ways. Multithreading is one place where this comes up, but you also have to be careful about using it in a recursive context, or use in a library that might be called from more than one place.
> And the fact that the designers of the stdlib didn't think about supporting closures still doesn't mean that the language itself doesn't support them.
Any Turing-complete language "supports" any feature of any other language in a sense, because it's always possible to emulate that other language. If we say functions are first class then we mean not only that it's possible to represent functions as values (because that will always be possible), but that functions represented this way are just as good values as the language's built-in notion of values, and just as good functions as the language's built-in notion of functions.
i think of declarative and functional vs imperative and nonfunctional as kind of the same thing. is there a word for nonfunctional?⬐ imglorpProlog was inspiration for the Erlang syntax and it's about as declarative as you can get.In Prolog, everything is either a fact or a rule involving facts. If you leave some variables unbound, you get what we think of as a program, where the system tries to infer values.
https://www.youtube.com/watch?v=BXmOlCy0oBM the first seconds
Fred probably forgot to mention it, but Joe, Mike, and Robert starred in a short film Erlang: The Movie, a very fine and concise demonstration of fault-tolerance of Erlang.The film has some magic power that I cannot describe but made me watching it over and over again.
YouTube link to the film with fixed audio: https://www.youtube.com/watch?v=BXmOlCy0oBM
⬐ JoelJacobsonMusic video based on the same video: https://www.youtube.com/watch?v=p1LjmDCOM-8&t=147s⬐ yellowapple⬐ bjconlanIn the words of a text-to-speech impression of Joe: "I absolutely love it. That name^H^H^H^Hsong is fucking gangsta."I'm glad that Joe (and the entire erlang team) got the deserved recognition while they were alive. I also appreciate the title because of the aforementioned film. I was always curious as to if the Simpsons' 'Hello Joe' was a nod to this.⬐ nvarsjSuch a great film! I’m embarrassed to admit how much time/money went into making a large JVM deployment support 0 downtime upgrades. Remarkable that these basic things are still not easy to do with most modern tech.⬐ exrookI'm fairly sure the ending lines:were a reference to the movie.Hello Mike, Hello Robert, Goodbye Joe.
I went to go watch it again after reading this but you beat me to posting the link here ;)
⬐ jackdhMost definitely a reference, what a touching way to sign off.
⬐ HocusLocusI had the privilege of working on the IT end of one of the first System 12 ITT/Alcatel 1210 switches in the US Virgin Islands (a prototype since local telco was owned by ITT). It may not sound like much now but in 1990 that "look! after this warm restart this existing call is still in progress!" was a big deal, since the smaller PBXs tended to wipe working memory and dump everything on restart. DMS would later dominate the ESS market, but ours was one of the first that could support class 3/4/5 operations simultaneously (trunks, operator positions and subscribers) within the same memory pool which was managed as virtual storage separate from the processors.Not Erlang but same concept and I'm not sure what the software development environment was, but the thing was loaded to the gills and almost all ops save major software upgrade only required warm restarts which preserved existing connections (perhaps with some delays of digit processing).
Two major problems I remember in those days was a bug in operator position handling where a certain operation created some sort of race condition that brought it all the way down. That was fixed but the other was not so easy... mainly because it was doing triple-duty as class 3/4/5, what functioned as a stack/event queue occupied an insufficient pool of memory to handle extraordinary events. And in that early state of development overflow of the event queue was a fatal cold start error ... from a cold start it took ~15 minutes to come up again.
Murphy's Law supplied TWO great examples to illustrate the problem. One was a severe cable cut, an auger down the street from the telco wrapped itself around ~3,000 pairs and triggered many events. The next was an earthquake... and everyone picked up their phones at once.
⬐ lake99I guess this is the source of all the insider jokes that people have been making for the past couple of days.⬐ sirpeetZotonic (an Erlang based framework and CMS) was inspired by the movie and referenced it in their introduction video some years ago: https://youtu.be/r9cmWJvXIj4⬐ falsedanGoodbye, Joe⬐ mproudGoogle captions calls it “Ireland” or “Airline”.⬐ spiralganglionThis video is ripe for remixing.Here's the (short) silly cut I made of it last summer: https://www.youtube.com/watch?v=UuSZ37vMIks
Here's another (longer) remix: https://www.youtube.com/watch?v=rRbY3TMUcgQ
⬐ ubercowIt's funny you mention that, I came here just to post another wonderful remix, "Erlang The Movie II: The Sequel".⬐ spiralganglion(Psst: That’s the second link I posted.)⬐ ncmncmThat is f'ing brilliant! And I'm no sock puppet.⬐ HocusLocusI am a sock puppet, it blew my sock off