HNHacker News
TopNewBestAskShowJobs

groovy2shoes

1,904 karma · joined February 3, 2011

https://github.com/baguette

cmburget@gmail.com

my topcolor is 8674a9

submissionscomments
groovy2shoes··on Gerbil – An opinionated dialect of Scheme designed for systems programming
You may find this paper helpful [1]. As noted there, syntax-rules consists really of two different parts: (1) the hygiene-preserving macro expander and (2) the pattern-matching facility. Once you wrap your head around the two pieces, it's actually pretty straightforward to implement them both. It's very common to write some "low-level" macro facility as a stepping-stone to syntax-rules (such as explicit-renaming macros or syntactic closures): the implementation of syntax-rules then becomes a composition of the pattern-matcher and the low-level facility. A tutorial implementation of an appropriate pattern-matcher can be found at [2],[3].

There's lots of good reading to be found at the ReadScheme Library [4]. Most if not all of the references in [1] can be found there.

Tangentially: yeah, syntax-rules kinda flies in the face of the oft-mentioned minimalism of Scheme, but there's a reason for it: at the time syntax-rules was standardized, there was no consensus on which (if any) low-level facility should be standardized (and, really, there still isn't any such consensus). The reason syntax-rules operates as a pattern-template rewriting system rather than as a procedural system is that such a system is able to guarantee that the macros it produces are hygienic in a (comparably) simple and intuitive way. The idea was to standardize on a high-level system so that Scheme could have a standard macro facility, whilst leaving the low-level systems open for further exploration and experimentation. The two main contenders are still, after all these years, syntax-case and syntactic closures: the latter being easier to implement and arguably easier to grok, the former being potentially more powerful (in that an implementation of syntactic closures within syntax-case is known, but not vice-versa (last I checked)).

--

[1]: http://mumble.net/~jar/pubs/scheme-of-things/easy-macros.pdf

[2]: http://blog.theincredibleholk.org/blog/2013/02/11/matching-p...

[3]: http://blog.theincredibleholk.org/blog/2013/02/12/patterns-w...

[4]: http://library.readscheme.org/

groovy2shoes··on “There Is No Reason for Any Individual to Have a Computer in Their Home”
Good ol' Wirth's Law.

https://en.wikipedia.org/wiki/Wirth%27s_law

groovy2shoes··on Sublime Text 3.0
> That said, caps to control is a great quality of life improvement for anyone that uses CTRL for anything

I agree. I've been a vim user for over a decade, but a few years ago I decided to try mapping capslock to ctrl and have never looked back. It's a much more natural place for a key that gets used as often as ctrl, while capslock is a key that is rarely used (as a matter of fact, my keymap doesn't even have a capslock at all anymore, and I haven't missed it!). Anyone who uses ctrl more often than capslock ought to give it a try, but beware:

> On other computers IT IS NOT UNCOMMON FOR ME TO END UP TYPING IN CAPS.

It's a real danger!

groovy2shoes··on My first fifteen compilers
> The boundaries between lexers and parsers differ by the parser in question.

Indeed, the division between lexer and parser is somewhat optional, since scannerless parsers can be defined to operate directly on a stream of basic symbols from the language's alphabet, but the usual division reflects notions from automata theory:

- A lexer (a.k.a., lexical analyzer, tokenizer, scanner) is founded, in principle if not in actuality, on a finite state automaton to group input symbols from an alphabet into basic meaningful units ("lexemes" or "tokens") and to classify those units according to their significance (identifiers, keywords, literals, delimiters, etc.). In a natural language context, it can be thought of as producing words from a sequence of letters.

- A parser is founded, in principle if not in actuality, on (usually and at least) a finite state pushdown automaton, which is basically a finite state automaton equipped with a stack which can be manipulated by the transition function. The goal of a parser is to convert a stream of input symbols into one (or sometimes more) derivations (a.k.a. parse trees, [concrete] syntax trees, parses) which represent the structure of the input in terms of a grammar. In a natural language context, it can be thought of as producing sentence diagrams from a sequence of words (or letters in the case of scannerless parsing).

> Grammar and syntax are also different,

No, grammar and syntax are the same. A grammar consists of an array of productions, which are rules that define how symbols in the language may be combined to form valid sentences in the language. Usually, "grammar" refers to a formalism that is sorta like a big regular expression, except that it's not limited to the regular languages (context-free grammars being most common, with extra-parser hacks to support context-sensitive languages if needed), but a grammar is really an abstract mathematical object and need not be formally manifest.

> Syntax are the rules which define the language while grammars are the conventions that define the context in which artifacts in a language instance are interpreted.

Indeed, syntax can be thought of as the rules which define a language (that is, can be thought of as a grammar). However, what you describe as "the conventions that define the context in which artifacts in a language instance are interpreted" is properly called semantics, which are rules for ascribing meaning to phrases in the language.

> Parsers commonly produce abstract syntax trees (AST), but can produce output in a variety of formats. I prefer parse tables personally. To say that a parser must produce as AST is rather short-sided and inexperienced.

This is true; indeed a parser can directly produce any sort of output: a single truth value that indicates whether the input is part of the language that it recognizes, a translation into another language, or even "no" output in the case of an interpreter. However, I'm confused by your usage of "parse tables" here. The term usually refers to the tables that are used to drive a parsing algorithm (i.e., an input to the parsing algorithm) rather than the output of a parser. Would you elaborate for me?

> Lexers, parsers, and compilers are all separate steps that can act independently provided a sufficient configuration.

Indeed, a parser does not necessarily require a lexer, nor must a parser's output be compiled. However, though your statement is technically true, I can't even imagine what a compiler without a parser might look like!

groovy2shoes··on I Am Graphics and So Can You
> For printers, there is PostScript. Why there isn't a similar standardized 3D rendering protocol?

There is. It's called OpenGL ;)

That said, I share your sentiment. Tossing aside the drivers and the general optimizations they offer seems to me to be akin to tossing aside your compiler because you can write more efficient assembly by hand. I think the ability to write such low-level code will always have its place, but I can't help but feel like we (as an industry) are going in the wrong direction with this.

In trying to be optimistic about Vulkan and the like, it may be an opportunity for developers to experiment with different higher-level APIs until we manage to find abstractions that are as good as the ones we have for networking (and hopefully better, even).

> it's like I am writing driver-level code, which is not my idea of fun.

Luckily, that's somebody's idea of fun :)

groovy2shoes··on Vim's 25th anniversary and the release of Vim 8
As long as your terminal is configured to send the Meta modifier as an ESC prefix rather than a shift bit, and as long as your Alt key serves as Meta.
groovy2shoes··on Arch Linux pulls the plug on 32-bit
Windows doesn't support shebang lines, so the exact name/location of the interpreter doesn't matter as much as it does on 'nix.
groovy2shoes··on Forth: The Hacker’s Language
Not to mention that you could just use C identifiers in the asm block willy-nilly:

    int foo(int c)
    {
        int r;
        
        asm {
           mov ax, 0x0b00
           int 0x21              /* poll stdin for input   */
           mov ax, offset c      /* get address of `c`     */
           call bar              /* call other C function  */
           mov r, dx             /* save the result in `r` */
        }
        
        return r;
    }
Or something like that — it's been a while. Those were the days! GCC's (and I'm assuming clang's is much the same) inline assembly is a joke in comparison. I remember, when I first encountered it, flipping back-and-forth through the GCC docs looking for how people actually do inline asm with GCC...
groovy2shoes··on Forth: The Hacker’s Language
They can, but I'm not even sure you'd be able to fit all of Ada's reserved words in a typical boot ROM ;)
groovy2shoes··on Using Vim as a Python IDE
vim (and emacs) can do that without the need for a terminal multiplexer (though in vim you need to use a "plugin" for it, or, at least, you used to, and I'm sure the new async functionality in vim 8 has improved the experience quite a bit)
groovy2shoes··on C++11 FAQ
I would say that's cute.
groovy2shoes··on Welcome, ACLU
I don't mean to imply that you're wrong (afaik, you're actually correct here), but I do want to point out that the interpretation and legal enforcement of the constitution is supposed to be done by the Supreme Court (and, to a somewhat lesser extent, the entire judiciary branch). I'm not sure to what extent the SC can pass judgments / make rulings without being prompted by a lawsuit, though at the very least it seems to me that the ACLU at least keeps the important stuff on their radar ;)
groovy2shoes··on C++11 FAQ
I've written code in over 50 different programming languages at this point (though only about a dozen or so professionally, including Python), and the only languages where I've ever been asked or required to work with a subset in lieu of the full language have been C++ and Perl. I've never worked on a project or for a company that allowed unrestricted use of all of C++.
groovy2shoes··on What a good commit message looks like (2011)
Pardon me for piggy-backing on your comment, but the Vim equivalent of Emacs's auto-fill mode is to `:set textwidth=74 wrap linebreak` (where 74 here is the column at which to wrap, and `linebreak` tells Vim to break at some character specified in `breakat`, which is set to a useful default consisting of whitespace and various punctuation). The default behavior is the same as @compsciphd describes for Emacs: it won't reflow automatically during editing, however, the sequence `gqap` in command mode will reflow the current paragraph (`gq` is a command to format text, and it is followed by a motion to specify the text to format: in this case `ap` is the motion for "a paragraph", i.e., the paragraph which currently contains the cursor).

Vim also has an auto-format feature, which can be enabled with `:set formatoptions+=a` and will make paragraph editing behave a bit more like, say, a word processing program, but the Vim help file cautions that formatting long paragraphs or paragraphs with complicated indentation can get slow. I haven't really used the auto-format feature myself, so I can't comment on how slow it actually seems to be in practice.

groovy2shoes··on What a good commit message looks like (2011)
The word "generally" here has a precise meaning when used in a formal (mathematical) sense. Using that meaning, the phrase "wrapped code is generally nonsensical" could be read as "there exists some code that is nonsensical when line-wrapped" or "the amount of code that is nonsensical when line-wrapped is non-zero". More precisely, it means that, in general, you cannot rely on any ol' code to remain sensical after wrapping has taken place. Hopefully, it's obvious that this is true.
groovy2shoes··on C++11 FAQ
One of C++'s most glaring problems is that everybody only ever uses some subset of some version of the language, but you still need to know basically the entire massive, monstrous language because not everybody uses the same subset and you need to be prepared for anything. On top of that, you're lucky if your employer or potential recipient of contributions (e.g., FOSS project) or whatever has actually codified the subset they want to you to use: most of the time, you need to infer the allowable subset from the existing code.
groovy2shoes··on C++11 FAQ
Modula-3. Bonus points are awarded to Modula-3 and Rust for safety.
groovy2shoes··on The practice of programming, 18 years later
Right, the particular prop is irrelevant to the practice. If my cat happens to be in the room, I might talk to them, or I might just talk to myself (appearances be damned!).
groovy2shoes··on Vimperator: a Vim-like Firefox
> Yes! I love being able to click on links from the keyboard!

You don't need an extension to do that in Firefox. Press the <'> key and start typing, you'll get an incremental search like </> gives you, but limited to hyperlink text. Once it's highlighted any bit of the link you want, press <CR> to follow it. Works in Seamonkey, too.

groovy2shoes··on App.net is shutting down
Sure, I realize that. But it seems I missed that initial event, and then everyone fell silent about App.net (nobody really continued to buzz about it).

Whenever stuff like this happens, I always wonder how many people, like me, hadn't heard of some service or product, and I wonder how many of them would have used it if they had. Would it have been enough to save the company from going under? Was it a marketing problem? I dunno, that's just the kind of strange places my mind tends to encounter in its errings.

groovy2shoes··on App.net is shutting down
This is my first time hearing of App.net.

(This is something that happens for me regularly -- I "discover" something only by its shutdown notice making the HN front page...).

groovy2shoes··on Graph Isomorphism Strikes Back
I was watching a talk of his the other day and thinking "he's old enough to be my dad, but damn, he's cute..." ¬_¬

Throughout my life, I've found that the best lecturers aren't necessarily the smartest or the most credentialed, they're the most apparently passionate and enthusiastic — so much so that their enthusiasm has a tendency to "rub off" on their audiences. Enthusiasm leads to engagement, which leads to attentiveness and self-motivation for learning. Even a mediocre teacher can be a great lecturer, and I've had a few in my lifetime (though unfortunately I can count their number on one hand).

groovy2shoes··on Show HN: Kitty – A modern, hackable, featureful, OpenGL based terminal emulator
I use awesome, and there's a way you can assign particular programs to specific tags, so that they always open on that tag. I'd be surprised if i3 didn't have a way to do the same, given that even dwm can do it ;)

Then, there's a third option in addition to the two you mentioned: spend two minutes (if that) doing the one-time configuration of having the wm reserve a tag for your browser (and perhaps other GUI apps that you anticipate frequently needing/wanting to run full-screen). In awesome, you'd do that by adding an entry to your global rules table like this one (in rc.lua):

    { rule = {
        instance = "firefox"
      },
      properties = {
        screen = "HDMI1",
        tag = "3"
      }
    }
Which will configure awesome so that any time a new client becomes managed by the wm, it will ensure that its window opens on the XRandR screen "HDMI1", and specifically on that screen's tag "3". ("3" is a string here because, while tags are by default "integers", "1" - "9", they can be named by any string afaik, and many people will rename them things like "www", "irc", "term", etc.).

You can also use awesome-client(1) to send Lua code to a running awesome instance for execution within the wm's context. This could be tossed into a shell script (and parameterized as you see fit) for convenience, if desired:

    $ awesome-client <<EOF
      require("awful").spawn("firefox", {
        screen = mouse.screen,
        tag = "3",
        switchtotag = true
      })
    EOF
The same awful.spawn() call you'd send to awesome-client can also be bound to a keystroke or a menu entry for quick access.

As for me, I tend to only use tmux under X11 if I'm worried about losing an ssh connection and therefore (without tmux, of course) the ssh session. However, I have DEC vt520 glass TTY that connects via RS-232 serial cable to a couple of servers (one OpenBSD, the other FreeBSD) and, while the terminal is pretty damn featureful, it has limited scrollback and awkward copy/paste functionality. So, on that terminal I use tmux quite a bit (although it seems to be rather chatty and during periods of heavy pty traffic can sometimes wind up spitting a garbage glyph on the screen here and there, but I think I may just need to increase the baud rate (despite already being set to ~56 Kbaud! cha-tty!)). The vt520 also only supports 2 sessions at once directly (and I can't even figure out how to get the OS to recognize the second one -_-), so tmux's multiplexing capability is also greatly appreciated when I'm basking in the amber glow.

groovy2shoes··on Dd is not a disk writing tool (2015)
Yup. Just don't do what I did earlier and `pkill -USR1 -f dd` if your desktop session is currently being provided to you courtesy of `sddm` …

As a programmer, it usually pays off to be on the lazy side, but every once in a while it comes back and bites me in the arse ;)

groovy2shoes··on I made my son cannabis cookies. They changed his life
Given our track record when it comes to "Wars on Concepts", initiating an outright "War on Extinction" seems to me like a sure-fire way to guarantee we go extinct within 20 years...

Maybe we ought to instead start a "War on Health" or a "War on Learning" ;)

groovy2shoes··on X86 Assembly Guide
I think I see where you're coming from. It's pretty much a matter teaching the most common thing, since common implies widely-applicable which implies most useful in practice. I think that's a fair point, and should certainly be a consideration to anyone planning to teach any topic in comp sci. However, having taken a semester-long course on 16-bit (8086) assembly language back in college (with MASM running in DOSBox on OSX, of course ;) ), I've never found any need for any further coursework or tutorial-style texts/articles/whatever in order to later write 32-bit x86 or amd64 (or even ARM, PPC, 68k, or 6502) assembly language. Just the reference manuals were enough, because the mindset is largely the same. I feel as though it's broadly similar to other programming paradigms, where if you learn a procedural language, there's no real need to study another before starting to code.

> What else runs x86...?

Well, as far as I know, every amd64 machine can run 16- or 32-bit x86 machine code. So, I'd say pretty much all of your examples of amd64 machines run x86 :p

groovy2shoes··on WebRTC: the future of web games
I don't have any problem using old stuff that worked 10 years ago. Our field is young, and there haven't been any major advances in the way programming is done for the last 25 years or so. Even if there had been major advances, I don't see anything inherently bad or wrong about oldness; conversely, I don't see anything inherently good about newness. Something can be 30 years old yet still be better than any of its alternatives, even in our field where obsolescence is a fact of life. I also don't think stable software is prohibited from continued evolution—obvious examples include the common open-source Unix-like OSs, many of which have been stable for years, yet have continued to evolve new features like loadable kernel modules, direct rendering interfaces, network firewalls, containers/jails/zones, nifty file system improvements, etc. Even Berkeley sockets were once introduced by an OS that was already old enough to be licensed to drive.

Also, I disagree that all of computing is built upon nothing but hacks. Computing is underpinned by lines of theory whose fundamentals can legitimately be described as elegant or even beautiful. I'm thinking of things like universal Turing machines, the lambda calculi, type theory, the structured programming theorem, theories of concurrent, parallel, and/or distributed computation, automata theory, computability theory, complexity/tractability, universal/abstract algebra, relational algebra, unification, etc., but the elegance doesn't end where the theory ends. Many people, including myself, would consider Lisp to be profoundly beautiful, for example, perhaps even on multiple levels. Whether you like the language or not, it was a crowning achievement of early computation science, and it is far from unique in that regard.

