HNHacker News
TopNewBestAskShowJobs

bokwoon

76 karma · joined April 10, 2020

submissionscomments
bokwoon··on A 10x Faster TypeScript
https://www.youtube.com/watch?v=10qowKUW82U

[19:14] why not C#?

Dimitri: Was C# considered?

Anders: It was, but I will say that I think Go definitely is -- it's, I'd say, the lowest-level language we can get to and still have automatic garbage collection. It's the most native-first language we can get to and still have automatic GC. In C#, it's sort of bytecode first, if you will; there is some ahead-of-time compilation available, but it's not on all platforms and it doesn't have a decade or more of hardening. It was not geared that way to begin with. Additionally, I think Go has a little more expressiveness when it comes to data structure layout, inline structs, and so forth. For us, one additional thing is that our JavaScript codebase is written in a highly functional style -- we use very few classes; in fact, the core compiler doesn't use classes at all -- and that is actually a characteristic of Go as well. Go is based on functions and data structures, whereas C# is heavily OOP-oriented, and we would have had to switch to an OOP paradigm to move to C#. That transition would have involved more friction than switching to Go. Ultimately, that was the path of least resistance for us.

Dimitri: Great -- I mean, I have questions about that. I've struggled in the past a lot with Go in functional programming, but I'm glad to hear you say that those aren't struggles for you. That was one of my questions.

Anders: When I say functional programming here, I mean sort of functional in the plain sense that we're dealing with functions and data structures as opposed to objects. I'm not talking about pattern matching, higher-kinded types, and monads.

[12:34] why not Rust?

Anders: When you have a product that has been in use for more than a decade, with millions of programmers and, God knows how many millions of lines of code out there, you are going to be faced with the longest tail of incompatibilities you could imagine. So, from the get-go, we knew that the only way this was going to be meaningful was if we ported the existing code base. The existing code base makes certain assumptions -- specifically, it assumes that there is automatic garbage collection -- and that pretty much limited our choices. That heavily ruled out Rust. I mean, in Rust you have memory management, but it's not automatic; you can get reference counting or whatever you could, but then, in addition to that, there's the borrow checker and the rather stringent constraints it puts on you around ownership of data structures. In particular, it effectively outlaws cyclic data structures, and all of our data structures are heavily cyclic.

(https://www.reddit.com/r/golang/comments/1j8shzb/microsoft_r...)

bokwoon··on I don't need your query language
https://twitter.com/edgedatabase/status/1620582614703964160

EdgeQL:

    select Child {name}
    filter .<child[is Parent].name = 'Uma Thurman';
SQL:

    select child.name
    from child
    join parent_child_rel using (child_id)
    join parent using (parent_id)
    where parent.name = 'Uma Thurman';
IMO EdgeQL is going too far with the sigils
bokwoon··on AstroNvim is an aesthetic and feature-rich Neovim config
I want to stress that for anyone looking to use Neovim as an IDE (lite), all you need is something that speaks the Language Server Protocol (LSP). You don't really need to download all these configuration frameworks.

- Neovim's native LSP (with the neovim-lspconfig plugin) handles completions, go-to-definition, linting, formatting and refactoring. (Here's my init.vim config for the LSP https://gist.github.com/bokwoon95/d9420fce4836f6b518b02bd60a...).

- Instead of trying to get an autcompletion plugin to work, just use vim's native omnicompletion <C-x><C-o>.

- Instead of a plugin manager, use Vim8 native packages (https://vi.stackexchange.com/a/9523). I use a custom shell script for updating plugins via git (https://gist.github.com/bokwoon95/172ecc04039afdbe9425678946...)

- I use Fern.vim for a file explorer.

- I use Telescope.nvim for fuzzy jump-to-file.

- Dynamic statusline is just a few lines of config (https://gist.github.com/bokwoon95/d9420fce4836f6b518b02bd60a...), no statusline plugin needed.

- No debugger support, I'll use a CLI debugger or an IDE if I need one.

I've been using this setup for very a long time, and I barely touch my init.vim anymore. Here's a recent thread from the neovim subreddit where the OP talks about how much effort it takes to properly setup a configuration framework https://www.reddit.com/r/neovim/comments/11p6iiu/i_love_vim_...:

> I want to fix my problems and consolidate my environments BUT setting it up is too painful and I don't another hobby as a job (I already have servers and a 3d printer lol). I've tried multiple times this week to setup either pure neovim, lunarvim, nvChad, astrovim and LazyVim starter and there's always something that I can't find how to change even after searching online and not even taking into account that setting it up takes like a day for each. I don't really want to dedicate a whole month to reading docs, debugging and discovering plugins to fix issues that i'm hitting and I don't wan to blindly learn some commands to then throw them away because that distro didn't work out.

bokwoon··on Ent: An Entity Framework for Go
> I didn't see anything to help me build back graphs

Hmm you've certainly given me something to think about. Thanks.

BTW joins are not challenging, but you made me realize I didn't show any joins in my basic examples. Here is an UPDATE with JOIN in the meantime: https://bokwoon.neocities.org/sq.html#postgres-update-with-j....

bokwoon··on Ent: An Entity Framework for Go
> at the same time, they provide little (or nothing) utilities to map the data coming from a complex query, back to objects

Example of a query builder with built-in mapping capabilities (it’s mine):

https://github.com/bokwoon95/sq

I feel some exasperation when I see query builders that throw a query string back to the user and ask them to map the results themselves. That’s easily the most tedious and mistake-prone part of using SQL queries. In the case of my library, projection and mapping are handled by the same callback function so in order to SELECT a field you basically map it and it’s automatically added to the SELECT clause.

bokwoon··on We lost 54k GitHub stars
> I assume that the cascading done on GitHub would be done on a FK constraint

GitHub doesn’t use foreign keys, the cascade delete must have been manually implemented.

https://news.ycombinator.com/item?id=21486494

bokwoon··on Roll your own Ngrok with Nginx, Letsencrypt, and SSH reverse tunnelling
By far the most important feature that ngrok provides, I’ve never used ngrok for its ability to replay requests
bokwoon··on New JSON query operators in SQLite 3.38.0
hi I was the one who made that comment. The JSON incompatibilities I was referring to at that time was for an older version of the JSON proposal. The current version of the JSON operator in SQLite mimics Postgres (and MySQL) perfectly and I'm very happy about that.

In the older version of the proposal, -> was identical to ->> except -> returned NULL on malformed JSON (while ->> raised an error). Both -> and ->> would automatically convert a JSON-encoded SQL string '"like this"' into an SQL string 'like this'. This is not how the -> operator behaves in Postgres and MySQL, and my examples were simply trying to point out that incompatibility.

bokwoon··on SQL vs. NoSQL Is the Wrong Distinction
I've seen a very good article on this: https://www.trek10.com/blog/dynamodb-single-table-relational.... It's an insightful dive into how KV stores can model relational data. However I also feel that these 'NoSQL can do relational modelling!' proponents are kind of hijacking the term: a relational model is understood to be based on relational algebra, and DynamoDB's Everything is One Big Table design ain't it.

NoSQL can model relational data, but it is not a relational model (as understood by E.F. Codd).

Also, NoSQL data access patterns are pretty much set in stone, which is kind of what the relational model explicitly avoids.

bokwoon··on Recursion in SQL Explained Visually (2020)
For modelling trees, I much prefer using a list of ancestors compared to the parent-child adjacency list because it doesn't require recursion to answer basic questions. I had thought about how I would model threaded comments in SQL some time ago and wrote down an example of what I mean:

https://gist.github.com/bokwoon95/4fd34a78e72b2935e78ec0f40e...

bokwoon··on Against SQL
Given that the author also wrote https://scattered-thoughts.net/writing/select-wat-from-sql/, I don't think he knows nothing about inner joins. I think he was just using that equivalent form to compare it with the terser `foo.bar.quux`. It is pretty strange to compare it with `fk_join(foo, 'bar_id', bar, 'quux_id', quux)` though, because SQL already has the equivalent `foo JOIN bar USING bar_id JOIN quux USING quux_id`.
bokwoon··on How JavaScript Works: deep dive into call, apply, and bind
You're not supposed to use `super` or specialization with factory functions, call the functions you need instead.

OOP inheritance does not belong in this pattern, even if you could hamfist it in (which you've already observed as unwieldy).

bokwoon··on Go in Production – Lessons Learned
Could you explain what you mean by things start getting hard? Why did the languages you mentioned stop using their HTTP interfaces?
bokwoon··on Simple SQL in Python
Don't query builders already let you do that? By making the WHERE clause map to a data structure, you can just duplicate the data structure to duplicate the WHERE clause e.g. https://bokwoon95.github.io/sq/query-building/reusing-where.... (full disclosure: I'm the author).
bokwoon··on I made an app that lets you split a file into horcruxes
heh, you seem to have messed up the bracket order for the markdown links. I memorise it as the mnemonic "square bracket": first the square [], then the bracket ().
bokwoon··on Dividing front end from back end is an antipattern
> The other killer „feature“ of webapps is that you can have a single one for multiple platforms.

That's a feature for developers, not consumers. Consumers will be unhappy if you tell them your mobile app doesn't exist on the app store and must be downloaded from some third party website.

bokwoon··on Have we let the LED indicator light go too far?
Ha, I used to have a shirt draped around the neck of the fan for this exact reason. Didn't work too well, some of the light still bled through
bokwoon··on Head asleep, body awake
> I did some things in Alaska before where I used yoga techniques to very slowly fall asleep, and I was able to stay awake while my sense of hearing and sense of touch went away

I would love to be able to "sleep" while preserving consciousness. Willingly losing consciousness terrifies me. It's like death. You are physically unable to observe the moment you transition from consciousness to unconsciousness, because observing inplies consciousness. Sleeping is basically leaping into the void.

bokwoon··on Ask HN: What's the worst piece of software you use everyday?
My use case is simple enough. Git provides a list of checkpoints I can rollback to. I generally squash over merge, and I use vimdiff to resolve conflicts. I know every command I need to do those things. What's complicated to learn?

If you want a coherent mental model of git, just do https://learngitbranching.js.org/ and never look back.

bokwoon··on Beginner's Guide to Abstraction
One of my favourite abstraction advice comes from this article: https://blog.carlmjohnson.net/post/2020/go-cli-how-to-and-ad....

"You want one layer to handle user input and get it into a normalized form. You want one layer to do your actual task. And you want one layer to handle formatting and output to the user. Those are the three layers you always need."

The "do the task" layer can be abstracted again further. But starting it off as a monolithic layer, separated from input and output, is always the right call.

bokwoon··on Go is boring, and that’s fantastic
In Go you use the pattern of prefixing enum constants with the enum category to indicate that the enums are related to each other (e.g. StatusOk, StatusNotFound instead of status.OK, status.NotFound). Which is funny because today I came across this quote that "patterns are a demonstration of weakness in a language" in a Go talk https://youtu.be/5kj5ApnhPAE?t=276. I wish enums will eventually be implemented, generics are coming after all.
bokwoon··on Ask HN: What did you make during lockdown?
A Go SQL Query Builder (and struct mapper).

https://github.com/bokwoon95/go-structured-query

It was created to solve one of my pain points about scanning columns into deeply nested structs. You have full control over what columns gets mapped to what struct field, no annotation-based reflection needed. The type safe query building part was inspired by jOOQ (https://www.jooq.org/doc/latest/manual/getting-started/use-c...)

bokwoon··on The Coming Chip Wars
China would squash any civil problems out, like a bug
bokwoon··on Modularizing SQL? (2007)
Don't typical query builders allow for composing SQL from smaller building blocks?
bokwoon··on GitHub to Remove 'Master' Terminology
I also think 'main' branch makes more sense, but GitHub is breaking away from an entire collective body of tutorials out there that already reference the 'master' branch. All for the sake of PC and a knee jerk reaction to a recent event. What will people think of this change 5 years on?
bokwoon··on Old Code Gets Younger Every Year
I think it's probably because COBOL has almost no dependencies. Correct me if I'm wrong.

> The real horsemen of the legacy apocalypse is the depth of the dependency tree. Modern software development stacks abstraction on top of abstraction.

bokwoon··on Editors (Vim)
I agree, but also understand that many people use only a subset of vim and think of that as the full package. And that's fine for them.
bokwoon··on In Praise of AutoHotKey
Something I don't see mentioned in this thread is that Autohotkey is more than just hotkeys. It can also create basic GUIs using native Windows widgets, and is probably the fastest way of producing a GUI on windows (the resulting script can be bundled into an .exe file)
bokwoon··on Tackling Webdev as a Bioinformatician: why is it so hard?
If a simple link to another page requires component orchestration and reactive state management I'd say it is a bit over-engineered.
bokwoon··on The Quiet Revolution of Animal Crossing
This was a hard article to read. Why does it try so hard to draw parallels between our world and Animal Crossing? It's just a Nintendo game. Tom Nook's not some "capitalist oligarch", he charges exorbitant prices so that the player can enjoy the process and slowly make their way towards a larger goal. "Conspicuous consumption still haunts the animal village". I'd bet this was far from the mind of the creator when he designed this game.

This is like those literature memes where the teacher conjures up a fantastic narrative trying to guess what the author meant when he really just meant that "the door is red".

Page 1 of 2Next →