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

Arguably the most famous block of code, of all time. Maybe fizzbuzz but there are so many flavors of it. And InvSqrt is way more memeable.

So I don't know if on this alone it proves Copilot regurgitates too much. I think other signs are more troubling, however, such as its tendency to continue from a prompt vs generate novelty.

comment 5y ago · link · parent

Exactly, there's a pressure/flow/salinity tradeoff triangle. Higher salinity needs higher pressure and/or waste bypass. This was running around 100-150 psi, was a few years back, don't quite remember.

But a few hundred bucks will still get you from either "potable but not great" to fairly pure, or brackish to potable. If you have effectively infinite seawater and power, you can still pump at lower pressure and get pure permeate, it's just less efficient per unit pump and filter lifetime. If you had a super reliable pressure system (low friction ceramic pumps for example, not cheap but last forever) and cheap first-pass filters, you can run it for quite some time. But you're spot on in that you get to a point of engineering-give-a-mouse-a-cookie and it just makes sense to optimize the whole stack.

comment 5y ago · link · parent

Heh, this is reminiscent of the infamous HN dropbox comment.

Free chlorine (technically assorted chlorine oxides like hypochlorite) attacks RO membranes, so now you have to deactivate your reactive species first. Usually UV lamps, you use sun, but now you need UV-clear tubing, not easy.

Reverse flow flushing can be done with the components you mention, that's another $20/50 plus sourcing logistics.

Yes, the theoretical expense in quality pumps is quality. There are tighter tolerances, beefier components, better polymers, and more QA. It all adds up.

It's still all fairly cheap by Western standards, but it's a tall ask for a lot of places that barely have potable water.

comment 5y ago · link · parent

I have first-hand experience that a) you need positive displacement pumps of a certain quality and power for RO and the cheap Ali ones self-destruct in minutes/hours b) you still need housing, plumbing, receptacles, etc c) fouling is a non-trivial issue.

Expect to pay around $300 minimum for a small RO solar plant, and a couple bucks a month for upkeep. And logistics. Granted that's USA prices (upstate NY, not SV) but that prices out a lot of developing regions.

comment 5y ago · link · parent

A standard QUERY verb should fix this.

https://www.w3.org/2012/ldp/wiki/Proposal_for_HTTP_QUERY_Ver...

comment 5y ago · link · parent

I consider myself pretty docker savvy. I had no idea about this footgun, and my brain is full of all kinds of docker minutiae.

Everyone knows docker runs as root, and therefore be careful using it, just as you would sudo. It seems this is a major fail in docs.

I kinda get why it's the default, but it needs to be made way better known that by default -p punches a hole through ufw.

comment 5y ago · link · parent

The FDA won't let anything be released to consumers that does not pass their review of the batch record. The whole point of the BR is it's the recipe in totality of how to correctly (which includes quality) make the drug.

The whole point is to open source the batch record.

comment 5y ago · link · parent

I'm down. Add a glucostat for optimal blood sugar level too. Just get a waterproof Ergodox, wrap around 8k monitor, and a sensory dep tank (with optional high-tech minimal techno piped in).

I call it The Precog. It'll be a hit in SV.

comment 5y ago · link · parent

Thanks for the taurine tip. I've always enjoyed the red bull sensation more than coffee. Never thought taurine would be neuro-active enough, but I'm revisiting that idea.

Theanine is great with caffeine also. I just spoon it in 200-400mg into my coffee.

comment 5y ago · link · parent

Taking the opportunity to point out, with most inferred type languages (mypy python, go, TS, rust, scala), you often don't have to write variable types at all, only functions. Gone are the days of `Foobar foob = new Foobar`, heck C++ has had `auto` for a decade.

So have your dynamic language functions you have to document (you do document your code right?), why not just use types instead? I'd far rather see

    def frob(data: np.ndarray) -> float:
      <code with no docstring>

than

    def frob(data):
      """takes an array and frobs it to give the frobitude score"""
