I dreamed about a combination of #AdventOfCode and #mscroggs .

Day 10: Day 3 should actually run for 7 rounds, not 4.

Running for 7 rounds requires #memoization . Of course.

#coding

The Useless useCallback

Why most memoization is downright useless...

🌗 毫無意義的 useCallback
➤ 緩存的陷阱與最佳實踐
https://tkdodo.eu/blog/the-useless-use-callback
這篇文章深入探討了 React 中 `useCallback` 和 `useMemo` 的使用場景,指出在某些情況下,這些 Hook 並不能帶來預期的效能提升,甚至可能是不必要的。作者認為,`useCallback` 和 `useMemo` 的核心目的是為了保持引用穩定性,避免不必要的重新渲染和重新計算,但如果沒有正確地應用,例如沒有將 memoized 的值傳遞給 memoized 的組件,或是不需要引用穩定性的情況下,則會造成資源浪費。文章通過具體範例說明瞭何時應該使用這些 Hook,以及何時可以簡化程式碼,避免不必要的複雜性。
+ 「這篇文章提醒我重新思考一下在專案中使用 `useCallback` 的方式了,之前一直照單畫,沒有仔細考慮是否真的需要它。」
+ 「作者的解釋非常清楚,讓我明白瞭 `useCallback` 的真正目的和使用時機,以後會更謹慎地使用
#React #效能優化 #memoization
The Useless useCallback

Why most memoization is downright useless...

🚀 Ah, yes, the riveting world of dynamic programming with Σ-types in Lean—because who wouldn't want to verify their #memoization techniques while sipping on a nice cup of existential dread? 🤓 If you thought solving recursive #algorithms was thrilling, just wait until you read about turning it into a 17-minute snooze-fest! 💤
https://tannerduve.github.io/blog/memoization-sigma/ #dynamicprogramming #Σtypes #Lean #existentialdread #HackerNews #ngated
Verified Dynamic Programming with Σ-types in Lean

1. IntroductionIf you’ve taken an algorithms class, you have likely seen dynamic programming, specifically a technique called memoization. Memoization works to optimize recursive algorithms by caching the solutions to subproblems in a table, and when a subproblem is encountered, it queries the table instead of recomputing the solution. This gives us an exponential performance boost.

Home

#commonLisp #programming #amop #mop #metaobjectProtocol #exercise #closette #learnToCode (my own experience) #oop
https://screwlisp.small-web.org/amop/eg1/

Today I simply share and solve (hopefully!) The Art of the Metaobject Protocol exercise 1.1

(the softball generic classes #memoization exercise from chapter 1)

I just added a lexical closure of hash tables.

@simoninireland wrote about the art of the metaobject protocol in his #lisp bibliography a year ago. https://simondobson.org/2024/07/23/the-art-of-the-metaobject-protocol/

Art of the metaobject protocol Exercise 1.1: Memoize Closette apply-generic-function

Memoizing the Cache in Laravel, by @amitmerchant.bsky.social:

https://www.amitmerchant.com/memoizing-the-cache-in-laravel/

#laravel #caching #memoization

Memoizing the cache in Laravel

When you cache a value in Laravel, it’s stored in the cache store (like Redis, Memcached, etc.) and can be retrieved later. This is great since it prevents expensive operations like database queries or API calls.

Amit Merchant

Between immutability and memoization, you might have to choose, by Rémy Hannequin
https://thoughtbot.com/blog/between-immutability-and-memoization-you-might-have-to-choose

Freezing objects, pre-computation, cache, #memoization.. which one you can use, when it's worthy?

#ruby

Between immutability and memoization, you might have to choose

It is not always possible to have frozen AND performant objects in Ruby.

thoughtbot

I started implementing some explorations in #Haskell but I had to ditch `data-memocombinators` because #MicroHs doesn't properly support #RankNTypes yet. Instead I'm doing manual #memoization with #array :

```
import Data.Array

-- memoized function, looks up in array
f :: Int -> Int -> Int -> Int
f = \x y z -> if inRange fBounds (x, y, z) then fArray ! (x, y, z) else 0

-- real algorithm, recursive calls use memoized function
f' :: Int -> Int -> Int -> Int
f' 1 1 1 = 1
f' a b c = sum [ f (a - 1) b c, f a (b - 1), f a b (c - 1) ]

-- array, generated with real algorithm
fArray :: Array (Int, Int, Int) [Bool]
fArray = array fBounds [ (i, f' x y z) | i@(x, y, z)<- range fBounds ]

-- array bounds
fBounds :: ((Int, Int, Int), (Int, Int, Int))
fBounds = ((1, 1, 1), (limit, limit, limit))

-- can be as large as necessary for the real problem,
-- but going too big consumes too much memory
limit :: Int
limit = 45
```

[Перевод] React useCallback() — полное руководство

Всем привет! На связи Разобраться с useCallback() полностью

https://habr.com/ru/companies/spectr/articles/869806/

#ecommerce #ecom #javascript #react #hook #memoization

React useCallback() — полное руководство

Всем привет! На связи Spectr и рубрика «Что читают наши разработчики». Сегодня разберем оптимизацию функциональных компонентов за счет мемоизации функций обратного вызова с помощью useCallback() ....

Хабр

React. Обновление узлов и мемоизация

В процессе разработки современных веб-приложений производительность часто становится одним из ключевых аспектов, которые волнуют и разработчиков, и пользователей. Пользователи ожидают молниеносного отклика, а разработчики стремятся создать приложения, которые работают быстро и эффективно. Одним из мощных инструментов, позволяющих достигнуть высокой производительности в React-приложениях, является мемоизация. Мемоизация помогает значительно сократить количество вычислений и, соответственно, обновлений интерфейса, что положительно сказывается на общей скорости и отзывчивости приложения. В данной статье мы заглянем "под капот" движка React и увидем, как именно происходит обновление узлов. Параллельно рассмотрим и основные принципы мемоизации и её применение в различных типах компонентов.

https://habr.com/ru/articles/821293/

#react #reactjs #reactjs #мемоизация #memoization

React. Обновление узлов и мемоизация

В процессе разработки современных веб-приложений производительность часто становится одним из ключевых аспектов, которые волнуют и разработчиков, и пользователей. Пользователи ожидают молниеносного...

Хабр