HNHacker News
TopNewBestAskShowJobs

saila

575 karma · joined February 20, 2019

submissionscomments
saila··on Python 3.12.0 is to remove long-deprecated items
If you type `func "arg"`, you get a generic syntax error.

If you type `print "arg"`, the syntax error is a bit more informative, but I wouldn't say that the compiler "understands" what you mean. It's just making a guess based on the fact that the previous token was "print".

On the other hand, supporting a special call syntax just for print, which includes more than just parentheses, would be substantially more complex. And then Python code in the wild would be more inconsistent and there will be endless debates about `print <args>` versus `print(<args>)`.

saila··on GitHub is replacing Rails front end rendering with React
I just disabled JS in my browser and most stuff still works, although there's a few things that don't, like loading commit data and dropdown menus. I would guess they're doing server side rendering and progressive enhancement so that at least the core functionality still works okay.
saila··on Kanye West is buying Parler
I've seen people on both the "left" and "right" claim that Twitter more heavily moderates "their side." Is there any way to know if either "side" is correct?

I doubt Twitter classifies moderated content into political buckets as this would create massive liability, but has any neutral third party studied what kind of content is removed and classified it into "left" vs "right"?

I'd like to see the system that could accurately perform such classification at scale, if such a thing is even possible, since no one seems to know exactly what "left" and "right" mean.

For example, "liberal" and "left" are often conflated even though hardcore leftists tend to have a healthy disdain for liberals (in the modern, colloquial sense).

saila··on Alex Jones told to pay $965M damages to Sandy Hook victims' families
Jones is already back on his show deriding the victims, saying he won't pay, and soliciting money. Given his conspiratorial bent and the type of people who support him, I wouldn't be surprised if this doesn't hurt him as much as you'd think, because it reinforces their world view and will make them double down even further. Even if he ends up paying out substantial amounts, which would take years, I think he'll be just fine. The only thing that would really take him out would be if he went to jail for fraud or something.
saila··on Private Prisons Are Behind the Push for Homeless Criminalization
I've lived in an urban area for the last ~25 years and I certainly don't have a "steady stream" of anecdotes of the type of crime you're describing.

On the other hand, there is a steady stream of news articles about street crime, which often seems to portray the situation as worse than it is.

People that comment under news headlines on Twitter, for example, sometimes seem completely detached from reality, thinking they'll be murdered in a Mad Max hellscape if they cross some imagined urban boundary (but many of these people have an ideological agenda, so it's not clear whether they actually believe this).

Of course, there are issues in the city, just like there is everywhere, including distracted drivers (my worst fear), domestic abuse, and so on. Street crime certainly does exist, and is worse in some areas for sure, but is it really the biggest threat to our everyday safety?

It's kind of like how my mom gets caught up worrying about gangs, and I always ask her if she's ever had an interaction with a gang member (the answer is always no). Sure, gangs exist and sometimes do bad things to uninvolved people, but if you compare, for example, domestic abuse or negligent car crashes, those are far more of a threat to most of us commenting here than gangs ever will be.

EDIT: And to the extent that the U.S. does have more crime/incarceration than other countries, I'd ask what we're doing wrong, or more neutrally, what's different about our approach? One major issue is that our prison system seems particularly ineffective at rehabilitation and reintegrating people into society, so recidivism is high.

saila··on Private Prisons Are Behind the Push for Homeless Criminalization
Drug use is rampant in rural areas too, so the "urban centers" thing doesn't come across that well.

If a person is addicted to drugs and needs to be removed from society "for their own good," this can be done without criminalization. Criminalization of drug usage seems entirely ineffective and even counterproductive.

saila··on Guido was right, there should be no lambda in Python (2018)
I've been working on a programming language / interpreter, and I'd guess that in the beginning it was probably just easier to implement len() and other such common / generic functions this way.

You can either implement a single function that handles the various types or you can add a method to each type, but the latter can be pretty tedious when you're implementing a bunch of functions / methods that operate on numerous types.

