Every Monday, @andysmanclubuk meet in the Shrimpers Bar at Roots Hall at 7pm, offering free peer-to-peer support groups.
If you're struggling, go along and get whatever's weighing you down off your chest.
Continuing my adventure of using coding assistants and LLMs to get the Slate.js react editor component working.
I'm going to cross over 4+ hours on what at times have felt like a bad side-quest — but as I'm getting closer to getting it to work, I'm super-excited at how much this can potentially unlock for me over the standard HTML textarea edit box.
Here are some important lessons learned for me...
1. Without doubt, LLMs are capable of amazing things. But to paraphrase @simonw and @Steve_Yegge: LLMs are also like summer interns with infinite energy, infinite self-confidence, infinitely quick to jump to conclusions — and non-novices will also observe LLMs can quickly go down crazy rabbit holes, digging deeper and deeper, and quite capable of taking gullible domain-newbies along with them.
Example: I probably spent 2+ hours asking Claude 3.5 Sonnet to fix an issue I was having, where if I "selected all text" and then replaced the text, the component would barf into the console messages like:
"Uncaught Error: Cannot resolve a Slate point from DOM point: [object Text],3"
Asking it to help me fix my code, I heaped scores upon scores of code, creating .onChange handlers, creating .onSelect handlers (which actually aren't even a thing!!! totally hallucinated!), sprinkling .preventDefault()s here and there, etc...
After giving up one evening, I started over the following morning, and tried to replicate one of the simple sample apps...
...and started reading the documentation.
What I learned twice (the hard way) in this mini-quest is how important it is to have a clear mental model of how things work. In this case, React, ClojureScript/JS interop, and how the Slate.js component actually works.
And here LLMs became so helpful — instead of LLMs acting as the infinitely high-energy summer intern to delegate things to, LLMs become the infinitely patient explainer.
Here are simplified versions of the (sometimes embarrassingly fundamental and simple) questions I asked while trying to get hovering toolbars to work.
1. What does isCollapsed mean in Slate.js? (answer: when no selection has been made.)
2. Why do I get selection errors when bolding text in renderLeaf? (because I was stuffing DOM elements that didn't mirror the SlateJS state)
3. How does the sample app Leaf component code reconcile with your guidance to wrap everything in a span? It doesn't seem to.
4. Can you rewrite render-leaf in ClojureScript to follow consistent wrapping?
5. Why do I get an error using #js for property access in ClojureScript? (rabbit hole)
6. How can I fix a type inference error when accessing properties on a JavaScript object in ClojureScript? (rabbit hole)
7. What does . and .- actually do? (it is JavaScript object property access — and the better way to do it is "aget" (!!!))
On how to get buttons to render alongside each paragraph:
1. How can I add a button next to each paragraph in Slate.js without interfering with selection? (by some CSS witchcraft)
2. Can you confirm that option #1 will interfere with selection in Slate.js? (yes, I actually learned something! I caught this — it's option #1 actually violated the rule of the DOM mirroring the SlateJS state!)
3. Can you show sample code for option #2? (the right way to do it.)
4. How would I add a floating toolbar in ProseMirror similar to Slate.js? (dangerous but short sidequest: exploring switching to ProseMirror...)
On trying to understand how to read ES6 JavaScript syntax (I never really needed to read the new lambda function form: () => { ... })
1.What are React hooks? Why do they exist, and how do they work? How do they affect ClojureScript? (simple way to store state, and retrieve state, and have it trigger DOM updates)
2.Explain this ES6 useEffect syntax. (I get it now. ES6 also has some nice restructuring syntax — and JSX does seem quite nice now. I appreciate its conciseness.)
https://t.co/KANSCa1gs8 the equivalent useEffect code in ClojureScript. (Not so bad!)
More learnings and ponderings...
- LLMs can be great at coming up with incredible solutions — but when you ask for big solutions with a shaky grasp of the fundamentals, great peril and hours of frustration potentially await.
- when embarking on tasks where you don't have a grasp of the fundamentals, LLMs are great at explaining things... if it's something important and potentially useful in the long-term, it's probably worth learning and understanding.
(OTOH, there are things I still have no interest in learning: complex ffmpeg filters, understanding every one of the vast nooks and crannies of JavaScript dialects, etc.)
- the important of incremental development — turning the "draw me an owl in one turn" to "let's break up drawing the owl into ten steps, and let's get feedback at every iteration."
Because if you don't, you can waste hours digging yourself deeper and deeper into a hole.
PS: thanks to @elstob and @idangazit for teaching me about editor components: specially TipTap, and how great CodeMirror is for experts.
I think I'll achieve what I need to with the much simpler Slate.js —
PPS: I'm realizing the hour I spent on rendering italics and bold text were absolutely a useless side-quest, but it did make me understand better how many things actually work.
PPPS: I got toolbars to work, which I think is going to replace putting buttons next to each paragraph.
PPPPS: text editor widgets are super complicated — such as, they don't necessarily come with things like undo/redo out of the box. Duh! I should have known this, after writing this summary of how insanely complicated editors are in this podcast interview!
Every Monday, @andysmanclubuk meet at Roots Hall at 7pm, offering free peer-to-peer support groups.
If you're struggling, go along and get whatever's weighing you down off your chest.
@CJPhillips1982 could you promote our new @andysmanclubuk branch in Hockley?
Andy's Man Club Hockley opening at Greensward School on Monday 2nd Sept. Free peer-to-peer mental-health support for men, no referral or registration required - just turn up: https://t.co/1WLK7B8hcT
The glamourisation of music of black origin that glorifies knife crime is a major problem.
The videos and photos of black and brown kids running around like feral dogs in Southend needs dealing with by the black and mixed ethnicity community because if we don't, the growing mood of needing an enemy, a scapegoat, in this country will turn towards the law abiding 4 million black and mixed ethnicity community. Trust me. Some of us have seen it in the 70's and 80's.
Let's have this right, at a time when 4 million black and mixed ethnicity Britons are going about their lives peacefully, adding significantly to British culture, several hundred feral youths with a "shank on their waist" ( a famous recent song lyric) are making every single one of the 4 million law abiding citizens of this nation targets of far right cheerleaders who glibly then tar all 4 million as "all the same", and it isn't on.
Idris Elba has done incredible work in tackling the issue and his recommendations should be implemented. Football clubs have also done some great work in highlighting the issue.
But at a time when easily lead people are looking to paint whole communities with the same brush, it's way past time the black and mixed ethnicity community unified against a problem in our community of increased knife carrying and as a consequence, crime.
Where are the record labels who promote a bewildering number of "artists" who's remit seemingly is to glorify "carrying"? Where's their responsibility to make sure that knife crime isn't currently what it is, glamorised?
Many would argue that the white community doesn't have to continually justify itself in the same way ethnic minority communities do. Frankly I don't care, I care about a fair image of the black and mixed ethnicity community being portrayed, which, if we're not careful will set to the default of the less than intelligent. "It's ALL of them".
So in our black and mixed ethnicity community a good starting point is condemning anyone who looks like us when taking part in knife crime, putting pressure on record labels who push music that only ever glamorises knife crime, call them out, grass then up and share their names. This isn't Ronnie and Reggie in the 60's or New York mafia omerta. Name the names and let's get them dealt with. Then get our biggest and brightest stars alongside Idris and community leaders to tackle this head on, while celebrating and amplifying the quite incredible positive achievements our communities have made to push British society forward.
Because if we don't, enough people with those less than forensic brains who don't see 4 million law abiding black and mixed ethnicity Britons working, grafting, contributing proudly, they'll amplify via some of the most extreme platforms, one simple message which will put all 4 million of us in the crosshairs.
It's all of "them".
We've been here before. National Front, BNP, the intimidation, the suss laws, the endemic racist policing of the 70's and 80's.
If we do nothing now to stop the feral few, in the hearts and minds of an increasingly loud minority, we'll all be viewed the same. Again.
Dead impressed with the Meta Ray-Ban Glasses. The quality of the photos is solid, while the video allows you to capture things happening around you instantly. The most underrated feature is the built-in speakers, you basically don’t need earbuds.