HNHacker News
TopNewBestAskShowJobs

diffxx

587 karma · joined August 16, 2022

submissionscomments
diffxx··on Forsp: A Forth+Lisp Hybrid Lambda Calculus Language
Thank for sharing that paper. I am currently implementing a compiler that has very similar ideas to those presented in it. It's very different syntactically, but the mental model is quite similar. It's simultaneously encouraging and discouraging to see your ideas reflected back to you from 30 years in the past :)
diffxx··on Instead of grinding LeetCode, learn mathematics, bro
I personally would make something like this the default interview approach for anything but entry level positions.
diffxx··on Why Triplebyte Failed
In my opinion, the only significant contribution Clean Code made was the concept of clean code. The problem is that my definition of clean code is almost completely contradictory to what the author of the book thinks constitutes clean code.
diffxx··on Ken Burns, Faux "Storyteller"
I certainly noticed that David Koch was a prominent funder of Vietnam. One of my great disappointments in it was it never seriously asked the question, who profited from the war. As I saw the napalm flames, I couldn't help but think of all the suppliers who made out handsomely.
diffxx··on Compilers are too smart
Great title. I feel like in some sense we've lost our way with compiler design. Languages do not help us write code that require minimal optimizations to run fast enough on most workloads. Instead, we overoptimize with -O[23] everywhere which slows down our development process and makes all of our code inscrutable. Better would be a faster -O0 experience and good profilers/observability so that we only optimize the hot spots (which could mean isolating specific subcomponents and compiling only those with optimizations on).

Of course it's much easier to just globally turn on release mode and optimize everything whether it matters or not. This both slows down the development process considerably and leads to bizarre issues like this.

diffxx··on Illegally parked cars are now getting hit by this dystopian windscreen barnacle
Or maybe don't park illegally.
diffxx··on Compromised Visions Are Superior
Reasonable general advice. It's important though to evaluate the quality of the constraints we submit to. There is both incredible freedom and oppression in constraint. Hopefully the constraints you choose push in the former direction.
diffxx··on The right not to be subjected to AI profiling based on publicly available data
It's not totally irrational. There is a reason for the phrase monkey see, monkey do.
diffxx··on Difftastic, a structural diff tool that understands syntax
I am quite sure that batch will work with good responsiveness for many, if not most, common languages provided source files have fewer than say 30k lines in them. If you just think about the io performance of modern computers, it should not be that difficult to parse at 25MB/sec which I estimate translates to between 500K to 1M loc, which again is in the 15k-30k loc range per 30ms.

I'm not saying that incremental is bad per se, but that the choice of guaranteeing incrementalism complicates things for cases where it isn't necessary. I am not super familiar with lsp, but I can imagine lsp having a syntax highlighting endpoint that has both batch and incremental modes. A naive implementation could just run the batch mode when given an incremental request and later add incremental support as necessary. In other words, I think it would be best if there were another layer of indirection between the editor and the parser (whether that is tree-sitter or another implementation).

Right now though, you have to opt in whole hog to the tree-sitter approach. As mentioned above, incrementalism has no benefit and only cost for a batch tool like difftastic or semgrep to mention two named in this thread.

diffxx··on Let's create a Tree-sitter grammar
I don't understand how you can say the code size has nothing to do with GLR and the explain that it is due to the formatting of the parse tables. The point is that table driven parsers are almost always huge compared to their recursive descent based alternatives (and, yes, recursive descent does have problems). The code size of the final binary is not all that matters because the huge c programs cause insanely slow compile times that make development incredibly painful. So that statement only holds if the time of grammar writers doesn't matter.

I was too vague on unicode. I meant unicode character class matching. Last I checked, tree-sitter seemed to use a binary search on the code point to validate whether or not a character was in a unicode character class like \p{Ll} rather than a table lookup. This lead to a noticeable constant slowdown of like 3x at runtime if I recall correctly for the grammar I was working on compared to an ascii set like [a-z].

diffxx··on Difftastic, a structural diff tool that understands syntax
As one of the harsh and rude commentators, I would say I basically agree with your interpretation. You also correctly inferred that I have experience with working with it in an area that is arguably outside of its true use case.

At the same time, I believe that there needs to be a corrective about what tree-sitter should and should not be used for. There are companies building security products on top of tree-sitter which I think is an objectively bad idea given its problems and limitations. Difftastic is to me a grey area because it could lead hypothetically to a security issue if it generates an incorrect diff due to an incorrect tree-sitter grammar. Unlikely but not impossible.

Your point about batch vs incremental is spot on, though even for IDEs, I think incremental is usually overkill (I have written a recursive descent parser for a language in c that can do 3million lines per second on a decent laptop which is about 60k lines per 20 ms, which is the window I look to for reactivity). How many non-generated source files exceed say 100k lines? Incremental parsing feels like taking on a lot of complexity for rather limited benefit except in fairly niche use cases (granting that one person's niche is another's common case).

That being said, it is impressive that their incremental algorithm works as well as it does but the cost is that grammar writers are forced to mold a language grammar that might not fit into the GLR algorithm. When it doesn't work as expected, which is not uncommon in my experience, the error messages are inscrutable and debugging either the generator or the generated code is nigh impossible.

Most of the happy users have no idea how the sausage is made, they just see the prettier syntax highlighting that works with multiple tools. I get that my criticism is as welcome as a wet blanket, but I just think there is something much better possible which your comment hints at.

diffxx··on Let's create a Tree-sitter grammar
Even if tree-sitter had no bugs it can never really be trusted because there is always a divergence between the language's official parser and the tree-sitter grammar -- unless the language actually uses tree-sitter as its parser, which no popular language does and it seems unlikely a future popular language will.

For syntax highlighting and code folding, what I said above is probably generally fine. Except for the fact that it will probably be wrong from time to time and then downstream users will waste hours of their lives trying to fix the broken highlighting instead of actually working on their real work.

On the implementation side, the whole thing has bizarre choices. It has created a culture in which checking in enormous generates files is common. It abdicates common and important features in popular languages like significant whitespace to error-prone external scanners. The GLR algorithm sometimes fails inexplicably and is essentially impossible to debug (not sure if the bugs are in the algorithm or the implementation). It bizarrely uses rust and node. The js dsl for grammars is needlessly verbose. The codegen is fairly slow in spite of using rust and the generated c files are insanely huge (probably a consequence of the GLR algorithm) which leads to horrific compile times which makes incremental development a nightmare. It also uses (unless it's been updated in the last six months) a terrible algorithm for unicode lexing.

In my opinion, the whole premise of tree-sitter is kind of wrong. What would be better would be a uniform dsl for generating an AST (which can easily be represented with c structs or classes in any oo language). Trying to make a universal glr parser for all languages is a bad idea. It would generally be much easier, more accurate and faster to write the AST in the dsl that external tools recognize and then handwrite the parser that generates the AST. In the best case, the compiler already exposes an api to get the ast for some source code and you just need to write a translation program from compiler format to dsl format. Worst case, you rip out the parser in the compiler and have it generate the dsl ast format. Most handwritten parsers are only a few thousand lines of codes (maybe 10k at the high end).

diffxx··on Let's create a Tree-sitter grammar
Abandon all hope, ye who enter here.

Tree-sitter is great until you inevitably run into a problem with it and find that it is impossible to fix properly if you can even figure out why the problem even exists.

The idea of a uniform api for querying syntax trees is a good one and tree-sitter deserves credit for popularizing it. It's unfortunately not a great implementation of the idea.

diffxx··on Desmos uses Pratt Parsers (2018)
I had the misfortune to use a sun workstation circa 2004 in a grad student lab. It was so sluggish and unpleasant to use that I developed a negative association with the logo. But now you've gotten me to look at it with fresh eyes and I see how brilliant the logo was.
diffxx··on Rodney Brooks on GPT-4
For me it's a little more subtle. When I sit down to write, say, an email, I usually have a specific point that I want to make but I usually haven't yet figured out exactly how I want to get there. I'm not even sure it is even possible to conceive of writing without doing it word by word. Perhaps the difference though is that we have the ability to go forward and backwards in the sense that we can usually think faster than we can type or write which allows our thoughts to advance beyond the tokens we have produced. This allows for a kind of real time editing process that incorporates both past and possible future information. But I imagine there us probably a way to enhance LLMs to branch and edit before producing the next word materially (if they aren't already doing that).