I ran into this when I started implementing map() for a few builtin types and found myself duplicating the loop-over-items code and started thinking, "Hmm, I wonder if this is why Python implemented len(), map(), etc as functions instead of methods."

Of course, you could implement an abstract class or equivalent for the generic aspects of len(), map(), etc, but then that gets pretty complex too.

So, based on that, which to reiterate is just a guess, I don't think the decision is bizarre at all. It's just an implementation tradeoff.

From a developer point of view, I slightly prefer method syntax for aesthetic reasons, but practically speaking it doesn't make any difference whether I type obj.len() or len(obj), and IMO neither is more or less object-oriented than the other (which is a common complaint about len() et al).

saila··on DocuSign to cut workforce by 9% as part of restructuring plan
I recently worked on a project that includes an in-flow step for users to sign an agreement without leaving the site. DocuSign makes this inordinately difficult. Their docs are obtuse and confusing, especially around auth, and you get a ton of annoying emails from a salesperson just for signing up for a dev account to figure out how things work.

HelloSign on the other hand provides a library for embedding an agreement into a flow and makes it a cinch. I didn't need to create a HelloSign account--I just `npm install`ed the library and got it working within minutes without having to look at any docs.

I'd imagine this is a big factor given that developers often have a lot of sway in influencing these kinds of decisions and get annoyed by unnecessary "enterprise" baloney when it's not really needed.

saila··on Growing indifference to relationships and sex in Japan
Asking this question on the internet is an interesting experiment, but it's not going to give you an accurate depiction of real life.

You can still ask people out at bars or even grocery stores, etc. The key is to strike up a conversation and not be so intent on asking someone out. If there's some chemistry, then maybe you ask them out. If you get rejected, take it in stride.

If you go in with the singular goal of getting a date or hooking up, there's a good chance that you'll come across as desperate and end up disappointed, but if you go in thinking about having fun and making friends, that can open new doors.

saila··on How to disagree with someone more powerful than you (2016)
> Power is the ability to do work quickly

This is absolutely not the definition of power. Perhaps it should be, but in the real world there is only a tenuous correlation between competence and power.

When a person has attained power, they are often less compelled to provide sound argumentation for a perspective or solution. This can be expedient, assuming competence, but it can also lead to anything from wasted resources to the downfall of empires.

Rather than placing the onus on those with less power, I'd say those with more power should remain humble and open to new perspectives, and impatience should be taken as a signal to guide those with less power, experience, and/or skill.

saila··on Long Covid, Cognitive Impairment, and the Stalled Decline in Disability Rates
Additional anecdata: This is similar to what happened to me. I got covid earlier this year and had it bad for a week, had stuffiness and a possible sinus infection for a few weeks, and was tired all the time for a few weeks after that. The coughing lingered for a while too. Eventually I got back to normal just waiting it out (disclaimer: this is not a recommendation).
saila··on Using Mypy in Production
It seems to me that the problem with the first version is that it's stringly typed with `key: str | ActivationType`. There would be no issue if `key` was required to be an `ActivationType` with `key: ActivationType`, as you've done in the second version.

Code like the first version is usually someone is trying to make the API more convenient, but perhaps a better way, that's more in line with static type checking, would be to have a separate `activation_from_str(...)` function.

For a similar situation, I was thinking about doing something along these lines (somewhat Rust inspired), although the duplication of variant names in the from_str method isn't ideal:

    import enum
    import typing

    # stubs so this example is self-contained & runnable
    class Sigmoid: pass
    class Tanh: pass

    class ActivationType(enum.Enum):
        sigmoid = Sigmoid
        tanh = Tanh

    class Activation:

        @classmethod
        def new(cls, variant: ActivationType):
            return variant.value()

        @classmethod
        def from_str(cls, variant: typing.Literal["sigmoid", "tanh"]):
            return cls.new(ActivationType[variant])

    activation1 = Activation.new(ActivationType.sigmoid)
    activation2 = Activation.from_str("tanh")

