
toast@donotsta.re
Posts
-
"I want my code to run fast, so I pick the fastest language runtime for my code", says the dev who does not know the ways of the tao.@fristi the worst implementation you've ever seen -
"I want my code to run fast, so I pick the fastest language runtime for my code", says the dev who does not know the ways of the tao."I want my code to run fast, so I pick the fastest language runtime for my code", says the dev who does not know the ways of the tao.
Behold, their JS code:
// remove items equal to "item" in array "arr" function removeItem(arr, item) { let idx = arr.indexOf(item); if (idx < 0) return arr; let newArr = []; for (let i = 0; i < arr.length; i++) { if (i !== idx) newArr.push(arr[i]); } // isn't recursion great? return removeItem(newArr, item); }
(this example isn't realistic because This Type Of Guy typically uses TypeScript with
any
all over, but I was too lazy to do that) -
explanations of "map" be likeexplanations of "map" be like
oh so you do a map +1 on a list and it does a +1 to everything on the list
how map actually works: -
I'm the giant rat that makes all of da rulezI'm the giant rat that makes all of da rulez -
chez Glorp nous sommes une startup qui accélère vers les STARS 🤩chez Glorp nous sommes une startup qui accélère vers les STARS 🤩
nous venons de finir notre levée de fonds en série Z pour 45 milliards d'euros
dans ce contexte, nous cherchons des nouveaux profils pour compléter notre équipe
si l'un de ces profils vous correspond, appelez-nous pour commencer le processus de recrutement de que onze étapes !
* Peintre spécialisé dans l'application de la peinture
* Chef spécialisé dans l'utilisation du couteau
avantages:
* un salaire compétitif (29 000€ à 42.5h)
* tickets resto (prise en charge à 50%)
* mutuelle (prise en charge à 50%)
* la chance de faire l'expérience d'un environnement compétitif demandeur
* la chance de vivre dans notre open space écologique (sans chauffage ni climatisation pour être respectueux de l'environnement), dans la plus belle ville du monde (Paris en face de la gare du Nord)
* la chance d'apprendre de nos thought leaders (notre Chief Product Officer (CPO) et notre fondateur Raphaël de la Marque (CEO)) -
we have poland at homewe have poland at home -
you know what they sayyou know what they say
the miku shall inherit the world
SEKAI DE -
@fristi@56k.dile-up.nl null isn’t an integer, and neither is false!@fristi@56k.dile-up.nl null isn’t an integer, and neither is false! How can you differentiate between false/null-that-is-there-on-purpose and the coincidental “not found” null? This lets you do that
In fact, procedural languages tend to emulate this, think about the typescript ?. for example, or the C# Nullable (both of which are kind of nerfed functors)What FP is good about is about making the flow of the program closely correspond to the way you think / would explain the flow
For example, you could do something like this:
makePrimes x = x # (2^x)-1 is likely-ish to be prime |> map(pow(2)) # raise 2^x |> map(-1) # -1 |> filter(prime?)
In a procedural language you would need to have a much bigger comment block at the top that explains the approach, and then hope that it stays up to date over time.
In an OO language you kind of just lose track of “how you even get to the right answer”.
In FP if done right it’s self evident and present there, and you can immediately skip to thinking about the thing you’re actually trying to do and potential improvements to the algorithm, rather than fighting with the language to get the result at all -
tried to touch a #rust codebase again@Johann150 (thank you though, it's slightly nicer than going through and_then) -
tried to touch a #rust codebase again@Johann150 I'm just not happy that a basic operation (monadic lifting) requires going through "bonus steps", essentially -
tried to touch a #rust codebase again@Johann150@genau.qwertqwefsday.eu I have an
Option<a>
and I want to call afn(a) -> b
on it.
If theOption<a>
is None, the result should be none.
The operation of taking anfn(a)
and making it work on anOption<a>
is called a "monadic lift", and it's the whole purpose of having this kind of "wrapper type" to begin with, it's meant to be one of the most basic operations.
What I'm having to do is a.and_then
with an extra wrapper lambda which actually returns anOption
anyway (rendering the point of it kind of moot) -
tried to touch a #rust codebase again@Johann150 they literally are monads! just… poorly implemented ones -
tried to touch a #rust codebase againtried to touch a #rust codebase again
no idea why I did that
what do you mean Option and Result and so on are monads but you can't just lift functions?
then why are they monads??
closest thing you get is `Option.zip_with` but it's Option-only and nightly-only
I'd have thought that moving fast and breaking compat literally every release would mean it wouldn't be literal decades behind