HNHacker News
TopNewBestAskShowJobs

Wilfred

161 karma · joined May 15, 2009

Technologist and aspiring Unix greybeard.

http://www.wilfred.me.uk

submissionscomments
Wilfred··on Difftastic: A diff that understands syntax
The getting started section of the manual should help: https://difftastic.wilfred.me.uk/getting_started.html

I've documented the minimum rust version required today, although I'm looking at lowering the minimum version.

Wilfred··on Difftastic: A diff that understands syntax
Ooh, I'd not seen this and I've seen a bunch of diff tools at this point! Thanks for sharing.
Wilfred··on Difftastic: Syntax-aware structured diff tool
Yep, that's a fair description. Note that I'm not providing a merge algorithm, just a pretty way of viewing changes.

I did look at modelling moves in an earlier prototype, but it's incredibly hard to display the result in a coherent way when there are also insertions. It was also easier to drop it when I moved to Dijkstra.

As you can see in the screenshot in the readme, it does support inserting tree nodes whilst preserving children, which covers a ton of cases.

Wilfred··on Difftastic: Syntax-aware structured diff tool
Yeah, so it's basically a lexer with an extremely simplistic parser.

Compiler parsers aren't a great fit for difftastic. They discard comments, they may not give you output if there are syntax errors, and they're usually tied to a specific language version.

Since this format works well for Comby (Rijnard's talk is excellent: https://www.youtube.com/watch?v=JMZLBB_BFNg ) I'm hopeful it's an adequate solution for Difftastic.

It will also users to add their own custom syntax/config formats.

That said, using tree-sitter might be an option. It's more forgiving than compiler parsers.

Wilfred··on Difftastic: Syntax-aware structured diff tool
Wow, thank you for the pointer! I've added it to https://github.com/Wilfred/difftastic/wiki/Structural-Diffs as I'm trying to understand the other solutions in this space.

Difftastic does not create a patch or worry about merging. That's a hard problem that I'm not trying to solve. Instead, it builds two ASTs, then marks each node as unchanged or novel.

To compute the diff, I use a graph search. Each vertex represents a position in both the left and right ASTs.

Suppose you're comparing A with X A.

Start node:

  Left: A   Right: X A
        ^          ^
The possible next nodes are:

(1) Treat A on the left as novel.

  Left: A   Right: X A
         ^         ^
(2) Treat X on the right as novel.

  Left: A   Right: X A
        ^            ^
Both (1) and (2) are the same 'distance', but (2) is closer to the end node, because there's a edge from (2) to the end that marks A as unchanged.

I've implemented this using Dijkstra's algorithm. My graph is directed and acyclic, so there are faster algorithms like topological sort. However, I don't construct the whole graph in advance (that would take O(N^2) memory) so instead I construct the graph nodes as necessary.

(This is very similar to Autochrome, which I've linked in the README. Autochrome has a worked example which is really helpful.)

At some point I think I'll have to use A* search instead. If there are more than 500 lines of code with lots of changes, difftastic can take a few seconds to terminate due to the naive graph search.

Wilfred··on Difftastic: Syntax-aware structured diff tool
Yep! There's a lot of .unwrap() and .expect() in the codebase, so it panics. Since it's Rust, you get a line number and an error message rather than a segfault.

I will tidy it up at some point, but I spend too much time throwing away ideas that don't work. Defensive code is silly if you delete it after!

Wilfred··on Difftastic: Syntax-aware structured diff tool
Definitely!

I still look at diffs in the terminal pretty often, but all my code reviews are in rendered HTML.

That said, there needs to be a credible tool before review tools can adopt it! GitHub does a line-based diff with word-based highlighting, which is probably the best you can do without syntactic smarts.

Wilfred··on Difftastic: Syntax-aware structured diff tool
Thanks, this is good advice. There are some super featureful diff tools out there. For example, https://github.com/dandavison/delta does a line-based diff but it also syntax highlights its output.

I'm hoping that defining syntax in a separate TOML file will let end users extend difftastic for their own languages/config files. I want to keep difftastic small and manageable.

Wilfred··on Difftastic: Syntax-aware structured diff tool
I agree sliders are a problem, and I hope to have a solution there.

Syntactic differs already do better because they understand that parentheses/brackets are paired. Difftastic does OK with this example: https://imgur.com/a/pVlVBo5

Wilfred··on Difftastic: Syntax-aware structured diff tool
A syntactic differ like Difftastic is very helpful when your codebase is autoformatted. Formatters often reflow code.

Given the code:

  foo(one, two, three);
If you add an argument and reformat:

  foo(
    one,
    two,
    new,
    three
  );
A line-based diff can make it hard to spot what's changed.
Wilfred··on Difftastic: Syntax-aware structured diff tool
Author here! Happy to answer any questions :)
Wilfred··on Ask HN: Who is hiring? (September 2016)
Numeric | https://www.numeric.com | Full time | Onsite | Boston, MA

Managing $19.7 billion of other people's money presents interesting technology challenges. At Numeric, we're looking for Python people to help build, test and deploy the whole trading pipeline.

If you have experience in building systematic trading systems, or if you're interested in learning, we'd love to hear from you. We do friendly code review for knowledge sharing, and we also support staff in getting qualifications.

We have all the benefits of being an established, successful hedge fund but the developer team is still small enough to do a single standup in the morning. We have the best of both worlds.

Interested? Drop me an email at wilfred.hughes@man.com, and mention HN.

Wilfred··on Ask HN: Who is hiring? (August 2016)
Numeric | https://www.numeric.com | Full time | Onsite | Boston, MA

Managing $19.7 billion of other people's money presents interesting technology challenges. At Numeric, we're looking for Python people to help build, test and deploy the whole trading pipeline.

If you have experience in building systematic trading systems, or if you're interested in learning, we'd love to hear from you. We do friendly code review for knowledge sharing, and we also support staff in getting qualifications.

We have all the benefits of being an established, successful hedge fund but the developer team is still small enough to do a single standup in the morning. We have the best of both worlds.

Interested? Drop me an email at wilfred.hughes@man.com, and mention HN.

Wilfred··on A Story about Symbolics Lisp Machines
> you can still buy the Symbolics OpenGenera LISP environment

I don't think this is still the case. I sent an email to their sales email address, and heard nothing. I also tried contacting their engineer, and even found the MIT email address of the current copyright holder nothing.

I also reached out to Peter Paine, but he only sells Symbolics hardware.

Is it still possible to legitimately obtain the software?

Wilfred··on Editing Julia code with Emacs
ESS includes a fork of julia-mode. I'm hoping to replace this with a dependcy on julia-mode, so ESS benefits from all the highlighting improvements we're doing. See https://github.com/emacs-ess/ESS/issues/119
Wilfred··on Emacs Rocks
You may also be interested in https://github.com/nschum/highlight-symbol.el which provides highlighting of the current symbol, and provides highlight-symbol-{next,prev} commands to move between occurrences of a symbol.
Wilfred··on Editing Julia code with Emacs
Wow, I wasn't expecting to see this on HN.

Thanks for the kind words :)