To go even more meta, there is an analogy I'm trying to make right now in which I am visualizing a road and thinking about how describing the road relates to the process of writing. In my mind's eye, I can see the full length of the road and all of its contours but I can't actually describe the individual stretches of the road coherently without enumerating them. Something similar happens with writing. I can visualize what I want to say far beyond the next word, but it's true that the actual process of writing goes word to word, much like how the process of token selection is described for an LLM. The question is whether the LLM has an analogous conception of where it is going. Going back to the process above, sometimes I know where I am going and haven't yet figured out how to articulate it yet. It is through the process of writing that I am able to articulate that thought. But the thought preceded my articulation of it. I don't know to what extent LLMs have coherent thoughts that they are articulating or if that even makes sense for the type of intelligence they project. My suspicion is that they don't have additional sensory inputs beyond language that give thoughts the immaterial shape that then is expressed in language. Without that, I am skeptical that they will truly get beyond regurgitating and/or remixing what has already been fed to them textually. That doesn't diminish how amazing they are, but I am somewhat more in the Brooks/Knuth camp that they are impressive and surprising, but there is something that ultimately leaves me a bit cold about them.

diffxx··on I want to lose every debate
Interesting perspective. This requires a level of inner strength that many of us do not always have. Increasingly though I realize that I don't need a lot of verbal feedback. You can tell a lot just by people's physical reactions to you. And the corollary is that I notice that there are some people that I try and shut down with body language to get them to leave me alone.
diffxx··on We Live in the Age of the Bullshitter
> what are the various stories of Jesus other than total ridiculous bullshit...?

Stories of deep psychological truth that transcend physical space and time. Just like all great religious stories.

diffxx··on NY Sabotages Right to Repair Bill [video]
I'm inclined to agree, but I am somewhat curious about this. The Boeing 737 max crashes certainly demonstrate that the industry does not universally prioritize safety above all. At the same time, there are strong incentives for any airline to not have a catastrophic safety incident. I recently flew on a 737 max and was willing to do so not so much because the FAA cleared them to fly but because I assume the pilots are not suicidal. In the absence of strong government safety regulations would things just devolve to YOLO? I'm not sure either way. Having said that, Chesterton's fence applies to any existing regulations.
diffxx··on Lies we tell ourselves to keep using Golang
Every failed project I've ever been a part of has been a direct result of poor choice of dependencies. My experience is surely not universal, but nor is it rare.
diffxx··on Log4Shell Still Has Sting in the Tail
The big problem here is really the library distribution system for java. Most jvm based projects use binary dependencies that are mostly sourced from maven central. A build tool could automatically block downloads of, or construction of a classpath including, binaries with known vulnerabilities. But then you might find yourself with a broken build that you can't fix yourself leaving you at the mercy of the developers of an upstream dependency that you inadvertently depend on (like log4j). I think the situation would be a lot better if java projects defaulted to source dependencies instead of binary dependencies and build tools were good at supporting remote binary caching so that you could build your own cache of binary artifacts rather than rely on a central one (so that not everyone in your org needs to burn cpu rebuilding libraries with each update). Then even if you indirectly depend on log4j, you could just grep your codebase for log4j, bump the version, rebuild everything and move on with your life. This also could make life easier for maintainers since downstream users might just fix things for them.
diffxx··on Lies we tell ourselves to keep using Golang
I think Not Invented Here syndrome is generally foolish and quite arrogant, but Not _Implemented_ Here syndrome can be a reasonable default. You rarely truly understand something unless you've implemented it yourself. You can draw inspiration from other sources of knowledge and in the process of implementation, you may decide that the source is better than what you would come up with. You might also discover that you can improve on the source, at least in some dimension. Your implementation could be as simple as a wrapper around the api of an existing library (or a DSL for using it). But after you've written the wrappers, you may find that it isn't too bad to just implement the darn thing yourself (probably don't do this with crypto!). I find it is generally a mistake to just bring in dependencies and directly build on top of them because then you become vulnerable to bit rot and vulnerabilities (or just needless complexity the use cases of other library users that are irrelevant to you) introduced upstream no matter how conscientious the upstream authors are.
diffxx··on I Lost All Faith in LastPass
But how do you determine if someone is an authority? Our world is filled with epistemological bubbles. One person's expert is another's snake oil peddler.
diffxx··on US Government demands direct police access to European biometric data [pdf]
I'm working through the stages of grief.
diffxx··on I have reached Vim nirvana
Also relevant, Before enlightenment: chop wood, carry water. After enlightenment: chop wood, carry water.
diffxx··on How to Befriend Crows
Once I was walking atop a mountain that is heavily populated with ravens at certain times of year. I looked over and noticed one was doing some aerial acrobatics. To my astonishment, it was holding a fairly large rock that it was using as a counterweight that it could spin against. When it landed, it dropped the rock and I tried to find it. I'm not 100% sure I found the right rock, but I estimate that the rock was somewhere between a quarter and half a pound. As much as I appreciated the bird's dexterity, it was a bit scary to think of the damage it could do if motivated.
diffxx··on California passes law banning Tesla from calling software FSD
I think part of the problem is the lax licensing standards in the US. For everyone's benefit, we should have higher standards. There also can and should be regional differences. Someone who has learned to drive in a rural or suburban area has not necessarily had the training and experience necessary to safely drive in a city alongside pedestrians and cyclists.
diffxx··on “I drove for Lyft for a week and learned its business model is broken”
> None of this shows Lyft's business model is broken. In fact it shows it's working splendidly for Lyft.

