Erlang, because of its architecture, has something of a habit of people rewriting various protocols in Erlang itself, rather than calling out to some C library.
Writing protocol code in Erlang is nice, because the parsing is so easy and clear. And if you want to do something that's not so easy by spawning a command, then you may as well build it in Erlang. And it's fun and symmetric to build both a server and a client... I've not looked at OTP SSH code, but I'd assume the ciphering is still calls to external c libraries, as it is in the OTP TLS code.
Of course, easy protocol parsing doesn't do the whole job; state management is required too (and was missed here, clearly).
This is probably because C NIFs run in the same process as the Erlang scheduler. If you have a long-running or blocking NIF, it can starve the scheduler and cause significant performance degradation across the system.
yes, but there is a finite number of them, by default equal to the number of available cores. If your connection stays in c-land for too long you might run into trouble, if more than one connection are desired.
libuv is more or less abstraction around an event loop for async i/o right?
The BEAM is also more or less an abstraction around an event loop for async i/o. If you want async i/o in nifs, I think you want to integrate with BEAM's event loop. Inside NIFs, I think you want to use enif_select [1] (and friends), available since OTP 20 originally from 2017-06-21. In a port driver, you'd use driver_select [2] which I think has been around forever --- there's mentions of changes in R13 which I think was mostly release 2009-11-20 (that may have been R13B though).
It uses different threads in order to make infrequent blocking calls look like they are asynchronous.
When we (or at least some quantity of “we”) want is infrequent native calls to be able to fail without taking the BEAM down.
The problem with doing it with threads though is that a bad thread can still vomit all over working memory, still causing a panic even if it itself doesn’t panic.
Oh I see. If you need to isolate your native code from your BEAM, then you've got several options.
a) run the native code as a separate process; either a port program, a c-node, or just a regular program that you interact with via some interprocess communication (sockets, pipes, signals, a shared filesystem, shared memory segments if you're brave)
b) some sort of sandybox thing; like compile to wasm and then jit back to (hopefully) safe native.
c) just run the native code, it's probably fine, hopefully. My experience with NIFs is that they are usually very short code that should be easy to review, so this isn't as bad as it sounds...
If your native code is short, option c is probably fine; if your native code is long, option a makes more sense. If you want to make things harder without real justification, b sounds good :P
I suspect the confusion of priorities comes from running native code that’s time consuming and wanting it to horizontally scale with your cluster, which is easier if you try to let the beam do it.
While what is easier for those of us not working on the beam is to put the glitchy code into its own service and put up with the maintenance overhead.
But when you have one or two solutions the friction to move to three becomes difficult. People start talking about how having dozens will be chaos. While true, sometimes you really do just need three and it’s not a slippery slope.
They've sussed out that if you suck up to him he'll give you an exemption. Of course if you are a medium sized business you are screwed and have to wait in line, but you'll get your chance as long as you can hold on through the summer.
People are likely to start suffering real, personal pain because of all the garbage coming from the White House. If you lost your job at the factory because of the tariffs, and hear some loud Americans next to you at the bar... maybe you don't feel so charitable towards them compared to a more abstract dispute over, say, your views on the best way to provision health care.
Not sure how likely that will be (the bars where factory workers hang out tend to not be the ones in tourist areas, for one), but it seems plausible to me.
I wouldn't let that stop me from travelling though.
One thing companies love is lots of uncertainty like this. It keeps their accountants entertained! "Maybe we should build a factory in the US" ... 24 hours later ... "well, not today".
What's really amazing is all the muttering from "Very Important Wall Street" type people who are saying that he's insane. Like... with that kind of salary, weren't you paying attention? We've known he wasn't right in the head for a while now. Maybe they should be replaced by AI.
Why would a company go through the trouble of building a factory when the next administration could just reverse the decision four years from now? Building factories will take years
How confident are we that there is a "next administration... four years from now"? I don't know what the number is, but it ain't 100% like it used to be.
The market is huge enough that the fact that something is being considered somewhere doesn’t mean much, right? If I consider building a factory in the woods, but I don’t have two pennies to clack together, does anybody hear it?
That was part of the entire purported purpose of this lunacy. They went on TV and everything about having people operating robots screwing in iphone screws and stuff.
Whether anyone bought into it is another matter, but opening factories is part of what they said they wanted.
Thailand is a good example. They have about $40b (USD) in balance of trade going the wrong way. Their initial ideas were simply to import more american petroleum, vehicles and aircraft. This likely could have accounted for more than half the difference and significantly reduced their tariff rate by just changing suppliers of already imported products.
The US news is pretty useless here. It's more nuanced than they would like to admit. Foreign sources of news are the most instructive as they're actually covering the options realistically.
At this point, I do wonder if long-dated (2-3 months) American-style Puts are a good idea.
The weirdness of this administration has created a lot of volatility. With American-style options you are allowed to exercise early, so if you think there's going to be a ton of ups and downs in the next few months, I wonder if this could be lucrative.
I might try this just as an experiment with one of the cheaper options.
Exercising early only makes sense in some pathological examples that do occur but practically never happen. In general, very loosely, a put is worth something for the hedge plus the amount you could get for exercising it right now. Thus, if you want to exercise it right now, you just sell it and get the hedge premium.
Also, the current VIX is the same as January of 2020. If you believe the current state of the world is less certain than the outbreak of a global pandemic, I have some options to sell you.
Yeah, misspoke, I meant selling the option, not exercising.
> Also, the current VIX is the same as January of 2020. If you believe the current state of the world is less certain than the outbreak of a global pandemic, I have some options to sell you.
I don't know if it's more volatile, BUT it it has shot way up since yesterday, and it doesn't seem too weird to think that it will go down to the numbers we had yesterday.
The number of people who are paid to be "professional knower of things" and "professional predictor of things" who are now saying "I never could have predicted that Trump would do something as crazy as this" is just baffling.
In a sane world all these people would be ignored by media outlets moving forward.
The media outlets are part of the problem. Lots of sanewashing and "both sides". Many of them also love "CEO says a thing" articles where they act as stenographers. You see that with a certain car company's wild promises.
I sold my stocks just barely in advance of this whole debacle. I remain confused that it wasn't already priced in by that point. I am not a savvy investor by any standard.
It's a confirmation to those that still needed it that finance people are stupid and ideologically blinded. Trump's been speaking of tariffs for years, what made them think his mandate would be good for them?
If I had any appreciable assets in the stock market OTHER than my retirement savings, I would sell like hell right now.
The market is absolutely delusional right now. It's not pricing in how devastating this general uncertainty is, nevermind the fact that massive tariff hikes are still in effect.
Unless what hits it is a miniature black hole or is made of solid metal, the moon should be fine. It gets hit by much bigger thing is on the regular - geologically speaking.
This is my regular reminder to stop reading 2/3 of the way through the book. It will feel like a traditional, abrupt Stephenson ending, but you will save yourself hours of time and potentially blindness-inducing eye-rolling.
The last third should have been a short epilogue or a full sequel. It's too much of a pivot in terms of tone and focus, and feels incongruous and mismatched with the first two sections (which are excellent). He clearly had a bunch of ideas that didn't fit into the main body of the work and grafted them on anyway; it wasn't bad, it just didn't fit.
The comparison would be Orson Scott Card writing Ender's Game to set up the universe of Speaker for the Dead, but instead making Speaker for the Dead a third of its size and calling it the last few chapters of Ender's Game. They should just be different works in the same setting.
But you had to read past 2/3 to find out how the book got its title. The bit in the beginning about the moon breaking into 7 pieces was just a bit of subterfuge.
Man I have exactly the opposite reaction: the last third at least has some nifty high-concept worldbuilding even though it doesn't have nearly enough room to get really explored. The first two-thirds are an absolutely cringe-worthy example of "if only the idiot normies would shut up and let the engineers run everything" nerd supremacy at its very worst, including a painfully obvious Elon Musk stand-in character saving humanity, which was a bad idea in 2015 and has aged even more horribly since.
reply