HNHacker News
TopNewBestAskShowJobs

goodoldneon

918 karma · joined July 23, 2018

submissionscomments
goodoldneon··on Is everything falling apart?
> Perhaps the next external threat will be carbon climate cancer?

Americans rarely unite against something that's partially and/or possibly our fault.

goodoldneon··on Four Eras of JavaScript Frameworks
Multiple dependency versions causes problems but the alternative is pretty bad, too. You can get stuck on older versions of a dependency because newer versions have a transitive dependency that causes a conflict with a different direct dependency
goodoldneon··on Four Eras of JavaScript Frameworks
The virtual env thing is extra friction but isn’t terrible:

  $ python -m venv .venv
  $ source .venv/bin/activate
  $ pip install -r requirements.txt
Most IDEs will automatically pick up the .venv folder
goodoldneon··on Four Eras of JavaScript Frameworks
It’s more of Python’s fault that pip’s, but (AFAICT) there isn’t a way to install multiple versions of the same dependency. You might have direct dependency A which needs version <2 of X, but also direct dependency B which needs version >=2 of X.

Since those version ranges of X don’t overlap, it isn’t possible to satisfy both A and B’s requirements. Node can handle this

goodoldneon··on Twitter set to accept Musk's $43B offer – sources
It depends who you follow. I only follow people I think are funny so now my Twitter feed is almost entirely toxicity-free. If you follow political accounts then you're gonna get hit with the toxic firehose
goodoldneon··on Nearly half of Mariupol has suffered grave damage
Don't get me wrong, Putin is a horrible horrible person. But there's a big difference between starting a war that resulted in 80+ million deaths (including the orchestration of ~10 million civilian deaths in camps) and Putin. Russia is committing war crimes and should be held accountable, but it's disingenuous to conflate Putin and the (arguably) worst person in human history
goodoldneon··on Nearly half of Mariupol has suffered grave damage
The quote said "Hitler" and not "Hitler when he invaded Poland but before he killed 10+ million innocent civilians"
goodoldneon··on Nearly half of Mariupol has suffered grave damage
There's a massive difference in magnitude between Putin and Hitler, but point taken
goodoldneon··on Python’s “type hints” are a bit of a disappointment to me
The second one raises an error:

https://www.typescriptlang.org/play?#code/AQMwrgdgxgLglgewqB...

This conflation of "optional" and "undefined-able" is more obvious in interfaces. This is why TypeScript added the `exactOptionalPropertyTypes` option:

https://www.typescriptlang.org/tsconfig#exactOptionalPropert...

Sometimes "is not defined" needs to be treated differently than "is set to undefined"

goodoldneon··on Python’s “type hints” are a bit of a disappointment to me
TypedDicts fall under structural typing, not nominal typing. So Mypy is cool with this:

  import typing
  
  class Foo(typing.TypedDict):
      a: int
  
  def do_thing(value: Foo) -> None:
      return
  
  foo: Foo = {"a": 1}

  do_thing(foo)
My complaint here is that Mypy doesn't go far enough with structural inference. I assume this is because it doesn't support anonymous TypedDicts, whereas TypeScript supports anonymous interfaces/types
goodoldneon··on Python’s “type hints” are a bit of a disappointment to me
Code is way less readable without types. If I see this:

  def create_user(user):
    other_function(user)
Then how do I know what `user` is? Is it a dictionary? An object? If it's an object, where's its class definition? To find the answer I need to search for all the code that calls `create_user`, and then code that calls that code, and then code that calls that code, ad nauseam.

Onboarding into a huge, untyped codebase is brutal

goodoldneon··on Python’s “type hints” are a bit of a disappointment to me
Types help to encourage readable code. If it's hard to add type annotations to a function then the function is too complicated. I've seen this with wildly polymorphic functions that needed dozens of overloads to properly type... which means that engineers need to hold all that complexity in their heads
goodoldneon··on Python’s “type hints” are a bit of a disappointment to me
Totally agree. Mypy isn't perfect but it's so much better than no type annotations
goodoldneon··on Python’s “type hints” are a bit of a disappointment to me
You can disallow `Any` with the `--disallow-any-explicit` option
goodoldneon··on Python’s “type hints” are a bit of a disappointment to me
Agreed. Also, Mypy's dict inference is too broad, making TypedDict a little less useful. For example, the following code raises a Mypy error even though `foo` conforms to `Foo`:

  import typing
  
  class Foo(typing.TypedDict):
      a: int
  
  def do_thing(value: Foo) -> None:
      return
  
  foo = {"a": 1}
  
  # error: Argument 1 to "do_thing" has incompatible type "Dict[str, int]"; expected "Foo"
  do_thing(foo)
