Hacker Newsnew | past | comments | ask | show | jobs | submit | hungryhobbit's commentslogin

I think anyone who uses Claude knows that it works smarter when you have it make a plan first, and ask it to research the existing code as much as possible first ... so the results in this article doesn't surprise me at all.

However, I'd be curious to hear back from others who have tried adding the shell script (at the end of the article) to their flow: does it (really) improve Claude?


Javascript and classes go together like toothpaste and orange juice. All good JS programmers I know essentially pretend that classes don't exist in the language (or if they use them, they only do so rarely, for very niche cases).

JS does not have classical OOP built in! It has Brandon Eich's prototypal inheritance system (which has some key differences), along with a 2015 addition to the language to pretend it has OOP (but really that's just lipstick on the underlying prototypal pig).

If you use classes in JS, you're bound to be disappointed at some point when they don't behave like classical OOP. Most devs accept that and use more functional approaches (like factory functions) instead of OOP.


Counterpoint: classes are a great way to bundle state and logic - which is exactly what UI components are - and components models should use classes more, not less.

React's "functional" components are simply poor approximations of classes. Instead of easy to read and reason about class fields, you put state in useState() function classes that are effectively named by their appearance order in source and who's current state you can't introspect with dev tools!

The component function mixes one-time setup (which should be a class constructor) with repeated render calls (which should be a method), so those of course have to be separated by putting the one-time work inside of a closure inside of the repeated should-have-been-a-callback function. Event listeners and other callbacks are another huge mess. Don't forget useMemo() or useCallback() (but which?).

It's actually quite mad.

And the differences between classical and prototypal inheritance basically don't even pop up under normal class usage in JS: just use class fields, don't mess with the prototype chain, and don't dynamically add or delete properties - all things that are how classical inheritance works - and things just work like you expect.


They're modeling reactivity, not classes. It's a well established pattern in functional programming

The one time setup mixed with repeated render calls is odd, but it's a design decision they made. It reduces boiler plate, though I don't necessarily agree with it because it is a leaky abstraction


Reactivity and functional programming are orthogonal though.

And in most functional systems the one-time setup function would return the render function so the render function can close over state.

Which is pretty much what a class with fields, a constructor, and a render method give you.


I have noticed that inheritance is largely ignored by experienced developers but it's a hard argument to make that "all good JS programmers do this".

Classes are invaluable and are an extremely efficient and ergonomic way to manage state in GUI applications.

That said, avoiding classes was published in some blog post at some point and the JS hype machine went crazy with FP. As a consequence, I have yet to observe a maintainable React codebase. Good looking and performant React applications are even fewer and farther between.

Personally, writing idiomatic React has me focus too much on render cycles that I think less about how the application looks & feels. Appropriate abstractions become more difficult to conceptualize and any non-trivial application ends up a 5mb bundle with no multi-threading or optimizations. This is also what I have observed "the best JS devs" do in the wild.


Inheritance is used here:

https://github.com/thalesfp/snapstate/blob/ba8a8d7ce25d6a4ef...

I'm not sure if it would support inheriting from a custom store very well. It might get tricky with the templating. But the author of this seems to have done a good job of not ignoring inheritance.


Personally this library isn't to my taste - but I successfully use classes (without inheritance) along with reactivity primitives to create beautiful, tiny and high performance React applications

Encapsulation, inheritance and polymorphism all work fine with JavaScript classes. OOP works just fine.

What doesn't work in JavaScript is functional programming.


I don’t see how? You can do all sorts of FP in js and it even has some of it in its built in APIs. .then comes from FP

Yes, but promises are (unfortunately) _not_ monads!

https://rybicki.io/blog/2023/12/23/promises-arent-monads.htm...


You are right, there are some FP features in JavaScript. But the way it is used in the predominant UI framework (namely React) is definitely breaks FP, see https://mckoder.medium.com/why-react-is-not-functional-b1ed1...

JS is primarily a functional language, it is built around functions as first class objects and closures.

The issue is the bar has been raised for what people call "functional" now. Everyone is picky "OMG not pure so it isn't really functional!!"

Yeesh.


> Javascript and classes go together like toothpaste and orange juice.

Even HN has been taken over by shills from Big Mint.


I think the biggest issue with classes is subclassing, it looks like a good feature to have, but ends up being a problem.

If one avoids subclassing, I think classes can be quite useful as a tool to organize code and to "name" structures. In terms of performance, they offer some good optimizations (hidden class, optimized instantiation), not to mention using the memory profiler when all your objects are just instances of "Object" can be a huge pain.


For clarity, what do you call "classical OOP"?

(disclaimer: FP all the way, regardless)


Essentially `new Foo()`, where `Foo` can be a subclass of `Bar` that inherits properties in the same way we all learned in our Java (or whatever actual OOP) language.

JavaScript gives you a class syntax that lets you make classes and extend them from each other, and for the most part they will work the same way as a class from a language like Java ... but some things won't.

You can either become an expert on prototype chains, and how JS actually implements OOP (differently from Java) ... or you can just write factory functions instead of classes.


Can you give examples of how they are different? I've only done OOP in JS so I'm not aware of what I'm missing or what's supposed to be different.

Don’t most OO languages have similar differences? My understanding is that even Java is quite different from, say, Smalltalk (which arguably is “more OG”).

Potato potato. Js classes are just closure sugar. So what?

Syntax makes sense and improves readability in business logic. Readability is good


I went through the code, and it is roughly equivalent to doing it without classes. The nesting level in the example isn't deep - everything seems to be beneath a SnapStore or a SnapFormStore, without inheriting from user defined classes. I think the use of classes is fine, and the way that it's introduced in the blog post is good, it says "plain TypeScript classes". It is used as a means for ergonomically writing and understanding the code more than it is for setting up invariants or complex polymorphism.

I mean, kinda? It's not like Zuck is selling his stock tomorrow, so daily fluctuations in stock price don't really affect him.

He can borrow against that, so it actually does matter.

Someday our robot overlords will be intelligent enough to ... optimize images!

(But today is not that day.)


The proper optimization in this case is to not use images at all.

This is addressed at the end of the article:

  The catch

  You're relying on garbage collection, which is nondeterministic. You don't get to know when the suspended function is collected. For our use case, that's fine. We only need to know that it will be collected, and modern engines are reliable about that.

  The real footgun is reference chains. If anything holds a reference to the hanging promise or the suspended function's closure, the garbage collector can't touch it. The pattern only works when you intentionally sever all references.

That should honestly be much higher up and much more clearly spelled out.

Asshole. The word you're looking for is asshole.

I once knew a guy who was disabled and walked on crutches. Jobs got mad at him for being late to a meeting, and the guy replied "well someone parked in the handicapped parking spot, and it took me awhile to walk from a normal parking spot.

No joke, Jobs looks him (a disabled person) directly in the eye, and says "oh, that was me; I think the country built an excess of disabled parking spaces after WW2." To the disabled guy!!!


insane story!

Wow, that's the rare kind of thing where I might consider quitting on the spot.

It's the golden rule of news article headlines: if the headline is a question, the answer to it is always a negative.


Surprise surprise: the arrogant selfish child doesn't have empathy for anyone else.

If four thousand kids were all laughing at a rumor that you had a small dick, and every girl you were interested in laughed you out the door for the rest of your college career, would you really be like "it's ok, 4k people are having fun"?

I guarantee OP would be the guy calling the site operator and threatening to jump him.


i mean i'd just prove that rumor wrong by uploading a photo

Given his background, you'd think he'd know that he should provide some evidence for his position (instead of making this completely unsupported rant).

I think you're interpreting the structure and goal of "Bram's Thoughts" wrong. It's a guy's blog, not a thesis defense.

It's a blog post, not an academic paper. Do you cite every source when you're conversing with colleagues?

I wasn't too upset with Bram's article, but I do think people should be citing specific claims, even in blog posts.

If you make an assertion in a blog post, I have no idea if you got the information from a respected scientific journal, or Reddit, or InfoWars, or the writing of a bathroom stall. It's hard to know if the assertion is grounded in reality or just something you made up.

The response I get to this is universally "LOL just look it up yourself man!", but that feels like a cop out. When I write blog posts, I put inline links all over the place to try and justify my assertions to show where I'm getting this information. If I sourced some bad information from a bad source, it's clear to know where I got it from and you can either notify me or disregard the assertion.


>> and those tasks were never just tasks. They were the mechanism that built judgment, intuition, and the ability to supervise the systems we now delegate to AI. >Bullshit. The busywork wasn't being done by low level engineers to train them up, they were doing it because it needed doing, it was undesirable, and they were lowest on the totem pole.

Why not both? It was work that needed doing AND it taught people to be better engineers.


> it taught people to be better engineers.

It generally does not.

And if it does, they can still do those tasks as exercises.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: