21,278 karma · joined Nov 23, 2012 (14y ago) · 6,746 submissions
blog: https://rtpg.co
email: raphael at above domain
comment 3y ago · link · parent
The fact is right now if the source language has a notion of blocking calls, the when compiled to a non-blocking target like WASM it currently has to do a bunch of tricks that outright makes things slower. WIth these improvements, those "blocking calls" can properly end up non-blocking at the JS layer, matching what we all know computers can do.
JS stuff is non-blocking because of the original sin of Javascript (we have to execute all the JS before we can render a page, since there can be some document.body = ... nonsense in there). This is incidental to the programming model, and not some deeper truth about how things should be programmed.
Case in point: non-blocking `async` code in Javascript ends up sometimes turning into blocking code for performance reasons in specific cases (when awaiting an already completed promise, notably). Jumping in and out of an event loop isn't exactly efficient either.
comment 3y ago · link · parent
This _should_ be gotten thanks to work on stack switching in WASM. As of the most recent working group meeting on this [0], it seems like V8 has made a good amount of progress on this. They published a thing back in January[1] on this, and hopefully if things go well and this is available across WASM engines then there will be one less "JS-ism" (everything async) that causes issues for transpilation.
[0]: https://github.com/WebAssembly/meetings/blob/main/stack/2023...
comment 3y ago · link · parent
comment 3y ago · link · parent
I had an opportunity to be exposed to Python and Ruby at roughly the same time.
Python the IPython notebook had started showing up, and the dust had settled a bit on the Py2 -> Py3 transition. So while I was working on a Python 2 codebase, the general vibe of the community was "let's not break more stuff". Pseudocode -> Python translations were pretty straightforward.
Ruby, the entry point was Rails. I bought books on Rails, could not for the life of me figure out how files got noticed by the project or not. I wanted to do something like passing in a function, went on an IRC channel, got yelled at for not doing things the "Ruby" way. Lots of "clever" methods on objects that were neat but didn't really look like pseudo code.
My experience was deeply coupled with Rails, and I think in an alternate universe where I was using Ruby for scripting I would have come out with a different feeling. But Python mostly had no blocking issues for me (a person who was programming for a while at that point), and Ruby was a bit of an undecipherable thing from an operational perspective (even if I could look at a code fragment and understand how it worked).
comment 3y ago · link · parent
I get what you're saying, but I don't think that's as true as you mean. I think that most experienced Python developers tend to gravitate towards the same style of solutions for things like coding puzzles (including the classic "read in data, map it through a comprehension, write out data" pattern).
There are multiple ways of expressing the same thing, but very often in a specific context one of the ways tends to be overwhelmingly a better fit than the other.
comment 3y ago · link · parent
"Explicit is better than implicit" is more around things like Django not just automatically importing every directory it sees (instead requiring you to list the apps used). It's also a decent rationale for changes made from Py2 to Py3 regarding bytes-to-string conversions needing to happen explicitly.
It's also about how usually you end up explicitly listing imports (wildcard imports exist but are pretty sparing), or lacking implicit type conversions between data types.
This stuff is of course dependent on what library you are using, the projects you are working on, etc. And there's a certain level of mastery expected. But I think the general ideas exist despite the language allowing for much more in theory.
comment 3y ago · link · parent
Of course if you're trying to do a registry-pattern style thing the constraints are different (though there I also think that you end up wanting to base your stuff on classes whose metaclass registers itself based on a string-y class attr or something...)
Though in the end it's super dependent on what kind of code you're trying to write. No rule is absolute, especially in this category of aesthetics.
comment 3y ago · link · parent
Maybe The Toyota Way is actually bunk from the get go. But if you buy into the idea that it does work, then why would it not be applicable in software development? This is the core thing that interests me.
comment 3y ago · link · parent
I wonder if there are IT operations that do try to aim for the ~no defect approach like this.
comment 3y ago · link · parent
In a world where artificial satelites aren't a thing that is a useful good, I doubt that NASA exists.
comment 3y ago · link · parent
It's kind of frustrating, because I think what's happening here is that the Surface Go line makes a lot of money, and a 11-inch-but-fast thing would probably be popular but have less juicy margins.
comment 3y ago · link · parent
I just wanted a tablet with good software, and the surface is so close to being that but the Go is a disgrace. Even an instore Go 3 barely handles opening Edge. Edge!
comment 3y ago · link · parent
And if you’re actually interested in riding the ranks as a career it’s a must that you can be able to work in the language comfortable for your superiors (in some places that’ll be English, of course…)
It’s possible to not have it, but every successful outsider I’ve seen in foreign countries learn the local language even if it’s “unnecessary”
comment 3y ago · link · parent
Classic example: Multitenant DB. I have a user table. I have a document table. I have a client table. documents and clients are key'd to user. In particular, there's a property of the system that document.client.user == document.user.
I do a "naive" query to count the number of documents per client, like:
- select count(*), client_id from document where document.text ilike %searchstring% and client_id in (select id from client where user_id = 1) group by client_id;
Now, it turns out that since I have this multitenant data, I have indexes alongside things like (user_id, client_id) on document. I also want to support text search so I have an full-text-search index on (user_id, document.text).
Without properly "guiding" the filtering (usually re-repeating the "where user_id = 1" fragment on every joining table) I will not be able to take advantage of my FTS index, because Postgres decides that's not slow (and _doesn't know about the relation between document.client.user_id and client.use_id). It instead tries hard to implement this either by pulling all of the client documents into memory and then doing an ad-hoc search there, or doing a FTS across all tenants (because I have an index on document.text for cross-tenant searching in an admin), and then scanning through that and removing by client_id.
This is a query plan I would not write if I wrote it myself, because it would be "obviously wrong". It would be a lot of work and clearly incorrect for what I want.
Meanwhile people writing features like this add indexes specifically to support certain workflows, and are often blissfully unaware that those indexes are not being used when it makes the most sense. Of course you gotta check experimental data and measure etc etc. But I like the idea of doing more data design before you start having performance issues, and I think that explicit index usage in particular would be a huge benefit on that front.
(there is a "fix" for the original query, involving repeating the user_id filter at other levels)
comment 3y ago · link · parent
On top of that, you can write a C extension that will let you run compute heavy work in a way that allows your task to be suspended (for example, the C extension spins up its own thread). This extension has to be "very careful", basically by avoiding touching Python-side data during this work.
The way this sort of stuff ends up working is you pass data into a C extension, and that extension takes ownership of the data or copies it or whatever, does what it needs, then gives Python back some result.
But if you're just pure-Python compute heavy, then your task won't be suspended. So everything will run, but your compute-heavy stuff will hog the CPU, and won't be suspended. (Though if you have compute heavy work that is, like, looping over data, you could add `sleep(0)` between every couple of iterations. This gives other tasks a chance to run! This could be good enough to prevent weird bottlenecks).
But the ultimate thing is if you have N compute-heavy tasks, you probably won't get speed advantages. If you have 1 compute-heavy task and N IO-heavy tasks, you can get advantages (even if the IO-heavy stuff is interspersed). But if you have N compute-heavy tasks and not much IO-heavy tasks, multiprocessing can get you where you want (since it's usually IO-heavy stuff that is helped out the most with async/await)
comment 3y ago · link · parent
I do understand the value of SQL + the planner for adhoc querying. But so many times I find myself reworking SQL to hint at the planner to use certain indexes, or to add "spurious" filters to make sure an index is used (spurious for application logic reasons). For applications with a relatively low cardinality of queries, some extra tedium might be worth stronger performance property guarantees.
Added advantage of the tedium is it would make a lot of "accidentally quadratic" stuff much clearer. There is no magic in the planner after all!
We can write inline assembler in C or Rust, it feels like it would make sense to offer something similar in SQL. Big problem is how to offer something that isn't too tedious.
Anyways FQL's index model seems to align with my idea, just unsure if I want the rest of it.
comment 3y ago · link · parent
This is less of a problem in other places that have less nuclear power setup because they can be used to cover the baseline. Now, EDF is turning off reactors over the weekend cuz the power isn't needed, and in periods of high demand EDF doesn't actually have the capacity, because they don't have much peak generation!
Building more nuclear plants to cover peaks would make everything even more expensive, And decomissioning reactors entirely would cause their own massive issues because, again, electricity generation is not fungible.
One would (correctly!) point that most renewables don't help with peak generation either, and you would be right. But if you're planning on decomissioning a nuclear power plant, replacing some of that capacity with renewables at least gets your operating costs down. And energy storage solutions that are more fungible... well... you walk and chew bubble gum. Use what you have, and build what makes sense. Just in 2023 your choices for clean power generation for energy storage are vast.
comment 3y ago · link · parent
comment 3y ago · link · parent
France has like 80% nuclear power, and most of the nuclear plants are actually underutilized! Why would France not use the plants at 100%? Because electricity is kind of fungible, except at massive scales where it totally isn't, and you can't "just" have power generated in the south be used in the north.
Nuclear is more expensive than gas, but once again it is worth pointing out that it is more expensive than solar and wind! Does this mean that we can replace all of the reactors with solar or wind? Obviously not. But if you're sitting there trying to produce energy in places that are not as close to the existing reactors, building energy production facilities that don't take decades to build (for "building big things takes time" reasons) and can work without a constant inflow of water (which is a practical and real concern for these power plants).
comment 3y ago · link · parent
France is the nuclear success story, of course! But the irony is that these power generators can only make money when used at 80-90% capacity. France's reactors don't get that high, and so they're quite a money pit. There's the argument that "losing money" generating power is fine (we don't expect to make money on libraries or streets), but it's important when people argue about regulation being the problem. The most open and willing ecosystem for nuclear power is one that exists due to massive state subsidies.
Yeah lots of renewables aren't 100%, but power is power is power, and it feels like doing a bunch of easy stuff that also happens to make money for private actors (sidestepping some of the trickiness of larger gov't-funded projects) is a thing that our modern society is well oriented towards.
EDIT: to be clear, if there was a huge pro-nuclear movement that showed up tomorrow that could get things done, I'd be all for it. I just like the idea of doing easy things that are accepted by wide swaths of the population rather than just sitting around lamenting that people are "being irrational" or w/e