HNHacker News
TopNewBestAskShowJobs

akubera

488 karma · joined April 4, 2016

[ my public key: https://keybase.io/andrewkubera; my proof: https://keybase.io/andrewkubera/sigs/lrFejFgqfBa8JC8yOc6yJjqVHcHqMiR8eoM2e9DWzgU ]

[ my other public key: https://keyoxide.org/DF564BCA14402C4D550E10FF9D3BC88718FB4D14 $2a$11$hK.oSfvqEJGRylzOeN6Pmu7kQzaCSE4rrLHKK3WBU.Iv50T4oqCF2 ]

submissionscomments
akubera··on Node.js 14 is over 20x faster than Python3.8 for fib(n)
I assumed since this seems to be testing function call overhead, rather than the math, that an equivalent function with BigIntegers would be about the same for JS. But I tried it just for fun:

    const { performance } = require('perf_hooks');

    function fib(n) {
       if (n == 0 || n == 1) { return 1; }
       return fib(n - 1) + fib(n - 2);
    }

    function fibn(n) {
       if (n == 0n || n == 1n) { return 1n; }
       return fibn(n - 1n) + fibn(n - 2n);
    }

    var t0 = performance.now(); fib(35); console.log("fib:", performance.now() - t0);
    var t0 = performance.now(); fibn(35n); console.log("fibn:", performance.now() - t0);
results:

    fib: 127.30008998513222
    fibn: 2134.1405459940434

yikes, I think you're right. (nodejs v15.6.0)

(An equivalent version with Python on my machine: ~2657.3ms)

akubera··on Idaho internet provider blocks Facebook, Twitter
dupe: https://news.ycombinator.com/item?id=25738457
akubera··on The Rise and Rise of JSON (2017)
I still think it's a shame that Amazon's Ion format never got widespread adoption.

https://amzn.github.io/ion-docs/

Superset of JSON with many extra features that people in the comments here desire from their data-language, such as support for comments, timestamps and s-expressions.

akubera··on Show HN: Pyp – Easily, magically, run Python at the shell
Also related is pythonpy[0], which added a similarly named command 'py', but apparently that project has died.

This looks like a big improvement, with math functions auto-imported, and the --script option is a fantastic idea.

Good job.

[0.0] https://pypi.org/project/pythonpy

[0.1] https://news.ycombinator.com/item?id=8158976

akubera··on This Video Has X Views
I'm reminded of this little gem: https://hookrace.net/time.gif

(Relevant post https://news.ycombinator.com/item?id=14996715)

But on the topic: is there actually a dearth of APIs "these days" vs peak Web-2.0, or have the major players just restricted theirs due to abuse, and thus it seems like the whole world of possibilities have veen restricted? One can easily find lists of public apis (e.g https://github.com/n0shake/Public-APIs), but perhaps the video was more about the facilitators, like Yahoo Pipes.

akubera··on Australia unemployment to soar to 11.1% by June
I always had a similar distaste for headlines with words like "blast" and "slam", but learned recently[0] that these are standard abbreviations for headline writers to save space. Your words are not on that list from Wikipedia, but "soar" & "crash" might be used in such a way to shorten "{in,de}crease". (But certainly not "skyrocket"!)

Of course, isn't that convenient that they carry greater emotional weight...

[0] https://news.ycombinator.com/item?id=22290486

akubera··on Programmer's critique of missing structure of operating systems
Yes but that's the underlying system, not your "application code" handling the structure parsing. Maybe I shouldn't have said JSON, but you do always get a JavaScript object back, as opposed to UNIX filesystem/socket operations which only really return application/x-octet-stream data. I thought that was the thesis of the article: it'd be a better world if your operating system supported parsing common structures for you.
akubera··on Programmer's critique of missing structure of operating systems
I think the browser is the described OS here: every-api passes objects around, IndexDB is your filesystem, remote REST & GraphQL servers are returning structured JSON objects to your program, you can add a <script> tag to your <html> to pull in your single-function scripts (i.e. leftpad).

Seriously though, the question of "why isn't it done this way" is answered a couple times: "it's all just bytes in the end". Bytes & arrays-of-bytes are really the only thing that you can trust that all systems and all languages interpret the same (even 2-byte integers can be interpreted differently by different systems). Presumably the author just wants to be able to memcpy structures between programs or from disk, or maybe with some high efficiency pre-allocated heap stuff, but you really need to have code to validate the bytes, essentially requiring the parsing of your data-structure which the author is trying to avoid.

Running programs with some common argument notation does sound really nice, but ideally that's just calling a function from your language's binding to their library (as their executable should do, right?).

akubera··on Why the foundations of physics have not progressed for 40 years
Didn't downvote, but they probably came because you asked a very tangential question to the subject.

I'll try to answer it: I think you just want to move units around so h (Planck's constant) has units of Joules instead of Joule-seconds. While this works mathematically, it doesn't really make sense physically, where we care about the energy of a photon because that's the value that is conserved (along with momentum, also relating to h) during any interaction (e.g. the quantity gained by an electron if the photon is absorbed). It really doesn't make sense to want to quantify the "power" of a photon, which doesn't have any physical meaning, in favor of a simpler constant.

You are right about the constant 'h' having a "hard-coded" 1-second built in, but so do ALL derived physical constants . If we, say, changed it to two seconds, the number would be cut in half to reflect the scale change and preserve the energy of the photon (or any action) because that does not depend on scale.

As to "why is it Joule-seconds?": that's the discovered law of nature. If the energy was proportional to frequency squared, h would be in units of J*s².

akubera··on iPod Product Timeline
The "fast project page" this links to is pretty interesting: https://patrickcollison.com/fast

> The Empire State Building. Construction was started and finished in 410 days.

> Unix. Ken Thompson wrote the first version in three weeks.

> Git. Linus Torvalds started working on Git on April 3 2005. It was self-hosting 4 days later.

Inspiring.

akubera··on Dairyland in Distress (2019)
There was that human-milk ice cream in the UK around 2011:

https://en.wikipedia.org/wiki/Baby_Gaga

I don't know how well that turned out.

akubera··on A Guide to WebAuthn
So this is like BrowserID/Persona but instead of including the third-party email service to prove identification, the only credentials are on device/in-browser, right?

I assume that if you only connect one computer (authenticator) and lose the device, you're either SOL or the service has some workaround where you pre-register an email address or a separate "Login With" service.

akubera··on Python is not a great programming language
Ah, yeah I see; there's an ambiguity in parsing expressions and tuples which could lead to subtle typing bugs. There's another ambiguity that (a for a in b) is not a tuple, but a generator, while [a for a in b] is a list.
akubera··on Python is not a great programming language
Part of the problem here is clearly this person is mapping JavaScript idioms to python; in particular "Needing to put dict property names `{'in': 'quotes'}": these aren't object properties, these are keys in a map, and they can be and often are variables themselves, (also, can be any hashable type, not just strings) and I don't see how that can detract from the 'greatness' of python.

Also "foo['bar'] returns a KeyError", then saying sometimes this is resolved by "getattr(foo, 'bar', None)" -- the split between attributes and items are one of the best things about python.

I don't know why list comprehensions are "magic syntax", and you can't complain about having to type list(map(...)) and then complain that you don't like list comprehensions!

"You have to cast your data back to a list/tuple after using enumerate() and map()." -- I don't know what that means

"Different syntaxes for lists and tuples." -- Again, what? They're different types!

How is r'a\nd' less "goofy" than String.raw`a\nd` in JS or any other language with prefixed strings?

Python is clearly not for everyone nor for every problem, but in my opinion it is a great programming language.

akubera··on Show HN: Discover and listen to artists performing in your city this week
It's the marketing of "in your city" when they only support (by my estimate) ~6% of the US population, which is at fault.

I assume your "middle of nowhere" comment is just trolling.

akubera··on CERN migrates to open-source technologies
The latter. It's about replacing things like Active Directory, Exchange, Skype, etc. None of the projects relate to the actual science, except maybe Visual Studio licenses? But I know of nobody that uses ROOT on Windows with VS.
akubera··on Understanding IPFS in Depth(5/6): What Is Libp2p?
https://github.com/libp2p/rust-libp2p

There's the Rust repository, and the auto-generated documentation can be found at https://docs.rs/libp2p/0.11.0/libp2p/

I'm curious what about a C implementation is the requirement for you? Is it the ability for to link against your C/C++ code, or for reading and understanding the structures and algorithms with the simplicity of C parlance, or another reason?

If the first one, it is possible to create a C shared-library "cdylib" with Rust (included in cargo by default), and using cbindgen[1] you can generate the headers to use the c-api.

It doesn't look like anybody has done that yet, unfortunately. But know that it should be a lot easier to create C/C++ compatibility than doing a rewrite or port.

[1] https://github.com/eqrion/cbindgen

EDIT:

Or as the sibling comment points out, there ARE C implementations out there, so you can ignore this post.

akubera··on What's Coming in Python 3.8
Perhaps to align with the final "else" clause, or it was familiar to c programmers due to the c-preprocessor directive https://gcc.gnu.org/onlinedocs/cpp/Elif.html, or they were mindful that every character counts when you want to push 80 character max-line-length style?

To be clear, that's not a new feature in 3.8.

akubera··on The Vision for Decentralized Web
I think equating "the internet" and "the web" is sloppy; the author does this in the first paragraph and throughout the article.

> It [The Internet/The Web] took off with hackers running independent servers in their basements.

Is that true? Maybe if we're talking "the internet", things like MUD, IRC, Usenet, or BBS servers were run by individuals, but looking at the "List of websites founded before 1995"[1] it seems like there were big players outside of labs/universities pretty early on in the history of The Web. I'm asking a legitimate question here: was www successful (at least in part) due to websites from individuals (let's maybe say "students on university networks" rather than "hackers in basements") over large institutions (like the magazines)?

> The informational landscape today shifted from people sharing personal websites to sharing social posts.

Again, I question the accuracy. Did more people have personal websites than BBS/Usenet/Web-Forum accounts?

Regarding the dpage.io site this article is promoting:

> As you can see, there are no ads, no clutter, only information that was created by the user.

This is a problem I think the "distributed web" community has to deal with: What if the user wants to monetize their content, perhaps with ads? Either people are going to do some "pay per view" of articles on your network (which seems to be antithetical to "information for the masses" that I have a feeling most decentralized developers identify with), or they use ads. Want your ads to do better? well don't fund the network that has reader anonymity built in.

> The domain name system enables any person on earth to have his human-readable address on the web. This system is decentralized by design and is owned by nobody.

So they want to fork DNS from ICANN so your identity is always linked to your website?

> Dpage.io is not a website builder, and it is not a blogging platform.

Design your own website, upload it to us and we'll host it for free.

Reading the contents of the strange little iPad on https://dpage.io/ it says:

> Your user profile details along with your data are by default stored on a free Blockstack's Gaia storage hub. DPAGE doesn't store your data on its own servers. You can run your own storage hub on a server of your choice.

So it is that kind of distributed server: the one you run yourself.

<aside> The phrase "a free Blockstack's Gaia storage hub" is strange and feels very corporate, being sure to indicate that it's not just any Gaia server, but the one OWNED by Blockstack. Sometimes it's the little things that show you how much control the marketing department has. </aside>

I'm not going to comment on their blockchain stuff.

I'm only criticizing because I think people are putting lots of effort into solutions that are misguided: "The people WANT to have their own websites! This is the platform they'll want for sure!". I very well may be missing the point here, but inaccuracies and romanticizing the past lead me to skepticism.

XAMPP[2] is still around after 17 years, (last updated 4 days ago), which I remember being super easy to setup your own site, and I have a feeling it's even easier now. CMS platforms like Wordpress.com, SquareSpace, etc, do allow you to own your own content, easily use themes/plugins, and backup/export everything if you want to move (for a price, because they're providing a service, which is reasonable).

I think the most interesting decentralized platform is dat/beakerbrowser, because

A) There's already a tangible working product (Beaker)

B) There's no login/user-admin: your browser upon startup is a node in the network

C) Backwards compatible with http(s), so it's not like there's a hard fork of the DNS namespace and links no longer work.

D) No concept of privacy/encryption (that I'm aware of). You really don't own your data, you publish it and the system is designed to allow anyone/everyone with the link to copy it, change it, host it, seed it. If you don't like that, don't use it.

Of course you have to seed your site, so again there's a chicken and egg problem of hosting your own server (but if it's just running the browser until your friend says they've downloaded the site, it's easy, right?)

I didn't mean for this to turn into a rant, but I guess it did.

I wish dpage/decentus/blockstack/gaia good luck because I think distributed webs do have a future and every player can bring something to the table, but I hope their message/intentions become a little more focused.

[1] https://en.wikipedia.org/wiki/List_of_websites_founded_befor...

[2] https://www.apachefriends.org/index.html

akubera··on I Can’t Answer Standardized Test Questions About My Own Poems (2017)
and a nice discussion at https://news.ycombinator.com/item?id=13348672
akubera··on Pytype – A static type analyzer for Python code
Thanks! It's been in front of me this whole time... if it was a python, it would have constricted me.

Actually it looks like I can get flake8 & pyright simultaneously; that's actually the ideal situation I was looking for.

akubera··on Pytype – A static type analyzer for Python code
As with everything, depends on the audience. If working on something web-related or has an obvious need for javascript, then yeah, node can be an assumed dependency (actually probably preferred because I'd imagine you get better integration with the rest of your project than with unittest/pytest). But if it's a pure-python library that has nothing to do with javascript/typescript I think it's too much to ask someone to be sure to install proper versions of node+npm+typescript+whatever-else so your `python setup.py test` runs correctly. The same would apply to a javascript project that had dependency on python3.6 for their type checker.

Many projects need node, but not all; I don't know any which require docker.

I want to be clear: with pyright, it's not bad! I think it's the right way to do the LSP plugin: no dependency on the current python version (am I using the python in the venv? or ~/.local/bin? or /usr/bin/?) and great integration with the editor.

If it's a large project that will benefit from "5x faster" typechecking than mypy, then yeah, it's probably worth the dependencies.

If you have a 5-file python package I found on pypi that I want to contribute to, but there's nonstandard hoops to jump through to get `python setup.py test` working properly, I would have preferred you made a different call in this regard.

I'm glad we have choices and it's not mono-culture.

akubera··on Pytype – A static type analyzer for Python code
As far as I can tell, Pyright is designed only for the VSCode plugin? Or at least is a typescript project that parses and analyzes python code, so if you're using that stack already it may be a good choice, but otherwise it's more stuff to install. Actually, I'll say people with python projects shouldn't "target" it because it's not a pure python stack, and it would add friction/overhead for people who don't already have npm installed. It's just for people coding python with the VSCode editor.

As I mentioned in a comment to that post, I used pyright for a few minutes and was impressed. You get red-squigglies under unexpected-type & no-such method errors, and I saw green squiggly under a "value may not be set" in a function like:

    def foo(x: int):
        if x > 4:
            y = 1
        return y 
The immediate visual feedback is great. The dependency on typescript is not.

Searching VSCode, I see no plugins for mypy & PyType, and the pyre-vscode plugin requires pyre-check to be installed, and a .pyre_configuration file in the directory? All I know is I couldn't get it to do anything, but pyright worked out of the box with no effort.

I haven't used this PyType project, but it looks like it competes with mypy. I like that it, too, uses your setup.cfg file for configuration (I'm all about single-file configuration projects). Someone else will have to speak to the differences between them. I'm sure they have the same functionality, so the differences will likely be in the specifics like what the error messages look like and how easy they are to configure. If you contribute to various python projects, I supposed it wouldn't hurt to have them both installed.

As for which to choose, mypy is Guido's project (or at least the one he's associated with) and until another is clearly superior, you can be pretty certain it will track changes in the python language closely for a while. I use mypy & flake8 for "static checking".

My question is: are there any plugins that show error-indicator squigglies for pep8 violations?

akubera··on Pyright: Static type checker for Python
I just installed it. It gives red squiggly lines under variables that haven't been assigned (typos) and for incorrect methods on variables it can type-deduce. This is without me adding any typing-hints to the script I'm working on.

Only issue I see immediately is it does not use the default sys.path that the vs-code-configured python interpreter uses, so it cannot resolve some of the packages I'm using.

But overall, very nice.

akubera··on Cookie Warning Shenanigans Have Got to Stop
What, to you, makes something a fundamental right?

The EU's document is "Charter of Fundamental Rights of the European_Union"[0], which does grant privacy as one. That pretty clearly does make it a "fundamental right".

Note the US Constitution's Bill of Rights does not offer right-to-privacy (but the 4th provides protection from searches-and-seizures without probable cause, which really doesn't deal with "privacy", especially from non-governmental actors).

Perhaps parent should have said "fundamental right granted by the EU", but in this context it's pretty clear.

[0] https://en.wikipedia.org/wiki/Charter_of_Fundamental_Rights_...

akubera··on Python exceptions considered an anti-pattern
I can't think of a single time I've needed a large collection of "backup" methods in case of a chain of failures; I can't even think of an example which could scale to 100. Anyways, this solution does scale:

    methods = [method1, method2, method3, method4]
    for method in methods:
        try:
            method()
        except Exception:
            pass
        else:
            break
    else:
        raise NoMethodWorked()
You can even pair specific exceptions to each method:

    methods = [(method1, TypeError), (method2, KeyError)]
    for m, e in methods:
       try: m()
       except e: ...
But the whole thing really sounds like you're trying to do too much with one function and you really should rethink the whole structure of your code.
akubera··on Ask HN: What’s your laptop?
ThinkPad T480 with touchscreen - runs Kubuntu well. Audio is terrible, but I like USB-C charger, builtin ethernet, & removable battery.

I was able to upgrade the SSD and it was a pretty good experience, if you're into that.

akubera··on Typed-Html: Type Checked JSX for Rust
f
akubera··on Exploiting Coroutines to Attack the “Killer Nanoseconds” [pdf]
Gor Nishanov, one of the authors, talks about this in his CppCon2018 talk https://youtu.be/j9tlJAqMV7U (jump to ~12:33 to skip background).

It amounts to using CPU prefetch instructions with C++ coroutines to simulate hyperthreading in software by scheduling instructions around cache misses (but is potentially better than hyperthreads because it's not limited to 2/core)

akubera··on Quark Deconfinement as Supernova Explosion Engine for Blue Supergiant Stars
The "as-a-service" was meant to be funny, but I have found that it is often difficult to find special-purpose scientific software (with adequate build system) mentioned in papers online, without sneakernet/emailing the authors directly. Hosting analysis-runners on the web would make doing a test much easier. (It's getting better; the ALICE collaboration (of which I'm a member) for instance uses github for the analysis code and dependencies https://www.github.com/alisw, but each scientist doesn't need to upload their fitting & plotting code.)

Writing a REST API in front of their software would help with "service-discovery", usability, and of course reproducibility; but there's the issue of sending back many-GB of data per run, questionable amount of customization (but if you allow uploading an ini config file, that should be ok), no institutional history of doing tasks this way, and the fact that this is not what I'm paid to do.

For more on scientific computation differs from a more typical setup, I highly recommend this StrangeLoop talk by Jim Privars: https://www.youtube.com/watch?v=jvt4v2LTGK0

← PreviousPage 2 of 4Next →