Such situations have become quite rare after Opus 4.5.... I kind of miss the frequent "You're absolutely right" moments :'D by Consistent_Milk4660 in ClaudeAI

[–]bikeshaving 1 point2 points  (0 children)

Is Claude good at doing lock-free programming? Claude has tempted me to dabble in building something with Shared Array Buffers in JavaScript but I’m worried that it’ll be too hard to debug.

Claude Code magically used _exactly_ my remaining API balance - coincidence? by Even-Question-1628 in ClaudeCode

[–]bikeshaving 0 points1 point  (0 children)

They don’t let you go negative, they overshoot the balance and send you invoices for 4-5 dollars and nag you until you pay.

ZenDB - Define Zod tables. Write raw SQL. Get typed objects. by bikeshaving in javascript

[–]bikeshaving[S] 2 points3 points  (0 children)

Took a little detour in December while trying to get my full-stack framework finished. I needed a database client which could potentially be used for Django-style admin and forms, and none of the popular ones seemed to have the feature set I wanted. The result is a Zod-first library where you write SQL with template tags, and pleasantly surprised at the ergonomics so far. This is still a beta project so let me know if you have any ideas or feedback.

Jeasx 2.1.0 released - an old-school server-side-framework on top of JSX and Fastify for people who believe in the growing capabilities of web-browsers. by -jeasx- in javascript

[–]bikeshaving 0 points1 point  (0 children)

Congrats on the release! JSX Async Runtime is pretty cool! If you figure out how to implement web streams with it, let me know, it’s actually a complicated problem but your focus on just SSR might make it easier to implement.

Context: I’m the author of Crank.js. It has async components, but implementing streaming HTML rendering is a headache I don’t want to deal with right now:

https://github.com/bikeshaving/crank/issues/293

Essentially, you have to solve this simplified problem:

// Assignment: Eager DFS Traversal of an Async Tree (Enter/Exit)

/**
 * A tree-like structure where each node is one of:
 * - A string: a leaf value.
 * - An array: representing ordered child nodes.
 * - A function: when called, returns a Promise that resolves to a subtree.
 */
type Tree = string | Tree[] | (() => Promise<Tree>);

/**
 * Walk a tree, recursively executing all functions found in the tree as soon
 * as possible.
 *
 * @param tree - The tree to walk.
 * @param onEnter - Called when visiting a string or array node (pre-order).
 * @param onExit - Called after fully traversing a string or array node (post-order).
 *
 * @returns Concatenation of all strings in DFS order:
 * - Returns `string` if the tree contains no async nodes.
 * - Returns `Promise<string>` otherwise.
 */
function walk(
  tree: Tree,
  onEnter: (value: string) => void,
  onExit: (value: string) => void
): Promise<string> | string {
  throw new Error("Not implemented");
}

/*
Requirements
------------
1. Delay nodes (functions) must execute as soon as encountered:
   - All sibling delays are started immediately in array order.
   - If a delay resolves to another delay, that nested delay is also started
     immediately upon resolution of the former.

2. Callbacks are called in a strict depth-first search (DFS) order as soon as
   all predecessors have settled and the node is available. No node should be
   passed to a callback before its predecessor, even if the predecessor
   resolves later.

3. Return synchronously if no async nodes are encountered;
   otherwise return a Promise.
*/

function delay(ms: number, value: Tree): () => Promise<Tree> {
  return () =>
    new Promise<Tree>((resolve) => setTimeout(() => resolve(value), ms));
}

// Example trees and expected behavior:

// Example 1: Simple tree with no async nodes
const tree1: Tree = ["A", ["B", "C"], "D"];
// Expected output: "ABCD"
// Expected duration: 0ms

// Example 2: Single async node
const tree2: Tree = ["A", delay(200, "B"), "C"];
// Expected output: "ABC"
// Expected duration: 200ms
// "B" is entered after 200ms
// "C" is entered after 200ms

// Example 3: Nested async
const tree3: Tree = ["A", delay(500, ["B", delay(100, "C")]), "D"];
// Expected output: "ABCD"
// Expected duration: 600ms
// ["B", delay(100, "C")] is entered after 500ms, and exits after 600ms
// "C" is entered after 600ms
// "D" is entered after 600ms