Wilfred··on Fish: Finally, a command line shell for the 90s
Sure. There's no single feature improvement that is much better, but when considering the improvements together the difference is striking.

1. The search term is highlighted.

2. The search is far more discoverable, its key binding means you can stumble across it.

3. The up cursor key is a better key binding choice. Pressing up without a search term may be considered as searching for commands that match "", namely everything. This conforms with fish's aim for orthogonality.

4. (Most importantly) The up cursor key has a natural undo button, down. Quick quiz: if you type "Ctrl-r foobarbaz", how do you get back to a terminal you can type in, preserving your search term? You can't. Pressing "Esc" dumps you in the middle of your history with something matching the first few characters of your search term. (Assuming you have nothing in your history matching 'foobarbaz')

Similarly, if you press "Ctrl-r foo Ctrl-r", you will get the second item in your history that matches foo. There's no way to get back to your first search result without repeating the search.

5. You can use previous commands as search terms. For example, I ran "mvn clean install", then hit "Ctrl-C" when I wanted to skip tests. I pressed "<Up> <Space> <Up>" and I was searching through all my history that contains "mvn install ". Using "Ctrl-C" I'd have had to retype "mvn clean install ".

Wilfred··on Fish: Finally, a command line shell for the 90s
1:

a. Superb readline colouring. Nonexistent commands are shown in red, commands that exist and are on PATH in green. Unclosed string literals become obvious.

b. A history search that is orders of magnitude better that Ctrl-r in Bash. (Though oh-my-zsh has the history-substring-search plugin which provides this functionality.)

c. Features work out of the box, fish helps you avoid managing a .zshrc equivalent file.

