Earlier quoted context omitted.
Curious, what new has been found?
There's a style of programming with no concept of loops or jumps. It's called functional programming. There's other styles that are drastically different as well. Most of these styles aren't new though.
Solid Relevance
41–50 of 55 posts
Re: Solid Relevance
#42Earlier quoted context omitted.
No you're very wrong. >No, one kind of technical debt arises that way. Not the only kind. There's another kind that arises when everything is in such small pieces that nobody can tell how the pieces relate to each other. You can easily understand each piece, but you have to go through a chain of a bazillion function calls to see what's actually going on. All this logic must exist regardless of whether it's coupled or…
You seem to think that FP is the one right answer. You are mistaken. There are places where it's the right answer, or at least a very good one - the best definition I've seen is when your program looks like a pipe. And there are places where FP is the wrong answer - where your program has state, and there are multiple parts to the state, and those parts have to be kept in sync with each other . At that point, bundlin…
All programs are pipes from IO to IO or from one state to another state. Purity lives in the pipes, impurity lives in the IO nodes between the pipes. The goal is to keep the impurity as small as possible and have most of your logic live in the pipe, as combinators are the most composeable primitive. I also never said FP is the one right answer. Most programs need to modify state. In FP everything is immutable so your program cannot be pure FP in most cases. What I am saying is to segregate state and IO from logic. Example:
void addOneToState()
can be broken down into int addNTo(int n, int m)
void changeStateTo(int x)
I have split the code above into a method that is devoid of logic and only updates state and logic that lives as a stateless combinator. All programs are made from a series of pipes and tubes. You just need to find the pipe and modularize it and seperate it from the parts that can't be pipes.>At that point, bundling the data to the functions is warranted.
It's never warranted. There is no benefit. Whether you couple it or uncouple it from data the logic still exists, the only difference is coupling. Adding coupling does not improve your code in any other way other than adding coupling.
>And if you're going to say "don't structure the data that way", well, there are times when that's the nature of the problem, not just the nature of the program to solve the problem.
There is no data structure that has to be coupled with logic. However you structure your data it can always be decoupled from logic. Always.
>where your program has state, and there are multiple parts to the state, and those parts have to be kept in sync with each other.
This doesn't change anything.
State makeNewState (State oldState) {
newY = addNTo(oldState.y, 1)
return New State {
x = oldState.x
y = newY
somethingToBeInSyncTo = newY
}
}
void updateState(State x)
y is still in sync with somethingToBeInSyncTo.Re: Solid Relevance
#43Earlier quoted context omitted.
You seem to think that FP is the one right answer. You are mistaken. There are places where it's the right answer, or at least a very good one - the best definition I've seen is when your program looks like a pipe. And there are places where FP is the wrong answer - where your program has state, and there are multiple parts to the state, and those parts have to be kept in sync with each other . At that point, bundlin…
>You seem to think that FP is the one right answer. You are mistaken. There are places where it's the right answer, or at least a very good one - the best definition I've seen is when your program looks like a pipe. All programs are pipes from IO to IO or from one state to another state. Purity lives in the pipes, impurity lives in the IO nodes between the pipes. The goal is to keep the impurity as small as possible…
> It's never warranted. There is no benefit.
When you make such a statement, you sound like someone with fairly limited experience. In particular, from your example, I suspect that you've never worked in a multi-threaded embedded system. somethingToBeInSyncTo, done that way, means that any other thread holding a reference, holds a reference to the old value, while this thread has the new one. And updating running threads with new values on the fly is... problematic.
There's a reason why some programs are not written the way you propose...
Re: Solid Relevance
#44Earlier quoted context omitted.
>You seem to think that FP is the one right answer. You are mistaken. There are places where it's the right answer, or at least a very good one - the best definition I've seen is when your program looks like a pipe. All programs are pipes from IO to IO or from one state to another state. Purity lives in the pipes, impurity lives in the IO nodes between the pipes. The goal is to keep the impurity as small as possible…
"I also never said"? Yeah, I suspected that you and lerptime were the same person. > It's never warranted. There is no benefit. When you make such a statement, you sound like someone with fairly limited experience. In particular, from your example, I suspect that you've never worked in a multi-threaded embedded system. somethingToBeInSyncTo, done that way, means that any other thread holding a reference, holds a refe…
to get around the post limit. Keep it on the DL.
>When you make such a statement, you sound like someone with fairly limited experience. In particular, from your example, I suspect that you've never worked in a multi-threaded embedded system. somethingToBeInSyncTo, done that way, means that any other thread holding a reference, holds a reference to the old value, while this thread has the new one. And updating running threads with new values on the fly is... problematic.
I find that you're the one who seems inexperienced. My example is thread safe ... makeNewState is a combinator. It makes no mutations. Like IO, and mutations, the problems with threading happen with mutation. Thus, locks and other procedural commands used to deal with threading live in the void IO function.
We're more referring to coupling functions with external data and mutations via objects. If you're talking about synchronizing two threads, this again needs to be handled with parent IO function outside the logic of your pipeline combinators. You can still segregate logic away from threading and IO.
My combinator in this case is useable for your example case of synchronizing two threads. If you organized your code in ways where my combinator will be unusable than you have failed to decouple your logic away from threading, IO and mutation.
Re: Solid Relevance
#45Earlier quoted context omitted.
"I also never said"? Yeah, I suspected that you and lerptime were the same person. > It's never warranted. There is no benefit. When you make such a statement, you sound like someone with fairly limited experience. In particular, from your example, I suspect that you've never worked in a multi-threaded embedded system. somethingToBeInSyncTo, done that way, means that any other thread holding a reference, holds a refe…
>Yeah, I suspected that you and lerptime were the same person. to get around the post limit. Keep it on the DL. >When you make such a statement, you sound like someone with fairly limited experience. In particular, from your example, I suspect that you've never worked in a multi-threaded embedded system. somethingToBeInSyncTo, done that way, means that any other thread holding a reference, holds a reference to the ol…
35 years professional software engineering, 30 years in embedded. I'm going to guess that you have less.
Your way of organizing code works great, on paper. Maybe on a small project. For a real embedded system, with multiple threads, with state data being used everywhere... your approach doesn't make much sense. It makes a much worse design than shared mutable state. (Yes, shared mutable state is in fact as evil as you have think it is. It's still better than trying to make your alternative work in that environment.)
Why is state data used everywhere? Because embedded systems often respond in different ways depending on the state of external inputs, and don't go read the state at the time they make the decision on how to respond. If those decisions are spread through the bulk of the code, there's really not much left to put in your combinator. And there's no point in trying to add that paradigm to a system that's going to have tons of shared mutable state anyway.
Re: Solid Relevance
#46Earlier quoted context omitted.
>Yeah, I suspected that you and lerptime were the same person. to get around the post limit. Keep it on the DL. >When you make such a statement, you sound like someone with fairly limited experience. In particular, from your example, I suspect that you've never worked in a multi-threaded embedded system. somethingToBeInSyncTo, done that way, means that any other thread holding a reference, holds a reference to the ol…
> I find that you're the one who seems inexperienced. 35 years professional software engineering, 30 years in embedded. I'm going to guess that you have less. Your way of organizing code works great, on paper. Maybe on a small project. For a real embedded system, with multiple threads, with state data being used everywhere ... your approach doesn't make much sense. It makes a much worse design than shared mutable sta…
Doesn't change the fact that you're wrong and 35 years of programming doesn't ensure that you're a good developer. There are examples of crap code and patterns that have been around perpetually.
>Why is state data used everywhere? Because embedded systems often respond in different ways depending on the state of external inputs
State being everywhere doesn't preclude it to being segregated from logic.
>If those decisions are spread through the bulk of the code, there's really not much left to put in your combinator. And there's no point in trying to add that paradigm to a system that's going to have tons of shared mutable state anyway.
The decision is what goes in the combinator.
#IO functions.
Data getIOFromModuleA()
void sendIOToModuleA(Response r)
Data getIOFromModuleB()
void sendIOToModuleB(Response r)
....
# combinators, reuseable in both module A and module B because of segregation from IO and State
Decision makeDecision(Data x)
Response createResponse(Decision x)
It's the same pattern for State. Just replace the word IO with State. Response can be anything, it can be the entire new state of the program. It can represent a delta of a change, it can be a response specific to a module. Also again, all threading commands go into State or IO functions.OOP fails to segregate code this way and if you don't organize your code like this then you have 35 years of experience of navigating someone elses mess or your own.
Re: Solid Relevance
#47Earlier quoted context omitted.
> I find that you're the one who seems inexperienced. 35 years professional software engineering, 30 years in embedded. I'm going to guess that you have less. Your way of organizing code works great, on paper. Maybe on a small project. For a real embedded system, with multiple threads, with state data being used everywhere ... your approach doesn't make much sense. It makes a much worse design than shared mutable sta…
>35 years professional software engineering, 30 years in embedded. I'm going to guess that you have less. Doesn't change the fact that you're wrong and 35 years of programming doesn't ensure that you're a good developer. There are examples of crap code and patterns that have been around perpetually. >Why is state data used everywhere? Because embedded systems often respond in different ways depending on the state of…
So I'll just leave you with this. "In theory, there is no difference between theory and practice. In practice, there is." You've got your theory. Nice theory. Use it for a decade of actual real-world work, and let me know how it works out. I'll be especially interested if any of that work is in embedded.
Re: Solid Relevance
#48Earlier quoted context omitted.
>35 years professional software engineering, 30 years in embedded. I'm going to guess that you have less. Doesn't change the fact that you're wrong and 35 years of programming doesn't ensure that you're a good developer. There are examples of crap code and patterns that have been around perpetually. >Why is state data used everywhere? Because embedded systems often respond in different ways depending on the state of…
So I said you were inexperienced. You said I was. I listed my experience. You said it was the wrong experience, but conspicuously declined to state your own. So I'll just leave you with this. "In theory, there is no difference between theory and practice. In practice, there is." You've got your theory. Nice theory. Use it for a decade of actual real-world work, and let me know how it works out. I'll be especially int…
If you have to know I'd say I have about 15 years of experience in research, gaming, embedded and web. I will say that the pattern I described can be followed in every one of those fields but it's a niche pattern because it is indeed promoted by people who do FP.
I don't know why you focus on embedded, but embedded people tend to follow these patterns the least due mostly to C++. The overall promoted pattern in C++ is to pass references everywhere and it's highly unlikely that someone in that world will follow this pattern because you have to go out of the way to do it and learn about it. It requires a disciplined approach.
The big problem is if you need to slightly modify a bunch of values in an array of 100 objects. It's hard to figure out the right way to do it in a combinator. The common pattern used nowadays is instead of having combinators handle it, have the combinators generate logical instructions to send to the IO function similar to how in web development your stateless servers pass SQL instructions to the SQL server. The IO function processes the instructions and handles the threading, mutation and IO. Here's a library that does this:
https://github.com/google/cpp-frp
Nothing I said is "theory" in the sense that you put it. These are rare but actual patterns that are used successfully by people in the know. You are not in the "know" despite your experience. As a result for most of your program experience you've just been dealing with and fixing mess after mess after mess.Re: Solid Relevance
#49Earlier quoted context omitted.
So I said you were inexperienced. You said I was. I listed my experience. You said it was the wrong experience, but conspicuously declined to state your own. So I'll just leave you with this. "In theory, there is no difference between theory and practice. In practice, there is." You've got your theory. Nice theory. Use it for a decade of actual real-world work, and let me know how it works out. I'll be especially int…
I said it as a minor minor retort. You want the full story? The full story is I don't care for experience. I find experience doesn't correlate with actual skill. Many experienced developers act and seem very inexperienced which is what I said about you: You "seem inexperienced" because you act that way. The very act of bringing up experience is off topic and a sign of lack of maturity. If you have to know I'd say I h…
You get the last word, if you want.
Re: Solid Relevance
#50Earlier quoted context omitted.
I said it as a minor minor retort. You want the full story? The full story is I don't care for experience. I find experience doesn't correlate with actual skill. Many experienced developers act and seem very inexperienced which is what I said about you: You "seem inexperienced" because you act that way. The very act of bringing up experience is off topic and a sign of lack of maturity. If you have to know I'd say I h…
"It is useless to have a conversation with those who will not listen." Neither of us are listening, because we're both sure we're right. So I'm out. You get the last word, if you want.
Don't back out, I'm not fighting for the last word. I'm having a discussion with you in hopes you can convince me. But you haven't really said anything substantial other than things along the lines of "Trust me I have lots of experience, your stuff is just theory."
If you start introducing the real arguments then this discussion can actually go somewhere.