Like, idk about you, but the former is way better at "self documenting" and you can do all kinds of automatic operations on it. If things are ill-defined and quickly shifting, I can mypy and flake my way to make sure the stack works without bricking something. If I have human docs, that's far more likely to drift out of date.

comment 5y ago · link · parent

Thanks for the reply! I think it highlights the fact that much of the "typing wars" depends a huge amount on what you're working on and how you like to work.

I wager much strain comes simply from individuals working in environments that force them to lean on their weaknesses.

I was absolutely floundering in one department simply because the senior devs loved bash and python2 and dynamic runtime everything and my brain couldn't keep up with the lack of structure.

comment 5y ago · link · parent

> who doesn't just toss args in a dict?

Me? Args in a dict, or worse, `**kwargs` chained through multiple functions, are awful to deal with.

I'm really curious about your stance. If anything, typing has gotten easier and better over 20 years. Types used to be verbose, you had to type out all characters, compiler messages were terrible. Now, type systems are better, inferred, flexible and structural subtyping is great. Type checkers are almost real-time. Autocomplete saves me keystrokes. Errors are helpful.

I used to hate types, 10 years ago, writing Java in Notepad++. Now I write python w/ mypy, go, and rust in Intellij, with lots of plugins to speed up autocomplete, and lint in real time.

comment 5y ago · link · parent

> A large portion of the kind of code I've written is impractical or impossible to actually "unit test" e.g. Unity3D components or frontend JS that interacts with a million things.

Opinion: This is actually a symptom of what is (imho) a pervasive problem lodged deep in the collective consciousness of software dev: OOP with fine-grained objects. I blame (early) Java in large part for exacerbating this mentality. Encapsulation of state with mutator methods in particular. It sprays state all over the application, encourages mutation in place over immutability, coupling, validating-not-parsing, and makes it nigh-well impossible to write good tests.

It's really hard to write objects that enforce all invariants under every mutation. And when you have state strewn everywhere, it's impossible to test every nook and cranny. The combinatorial space explodes.

Objects are helpful for encapsulating state when they are course-grained, mutations are atomic, coupling occurs in one place, state changes are auditable, and the entire state can be replayed/set at once, to enable mock tests and subsystem integration tests. AKA, things like databases, reactors, and persistent data structures.

comment 5y ago · link · parent

The world of data science, ML and computer vision research. It's very academic-heavy, which has two effects. There's an insulation between commercial software dev and it, which results in a lot of NIH, a lot of reinforcement of bad habits, and a lag in propagation of best practices. Second, and related to this, there is a tendency to just piecemeal hack towards the solution, rather than architect the system from the ground up.

It's not zero consideration of data structures, it's mostly a focus on the main data type (arrays and data frames) and not really thinking about typed records, data models and such. The majority of types are float, str, dict, np.ndarray, pd.DataFrame. No dataclasses, minimal classes, and when classes are used, it's Java101 style "all the bad parts of OOP" programming. Sadly, I've spent years in this space before learning better.

comment 5y ago · link · parent

> However, the top post approaches religious dogma.

I don't deny it. Join the cult of Static Python. We have cookies! And lower stress levels!

I usually wrap that spiel with my caveat "this depends greatly on your neurotype, style, environment, and other things." I have ADHD and my brain struggles with keeping bits of state in memory, so having to remember the type of every variable without my IDE tracking it for me is a huge performance drain.

However, I would contend even if your neurotype supported that mental workflow... it isn't actually better. Humans on average can handle 7 +/- 2 "pieces" of information in focus. Why spend any of your precious half-dozen pieces of salient consciousness on something a machine is really good at doing?

comment 5y ago · link · parent

> "All the time" is an english expression, please, look it up before going all-caps Python name mangle convention on me.

I know reaction comments are discouraged on HN, but this had me in stitches. Top-tier gourmet dig right there.

comment 5y ago · link · parent

