Hacker News new | past | comments | ask | show | jobs | submit | davidw's comments login

It works pretty well, but it took me a while to give it a go, because the name sounds like the scammiest thing ever.

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.

This has pros and cons.


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.

I think they now have "dirty" NIFs that use a separate scheduler for this.

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.

I wonder if there's space for a libuv inspired solution now.

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).

[1] https://www.erlang.org/doc/apps/erts/erl_nif.html#enif_selec...

[2] https://www.erlang.org/doc/apps/erts/erl_driver.html#driver_...


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.


> sometimes you really do just need three

If it's worth doing, it's worth doing three times.


"Gilgamesh's Island"

How are markets going to figure anything out with tariffs changing every day, depending on the mood of dear leader?

That's a problem for the markets to suss out.

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.

In two years of course it won't matter.


> They've sussed out that if you suck up to him he'll give you an exemption

It's a very thinly veiled protection racket. People do tend to repeat the plays that they know.


sounds about right.

Given that tires produce a lot of particulate matter, even EV's contribute to pollution significantly.

Wouldn’t that mean bicycles contribute to air pollution?

It's proportional to weight, so I imagine bicycles are negligible.

I would imagine there is more wear and tear on a bike tire because of rough handling.

By a miniscule amount - probably less pollution than that produced by people walking.

Yes, but so do humans walking. The proportions matter.

Yes cars are bikes

Tailwind feels like the bad old days of style="........". And it looks like some weird dialect of Forth code.

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.


If you give a bully your lunch money, it's not like they leave you alone the next day. They come back for more.

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.


Absolutely no one was seriously considering building a factory in the US based on the insansity of last week

The market is huge. Absolutely someone was considering it. Whether they had time to put plans in motion is a separate matter altogether.

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.

I would put it at less than 50% at this point. It entirely depends on whether or not he's alive.

The market is huge but the actual capital is held (or at least controlled) by relatively few (probably more rational than average) people, no?

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?

Cost differences by everyone's gut estimate is like >10^3 or however many digits. Tariffs are cheaper until it starts T2D3ing.

The costs are huge too which makes the margin small

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.


There are more consequences if you change the supplier because different supplier often means different product

Which way is "going the wrong way"?

> Foreign sources of news are the most instructive as they're actually covering the options realistically.

Curious about what your go-to sources are?


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.


You can just sell the options. You don't need to exercise.

Yeah, that's actually what I meant, sell the option. I misspoke.

Given my exposure I've loaded up with long puts right after this news.

Puts are a necessary hedge now for your 401ks or stock grants.


i doubt you're the first person to think of this. not to be an "it's priced in" guy, but... something to consider

The only way to know is to wait 3 months and see.

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.

In a sane world Trump wouldn’t be president

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?

They knew he was a moron. Their mistake was thinking he was their moron.

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.


They always knew he was an idiot, the reason they are muttering is to give ammunition and support to anyone who will push back on this insanity.

Someone didn't read Neal Stephenson's book.

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.

Seveneves was a fun book!


Many asteroids are made of solid metal.

But the moon has handled much bigger collisions without a single fatality!


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.

I don't know why everyone seems to hate the last 1/3 so much. I find it a very interesting, fresh take on things. I enjoy it every time.

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.


For me I skipped the 4th third. Like I always do.

For me, it was the middle third I skipped. Seemed to drag forever.

You know it’s a great book when everyone seems to dislike it in a different way!

Same, I enjoyed that book beginning to end.

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.

Likewise. I thought the last third was kind of fun science fiction. The first two thirds were a huge downer.

Huh, interesting. I never re-read it, but noped out of Termination Shock for the same reason.

Seveneves was mild, diluted nerd supremacy. Anathem, was absolute, unhinged nerd supremacy.

I loved them both.


I've been thinking a lot lately about the Ita's version of the internet and the garbage data they have to contend with.

It wouldn't even make a top-100 craters-of-the-moon-by-size crater if it hit.

Which one specifically?

Mentioned in other comments, but to be explicit since the title is odd: "Seveneves"

Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: