Better HN
topnewbestaskshowjobs
Log inSign up

TOGoS

584 karma · joined Feb 9, 2012 (14y ago) · 357 submissions

Submissions

comment 1y ago · link · parent

> why is having more than one account an "exception" at all? That's not an error or fail condition

It is if the caller is expecting there to be exactly one account.

This is why I generally like to return a set of things from any function that might possibly return zero or more than one things. Fewer special cases that way.

But if the API of the function is to return one, then you either give one at random, which is probably not right, or throw an exception. And with the latter, the person programming the caller will be nudged towards using the other API, which is probably what they should have done anyway, and then, as you say, the returns-one-account function should probably just not exist at all.

comment 1y ago · link · parent

This is fine and interesting, but what I think is lacking in S-expression isn't funky vertical syntax, but a way to directly represent objects that are not lists. Otherwise one needs to invent some representation on top of S-expressions (and then a list isn't necessarily a list anymore; everything goes through an additional layer of encoding/decoding, losing the elegance of S-expressions), or use some extension syntax (usually involving '#'), which varies from language to language and might not even be interpreted by the reader (but logically expand to some list expression that needs to be interpreted again later, so you're not really any better off than with the first approach).

I kind of want something like, to borrow JSON-like syntax and gloss over namespacing issues:

  (foo .
    {type: listy-cons-cell
     head: bar
     tail: (baz quux)})
...which would be another way to say (foo bar baz quuz), but would make it possible to represent any data structure you like at the same level as atoms, strings, and lists.

comment 1y ago · link · parent

Some people are wizards with the debugger. Some people prefer printfs.

I used to debug occasionally but haven't touched a debugger in years. I'm not sure exactly why this is, but I'm generally not concerned with exactly what's in the stack on a particular run, but more with some specific state and where something changes time after time, and it's easier to collect that data programatically in the program than to figure out how to do it in the debugger that's integrated with whatever IDE I'm using that day.

And the codebase I deal with at work is Spring Boot. 90% of the stack is meaningless to me anyway. The debugger has been handy for finding out "what the f*$% is the caller doing to the transaction context" but that kind of thing is frustrating no matter what.

Anyway, I think they're both valid ways to explore the runtime characteristics of your program. Depends on what you're comfortable with, how you think of the problem, and the type of codebase you're working on. I could see living in the debugger being more useful to me if I'm in some C++ codebase where every line potentially has implicit destructor calls or something.

comment 1y ago · link · parent

That's why you put enough context in each packet that nobody gets confused if the order changes or some get missed.

comment 1y ago · link · parent

I've used systems that did this (some TypeScript TUI library comes to mind) and was similarly confused. I think what actually happened was that the x function/getter/whatever had some 'magic' in it that let it communicate with `Computed` as a side-effect of `Computed` computing the value.

Too magical for me. I'd rather have something like you described where inputs are explicit, so I don't have to guess about whether the magic will work in any given case.

comment 1y ago · link · parent

Back when I was a lad we called that "a computer program"

comment 1y ago · link · parent

I assumed it meant that the emulator is written as a ROM that loads itself.

But that's probably not what it means. Kids throw words around meaning all sorts of strange things these days.

comment 1y ago · link · parent

Why not? Git should handle this just fine. And you can always make details-in-second-parent merge commits or squash them down later, if you don't like the whole history having that level of detail.

comment 1y ago · link · parent

In summary: The more layers of interpretation your `eval` function needs to do (assumption of source language, tokenization/parsing rules, symbol definitions, etc), the less well-defined the semantics are.

So on the less-well-defined end, you have something like JavaScript's `eval` function, in the middle you have lisp macros, which get an AST instead of just source code, and on the actually-pretty-well-defined end, you have a lambda that's already been parsed/compiled and just needs to be evaluated.

comment 1y ago · link · parent

Ostensibly, making French cleats to put on the walls around my house to hang all my computers (and other stuff) on.

In practice, writing journal entries about why I can't seem to get myself to make all these French cleats that I supposedly need.

Also some software stuff.

comment 1y ago · link · parent

The square brackets aren't really analogous to Lisp's parentheses; REBOL / RED use parentheses for the same purpose, if you need them. The square brackets are more like square brackets in Factor or Joy; they are 'quotations' around a list of words (or other syntactic structures; basically they make a list that is not evaluated immediately).

comment 1y ago · link · parent

I wrote a paper on REBOL back in college. It is very interesting, but the syntax is definitely weird. You might think of the function call syntax as being sort of Forth-like, but with the tokens in reverse order. So like a Lisp, but without required parentheses. e.g. in the example

  send friend@rebol.com read http://www.cnn.com
`read` knows that it takes one argument, and `send` knows that it takes two, so this ends up being grouped like

  (send friend@rebol.com (read http://www.cnn.com))
(which I think is valid syntax; that AST node is called a 'paren').

Weirdly, the language also has some infix operators, which seem a bit out-of-place to me. I have no idea how the 'parser'[1] works.

[1] 'parsing' happens so late that it feels funny to call it that. The thing that knows how to treat an array as a representation of an evaluatable expression and evaluate it.

comment 1y ago · link · parent

This is a wacky, seemingly out-of-place philosophical comment, yet I have had similar thoughts, so I give you an irreverent upvote.

comment 1y ago · link · parent

This is something I try to do every day. "What would future me like me to have gotten done right now?"

Future me doesn't really care if I spent 3 hours playing Minecraft, but they would be pleased if that shelf I've been meaning to build for months were finally done.

But also, my brother died recently and left behind a house that was kind of a mess, and that has added "dying me would like my friends/family to be able to easily find the important stuff among all this clutter."

comment 1y ago · link · parent

Agreed. I even voted for the fall to last a bit longer, but instead we got ground.

comment 1y ago · link · parent

The controlled opposition party makes dang sure that the only other option in major elections is "more of the same". (i.e. Democrats generally fail to clean up whatever mess the last Republican administration made, continue funneling money to Israel, yaddah yaddah, and don't to a whole lot to help the working class.)

A lot of people are completely fed up with "more of the same", so they voted for the clown or didn't bother to show up.

Don't blame the voters when they were never given a real choice.

comment 1y ago · link · parent

I'd start by standardizing the interface between plastic storage tubs and their lids.

comment 1y ago · link · parent

  import { SystemDBus } from "npm:@clebert/node-d-bus@1.0.0";
works surprisingly well, in my experience.

comment 1y ago · link · parent

But the numbers next to their names aren't big enough. We're gonna have to gut social services and environmental protections in an attempt to pump those numbers up. Oh and definitely everything we can to cast unions in a bad light. Who needs a union? All they do is eat your hot chip.

comment 1y ago · link · parent

Some music control using Wii balance boards thing: https://gitlab.com/TOGoS/SG-P27

So far this has means orchestrating a set of processes just to talk to bluetoothd, automatically connect to boards, guess which /dev/input/event* device each one is associated with, and start reading those and sending data somewhere over OSC. Every step of the process is about 10 times as difficult as I initially expected it would be, which is why, after months of work, I'm still putzing around with process orchestration instead of actually doing anything with music.

The bit of hair on this yak that I'm currently shaving is building a TUI library for Deno so that I can build a nice dashboard for keeping tabs on the state of all the different pieces. I prototyped a bit of the orchestration process in Node-RED, which was neat, but not exactly what I'm going for. There is a TUI library for Deno already, but it's kind of buggy and non-ergonomic for my brain.

comment 1y ago · link · parent

Don't even need to 'distribute' the wealth[1]. Just burn it. It's the inequality itself that causes problems--out-of-touch billionaires having the power to make the rest of us do their bidding, whether it makes any dang sense or not--not the lack of giant wads of dollar bills in everybody's pockets.

[1] If by 'wealth' we mean numbers in computers. Actual wealth, like healthy land and clean water and manufacturing capacity should be shared by everyone, but currently money is what controls it.

comment 1y ago · link · parent

Every time I hear about D it sounds awesome. I actually used it to prototype an image collage-composing algorithm which I then rewrote in Scala[1], and the D version might have been nicer to write.

The only reason I didn't write more stuff in D was that the stack traces from my programs were pretty much useless. Maybe I was supposed to set a --better-stack-traces flag when I compiled it or something idk.

[1] One of the algorithms used by https://github.com/TOGoS/PicGrid

comment 1y ago · link · parent

They did touch on that.

> You might think that this issue is just about trying to cram everything onto a single line, but frankly, trying to move away from that doesn’t help much. It will still mess up your git diffs and the blame layer.

Diff will still be terrible because adding a step will change the indentation of everything 'before it' (which, somewhat confusingly, are below it syntactically) in the chain.

comment 1y ago · link · parent

Unison of course works this way, as has been mentioned.

I like Deno for similar reason. It's a coarser level of granularity, and not explicitly content-addressed, but you can import specific versions of modules that are ostensibly immutable, and if you want, you could do single-function modules.

I like the idea so much that I'm now kind of put off by any language/runtime that requires users of my app/library to do a separate 'package install' step. Python being the most egregious, but even languages that I am otherwise interested in, like Racket, I avoid because "I want imports to be unambiguous and automatically downloaded."

Having a one-step way to run a program where all dependencies are completely unambiguous might be my #1 requirement for programming languages. I am weird.

One reason not to do things this way is if you want to be able to upgrade some library independently of other components that depend on it, but "that's what dependency injection is for". i.e. have your library take the other library as an argument, with the types/APIs being in a separate one. TypeScript's type system in particular makes this work very easily. I have done this in Deno projects to great effect. From what I've heard from Rich Hickey[1] the pattern should also work well in Clojure

[1] something something union types being superior to what you might call 'sum types'; can't find the link right now. I think this causes some trouble in functional languages where instead of something being A|B it has to be a C, where C = C A | C B. In the former case an A is a valid A|B, but a C A is not an A, so you can't expand the set of values a function takes without breaking the API. Basically what union types require is that every value in the language extends some universal tagged type; if you need to add a tag to your union then it won't work.

comment 1y ago · link · parent

> Application developers can avoid both current warnings and future restrictions by selectively enabling the ability to mutate final fields where essential.

/me raises hand

Maybe if you want to mutate a field, don't mark it `final`?

I know, I know, people like to pretend things are one way and then hand their objects over to some horrid framework that breaks all the rules, because apparently giant web of mutable spaghetti is just fine, not an anti-pattern at all if you let some third-party bull$#!7 ORM/dependency-injection-framework-for-people-who-don't-like-constructors do it.

comment 1y ago · link · parent

I wrote a lot of applets back in the day for little graphics experiments and such, somewhat inspired by Ken Perlin's homepage[1]. I found that it's quite possible to make applets that load fast and run fast if you care about those things while building it and do some profiling. If you pull in hundreds of megabytes of libraries and trigger a GC every second then of course it will be slow.

[1] https://mrl.cs.nyu.edu/~perlin/

comment 1y ago · link · parent

Of course you could also "offset your feet" until they're past the end of the last thing, and then you've counted the number of things. But the offset of the thing itself (as opposed to that of your feet) could be considered zero, assuming the natural position of the thing is for its left edge to be at the left edge of the space.

But maybe its natural position is to be centered at x=0 and it had to be moved by 0.5 for the left edges to line up, in which case see my other comment.

In any case, I think the argument over 0 or 1 or 0.5-based indexing can be resolved just by being clear about what it is you're counting.

comment 1y ago · link · parent

Not sure about old Mac OS, but I think HTML canvas works that way.

comment 1y ago · link · parent

I like this. I feel like "offset" hints at the reason for starting at 0. "How far do you have to offset your feet (from the beginning of whatever space we're talking about) before you're touching the thing in question?" If it's the first thing, you don't have to move at all, so zero offset

comment 1y ago · link · parent

He was right. If the first fencepost is centered at x=0 and the second at x=1, and you want to give the rail in-between some identifier that corresponds to its position (as opposed to giviung it a UUID or calling it "Sam" or something), 0.5 makes perfect sense.

In computer programming we often only need the position of the gap to the left, though, so calling it "the rail that starts at x=0" works. Calling it "the rail that ends at x=1" is alright, I guess, if that's what you really want, but leads to more minus ones when you have to sum collections of things.

12345
12