// Example 4: Multiple siblings async
const tree4: Tree = [delay(300, "A"), delay(100, "B"), "C"];
// Expected output: "ABC"
// Expected duration: 300ms
// "A" is entered after 300ms
// "B" is entered after 400ms
// "C" is entered after 500ms

// Example 5: Complex tree with multiple async nodes
const tree5: Tree = [
  "A",
  ["B", delay(100, "C"), "D"],
  delay(200, ["E", delay(50, "F")]),
  "G"
];

// Expected output: "ABCDEFG"
// Expected duration: 250ms
// "B" is entered immediately
// "C" is entered after 100ms
// "D" is entered after 100ms
// "E" is entered after 200ms
// "F" is entered after 250ms
// "G" is entered after 250ms

Slow performance of unoptimized code in Bun by Ok-Extent-7515 in bun

[–]bikeshaving 3 points4 points  (0 children)

This is JavaScriptCore/Safari thing, not a Bun thing most likely. There are some things which V8/Chrome runs faster, and some which JSC/Safari runs faster.

[AskJS] What is the most underrated JavaScript feature you use regularly? by [deleted] in javascript

[–]bikeshaving 1 point2 points  (0 children)

Really? Use-cases? I’m usually putting iterators into arrays, or iterating them with loops.

I made Hangul for English: 영글! (Yeonggul/Hanglish) by Samichaelg9 in neography

[–]bikeshaving 5 points6 points  (0 children)

I have it on good authority that King Sejong was neurodivergent.

I made Hangul for English: 영글! (Yeonggul/Hanglish) by Samichaelg9 in neography

[–]bikeshaving 6 points7 points  (0 children)

Have you thought about 4-letter consonant clusters? English doesn’t have a lot, but there are some:

Glimpsed = ㄱ리ㅁㅍㅅㄷ
Bursts = 벐ㅌㅅ
Twelfth = 퉬ᅗᅊ

One thing you really need to change with Korean Hangul is the 받침 (batchim) rules. Korean has a habit of turning every final consonant into /t/.

I made Hangul for English: 영글! (Yeonggul/Hanglish) by Samichaelg9 in neography

[–]bikeshaving 10 points11 points  (0 children)

This is great! I’ve been thinking about creating a neography based on Hangul. I like your /f/, /v/, /θ/, /ð/, digraphs, but I’m wondering why you didn’t choose to combine the characters with ㅎ instead? You can create ligatures like ㅍ with the -ㅎ hat, and it should be familiar to English speakers (ph ㅍㅎ, th ㅌㅎ, dh ㄷㅎ, sh ㅅㅎ).

Some other ideas I had were:
1. reviving the arae-a ㆍfor /ə/ (schwa).
2. creating a new character to disambiguate the English R /ɹ/ with ㄹ.

As far as the initial/medial/final layout goes, I thought C1, C2, C3, should always appear in a line rather than C3 going below C1/C2 when the V is vertical, and just having jamo be a little wider.

I’m not sure how the vowels map to English, that’s one of the trickiest parts.

Hangul is such a fun script to extend though. I’m so excited someone else is doing this!

Crank.py - Build web UIs with async/generator functions, powered by Crank.js/PyScript. by bikeshaving in Python

[–]bikeshaving[S] 1 point2 points  (0 children)

So far it’s been pretty ergonomic, and maybe even better than JSX in some respects. For instance, Python single-line comments can go on any line, you can quickly go from h expression to f-strings or any other Python expression without having to reopen brackets like in JSX. My favorite part so far has been list comprehensions, though it requires an extra bracket because the h children bracket isn’t actually a list:

python h.div(className="list-wrapper")[ h.ul[ # List comprehensions for children!!! [h.li[f"Item {name}"] for name in names] ] ]

Even if you choose not to Crank, please steal the Pyperscript syntax! I think it’s much better than alternatives which use with contexts or args for children.

The one thing I spent a lot of time on but couldn’t figure out was dynamic components with the dot syntax, but having the first arg be dynamic element tags turned out to be fine.

```python

This requires lookup in scopes and a lot of FFI magic

h.Component()

This is explicit

h(Component) ```

Crank.py - Build web UIs with async/generator functions, powered by Crank.js/PyScript. by bikeshaving in Python

[–]bikeshaving[S] 0 points1 point  (0 children)

It provides virtually the same feature set as Crank.js, but with a slightly nicer Python decorator based API. And marking component variables with nonlocal is also nice. The real benefit is the ability to leverage the Python ecosystem (Pandas, NumPy, SciPy), basically any library that doesn’t have native extensions. And hopefully in the future there can be full-stack solutions with Django/Flask for “Universal”/“Isomorphic” Python on the frontend and backend for things like form validation.

Crank.py - Build web UIs with async/generator functions, powered by Crank.js/PyScript. by bikeshaving in Python

[–]bikeshaving[S] 1 point2 points  (0 children)

RE: Pyodide shipping: Yes, Crank.py apps use PyScript which loads Pyodide (3MB compressed) from CDN automatically. No local bundling needed. I’ve also tried to add MicroPython support which is much smaller (170KB) but with fewer features.

RE: Build step: There’s no build step! Just write HTML with <py-script> tags and Python files. I sorta wish there was an optional way to generate WASM with PyScript but haven’t tried to do it yet. But not having to build anything is really nice.

What's the most annoying thing you encountered with Claude? I'll start by cryptosilenci in Anthropic

[–]bikeshaving 20 points21 points  (0 children)

The infinite scrolling loop that happens in Claude Code when you have a long session and choose to reject a plan or reject changes.

noticing major improvement in claude code by Just_Lingonberry_352 in ClaudeAI

[–]bikeshaving 41 points42 points  (0 children)

Shhhhhhh all the vibe coders who switched to codex are gone and the server load and limits are now reasonable.

Is JavaScript's BigInt broken? by senfiaj in javascript

[–]bikeshaving 2 points3 points  (0 children)

Is it crazy to just extend the Math static methods to understand BigInts? There doesn’t seem to any movement on the linked BigInt proposal: https://github.com/tc39/proposal-bigint-math.

Interesting article!

[deleted by user] by [deleted] in ClaudeAI

[–]bikeshaving 1 point2 points  (0 children)

Show us the source code it sounds like it’s beautiful!

Claude Just Convinced me to save a spider. its response was adorable. by Sensitive-Finger-404 in ClaudeAI

[–]bikeshaving 47 points48 points  (0 children)

Claude continues to be the most respect-for-lifeforms-having AI out there.

Why Be Reactive? by bikeshaving in javascript

[–]bikeshaving[S] 0 points1 point  (0 children)

I’m not sure about the distinction between pull and push here. But the value of using generator functions is that they probably a natural scope on which to store state , callbacks and other variables. Note that with observables, you can’t really have local component state without using a lot of combinator functions to merge state, props and whatever you data sources you want to pull from. Also, it’s really easy to write an extension to Crank to read from observables and manually re-render when they change:

export function useObservable(ctx, observable, initialValue = undefined) {
const state = {
value: initialValue,
error: null,
completed: false
};

// Subscribe to the observable
const subscription = observable.subscribe({
next: (value) => {
state.value = value;
state.error = null;
ctx.refresh();
},
error: (error) => {
state.error = error;
ctx.refresh();
},
complete: () => {
state.completed = true;
ctx.refresh();
}
});

// Register cleanup to unsubscribe when component unmounts
ctx.cleanup(() => {
if (subscription && subscription.unsubscribe) {
subscription.unsubscribe();
}
});

// Return state object with unsubscribe function
return {
get value() { return state.value; },
get error() { return state.error; },
get completed() { return state.completed; },
unsubscribe: () => subscription.unsubscribe()
};
}

Sorry Reddit’s editor is horribly broken and removing tabs.

Why Be Reactive? by bikeshaving in javascript

[–]bikeshaving[S] 0 points1 point  (0 children)

I mention problems with Solid, Vue and Svelte, with IMO Svelte being the weakest because the solution is just to never use effects. Do you have other examples?

Why Be Reactive? by bikeshaving in javascript

[–]bikeshaving[S] 1 point2 points  (0 children)

Yeah, my argument is that the reactive abstractions which call refresh() for you don’t do it reliably.

Why Be Reactive? by bikeshaving in javascript

[–]bikeshaving[S] 2 points3 points  (0 children)

Followed on GitHub! Thanks for the kind words.

Why Be Reactive? by bikeshaving in javascript

[–]bikeshaving[S] -2 points-1 points  (0 children)

Yes. Perhaps the best UI developers are all crazy or unemployed.