Now, adding a new activation type just means adding it as a variant to ActivationType and adding a string to the literal list in from_str. Duplicating the name in from_str isn't great, but IMO it's better than having to add a new branch for each variant and the external API is nice too.
saila··on Using Mypy in Production
There's some info in the PEP for protocols about their advantages versus other approaches:

https://peps.python.org/pep-0544/#rationale-and-goals

https://peps.python.org/pep-0544/#existing-approaches-to-str...

As to mypy being optional, it's easy enough to make it required via git hooks and/or CI. If your process doesn't make this easy for mypy or any other tool (e.g. formatting), I'd wager there are more fundamental issues.

saila··on Using Mypy in Production
For those who aren't familiar, typedload is a third party library: https://pypi.org/project/typedload/
saila··on Moving to zsh (2019)
Did you try "bash <script>" or adding a #! line, which scripts should generally have anyway?
saila··on What happened to the lab-leak hypothesis?
Most people are referring to PRC (AKA mainland China, nominally communist) not ROC (AKA Taiwan, a republic) when they say China (at least in the west), so your statement is true but not particularly helpful in this context.
saila··on What happened to the lab-leak hypothesis?
From the Wikipedia link: "A lab worker was bitten and infected by a mouse infected with the SARS-CoV-2 Delta variant at a high-biosecurity facility in Taipei [Taiwan in December of 2021]".

From there, news articles speculate that "this will add credibility to the lab leak theory [if confirmed]" and this "gives legs to Wuhan lab leak theory," which is hardly conclusive.

I don't see how this incident would indicate that SARS-CoV-2 initially came out of a lab. It demonstrates a possible vector out of a lab, but I'm guessing that's already a well-known vector when dealing with lab animals, and it doesn't provide any evidence that SARS-CoV-2 was actually developed in a lab or initially spread from one.

saila··on Things I do every time I start a Django project
Regarding apps, I was just thinking you could create a directory structure like this, essentially eschewing the whole concept of Django "apps":

    <project>
        src/
            <package>/
                models/
                    __init__.py    # Import all model classes (necessary for Django to find them)
                    some_model.py  # Define SomeModel class
                views/
                    __init__.py
                    some_view.py   # Views for SomeModel
                settings.py        # Add "<package>" to INSTALLED_APPS
                urls.py
You still need to register the top level package as an app for Django to find things, but then you don't have to deal with Django's concept of apps beyond that. All your tables will be named <package>_<model> by default, which seems nice.

If it turns out later you need resusable "apps" for some reason, you could always add an apps/ subpackage for them.

I haven't tried this in a real project, so I don't know if there are any downsides, but it seems like a decent approach.

saila··on Don't be that open-source user, don't be me
I think what you're describing here is more like free/libre software and not open source, although the lines between those terms have become fuzzy. IMO, open source is pretty much all about expecting something in return.
saila··on Fish Shell 3.5.0
Every script should have a #! line, but if it doesn't, you can always run it with `bash <script>`.
saila··on System Preferences Reimagined on macOS
> There’s no timestamps on messages

Right click in the message pane and select "Show Times"

> I’m not sure search even exists

Search exists and seems to work pretty well

saila··on NetScape: A Sneak Preview of the shape of WWW Browsers to come (1994)
I prefer no-www for aesthetic reasons, but there do seem to be some good reasons for some sites to use www: https://www.yes-www.org/why-use-www/
saila··on The Central Social Institution in Prague, Czechoslovakia, 1937
Regarding that last bit, that's something I'd like to see explored a bit more in apocalypse stories (whether due to a pandemic, natural disaster, civil breakdown, zombies, aliens, etc). If we lose our steady supply of caffeine, nicotine, and alcohol, after the first day or two people will absolutely lose their minds as withdrawal kicks in on a massive scale.
saila··on Ask HN: Visualizing software designs, especially of large systems (if at all)?
I've worked at a variety of places and have never seen any kind of system or architecture diagram going in (should probably ask about this in the interview stage). Further, it often seems that no one understands the overall system well, in some cases even when there's an architect.