Although I personally loathe the state of Web development, I don't hate Web developers. On the contrary, I'm very glad that there's no shortage of people who seem to enjoy it—especially as a long-time Linux user, I'm glad that since the dawn of "Web 2.0", I've had to worry less and less about being left out because third-party developers decided not to support my OS: more and more, I can just pop open my Web browser and use the exact same software anyone would use on Windows or MacOS. It's a double-edged sword, for sure, since along with the convenience and compatibility, browsers have become insane, bloated resource hogs, and if I'm not connected to the Net, there's a chance I won't be able to use the software I want or access the data I want. On top, philosophically I can't help but feel that XaaS for various values of X and "the Cloud" are regressions back to a time when personal compute power was prohibitively expensive, for reasons that are billed as convenience but in reality only serve to remove the freedoms of end users; notwithstanding, I'm just going to focus on the technological issues that I perceive for now, since the philosophical issue(s) demand a different class of solution altogether, nor do said issue(s) belong uniquely to the Web.

I suppose most of the issues I have with the Web as a software platform stem primarily from one force: organic growth over the course of two decades, as opposed to thoughtful and deliberate design by an engineer or group of engineers. The way the Web is now, especially when viewed as a software delivery and execution platform rather than as a document delivery platform, it's a Frankenstein's monster that has been pieced together from numerous disparate protocols and data formats all designed by different people, revised by still more different people, and oftentimes extended by yet more different people in order to cover use cases that had not been considered by the original designer(s), and then connected in the most straightforward ways possible, where each connection might consist of an entirely different mechanism than any other (rather than, for example, extending the protocols such that they provide a uniform connection mechanism).

However, I don't think organic growth on its own necessarily leads to monstrosities. I think that the force of organic growth has been guided by a couple of factors, similar to how evolution is guided by various forms of selection. For one, throughout the history of the Web, the goalposts of its continued development have moved time and again. Once a system for the distributed service of hypertext documents, it quickly became a service for hypermedia in general. Then it became a service for interactive trinkets. And it quickly became a service for commerce and enterprise. With the advent of Java applets and ActionScript-programmable Flash "movies", it became a service (but not yet a platform) for the delivery of applications. Then, of course, AJAX sparked a fundamental change in how the Web was viewed by developers and users alike: it finally became not only an application delivery service, but also a software platform! Since then, the goalposts have shifted only slightly, and the majority of these goals can be summarized as a desire to further enrich the software platform, first by doing the things Flash was once used for, then the things Java was once used for, coming to the point where there is a desire for a Web page to be able to do the things native desktop applications are typically used for, including even AAA games. For each set of goalposts, the context of the design of new Web technology has been different; as such, the notion of what has constituted a "good" design decision has also changed: sometimes, what was a good design decision at the time became not-so-good in a new context. The result has been—rather than a clear progression towards a single goal—a bunch of tumorous outgrowths in various directions with a line of best fit trending from "hypertext document service" to "hardware and operating system abstraction layer and virtual machine for shitty, poorly-performing, inefficient, possibly-distributed applications". The curious "architecture" of the Web is reflected in the architecture of Web applications: the number and complexity of the technologies that are needed to create even the most basic Web application is, frankly, ridiculous. And on top of it all, where platforms with like goals such as the JVM and CLR manage to provide first-class support for multiple programming languages, the Web manages to offer only one, and it happens to be particularly grimy (my fingers are crossed for WebAssembly).

The lesson of all this (and it's not a lesson unique to the Web by any means), is this: backwards compatibility is a bitch.

tl;dr all these young punks need to get off my lawn

groovy2shoes··on Quantum computers ready to leap out of the lab in 2017
I'm reminded of the film "October Sky" where Jake Gyllenhaal's character (and I feel like a terrible nerd for not recalling the character, who is (was?) an actual NASA engineer, iirc), upon witnessing Sputnik-1 on a clear night, became obsessed with space flight and rocketry in particular. Got himself a bunch of really advanced texts on the subject and just powered through them, lazily learning the necessary math as needed, as you suggest. Once a poor student (bit of a slacker), he went on to make himself some rockets in relatively short order.

Excellent flick. If you haven't seen it, I recommend giving it a watch.

groovy2shoes··on Quantum computers ready to leap out of the lab in 2017
But what should I learn if I'm interested in learning algebra?

N.B. My maturity level is normally only a half step above the average 12-year-old. I can play this game all day ;)

groovy2shoes··on X86 Assembly Guide
You're insinuating that x86 isn't useful. Why do you think so? (Not trying to be combative—I'm genuinely curious).
← PreviousPage 5 of 34Next →