HackerTrans
TopNewTrendsCommentsPastAskShowJobs

ekipan

no profile record

Submissions

Show HN: Code garden deep-dive: my Forth C64 tetromino game

github.com
3 points·by ekipan·3 tháng trước·1 comments

comments

ekipan
·3 tháng trước·discuss
Doc excerpts, as a teaser:

  - SDF JKL layout keeps me on home row, ready to type Forth.
  - 39 columns source text to fit the C64 screen.
  - `0 prof` patches the first instruction to an `rts`,
    disabling the profiler. `1 prof` restores the `eor`.
  - The `dup 0= +` phrase ensures nonzero seed, harmless but
    it's cute and I've grown fond of it.
  - Might be able to spread `land` work across frames but the
    complexity isn't worth it.
  - I choose the extra `rdrop` cognitive load just for its
    aesthetic.
  - <!-- It's better left unsaid. -->
I would be tickled if this was the thing to bring at least a few people from vaguely Forth-curious to writing something substantial. Tell me what delights or confuses you. What could be better, what needs examples.
ekipan
·4 tháng trước·discuss
> - Function composition was being used as a binary operator between two functions. You just replaced the infix notation with prefix notation.

That's incorrect. Here's the definition of function compose:

  (f . g) x = f (g x)
So in `foldr (+) 0 . map (const 1)`, the author gives `f = foldr (+) 0` and `g = map (const 1)` but doesn't supply `x`. That's a partial application. Similarly for const:

  const x y = x
Even if I concede length and (+), these two are partially applied.

> you would only have to use it in partial applications of that function.

So why not const and (.)? If they're allowed to curry, why not foldr and map?
ekipan
·4 tháng trước·discuss
From the article:

    length = foldr (+) 0 . map (const 1)
    length2d = foldr (+) 0 . map length

    -- and the proposed syntax the author calls more readable:
    length = foldr((+), 0, $) . map(const(1), $)
    length2d = foldr((+), 0, $) . map(length, $)
But I don't understand. Why does the author think it's confusing to partially apply foldr and map but not (+), (.), const, and length? Applied consistently:

    length = (.)(foldr((+)($, $), 0, $), map(const(1, $), $), $)
    length2d = (.)(foldr((+)($, $), 0, $), map(length($), $), $)
And clearly no-one thinks this strawman is clearer. Further, it's impossible to make it 100% consistent: any function you write with polymorphic result could instantiate as a function needing more arguments. I think currying is the better default.
ekipan
·5 tháng trước·discuss
Yeah, this. Plus a mistake from the article:

  $ echo '*\n!.gitignore' > build/.gitignore
The \n won't be interpreted specially by echo unless it gets the -e option.

Personally if I need a build directory I just have it mkdir itself in my Makefile and rm -rf it in `make clean`. With the article's scheme this would cause `git status` noise that a `/build/` line in a root .gitignore wouldn't. I'm not really sure there's a good tradeoff there.
ekipan
·5 tháng trước·discuss
"Agreement" of time is probably nonsense, yeah. I realized after posting so I edited in the parenthetical, but as [3] notes, locality probably makes this less of a real issue.

Apparently with the birthday paradox 32 bit random IDs only allow some tens of thousands per second before collision chance passes 50%. Maybe that's acceptable?

[3]: https://news.ycombinator.com/item?id=47065241
ekipan
·5 tháng trước·discuss
I forget the context but the other day I also learned about Snowflake IDs [1] that are apparently used by Twitter, Discord, Instagram, and Mastodon.

Timestamp + random seems like it could be a good tradeoff to reduce the ID sizes and still get reasonable characteristics, I'm surprised the article didn't explore there (but then again "timestamps" are a lot more nebulous at universal scale I suppose). Just spitballing here but I wonder if it would be worthwhile to reclaim ten bits of the Snowflake timestamp and use the low 32 bits for a random number. Four billion IDs for each second.

There's a Tom Scott video [2] that describes Youtube video IDs as 11-digit base-64 random numbers, but I don't see any official documentation about that. At the end he says how many IDs are available but I don't think he considers collisions via the birthday paradox.

[1]: https://en.wikipedia.org/wiki/Snowflake_ID

[2]: https://youtu.be/gocwRvLhDf8
ekipan
·5 tháng trước·discuss
I think everyone agrees with the sentiment but practically speaking that ship sailed decades ago. Browsing the web without uBlock or similar is ill-advised.

Morbidly curious, I turned off my blockers and it's not as bad as I expected honestly. I can still read the article copy.
ekipan
·5 tháng trước·discuss
> And they keep forgetting the purpose of software is to serve users, not developers.

I don't have any horse in the game, but I do think Zig is interesting. This remark is funny to me because it's literally one of the tenets the Zig devs make decisions by!

https://ziglang.org/documentation/master/#Zen

> * Together we serve the users.
ekipan
·5 tháng trước·discuss
Oh, it's a list you can add to your uBO. I thought it was a descriptive headline: "(The) uBlock filter list (is going) to hide ..."

I only watch Youtube via browser now for both adblocking and my own custom userscripts, both on my laptop and my phone. A couple creators I watch mostly do shorts so I tolerate them but I wrote a userscript that changes all /shorts/<videoid> URLs into normal /watch?v=<videoid> to lessen the temptation to doomscroll.
ekipan
·5 tháng trước·discuss
It seems to me that AI is mostly optimized for tricking suits into thinking they don't need people to do actual work. If I hear "you're absolutely right!" one more time my eyes might roll all the way back into my head.

Still, even though they suck at specific artifacts or copy, I've had success asking an LLM to poke for holes in my documentation. Things that need concrete examples, knowledge assumptions I didn't realize I was making, that sort of thing.

Sweet Gameboy shader!
ekipan
·5 tháng trước·discuss
I actually have the below clashes function in my bashrc to detect overloaded names, and a few compgen aliases for sorted formatted command lists. Clashes takes a few seconds to chew through the 3000ish commands on my Steam Deck.

I also discovered the comma thing myself, and use it for `xdg-open <web-search-url>` aliases, i.e. `,aw xdg` searches archwiki for "xdg", since the SteamOS on this thing doesn't have manpages.

  alias words='iftty xargs'   # join by spaces
  alias c='compgen -c | sort -u | words' # eg: c | grep ^k | chop
  # ... a for aliases, f for functions etc ...
  alias man='g !archman'      # https://man.archlinux.org
  alias ,aw='g !aw'           # https://wiki.archlinux.org
  alias ,mdn='g !mdn'         # https://developer.mozilla.org
  alias ,nix='g !nixpkgs'     # https://search.nixos.org
  # ... a dozen others ...

  g() { local IFS=+; xdg-open "https://ddg.gg/?q=$*"; }
  iftty() { if [ -t 1 ]; then "$@"; else cat; fi; }

  chop() { # [TABS] [STARTCOL] [CUTOPTS..] # eg. ls ~/.co* | chop
    set -- "${1:-2}" "${2:-1}" "${@:3}"
    cut -c "$2"-$(($2+8*$1-2)) "${@:3}" | column #| less
  }

  clashes() { # [CMDS..] # print overloads eg: clashes $(c)
    (($#)) || set -- $(compgen -A alias -A function)
    local ty cmd; for cmd; do ty=($(type -at "$cmd"))
    ((${#ty[@]}>1)) && echo -n "$cmd "; done; echo
  }
ekipan
·6 tháng trước·discuss
(Edit: in the old post title:) "everything is a value" is not very informative. That's true of most languages nowadays. Maybe "exclusively call-by-value" or "without reference types."

I've only read the first couple paragraphs so far but the idea reminds me of a shareware language I tinkered with years ago in my youth, though I never wrote anything of substance: Euphoria (though nowadays it looks like there's an OpenEuphoria). It had only two fundamental types. (1) The atom: a possibly floating point number, and (2) the sequence: a list of zero or more atoms and sequences. Strings in particular are just sequences of codepoint atoms.

It had a notion of "type"s which were functions that returned a boolean 1 only if given a valid value for the type being defined. I presume it used byte packing and copy-on-write or whatever for its speed boasts.

https://openeuphoria.org/ - https://rapideuphoria.com/
ekipan
·6 tháng trước·discuss
Strange. Middle-clicking the link opens a HackerNews frontpage, but copypasting into a new tab shows the article. Presumably the server shoos away referer links? To reduce load maybe somehow? Or maybe something's weird in my own configuration idk.
ekipan
·6 tháng trước·discuss
Haskell, then.

    f x = let y = x + 1 in y + 1
Same deal. In (f 3), y = 4, in (f 7), y = 8. y varies but cannot mutate. Should be a true enough Scottsman.
ekipan
·6 tháng trước·discuss
Mutability is distinct from variability. In Javascript only because it's a pretty widely known syntax:

    const f = (x) => {
      const y = x + 1;
      return y + 1;
    }
y is an immutable variable. In f(3), y is 4, and in f(7), y is 8.

I've only glanced at this Zen-C thing but I presume it's the same story.
ekipan
·6 tháng trước·discuss
That makes me sad. I also love Posy's content, I'm using his cursors right now, and this new knowledge that there is some of it I cannot see gives me real consumerist FOMO anxiety. A little digging and I couldn't find anything. I don't suppose you remember any keywords?
ekipan
·6 tháng trước·discuss
Shoutouts to SimpleFlips: https://www.wario.style/s/BRwFnLDe

TTYD File Select: https://www.wario.style/s/paznaBKf

Chemical Plant Zone: https://www.wario.style/s/L7kD5jJP

Robo's Theme: https://www.wario.style/s/MzeU9PVc

Everyone's beloved Rick: https://www.wario.style/s/byMyoc3Z

Better MIDI search: <https://bitmidi.com/> I guess you could copypaste the 12345.mid id number into the Wario Synth URL, but it's a bit tedious.
ekipan
·6 tháng trước·discuss
Wanted features: (1) a way to preview the original MIDI again from a share link like this so I could still compare. Searching "ABBA Gimme Gimme Gimme" found one with the title "ABBA Gimme Gimme Gimme L" so I can't be 100% sure it's the same. And (2) a seekbar for the preview as well.

Kinda weird that search results seem hard-capped at 5. I guess it keeps things simple.
ekipan
·6 tháng trước·discuss
Cool enough I suppose, but the framing had me expecting the more farty twisted squarenoise instruments like in Wario Lands 1-3, and less smooth sines and squares. I tried out Kimi No Shiranai Monogatari and Daft Punk's Aerodynamic.

https://www.wario.style/s/yWHphmhO

https://www.wario.style/s/BSN15NEs

Maybe you could list examples for midis you thought sounded cool next time you share this, or in a comment.

Edit: though I guess a huge part of Wario flavor is the dissonant intervals in the music, as much as the farty instrumentation.
ekipan
·6 tháng trước·discuss
A fine sentiment, and would probably even be somewhat enforceable, as most AI slop is pretty obvious, but I suspect a lot isn't. You'd have to decide where to draw the line. How much LLM assistance transitions a work from HackerNews into SlopperNews? And how do you tell if the author (or "author") isn't forthcoming?

I'm pretty sure you aren't terribly serious, but I found it interesting enough to give it a little thought.

Edit: I realize now that my assertion "most AI slop is pretty obvious" could be hubris. I'm not actually very confident any more.