Even if this is true, should this be celebrated even it comes at the expense of the > 99% of the population that doesn't work for Lyft as well as the thousands of drivers who are being exploited by their business practices? It is a relatively small minority of citizens who actually rely on these businesses for their day to day lives but their externalities are borne by all.

> The idea that taxi dispatchers could be more efficient, or as efficient, is ludicrous. Does nobody remember regularly waiting 30-60 minutes for a taxi from a dispatcher?

Even if you're right, this presupposes that it is a net benefit to have easily available taxis. It also seems to suggest that efficiency is best measured by latency between ordering a taxi and being picked up. Taxis are easily the least efficient form of transit. They are even worse than private vehicles because of the deadheading. Then there is the whole induced demand problem where they actually make traffic worse as people with the means opt out of more efficient mass transit so overall transit efficiency suffers even if it is (seemingly) more convenient for many users.

> In any case, yes surely Lyft could cut costs drastically in order to become more profitable, but it's also continuing to invest in growth as much as possible.

So they can try to hold the public hostage and mobilize their minority user base against any legislation that will rein in their excesses.

diffxx··on Are Progressives in Denial About Progress? Yes, but So Is Almost Everyone Else
> we can't even eliminate tangible, clear-cut physical-reality problems like murder?

Call me a pessimist, but I don't think it's possible to eliminate murder so I think that is an unreachably high bar.

That being said, I think that there is lots of low hanging fruit that we absolutely could do something about. Traffic fatalities and injuries are an obvious one. In the US, if we collectively decided that it is unacceptable to have tens of thousands of people die every year in auto incidents and scores more seriously injured, we could rework our road infrastructure and impose regulations that would drive these numbers down dramatically, even if not to zero.

The biggest challenge to enacting the types of reforms that would improve most people's quality of life is that advocates have mostly done a poor job of communicating their positive vision for how such changes would improve most people's lives. The story progressive transit advocates (myself included) tend to tell sounds like it's about taking away the rights and freedoms of drivers. This is undeniably true. Freedoms and rights are always in tension. Progressives will always lose though if they aren't able to tell a compelling story about the benefits of the changes they wish to impose. Otherwise the other side will be able to successfully hammer them on whatever is being taken away.

In our current regime in the US, we have essentially legalized murder if you are driving a car. If someone runs me over with their SUV while I am legally crossing the street because "they didn't see me," they are extremely unlikely to face any consequences unless they were drunk. But at the same time, if I'm driving a car a lot, I also face the risk of killing or harming someone else even if I am always doing my best. This would be devastating even if I wasn't legally at fault. In other words, the freedom to kill someone with no accountability is no freedom at all.

The point is not that I want people to go to jail for killing people with their cars. I want to live in an environment where people are not killed by cars. There are many things like this where I think there is a more positive vision for society that is not that hard to imagine but that does require letting go of some of our past ways of looking at things. In this particular case, a century of marketing and pr by auto/oil companies has warped our perspective that we can't even see how anti-human the industry and our infrastructure has become. That doesn't mean we have to get rid of cars entirely, but we should rethink our relationship with them. There are many things like this.

diffxx··on Is Dark Mode Good for Your Eyes? (2020)
Amen.
diffxx··on Building a walking routine
In theory, cycling could be comparable, but in practice I find it worse (and I spent 10+ years riding ~10 hours per week). With road cycling, you spend a lot of time riding on roads that are extremely unpleasant to share with cars which is quite stressful. With mountain biking, you need to live near good trails or either you have the same sharing the road problem as road cycling but worse because mtbs suck on the road or you have to drive which adds a lot of overhead. Plus I find wearing walking clothes a lot nicer than lycra, which is basically necessary for long rides.
← PreviousPage 3 of 5Next →