But TypeScript can figure it out:

  interface Foo {
      a: number
  }
  
  function doThing(value: Foo): void {
      return
  }
  
  const foo = { a: 1 }
  
  doThing(foo)
goodoldneon··on Python’s “type hints” are a bit of a disappointment to me
There's a subtle difference between TS' question mark and union. The question mark means "this argument is optional", which can be different than "this argument can be undefined".

The following code is valid:

  function foo1(value?: number) {}
  
  foo1()
But the following code will raise a type error:

  function foo2(value: number | undefined) {}
  
  foo2()
In practice, that rarely becomes problematic. But it's good to know the difference
goodoldneon··on The tech bubble that never burst
> There is enough vacant housing in China to house Spain.

This sounds bad off-hand but you have to consider the scale of China. Spain's population is roughly 3% of China. 3% of the US population is 10 million, which is less than the 16 million vacant homes in the US (https://www.nytimes.com/2022/03/10/realestate/vacancy-rate-b...). And that's still a generous comparison since more than 1 person lives in a home.

goodoldneon··on Twitter takeover battle: Elon Musk and Jack Dorsey turn up pressure on board
Yea... you're stretching this one
goodoldneon··on Twitter takeover battle: Elon Musk and Jack Dorsey turn up pressure on board
They were elected to the board by shareholders. That's entirely different than a hostile takeover. You can't say "this is not in the interest of the shareholders" when the shareholders voted for it
goodoldneon··on Twitter takeover battle: Elon Musk and Jack Dorsey turn up pressure on board
Are they actively attempting a hostile takeover and the board thinks that they'll hurt the company? Then I think that'd be legal. Otherwise I don't see how you could make a legally defensible argument around diluting shareholders just because of their beliefs
goodoldneon··on Twitter takeover battle: Elon Musk and Jack Dorsey turn up pressure on board
Is it illegal for 51% of shareholders to dilute away the stake of the remaining 49%? Serious question -- I don't know.

AFAIK (IANAL), companies have few restrictions on stock dilution as long as the dilution is in the best interest of the shareholders. You can make a legally defensible argument that one actor is bad and should be diluted, but it's probably hard to make a legally defensible argument for selectively diluting shares of idle shareholders.

goodoldneon··on Podman Desktop Companion GUI – Parity on All Major Operating Systems
I use it to build x86 images on my M1 MacBook
goodoldneon··on The 'Batman Effect': How having an alter ego empowers you (2020)
This reminds me of the great Vonnegut short story “Who Am I This Time?”.

https://en.wikipedia.org/wiki/Who_Am_I_This_Time%3F

goodoldneon··on How Go mitigates supply chain attacks
Wouldn't build size increase a lot if transitive dependencies were pinned to direct dependency lockfiles? Like if library A says "use version 1.0.0 of library X" and library B says "use version 1.0.1 of library X", then you'd likely end up bundling duplicate code in your build.

Not saying the tradeoff isn't worth it, but pinning to dependency lockfiles isn't without downsides.

goodoldneon··on React v18.0
If you'd like to migrate them, the React team maintains some awesome codemods:

https://github.com/reactjs/react-codemod

goodoldneon··on Python 3 Types in the Wild
You missed my point. If you validate input, then the static types are representative of runtime types
goodoldneon··on Python 3 Types in the Wild
Python does ignore them at runtime, but as long as you're validating your inputs (e.g. using Pydantic for HTTP request validation) then you can trust that the static types are truthful
goodoldneon··on Go 1.18
A more robust type system can help you deal with coordination between various nooks of a codebase.

For example, let's say our platform supports multiple authentication methods. If we need to add a new auth method, how do we know all the spots we need to update? TypeScript can handle this using a sum type:

  type AuthMethods = "push" | "sms" | "fancy_new_thing"

  // No errors
  const authMethodHandlers: {[key in AuthMethods]: CallableFunction} = {
      push: () => {},
      sms: () => {},
      fancy_new_thing: () => {},
  }

  // Error: Property 'fancy_new_thing' is missing
  const authMethodTitles: {[key in AuthMethods]: string} = {
      push: "Push",
      sms: "SMS",
  }
With the above approach, static analysis tells us when we missed a spot. That adds a ton of safety and expedites feature work (since engineers don't need to manually find all the spots that need updating).
goodoldneon··on Russia to punish ‘fake news’ about Ukraine war with 15 years’ jail
https://en.wikipedia.org/wiki/List_of_journalists_killed_in_...
goodoldneon··on Asian-Americans fight back against school discrimination
How do you suggest we increase admissions for under-represented groups?
← PreviousPage 7 of 10Next →