HNHacker News
TopNewBestAskShowJobs

lilactown

849 karma · joined September 2, 2015

submissionscomments
lilactown··on Crank.js – Write JSX-driven components with functions, promises and generators
I haven't used concurrent mode in anger yet, but I have used frameworks built on top of React that introduce their own async scheduler for rendering - Reagent, re-frame in ClojureScript-land.

You end up with two issues IME with async tasks (rendering being one of them):

- Making everything async - without prioritizations - means that at some point you have simply moved the problem into the scheduler. Just like taking a sequence of sync operations and wrapping them in a promise chain doesn't speed them up, likewise making every render async by itself doesn't speed things up at all (on the contrary it can make things slower).

- Using prioritized async tasks only allows you to prioritize the things which participate. If a component renders, or any other computation occurs, and isn't sent to the scheduler, it can steal work from higher priority things because the scheduler doesn't control it.

This is why IME a la carte async async rendering isn't super useful. It is a lot of mental overhead (and potentially laborious) to manage your application's schedule while also trying to build features. It would be interesting to have tools to tune it when necessary (which I assume React will provide in the form of ways to schedule computations at different priorities), but having it opt-in means that the default case is everything will steal work from the things that you are actually marking as high priority!

lilactown··on Crank.js – Write JSX-driven components with functions, promises and generators
I enjoyed reading this blog post, and the perspective that the author brings. The notion that a cache is a big ask is novel to me, but I think it is a good point that it does complicate things more for simpler cases.

However, I would like to hear the author's thoughts on Concurrent Mode in general, and how Crank.js addresses the same issues. There's no mention here of time slicing, which is what Concurrent Mode really unlocks. IIUC Suspense was discovered, not invented, after implementing React Fiber and exploring the knock-on effects of being able to restart rendering from a place in the component tree.

React's insistence on rendering being "pure" is not dogma; it is an attribute that unlocks the ability to pause and resume rendering at any node in the component tree... like if an important update from a keyboard press comes in that you need to handle right now. This means that when CPU is scarce, jank can be alleviated by prioritizing user input and other high priority updates.

There's a tweet out there by sebmarkbage that gives a slightly cryptic response to using generators, but the gist that I remember is that because generators are mutable, you don't get the properties you need to arbitrarily pause and resume a component just like it was when you paused rendering it.

The author claims that this is just dogma, but I believe (and the React team believes too) that time slicing provides a measurable benefit to the user experience. This point is contentious still; Rich Harris of Svelte fame claims that _doing less work_ is more important than prioritizing it. But the author here doesn't address this at all, instead claiming architectural simplicity is its own goal.

I'm excited to see alternatives to React come out and generate excitement, and I'm very interested to see where Crank.js continues to evolve. My hope is that in 5 years we'll know way more about all of these questions than we do now, and we'll be able to put those into practice in better frameworks, delivering better applications.

lilactown··on Restarts in Common Lisp
AFAICT Algebraic Effects are a way of encoding conditions into a static type system. The idea of signaling a condition and passing a continuation is not the new part (as you've noted), it's the _algebra_ part, where a type system can check at compile time that these conditions that a piece of code calls are implemented by the context it is called in.
lilactown··on Restarts in Common Lisp
what's the difference from what you said (handlers and restarts are functions) vs. a continuation, which could ostensibly just be a function that has closed over the state of the runtime before the condition was triggered?
lilactown··on Multicore OCaml: March 2020 update
ReasonML is just a different syntax that compiles to the OCaml AST format. If you're writing in ReasonML you'll be interacting, reading and fixing code in ReasonML.

There's even a browser extension which converts OCaml syntax to ReasonML and vice versa in docs.

lilactown··on Urbit Is for Communities
Urbits supposed value proposition isn't technical, so I think it's completely valid to analyze its founders political and social philosophy to try and understand its vision and decisions.

The urbit website does very little to explain, on a technical level, how any of it works. It goes to great lengths to explain the supposed impact of its design decisions and how it will make all of our lives better (supposedly).

Another post recently popped up about Urbit last week and I did (against my better judgement) a bit of a dive to try and understand all the lingo. It's a real WTF. The "Hoon" language is completely esoteric, the website a mess, the docs written in this very philosopher-intellectual like way that is completely incomprehensible.

I see that the website has gotten a lift recently and they are clearly trying to make an effort to be more approachable, but its cultural roots are in a lot of problematic stuff and it still does not convince me that it's anything more than crypto-LARPing.

Urbit might be technically interesting, I can't tell, but that's not what this blog post is about. It's not what Urbit is trying to sell to me. And based on the thought leadership, I am not interested in buying.

lilactown··on Defunctionalisation: An underappreciated tool for writing good software
There are, of course, tradeoffs to using defunctionalization (I've also heard this called a "data DSL"). I have seen these tradeoffs often ignored or argued past when discussing various solutions that take advantage of it.

The cons to defunctionalization that I have experienced are things like:

You now not only need to test your application, but also the runtime that turns this data representation into actual work. Bugs can now occur in the runtime, in the reification of the app logic, or in the integration between the two.

If your application is particularly concurrent or lazy, then ensuring that your DSL works well with your main language's concurrency and laziness machinery can get pretty hairy when you start executing your side effects.

It becomes harder to leverage your languages developer tools; breakpoints and debugging often end up in your DSL runtime's code, not your application code, often requiring special-purpose tools to be built to debug your defunctionalized DSL.

Performance can also be a double-edged sword. On the one hand, you can do some very clever things; use tricks like memoization, all the way up to writing a JIT compiler for your defunctionalized DSL to improve performance. However, you're taking on that work due to the fact that your main language's runtime can no longer do that work for you. Often these data DSLs end up allocating a lot of data structures that end up being parsed and thrown away later, and those allocations increase work in cleanup and the parsing itself.

I also heavily question the efficacy of testing these data DSLs. It is objectively easier to test pure functions, but on the other hand, how do you validate that they are correct? Often we don't care about the actual data representation, we care that it does the work it describes; properly testing then essentially becomes a re-implementation of the DSL runtime with mocks / etc.

For a concrete example of all of these tradeoffs, take a look at React in the webdev world. React is unequivocally a good idea, but it has required a massive investment from the React team and the ecosystem to make it correct, make it fast enough, to create developer tools for it, and to figure out how to effectively test applications that use it.

lilactown··on Signal is finally bringing its secure messaging to the masses
I believe the OP was being sarcastic there.
lilactown··on Back pain is a problem which is badly treated
I've dealt with chronic back pain for years, and physical therapy has changed my life. But I had to have a certain period of time with pain free movement before I could progress.

I also had lots of signs and symptoms that things were wrong before it got really, really bad (I herniated a disc). Knowing how to understand when your body is not in alignment / moving right, and how to correct it, is what the GPs advice is really about. A lot of chronic back pain is due to muscular imbalances; too weak, too tight, too loose, not firing right. Exercises and body work can be done to help correct these things, to ease pain and return functionality.

lilactown··on Thinking in React Hooks
Performance, primarily. Hiccup that is generated _at runtime_ is incredibly wasteful; you allocate a bunch of immutable vectors and maps, then parse them into React elements and throw them away, every time your component is rendered.

This is a constant performance tax on your application and makes Reacts tradeoffs re: virtual DOM worse. React Elements are already data (they are POJOs), so you lose nothing in terms of declarative-ness using hiccup vs. functions/macros.

If you're very attracted to hiccup syntax, you can still use hx's hiccup parser with helix (docs incoming) or try out a library I wrote called thump[0], which uses reader tags to parse the hiccup at compile time into React Elements.

0: https://github.com/Lokeh/thump/

lilactown··on Thinking in React Hooks
Classes are not verboten :) I typically create an error boundary that wraps my app/feature/etc. with a fallback component and call it a day.
lilactown··on Thinking in React Hooks
You use the word "simple," but it sounds like you mean something more like "familiar." That's not a knock; familiarity is important when designing an API that thousands of developers are going to use every day.

But as you can see by the blog post, there are tradeoffs between doing something the way people are familiar with, versus a different way that's less familiar, but has different capabilities that might fit the problems better.

Classes map to certain use cases very well; for instance, there's no Hook for "componentDidCatch" or any other error handling.

That being said, you are not losing anything. The tools are simply different (although the old tools are still there, too!).

As the blog post goes into, you can still implement the same _behavior_ as you did with componentDidMount/componentDidUpdate, but with Hooks you can formalize the different patterns you would find when using those methods into a custom hook that you can reuse. This wasn't possible before.

shouldComponentUpdate can be easily replaced with React.memo, a higher-order component that takes a function that compares the previous props to the new props and returns whether they are the same. Wrapping it in React.memo without a custom comparator is the same as PureComponent.

lilactown··on Thinking in React Hooks
The function given to useEffect will be fired after a successful _commit_ (aka React actually manipulates the DOM after a render).

Here's a helpful diagram that shows the difference between render and commit phases in terms of the class lifecycle methods: http://projects.wojtekmaj.pl/react-lifecycle-methods-diagram...

So when a render executes useEffect with a callback (and values in its dependency array has changed), it will schedule the callback to be run once React has committed the DOM changes based on the current render.

lilactown··on Thinking in React Hooks
I think that hooks and Reagent developed somewhat independently; or at least, they are not as related as one might think at first glance.

The primary difference is where the data _flows from_. Like another commenter pointed out, your examples can be done similarly as trivially with Hooks. The difference is that the state is stored in Reagent in a global mutable atom, while the state in React is stored in the React tree, and is tied to the render lifecycle.

This doesn't seem like a huge difference on its face, but in practice it makes for very different experiences navigating a code base.

In Reagent, your data is flowing down via props but also from the side via any number of atoms/subscriptions/etc. In React, you know that your data is always either state local to the component or passed via props.

This isn't even to mention the other various hooks like useEffect, which allows you to coordinate side-effects with changes in data in a composable, locally-scoped way that Reagent does not allow you to do. In order to coordinate side effects, it requires you to keep the description of side effects completely separate from your components, which makes them less composable.

For people who enjoy the way that React Hooks makes you think, and are also interested in ClojureScript (immutable data structures + amazing standard library + hot reloading + macros built into the language), check out https://github.com/Lokeh/hx or its WIP successor, https://github.com/Lokeh/helix (I am the author of these libraries).

lilactown··on Local-first software: you own your data, in spite of the cloud
I recently started using Actual[0], a local-first budgeting app. It's encrypted (soon to be end-to-end), local-first and can be synced across my devices. Would recommend, and I was inspired to use it after following its author, James Long[1] on twitter for awhile.

[0] https://actualbudget.com/

[1]https://twitter.com/jlongster?lang=en

lilactown··on Two Years With Emacs as a CEO and now CTO (2018)
I still prefer Emacs/CIDER to the other Clojure editor plugins, but IntelliJ/Cursive is a close second. Atom/Chlorine and VS Code/Calva are getting better all the time, too.
lilactown··on 'My son spent £3,160 in one game'
One thing that I haven't used on my Switch (no kids), but I understand as a great feature, is that you can add funds available for games as a one-time purchase that can be used across the system.

The actual purchase of system currency can be controlled while allowing the dependent to make their own choices on how to spend it.

lilactown··on Data-Oriented Design (2018)
With things like EAV and Datalog, you still end up coupled to the names and kinds of facts that you store and the relationship between entities in your structure. It turns out that there can be many ways to store facts about an entity, and model the relationships between them, which may be convenient or not depending on the context. But it does help in that it can much more easily evolve with the kinds and shapes of data that you need to store in your app as your app changes and grows.

More abstract constructs like lenses can help with this as well. By building lenses for reading that can transform to a domain context structure from your global program state, you can keep them relatively decoupled and ensure all of the glue lives only in those lenses.

I'm undecided on the utility of leveraging lenses for mutation as well; on the one hand, mutation allows one to operate strictly in the local context, but on the other hand, it requires your lenses to be truly bidirectional (which I think is harder in practice than in theory), and counts on either synchronous sync of local state and global state _OR_ eventual consistency with the rest of the app.

Going a more CQRS-esque way like Redux/re-frame allows you to not rely on the bidirectionality of your lenses and also ensures consistency in that local state is only ever driven by changes to the global state.

lilactown··on Clojure and Deps.edn: A basic guide
I think that while leiningen does a lot of what tools.deps/deps.edn and the CLI tools do, the reverse is not true.

tools.deps/deps.edn is about building a classpath to run a clojure process. The clojure CLI tools has some additional machinery for starting a simple REPL. That's it.

What this allows is a potentially more composable ecosystem, where instead of having every new build tool implement a way of declaring dependencies and building a classpath, they could instead use tools.deps + deps.edn.

It also has a slightly different feature set, allowing local dirs and remote git repos to act as first-class deps.

Lein and boot are incumbent, and have legacy projects to think about, so they can't go about just adopting deps.edn + tools.deps without breaking things. So at the moment, things are a bit fragmented. C'est la vie.

lilactown··on Why Continuations Are Coming to Java
On its face, sounds like Erlang/OTP.
lilactown··on Why Continuations Are Coming to Java
It depends on your perspective.

The OS one has more _requirements_ (the number of "it must do..." is much higher), which constrains it's design space much more. I think you can call that as "having more constraints" because it must meet more needs to be even viable as a solution.

The number of requirements for JVM threads is much lower, thus less constraining, allowing it more freedom to implement solutions that can meet its narrower window of features.

lilactown··on What I Want from a Type System (2016)
I haven't used Haskell, but in OCaml things tend to be organized in modules related to the particular type, which allows you to get autocomplete like:

    List.
        | length
        | hd
        | tl
         ...
lilactown··on Show HN: Easy intro book to Clojure and immutability
I would pay money for that.
lilactown··on YouTube is trying to reward “quality” content
I think the things I've outlined are pretty popular TBH.
lilactown··on YouTube is trying to reward “quality” content
Yeah, those should be prohibited by law. I think that genocide should also be on that list. And youtube can (and IMO should) continue to prevent the rest. Death, gore, genocide, fascism, violence, etc. do not belong in general public discourse. There's always some other website to post snuff porn.

I don't agree with the way that youtube has applied their guidelines for removing content in general, but I do generally believe that they should moderate their content.

lilactown··on YouTube is trying to reward “quality” content
Posting videos of death, gore, kiddie porn, targeted bullying, fascist propaganda, trying to incite genocide, rape and other violence.

The idea that we should allow sites that are marketed to the general public to be unmoderated is completely ridiculous.

lilactown··on A course that has brought women even with men on a spatial cognition test (2016)
That's a really strong claim.
lilactown··on Why I Quit Tech and Became a Therapist
TRP has done a great job of appropriating decent life advice and using it to make their misogynistic message more palatable. They're not the first group, nor the last, to employ this technique.

The ideas can be found in various philosophy and culture including Stoicism and eastern philosophy. "Shit tests," though, that's just the misogyny.

Skip the turd, go read philosophy.

lilactown··on Scheduling in React
Putting everything in global state gets really hard to maintain above a medium-sized app.
lilactown··on Scheduling in React
I found the second example to be way less janky. I want to be able to see what I type as I type it (e.g. for spelling mistakes).

Taking a second to correlate that with results I am willing to accept, but if an app is janky with basic interactions I am leaving.

← PreviousPage 4 of 9Next →