Better HN
topnewbestaskshowjobs
Log inSign up

kortex

8,487 karma · joined Feb 1, 2017 (9y ago) · 2,549 submissions

Submissions

comment 5y ago · link · parent

I've never had a circular dependency I couldn't resolve. Just organize your modules into a DAG. I have a pretty standard flow:

- protocols and abcs. Depend only on builtins, this sits at the top of the hierarchy and can be used anywhere

- top-level types/models, data structures. Only depends on external libraries

- config and logging. Depends on pydantic, which handles all init config validation, sets up log level. Many things import this

- specific class implementations, pure functions, transforms. imports from all the above

- dependency-injected stuff

- application logic

- routers and endpoints

I've had some close calls since I type check heavily, but protocols (since 3...6? 3.7 for sure) are a fantastic tool for both structuring and appeasing mypy.

comment 5y ago · link · parent

I use a very similar flow. The highly-opinionated-yet-effective pattern I use involves pydantic, cleo, and entry_points/console_scripts in setup.py.

- everything is structured as a module

- options and args are stored in their own module for easy reuse

- the whole stack has one cleo.Application, with however many subcommands. Usually of the form "mytool domain verb" e.g. "mytool backend start."

- cleo args/options are parsed into pydantic objects for automatic validation (you could do this with argparse and dataclasses to skip the deps but it's more work)

- each subcommand has a `main(args: CliArgsModel)` which takes that parsed structure and does its thing. This makes it super easy to unit test

I install into a venv with `poetry install` or `pip install -e` for editable installs.

It all just works, no fuss, and so damn modular.

comment 5y ago · link · parent

Thanks for clearing that up. Say, you know a lot of things about the rust ecosystem. Do you have any insight into how hypothetical rust driver code would integrate with the rest of the kernel build process? I imagine it would have to use llvm-rustc, or is gccrs ready for the job?

Would it be emitting objects that gcc/ld would link against?

comment 5y ago · link · parent

Ah, yeah I see your point. I suppose that's a useful shim to having full Rust interop with a pre-existing C codebase as you convert, or if you have a mature lib you just want to include wholesale in Rust.

But yeah bottom line, nowhere does Rustc "stop" you from doing things. Just strongly discourage :)

comment 5y ago · link · parent

Cargo != rust. They are different things for a reason. You don't ever need cargo to manage deps or build, it's just idiomatic to do so.

Nothing stopping you from building rust code with manual vcs, rustc, autoconf, and make, just like C.

comment 5y ago · link · parent

To each their own. I find Rust a huge step up from C and even C++...especially C++. I've been writing Rust for months and C++ for years. I still feel more comfortable and confident my Rust code has fewer bugs and does what I intend vs C++.

comment 5y ago · link · parent

That's "translate c to rust" in the same way as translating English to Japanese by looking up the kanji for an English word, and replacing it word by word. Why not just generate bindings at that point?

comment 5y ago · link · parent

Exactly, it's subjective fun. Some people like languages where compiler errors point you in the right direction, expressive features like ergonomic strings, closures, syntactic macros, etc.

Other folks are masochists and get their jollies from cryptic errors, segfault debugging, pouring through valgrind traces, and of course manually managing memory. If you aren't suffering, are you really programming?

I tease, but not entirely. Sometimes I do in fact enjoy the challenge of C programming. But it's squarely type 2 fun.

comment 5y ago · link · parent

> In general, I would avoid exposing Rust subsystems to C. It is possible, of course, and it gives you the advantages of Rust in the implementation of the subsystem. However, by having to expose a C API, you would be losing most of the advantages of the richer type system, plus the guarantees that Rust bring as a language for the consumers of the subsystem.

This feels like putting the cart before the horse. "we shouldn't integrate Rust into the kernel in a modular sort of way cause it's not as optimal as more thorough type-aware integration."

Like, cross that bridge when you come to it, eh? The kernel is currently comprised of hundreds if not thousands of components, talking to each other via C API/ABIs. And talking to hardware is almost entirely ABI. That is how the kernel do.

Would we benefit from more type knowledge across boundaries? Absolutely, but this is hard (especially given how different the c and rust approaches to allocation are), and shouldn't stand in the way of progress.

comment 5y ago · link · parent

That gives me the interesting idea of a twitter UX where the buttons are volume-greater and volume-less (just like sound control). With or without limits.