> What routers call "dynamic routing" is having the lookup table mutable at runtime.

> There can be no equivalent to that in type-safe languages because when you mutate the dispatch table you lose type-safety.

That's exactly what I mean by escape hatches. Rust has unsafe. You can write a WTF FastInverseSqrt in Rust. You shouldn't 99% of the time. But you can.

Rust also has Box, Rc, Arc, and other tools. I'm not fluent enough in rust to know how to, but I'm quite confident and will eat my hat if you can't accomplish what is effectively a mutable vtable dispatch in Rust.

But also...why? Yeeting a function call into the void without any type knowledge seems way more bug-prone than interface/trait-based dispatch, to what benefit? Save developer time? I've spent countless dev-days of my life I won't get back debugging exactly this kind of dynamic-dispatched, json-dsl, frankly loosey-goosey untyped bullshit. There's so many better ways.

comment 5y ago · link · parent

Personal opinion: pydantic crushes Marshmallow. Not even a fair fight. Pydantic is more performant, has better mypy/linter integration, and more powerful data model. We had a project where we pre-emptively used marshmallow to marshall/validate data. Had to remove that and solely use it at the ORM layer because of performance (and it still struggles).

I haven't used pydantic's ORM integration, but I don't hesitate to use pydantic models everywhere as business logic classes unless I need ludicrous speed.

That's all opinion, but I'd definitely give pydantic a swing.

comment 5y ago · link · parent

> x: typing.Union[str, typing.Any]

That's absolutely a valid and useful annotation. It tells me, and autocomplete, that "x" is probably a str, more likely than not, but I need to be aware that it might not be.

comment 5y ago · link · parent

> Typing helps the most with large, venerable projects

I disagree. I've started using types from the ground up and it helps almost equally at every stage of the game. Also I aggressively rely on autocomplete for methods. It's faster this way than usual "dynamic" or "pythonic" python.

Part of it might be exactly because writing my datatypes first helps me think about the right abstractions.

The big win with python is maybe 2-10% of functions, I just want to punt and use a dict. But I have shifted >80% of what used to be dicts to Models/dataclasses and it's so much faster to write and easier to debug.

comment 5y ago · link · parent

No this was like over a week, and 100% due to the tooling. Pydantic, pycharm, black, mypy, and flake8. Pretty much went from "type hints here and there" to "what happens if I try writing python as if it were (95%) statically typed." I'd been testing well before this point but it's not the same as writing test.

The development process is totally different when you write structured types first and then write your logic. 10/10 would recommend.

Usual caveat: this is what makes sense to me and my brain. Your experience may be different based on neurotype.

comment 5y ago · link · parent

> Haha, "Those symbols need not be text", you say, right after quoting a definition that says they need to be "a string or text"!

Ha yeah nice catch, that's why I added that in there. In this case the dictionary is slightly wrong.

> The defining aspect of parsing, that makes it difficult and an interesting thing to study, is that you're starting with a list and ending with a tree.

Ah, I didn't know that! Great bit to learn.

In that case, I will say that the "increase a data structure's rules" is a bit ambiguous.

I think my statement is still correct in that "a symbol could be a data structure," right? Like you could take a list of dicts and emit a tree of dicts.

But wait, a list is a kind of tree, or rather, there is a parse tree of recursive head/tail branches. So I think you could still argue List->NotEmptyList is a Parse because NEL requires a nonzero "head" and zero or one NEL as "tail."

comment 5y ago · link · parent

> verify and validate once, then put it in a specially marked datastructure

Not to steal vvillena's thunder, but that's pretty much the dictionary definition of "parsing"

> analyze (a string or text) into logical syntactic components, typically in order to test conformability to a logical grammar.

Parsing is taking some collection of symbols, and emitting some other structure that obeys certain rules. Those symbols need not be text, they can be any abstract "thing". A symbol could be a full-blown data structure - you can parse a List into a NotEmptyList, where there's some associated grammar with the NEL that's a stricter version of the List grammar.

