HackerTrans
TopNewTrendsCommentsPastAskShowJobs

xiaq

no profile record

Submissions

Designing a shell language for the 2010s [video]

youtube.com
2 points·by xiaq·2 anni fa·0 comments

Beginner’s Guide to Elvish

elv.sh
4 points·by xiaq·2 anni fa·0 comments

comments

xiaq
·anno scorso·discuss
Elvish author here, seems like I missed the annual posting of Elvish to HN this time :)
xiaq
·2 anni fa·discuss
> Later, it will be a rejection of the insurance claim for a kid's life-saving surgery.

According to this article, it's been happening for a while now: https://www.statnews.com/2023/03/13/medicare-advantage-plans...
xiaq
·2 anni fa·discuss
Such old urban places would just be car-free in the Netherlands (sometimes with limited access for delivery and emergency vehicles), a trend fortunately becoming popular in other European cities now.

The “urban” in the title is a bit misleading, this intersection is definitely more suburban, or on the boundary of an urban center. (Or rather, the author has a different definition of urban - in my definition cities like den Bosch are really just a small medieval urban core surrounded by continuous medium-density suburban neighborhoods.)
xiaq
·2 anni fa·discuss
I would love to see the diff between the hand-rolled recursive-descent parser and the ANTLR syntax!

I certainly feel the amount of boilerplate in my hand-rolled recursive-descent parser is manageable. Of course it's not as succinct as an EBNF grammar:

- For example, you have to write an actual loop (with "for" and looping conditions) instead of just * for repetition

- The Go formatter demands a newline in most control flows

- Go is also not the most succinct language in general

So you do end up with many more lines of code. But at the end of the day, the structure of each parsing function is remarkably similar to a production rule, and for simpler ones I can mentally map between them pretty easily, with the added benefit of being able to insert code anywhere if I need something beyond old-school context-free parsing.
xiaq
·2 anni fa·discuss
Yeah, ultimately there's an element of personal taste at play.

The authoritative tone of "how to write ..." is meant in jest, but obviously by doing that I risk being misunderstood. A more accurate title would be "how I wrote ...", but it's slightly boring and I was trying hard to get my talk proposal accepted you see :)
xiaq
·2 anni fa·discuss
History entries are kept indefinitely.
xiaq
·2 anni fa·discuss
FWIW, I've just added this instruction to https://elv.sh/get/default-shell.html#vim-/-neovim
xiaq
·2 anni fa·discuss
Did you set your login shell to Elvish? Vim unfortunately relies on your shell being a POSIX shell, but you can fix that with "set shell=/bin/sh" in your rc file.
xiaq
·2 anni fa·discuss
Thanks, I appreciate the comment the appreciation :)
xiaq
·2 anni fa·discuss
Thanks! Glad that the talk is working as a marketing pitch for Elvish :)
xiaq
·2 anni fa·discuss
Thanks! Murex talk when??? :)
xiaq
·2 anni fa·discuss
Thanks for your question and glad that you enjoyed it!
xiaq
·2 anni fa·discuss
Right, I may have forgot to mention that lexerless parsers are somewhat unusual.

I didn't have much time in the talk to go into the reason, so here it is:

- You'll need a more complex lexer to parse a shell-like syntax. For example, one common thing you do with lexers is get rid of whitespaces, but shell syntax is whitespace sensitive: "a$x" and "a $x" (double quotes not part of the code) are different things: the first is a single word containing a string concatenation, the second is two separate words.

- If your parser backtracks a lot, lexing can improve performance: you're not going back characters, only tokens (and there are fewer tokens than characters). Elvish's parser doesn't backtrack. (It does use lookahead fairly liberally.)

Having a lexerless parser does mean that you have to constantly deal with whitespaces in every place though, and it can get a bit annoying. But personally I like the conceptual simplicity and not having to deal with silly tokens like LBRACE, LPAREN, PIPE.

I have not used parser generators enough to comment about the benefits of using them compared to writing a parser by hand. The handwritten one works well so far :)
xiaq
·2 anni fa·discuss
I gave a talk about the design: https://www.youtube.com/watch?v=wrl9foNXdgM

As the sibling comment mentioned, you can find documentation on Elvish itself on the website https://elv.sh. There are tutorials and (not 100% but fairly complete) reference documents.
xiaq
·2 anni fa·discuss
I don't have a version with captions, sorry. You can find the slidedeck at https://github.com/elves/elvish/blob/master/website/slides/2...

The remaining 8% mostly falls into the following categories:

- Code that use OS functionalities that are cumbersome to mock in tests

- Code paths that are triggered relatively rarely and I was simply too lazy to add tests for them

Nothing is impossible to cover, but for whatever reason it was too much work for me when I wrote the code.

However, it's worth mentioning that I only settled on the transcript test pattern fairly recently, and if I were to rewrite or refactor some of the untested code today I would add tests for them, because the cost of adding tests has been lowered considerably. So Elvish's test coverage is still increasing slowly as the cost of testing decreases.
xiaq
·2 anni fa·discuss
Hey, it's my talk, AMA :)

If you're interested in Elvish, you may also be interested in the talk on its design - https://www.youtube.com/watch?v=wrl9foNXdgM
xiaq
·2 anni fa·discuss
Look for “POSIX” on https://justine.lol/cosmo3/
xiaq
·2 anni fa·discuss
That seems to be a bad translation, the original text means something like “sharpen something fully and it won’t last so long” (presumably due to it being more brittle). The text (like the rest of Tao Te Ching) is pretty vague and doesn’t actually refer to knives, so it could also be read metaphorically.
xiaq
·2 anni fa·discuss
Oh, I definitely didn't read your entire comment as negative, just the way you used "elvishism". Elvish definitely has its quirks! But I hope you'll find it a compelling package overall :)
xiaq
·2 anni fa·discuss
> In case there are no jpg files in the working directory, Bash will put the pattern itself (*.jpg) into the $x variable. You need to explicitly check that the file in the variable actually exists before working on it.

Indeed that's one thing Elvish has better defaults that I forgot to mention in https://elv.sh/learn/scripting-case-studies.html#jpg-to-png...., and now I've added that, thanks :)