It's pretty much what people are trying to accomplish already; this just makes it explicit.

Would be neat to see how people react to hitting "max volume". You could model it in all sorts of ways. Do you silently accumulate, or do you keep hysteresis, such that you need a constant stream of positive engagement to keep it up?

comment 5y ago · link · parent

Looks like you are being rewarded quite handsomely.

Not only is "there is no info provided by which button was clicked" a really odd take when we humans explicitly assign semantic to up/down vote, this contradicts your other point, which is that "having your post read is the real reward," since there is no guarantee the post was read before voting.

comment 5y ago · link · parent

Guilty. There's not a great level of abstraction between bookmarks (I definitely want to remember this) and open tabs (I need this in my working memory for a day/week/month, and/or this is interesting but I don't have time to read it).

I guess session savers? Never really got into them because (at the time a few years back) they weren't great for indexing within pages. Might give it a try again.

comment 5y ago · link · parent

The part of the bookmark UX flow I dislike is having to organize them. Especially on mobile chrome. The UX there for folder org is so bad I just have a "log" folder and basically everything goes in there, like a sightly more durable and focused history.

I use the exact same trick - just let the search bar index it.

What I really want is a system like a personal search engine. Bookmarking starts a flow which downloads the page, strips out all the garbage, indexes it in something like Elasticsearch or Bleve, tags some metadata, and organizes it by facets.

Google is decent at getting back to places I once found, but there are still 404s that Archive misses. There's also sites like stackexchange where it's easy to get drowned out by irrelevant results. It would be nice to have a more personally curated view into it.

comment 5y ago · link · parent

Python, works quite well, golang works super well. C++ and JS are reasonable. Rust, you might as well turn it off. The more popular the language overall, the better it does. Swift and Kotlin might have too little to have refined the model on.

Another thing: I was using the free version in beta so it was effectively the full blown version. It worked super well. I changed jobs, changed hardware, and haven't set up my key yet (hopefully still grandfathered in) but it's felt not as good - the output is a lot shorter, for one. I would likely get the paid version if I lose my beta key. But it's weird that you have the paid version and it's not useful.

It's also possible they nerfed the models over time in the name of some other tradeoff, like cpu or memory. May still be able to configure it. But I distinctly remember it spitting out entire lines or chunks of code, exactly as I would have written them.

It works best when you are writing stuff similar to your own codebase. Perhaps try vendoring some Swift or Kotlin in your project dir to get the engine to fine-tune on it?

comment 5y ago · link · parent

No, lol. But they've made it abundantly clear that when it comes to the Fed and anything involving nuke sec, personnel are basically dogmeat in any situation where the poop hits the fan. Anyone ex-mil or who runs in those circles knows this; it's hardly a secret.

Of course, you are expected to not let it get to that point. But re: the comment about hostages, yeah, Uncle Sam would not hesitate to disable a nuke or material, even if it meant casualties of NMCs held hostage.

Civilian casualties, no idea. That is the kind of fodder of actual classified conops. But in the metaphorical trolley problem between "N civilian casualties" and "nuke gets away", yeah my guess is N will be nonzero.

comment 5y ago · link · parent

The thing I love the most about tabnine is how it learns on your own code base. So if you have particular naming schemes or weird idioms, it eventually picks up on them.

comment 5y ago · link · parent

I have a friend who works with the DoE and this squares with what I've heard. Nuclear/DoE tends to go above and beyond even other sensitive fields.

It would not surprise me in the slightest to hear that contingency plans prioritized preventing material from falling into the wrong hands over basically all forms of collateral damage. I'm sure the NMCs are well aware they'd be hellfire missile'd before letting a nuke slip away, if those were the only choices.

comment 5y ago · link · parent

Can't we just write some --hella-strict flag and refuse to compile any of these corner cases?

> Does this Add operator have a Result type now?

Essentially yes. There could be other APIs which accomplish the same results but have different constraints, such as not being able to mutate strings without also creating a Result to be handled. Yeah you lose some ergonomics but even that feels more ergonomic than C.

I think Rust is in a unique position in that zero / extremely few panics is actually achievable, and easier to achieve, with less manual discipline, than C.

comment 5y ago · link · parent

Sure, it's better than nothing. But carbon output has increased X% compared to pre-industrial times, where X is some mind-boggling number.

comment 5y ago · link · parent

Sure, but a) that's still spraying, albeit more targeted (still a win) b) I'd have to give money to John Deere.

comment 5y ago · link · parent

It's not just any style though. All of the X-punk genres are alternative imaginings of the world. So the rebellion is against the current consensus reality.

Also, this is just what words do over time. Punk used to mean prostitute. Then it generalized to any ruffian. See also, words like: gay, awesome, nice, robot/bot, slave.

comment 5y ago · link · parent

We are already many steps of the way there.

https://replika.ai/

comment 5y ago · link · parent

> just can't possibly care less about their rainforest

Is it their rainforest though? It raises some interesting philosophical and geopolitical questions. Paving the Amazon rainforest would almost certainty disrupt many things outside Brazil's borders.

I think it's tantamount to discussions about putting carbon, cfc, and pollution into our atmosphere.

comment 5y ago · link · parent

I think this is reasonable. The bigger the entity is, the more likely it is to act predictably like a corporation, with fleets of lawyers and boards of directors and general risk-aversion. Smaller corps and indie devs have different risk tolerances, and thus act differently.

But also, bigger corps are bigger revenue streams for Google. Google has less to lose by alienating indie devs than Twitter.

comment 5y ago · link · parent

There have been some interesting findings in aging studies (e.g. the 90+ study [0]) that suggest some people who have all the physiological signs of Alzheimers, but show no symptoms of dementia.

I suspect the arrow goes:

    X -> brain degradation 
    brain degradation -> cognitive decline
    cognitive decline -> driving bad
    brain degradation -> post-mortem Alzheimers diagnosis

The loose link there is the path from brain degradation to cognitive decline. The 90+ findings (plus other findings on TBI and plasticity) suggest that by maintaining high plasticity through brain assaults (old age, trauma), it seems the brain can "route around damage" and remain comparatively functional.

[0] The 90+ study: https://mind.uci.edu/research-studies/90plus-study/

60 Minutes on Superagers - Video + Transcript: https://www.cbsnews.com/news/long-life-retirement-community-...

comment 5y ago · link · parent

It's definitely "injective but not bijective" or something like that.

Like I look at the prompt "sheep grazing on a hillside by tim burton". I look at the pic. Brain goes, "yup, that checks out". You wouldn't necessarily derive the domain from the range (preimage attack), but I can readily say, "if I fell asleep after watching Wallace and Gromit - Close Shave, and Nightmare Before Christmas, this is what I would dream".

comment 5y ago · link · parent

I interpret it to mean "adding lots of superfluous adjectives makes the outcome better".

comment 5y ago · link · parent

a) very few people work on the scale where miles and feet are interconverted.

b) The mistake was picking base-10 as the basis of the metric system. The Base-12/Reciprocal-halves (2^63/2^4) system of feet, inches, fractional inches, is hands-down the best way to engineer and build things on the human scale. It makes it super easy to scale measurements by N/2, N/3, N/4, N/6, N/8, N/12, N/2^m. Three weeks ago had to make 9 evenly spaced holes in a 24' board, with an inch of buffer on either side, which works out to 35-3/4". This results in really convenient interval of N3'-less-N/4" (35-3/4, 71-1/2, 107-1/4, 143"), so convenient I still remember them weeks later.

The yucky part is when you have to use a base(2*5) calculator. Now you get 35.75, 71.5, 107.25, 143", which is a much less obvious pattern.

Every day I'm in the shop, I yearn for a dozenal calculator and measuring tape.

One can dream.

http://www.dozenal.org/

Base 6 is also nice:

http://www.seximal.net

comment 5y ago · link · parent

You can derive pi/4 from summing alternating reciprocals of odd numbers. No geometry. You do need limits (since pi is transcendental, there are no purely algebraic solutions. You can use special functions, but those have limits or other transcendentals "in them").

https://en.wikipedia.org/wiki/Leibniz_formula_for_%CF%80

comment 5y ago · link · parent

That's pretty common on HiFi. It's not indicating "remaining" per se, the dB value is reduction from line level - -20dB is a 100-fold reduction in output power.

I actually find it pretty convenient since the dynamic range is actually useful (unlike most phones which have a step-change from 0 to 1).

I'm sure it's somewhat deliberate, "only plebs lack understanding of dBs and log scaling. I'm a refined audiophile! "

1
515253
85