comment 5y ago · link · parent

Validation is checking if something looks like a data structure. Parsing is smashing data into a data structure, and failing out if you can't do it.

At the end of parsing, you have a structure with a type. After validation, you may or may not have a structure with that type, depending on how you chose to validate.

But I think the big win is, parsers are usually much easier to compose (since they themselves are structured functions) and so if you start with the type first, you often get the "validation" behavior aspect of parsing for "free" (usually from a library). Maybe title should have been "Parse, don't manually validate."

But if your type doesn't catch all your invariants, yeah it does feel kinda just like validation.

comment 5y ago · link · parent

This principle is how pydantic[0] utterly revolutionized my python development experience. I went from constantly having to test functions in repls, writing tons of validation boilerplate, and still getting TypeErrors and NoneTypeErrors and AttributeErrors left and right to like...just writing code. And it working! Like one time I wrote a few hundred lines of python over the course of a day and then just ran it... and it worked. I just sat there shocked, waiting for the inevitable crash and traceback to dive in and fix something, but it never came. In Python! Incredible.

[0] https://pydantic-docs.helpmanual.io/

comment 5y ago · link · parent

I mean, GP said "you can't have routers" and maybe I'm being dense by interpreting that as "never or almost never," but even with a generous "too hard to be practical," I still don't think it's correct.

And I explicitly said "escape hatch" meaning language feature. You don't need that much indirection to get routers in Haskell, Rust, Go, C, C++... like I fail to see how implementing routers are a barrier in strict type system languages.

Is it easier in python or js? Sure. can't? hardly.

E: here's some vtable dispatch (unless that doesn't count as "dynamic dispatch") in Rust. Looks really straightforward.

https://doc.rust-lang.org/1.8.0/book/trait-objects.html

comment 5y ago · link · parent

Sure you can. You just need the right amount of indirection and abstraction. I think almost every language has some escape hatch which lets you implement dynamic dispatch.

comment 5y ago · link · parent

I should define "shimming their way". I mean smoothly interoperating python2 code with py3 mechanics in a piecemeal way.

Writing 2/3 python is harder than writing either 2 or 3. Porting 2 code to 2/3 is about as hard or slightly more work than just converting straight to 3. But at the end of it, the benefit is your code can run in both environments.

So let's say instead of pulling the plug, py leadership says "Python '2.8' will only run 2/3 code." How is that any different? You're gonna have the people who already ported, who have no need for 2.8 cause they can run 3, and the holdovers who have yet to port from 2.7.

That's what I mean by there's no shim.

> The entire issue with Python 3 was that there originally was not, the core team had to be dragged kicking and screaming into carving it out through backports and reintroductions because their original strategy was not workable.

Maybe I got into the game too late then, but I don't recall it being this much of a dust-up.

"six" was released on pypi as 0.9.0 on Jun 28, 2010. 1.0 was in Mar 2011. Even if the py core team was dragged kicking and screaming, that's still 4 + 5 years of people who could have been porting, and weren't.

Basically, my primary point is, it was a damn hard problem, and I doubt there's much the core team have done better at the time. All the porting tools in the world won't get people to upgrade if they are resistant for any reason.

E: py3 was released in Dec 2008. So I guess those first two years might have been tough. But to me that seems exactly like the ripe time to work on the translation infrastructure and things like six, where you have public release but no immediate pressure to switch.

comment 5y ago · link · parent

Ruby's also a bad comparison because not many folks are running ruby on windows.

Huge chunks of industry and academia run python on windows (usually through (ana/mini)conda). That's a whole 'nother world of encoding hurt.

comment 5y ago · link · parent

Man, it's it's harrowing in hindsight to look back on porting 2->3 on linux, and remembering my coworkers that had to do it on Windows with encoding-oblivious libraries.

They're still constantly finding bits of code that break cause some customer decided to switch from "delta" to “Δ” in some machine learning log output.

1
535455
85