So I usually find myself in the same position of using jump-to-definition and trying to get a handle on things that way.

From there, I'll sketch a simple diagram on paper to aid my own understanding of whatever piece of the system on working on. Personally, I'd avoid software diagramming tools at this stage. A simple hand drawn diagram can be extremely helpful and doesn't take long to create.

After a while, I'll often start sketching out a more comprehensive system diagram with the database(s), processes, etc. At this point, I'd ask management about working on this because it can be a time consuming process that involves talking to a lot of people.

In my experience, this has usually been an uphill battle and somewhere between difficult and impossible to take on as an individual developer, but I think it's worth a try. Taking this kind of initiative could lead to career advancement, but I've often found that there's a lot of resistance and it's not seen as a priority.

It might seem a bit cynical, but as a junior or even intermediate developer, I'd also advise caution against stepping on anyone's toes. I'm not sure why, but some people tend to get defensive about this kind of thing.

saila··on WTFPython: Exploring and understanding Python through surprising snippets
The first example can be written like this in Python >= 3.8:

    a = 1
    b = 2
    ((a := a + 1) if a == b else (b := b + 1)) + 1
although that's a lot to cram into a single line IMO.

The closest I could come up with for the second example is this (noting that the datetime constructor requires both the year and month):

    from datetime import datetime
    timestamps = [
        "2022:04:30:02:17:36",
        "2022:04:26:07:44:25",
        "2022:04:25:19:30:38",
        "2022:04:25:07:40:47",
    ]
    datetimes = [
        datetime(*map(int, timestamp.split(":")))
        for timestamp in timestamps
    ]
That said, it'd probably be better to use datetime.fromisoformat() or datetime.strptime() rather than manual parsing.

And you could maybe use the operator module[1] for the last example, like this:

    import operator as op
    (op.add if 1 < 0 else op.mul)(42, 100)
[1] https://docs.python.org/3/library/operator.html
saila··on Who Owns 4chan?
I've been to a lot of protests of all types [to be clear, as an observer, not a participant], including far right and antivax protests where many QAnon types were present, and I can say without any doubt that most of the people involved are sincere.

I also spent an inordinate amount of time watching protest/political live streams in 2020 and 2021, which further reinforces this.

saila··on Who Owns 4chan?
Susceptibility is a big factor too. Seeing something mysterious on the internet is one thing, but believing in something that has no factual or verifiable basis is quite another.

So a followup question is, why are so many people susceptible? It seems to have something to with making sense of the world when you feel like you're being lied to all the time, and I totally get that part, but I don't get how these conspiracy theories help with that.

It would be one thing if it was just a handful of people, because there's always a few people who will believe anything, but it's a lot more than just a few in this case.

saila··on Who Owns 4chan?
It's a joke to 4chan et al but not the people who fell down that rabbit hole. I don't know how many people actually believe in it, but based on watching protests and other political activity over the last few years, it's substantial.
saila··on In praise of the humble Sheffield stand
The images don't load for me on desktop Firefox, but I can see them when I view the thread on Twitter. They seem to be blocked on Thread Reader because they're classified by Firefox as "Social Tracking."
saila··on In praise of the humble Sheffield stand
Not sure what kind of racks you have but for some back-in parking might be easier than front-in. I try to lock one of the back tubes and wheel if possible.

I'm also a fan of the Sheldon Brown lockup strategy[1]. There's also a modified version that may be more secure[2].

[1] https://sheldonbrown.com/lock-strategy.html

[2] http://www.802bikeguy.com/2011/07/the-modified-sheldon-brown...

← PreviousPage 3 of 9Next →