d. Tab completion offers hints. If I type l<tab><tab>, I get:

  leaftoppm  (Convert Interleaf image format to a portable anymap)
  less                                          (Opposite of more)
  lessecho                                 (Expand metacharacters)
  lessfile                        ("input preprocessor" for less.)
  lesskey                          (Specify key bindings for less)
  lesspipe                        ("input preprocessor" for less.)
  lexgrog                  (Parse header information in man pages)
(These summaries are the first lines of the man pages.)

2: I've only seen it crash on me once, which matches my experience with zsh. YMMV.

I used fish exclusively for a number of years, but eventually moved back to something sh-compatible. Too many wrapper scripts assume this.

Wilfred··on Smart people don't think others are stupid
> "Smart people don't assume others are stupid".

FWIW: This is Chersterton's fence fallacy. This states that you should not criticise a viewpoint without understanding the reasoning behind it. The reasoning may be unsound, but without knowing it at all, criticism is useless.

Wilfred··on Learn to read a sentence of Chinese in 3 minutes
> The word and character etymologies are also treated abominably poorly in the Memrise story. I never advocate filling one's mind with junk just to have memory hooks for learning new information.

Etymology is a complex and often convoluted topic, particularly for a language learner who may not be able to understand etymological information in the target language. Do you think there's no value at all in simplified memory aids, such as James Heisig's approach?

Wilfred··on Nobody's Going to Help You, and That's Awesome
I've read the paperback version and came away slightly disappointed. The book is essentially a distillation of papers the author found interesting and applicable. The separate chapters felt completely disconnected from each other. There were a number of interesting points, but no cohesion.

As for Kindle, the book design was sufficiently plain that I would have no concerns.

Wilfred··on .bit non-governmental domain name registrar, for the post-SOPA era
The death of Kazaa was a major contribution to BitTorrent usage. If it becomes the easiest way of accessing pirated content then I could see it doing very well.
Wilfred··on Regular Expression Engine in 14 lines of Python
Interesting that it's on paste.lisp.org. It strongly reminds me of Emacs' rx macro. I suspect this a port of another toy regexp implementation -- otherwise I would expect the author to use `itertools.chain` rather than implementing something that does exactly the same (`iconcat` in this sample).
Wilfred··on Node-fib: Fast non-blocking fibonacci server
That's a consequence of memoisation. It scales better than the original code though.

Still, the original point (node is cooperatively multitasked) was clear. Anything beyond that and I just want to reach for better Fibonacci algorithms.

Wilfred··on The most stupid C bug ever
For what it's worth: that's stock Emacs behaviour, at least on the current version (23.3). Seems like a highlighting bug.
Wilfred··on JavaScript is Dead. Long Live JavaScript
It is, though that's not very surprising. Here's a quick proof:

S-K combinators[1] are a Turing-complete subset of lambda calculus. Here's an implementation of them:

  k = (x) ->
    (y) -> x
  
  s = (x) ->
    (y) ->
      (z) -> x(z)(y(z))
1: http://en.wikipedia.org/wiki/SKI_combinator_calculus
Wilfred··on LastPass Disclosure Shows Why We Can't Have Nice Things
It's remarkably hard to get this right. pwdhash notes[1] that being a browser plugin stops JavaScript grabbing the password, but it's still possible with Flash. Third-party ports to other browsers don't even have the JS protection.

pwdhash still leaks the length of the password since it aims to give users visual feedback of characters being typed.

Then you've also got the issue of automatic update of plugins being compromised. The question is really: is it more secure than the alternatives?

1: http://crypto.stanford.edu/PwdHash/pwdhash.pdf

Wilfred··on The Prime That Wasn’t
> determining whether a given file constitutes a virus seems equivalent to solving the halting problem.

In fact (for a sufficiently rigorous definition of virus), it is provably the case that we cannot determine whether a file is a virus, using an argument very similar to a halting problem proof.

You might be interested in 'Computer viruses: theory and experiments' by Fred Cohen for the full working-out of the proof.

Wilfred··on Does the world really need yet another Twitter client?
Yes. Why not? Who does it hurt?

I intend to write a Twitter client this year, since existing clients don't meet my needs:

* web app * multi-account support * rate-limit noisy accounts * automatic language detection for people who tweet in multiple languages

Sure, I'd love to find something that does this already. But I don't think it exists.

← PreviousPage 2 of 3Next →