I've been coding for 26 years. if I could distill my experience into one sentence it would be:

"functions and data is all you need"

don't get distracted by fancy language features. every language has functions, every language has structs. mastering programming is just composing functions and transforming data. once you master this you can program in any language.

if you focus building programs as small, pure, modular functions that operate on *only* the data it needs, then you will have a large set of functions that are highly composable. you will never have to do large rewrites of your program, because your program will compose of lego blocks that you can snap together in different ways.

gm nostr!

Reply to this note

Please Login to reply.

Discussion

Appreciate this! I’m trying to be the meme, ā€œLearn to Codeā€

i spent the first 10 years of my programming life struggling with why I had to rewrite my programs all the time. it was mainly because I didn't appreciate or understand this simple fact.

to be fair I was trying to teach myself programming from a "c++ for dummies" book with no internet, so that was probably why. "fancy" c++ teaches you the absolute worst programming practices.

I tried to jump into Rust as all the cool bitcoin projects seemed to use it. My only experience being some Python scripting at best. That seemed like a mistake, going back to Python to cut my teeth.

Program = Algorithm + Data Structure

Yep I'm finally getting this these days and the Lego approach has not failed me

This, however, makes me feel better and gives hope.

Instead of ā€œClaude, write this appā€ I probably need to do ā€œClaude, write this functionā€. Then, any damage will always be limited to particular functions.

nostr:nevent1qqsvxy678e83uz9m7gnjsxeckx4x82dxr9pjmgzy6ev98ceprd3an9gpzemhxw309ucnjv3wxymrst338qhrww3hxumnwklg6rq

The core philosophy of functional programming. I'm almost to the point of saying that not even the functions matter: just organize your data well. nostr is an amazing example of this

i think you mean the opposite. all you need is functions. data can just been seen as a function with all of its arguments curried, since the codomain is a part of the definition of a function.

No, though I used to think this as well. The way your data is organized has a profound effect on the shape of the software that manipulates it. Imagine one scenario where user information is stored in a document format, but an important attribute is stored on a separate server that requires per-user authentication. Compare this to a scenario where the data for all users is encrypted and can be stored locally. In one, you are able to download a single block of data and render the entire list of users in milliseconds, with additional details immediately available if you authenticate and get a decryption key. In the other you can only search for users, and potentially not even render them except for the logged in user. All of your calls must be async, because they are all slow, and must be individually designed to accommodate the various ways they can fail. Your UI must constantly deal with partial data, etc.

Fred Brooks said in The Mythical Man-Month: "Show me your flowcharts and conceal your tables, and I shall continue to be mystified. Show me your tables, and I won’t usually need your flowcharts; they’ll be obvious."

yes this is a good point, the most important and frequently accessed data should be closest to the lowest level cpu caches. Unfortunately most devs are so abstracted away from this idea these days.

This is another reason i love nostrdb’s design. All the nostr data is always hot in cache, and is in a compact binary format for cache efficiency, and even lmdb has an optimial cpu cache structure. The effect is very noticeable.

It also completely changes the way I built notedeck compared to damus ios. No async db calls, since its fast enough to do in realtime at 144fps. No need to keep ui in sync with the db. Each frame always has the latest version. Works offline. Greatly simplifies building nostr apps.

So in other words you are correct, but it’s a very subtle point!

Yes, it's a subtle lesson, and usually learned from decades of frustration. You seem to be most of the way there though!

I have started doing something like this in the last year and it has been nothing but great

everything is modular, dependency injection if anything is needed, shared-almost-nothing

haskell also teaches you another important lesson: most of your program can be pure functions that do not mutate anything, they purely transform data from input A to output B. A program is simply a machine that is mapping and reducing data over some time.

For side effects, like reading from db/files or writing to a socket, you can do this in a small impure layer at the top your program. This layer just builds values so that they can be passed through the pure machinery.

The pure code can’t really crash due to total pattern matching, so it is nice for super robust programs.

Very good advice. I am retiring soon as an InfoSec analyst and am looking to spend my newly acquired free time learning to develop more. Most I did in my career is simple Python scripts for pen testing, etc. I've never built an actual fully functioning application.

26 years! When did you start coding? In kindergarten???

10

Close enough

GM 🌻

Yes

Data structures and operations on data. That’s all it’s ever been

Is there any language u "love" coding?

I mean really enjoying it?

Haskell is the only language i’ve coded in that is pure nonstop dopamine hits. When you get your program to compile it’s so satisfying, the resulting program is like a crystal of mathematical beauty.

If your code does not algebraically fit together it is rejected. There are no ad-hoc programs, only correct platonic forms.

Besides composing functions I assumed the way how you structure your code depends if you need to rewrite.

Yes

Wait dude, how old are you šŸ˜€ you look like 26 šŸ˜‚

I'm old. 36

I would gladly have a 2hour convo with Dave on this thread.

Looking forward to Damus Android!

Functions do not matter at all. Customer outcomes do, though. Different perspective. Important difference in my humble pov 🫔

being able to change your codebase quickly without introducing bugs is pretty important when it comes to customer outcomes, so in effect you do have to care even still

I agree with you. Still, outcomes > features.

A wise enterprise SaaS customer once to me: ā€žstop talking feature fucking Dave, tell me how this is making me or saving me money I don’t care about your shit functions I need outcomes Dave! Closed a 10M deal with them the same year. No single function mentioned during demo for board. Outcomes only. Life lesson for me personally.

Should do one thing and

Very true

Sounds easy 🄲

Output and resilience matters