No I'm using the mathematical definition of a function. ML is not Math nor is it purely functional.
All functional languages need to bend the rules a bit in order to have side effects but in general the person is not writing functions and therefore is not getting the benefits of using functions.
FP is about reducing and restricting these functions that break the rules. Defining a class in terms of mutations and side effects is going against the philosophy of FP.
> No I'm using the mathematical definition of a function.
Which mathematical definition? A "box" is not a mathematical definition. There are multiple mathematically precise definitions of "function" possible. Yours is none of them. Some of them accommodate objects that model mutable state.
I don't think many (any?) PL theorists or functional programming practitioners would agree with your dogmatic stance. Where are you coming from with all this?
It’s curious you think this piece is written by a “JavaScript programmer”, and the person who responded to you here is a “junior” — the implication being that you know more.
It might help to take a step back and assume intelligence in others: what if these people are smart? What could you learn from them? If you think the idea is wrong, assume it’s coming from a peer. One way you know you are doing that, is if you form your disagreement as a question.
—
I took the time to respond to you, because it looks like you have some real love for programming, but know less than you think. You can grow a lot more if you shift some of your thinking
Tell me what you think the point is. Typically when someone thinks a point was missed they address the point rather than devolve the conversation into a condescending description about my character and how I should act. It's a sort of tactical what you're doing here. But who cares, no one is reading.
It's curious how you don't even address my points and just say that I missed the point when I'm the one dictating the point in my original comment. Typically this isn't how you respect other people and get them to respond positively to your comments, what you're doing will draw other people to support you but anger your target because of the condescension. I'm not sure what you're objective is because people aren't really reading this thread... it's already buried.
>It’s curious you think this piece is written by a “JavaScript programmer”,
The examples in the original piece are in javascript. Why don't you RTFA before commenting on the "point."
>and the person who responded to you here is a “junior” — the implication being that you know more.
The Junior thing was more of a retort. I said it with full awareness of what it implies and how the other person would take it because his tone obviously implies that he doesn't think he's a junior. Basically the replier has his own opinion which he is entitled to say (and that I respect) but when you say things like "dogmatic" and then vote me down... that's just not respectful. Since I can't vote him down I inject a bit of subtle rudeness in my replies as a subtle retort in return. Just being a mirror. Similar in a way to the subtle game you're playing. That's all this is.
>It might help to take a step back and assume intelligence in others: what if these people are smart? What could you learn from them? If you think the idea is wrong, assume it’s coming from a peer. One way you know you are doing that, is if you form your disagreement as a question.
Maybe you should take a step back and look at your own post. Telling people to shift their thinking implies you have a sort of superiority complex. As if you're not the one that's mistaken. How do you know I'm not a peer? How do you know I'm not superior. Perhaps you should take a look at yourself. You seem like a guy who thinks he's superior to me in programming but you haven't demonstrated as much, you haven't even addressed the point.
You went on a side tangent talking about my behavior. Trust me, if you want someone to change or listen to you, talking to them like this is not the path.
You want to know what will make people respond to you and listen to you? Address them without any subtle disrespect. It's very simple.
You could've responded to me like this:
I disagree with you. I also think there was a misunderstanding of the point. Here's why...
By proving the other person wrong without being disrespectful you can change the other person's' character. But obviously this isn't our objective here is it?
That being said take a look at this wikipedia post and tell me. Who missed the point?
"Functional programming is sometimes treated as synonymous with purely functional programming, a subset of functional programming which treats all functions as deterministic mathematical functions, or pure functions. When a pure function is called with some given arguments, it will always return the same result, and cannot be affected by any mutable state or other side effects. This is in contrast with impure procedures, common in imperative programming, which can have side effects (such as modifying the program's state or taking input from a user). Proponents of purely functional programming claim that by restricting side effects, programs can have fewer bugs, be easier to debug and test, and be more suited to formal verification.[1][2]"
Literally that's the definition I'm following. It's one form of the definition and certainly a popular one. That's my opinion. You disagree? You think I missed the point? Elucidate. The original poster can disagree but my opinion is far from as he puts it "absurd."
Read the article. What definition of functional programming does that class with a setter even fit under? Ok he redefined it as a higher order function... Is what he doing procedural programming or functional programming. It looks to me he's doing a bit of everything and calling it a function. Does the guy even know that the class keyword is just sugar for "function" in javascript?
Literally it says "classes" are just special functions. He's just reiterating the javascript spec as if it's a new fangled discovery. In fact, before ES6 all "classes" were written with the keyword "function." No dude. The article writer doesn't get it and neither does the person who responded to my post. When you do OOP with LISP you're not doing FP period. The article writer just noticed an isomorphism and is likely amazed by what all JS programmers were doing before ES6. Not to be insulting but the parent poster likely doesn't have much experience.
>I took the time to respond to you, because it looks like you have some real love for programming, but know less than you think. You can grow a lot more if you shift some of your thinking
I too took the time to respond to you. Despite your condescending attitude/game. Let's see where this goes.
If you decide to dismiss a position by saying that it chose the wrong definition, you're not contributing anything useful. "Pure" functional programming is not more functional programming than "Functional programming", the adjective specializes it and makes it more narrow. I don't really care what a wiki article says. I can run a survey of my colleagues if you want?
As for calling me a junior, well, you don't know how much experience I have, do you? It's probably more than you, though. I've used and participated in the development of functional programming languages for over a decade at this point.
Unsolicited advice: Sophomoric pedantry isn't a good look.
>Unsolicited advice: Sophomoric pedantry isn't a good look.
Starting conflict and calling people "dogmatic" and voting people down is not a way to win people over. I can see a number of paths this road could have gone down where you can easily get another person to agree with your ideas as an alternative viewpoint despite a wikipedia article saying otherwise. You chose to take none of these roads, maybe largely because you don't know how to do this.
>I don't really care what a wiki article says.
Right because your opinion is the best opinion and only opinion that matters. The community opinion and the majority opinion has no relevance to you because you participated in "functional development for over a decade." Whoop dee doo. I chose a definition of functional programming that has huge relevance to the community at large. You on the other hand... haven't even stated your definition yet.
Unsolicited advice: Arrogance and the inability to admit your own mistakes is not a good look. A decade of experience does not earn you the right to act like an ass hole nor does it make you a good programmer.
You chose a definition among many and then dismissed the submission as "confused" because it does not meet your definition.
I noted that your definition would preclude ML functions from being called functions. Your response was that ML wasn't purely functional, but that doesn't make it not functional. The pure in "pure functional" doesn't "to the exclusion of non-functional", it is simply a narrower category.
Considering that ML is one of the most impactful functional programming languages both in theory and practice, I think it's right to call that absurd and dogmatic. If you take it as a personal attack that I called your argument absurd, I don't know what to say. Maybe grow a little bit of skin?
> You on the other hand... haven't even stated your definition yet.
I don't need to provide a definition to find a flaw in yours. I did not come into this submission looking to smugly dismiss the topic at hand with my obviously irrelevant preferences for terminology. You did.
>You chose a definition among many and then dismissed the submission as "confused" because it does not meet your definition.
My definition? I quoted wikipedia. A lot of people use "my definition" Basically under "your" definition C++ and go might as well be a functional programming language.
>Considering that ML is one of the most impactful functional programming languages both in theory and practice, I think it's right to call that absurd and dogmatic. If you take it as a personal attack that I called your argument absurd, I don't know what to say. Maybe grow a little bit of skin?
Why grow skin? I literally didn't care. I just decided to call you junior because you were acting like one. It seems like you cared more. I was just explaining to the other guy why I called you a junior. I recognize the attack but I literally don't care, but that doesn't mean I won't respond or address it.
>I don't need to provide a definition to find a flaw in yours. I did not come into this submission looking to smugly dismiss the topic at hand with my obviously irrelevant preferences for terminology. You did.
My Definition doesn't have flaws. Like I said, if I expand it to encompass mutability (as you have) then you can place Go and C++ on the functional pedestal. I haven't used ML but clearly a language like ML only allows mutability as a small exception that's rarely used otherwise there's no point to classify ML as functional.
But let's get back on topic. You literally said that no PL theorist would agree with me. But look at wikipedia. Apparently many do. So you're wrong.
I don't take wikipedia to be authoritative about anything but I'll bite.
> Functional programming is sometimes treated as synonymous with purely functional programming, a subset of functional programming which treats all functions as deterministic mathematical functions, or pure functions.
Well, obviously in this context the author of the submission wasn't using that definition. So you coming in and dismissing the conversation because sometimes people mean "pure functional programming" when they say "functional programming" is clearly erroneous. I know when people make this conflation, often when they're talking about Haskell. When talking about ML, no one would take that synonym. Context matters.
I just looked, you provided a set theoretic definition of functions, the wikiwand one. You chose a poor definition for the topic at hand. In most mathematical settings it would be a perfectly fine definition, but not here. Context matters.
Here are the problems with it: It assumes an interpretation in sets when there are a plurality of interpretations of functions qua functional programming which are not compatible with set theoretic models. For example, functions in homotopy type theory have higher dimensional structure than just being elements of a set. Functions in domains have more structure than just the extensional mapping from inputs to outputs. Your chosen definition also includes non-computable functions which are simply not admissible in this context.
So your definition is simultaneously too restrictive and too lax.
You seem to be confused by the existence of multiple definitions and how they are appropriate in context.
>I don't take wikipedia to be authoritative about anything but I'll bite.
No but it's more authoritative than a random person on the internet (you). For things like this it's good enough. I'm not writing a paper here.
>Well, obviously in this context the author of the submission wasn't using that definition.
>Context matters.
>In most mathematical settings it would be a perfectly fine definition, but not here.
In this context it's also perfectly fine. OP did not make a distinction between subroutine or function. He also uses the term higher order function wrong. It shows two things. He does not know what a higher order function is and he does not know what a function is.
>Here are the problems with it: It assumes an interpretation in sets when there are a plurality of interpretations of functions qua functional programming which are not compatible with set theoretic models. For example, functions in homotopy type theory have higher dimensional structure than just being elements of a set. Functions in domains have more structure than just the extensional mapping from inputs to outputs. Your chosen definition also includes non-computable functions which are simply not admissible in this context.
This is the garbage pedantry that I warned you about earlier. I'm choosing the generally accepted academic definition. Hopefully you're not one of those people who can't comprehend "generally accepted" without an expose into axioms and different obscure branches of math.
>You seem to be confused by the existence of multiple definitions and how they are appropriate in context.
Find the generally accepted definition in wikipedia that this person is using (Hint: no actual technical definition exists). Obviously he's using "function" in place of procedure or subroutine. But then he uses the term "Higher Order" to imply an actual functions instead of procedures.
Not only does he use "Higher Order" incorrectly but his usage of the term indicates he doesn't know what a function is and the difference between a function and a procedure.
Yeah I'm not going to reply to your shit any more. HN really needs to change the policy of not letting parent posters vote others down.
> This is the garbage pedantry that I warned you about earlier. I'm choosing the generally accepted academic definition. Hopefully you're not one of those people who can't comprehend "generally accepted" without an expose into axioms and different obscure branches of math.
I think you should look into domain theory it is one of the most celebrated discoveries pertaining to the semantics of functional programming languages. And maybe you'll understand that from a programming point of view, what a function is is much more flexible and subtle than you think.
> Yeah I'm not going to reply to your shit any more. HN really needs to change the policy of not letting parent posters vote others down.
Would it help if I pretended that you downvoted me? Every time I see my imaginary internet points I will subtract 5.
No you should just stop voting me down. I'm literally going to go negative soon, I just joined. I literally cannot talk to you if you continue voting me down. It's bad form.
>I think you should look into domain theory it is one of the most celebrated discoveries pertaining to the semantics of functional programming languages. And maybe you'll understand that from a programming point of view, what a function is is much more flexible and subtle than you think.
Sure I could. But "context matters." This is not the topic of the conversation. There's a level of depth we're operating at here. Very few people understand "domain theory" and you shouldn't assume as much when you communicate with anyone.
There's nothing for me to learn here other than domain theory which is very advanced math and how people behave.
If you follow the conversation you'll see that the entire argument turned into a battle of definitions with me turning to a very generally accepted definition of a function and bitdizzy turning to using more obscure mathematical definitions of "function" and arguments about semantics what context is relevant to what definition of "function." Whatever definition you choose to believe domain theory looks like very advanced stuff and clearly outside the scope of your average technical conversation.
Either way, I didn't have time to respond to your other comment below. But I will now.
Don't worry about the upvote thing. It's just for this thread I can switch accounts.
I'm not downvoting you. I can't downvote anyone. I don't think I have enough points to downvote. If I didn't want to talk to you I wouldn't be replying!
> It's curious how you don't even address my points and just say that I missed the point when I'm the one dictating the point in my original comment.
> Typically this isn't how you respect other people and get them to respond positively to your comments
> The examples in the original piece are in javascript. Why don't you RTFA before commenting on the "point."
I wrote that article, so in effect you are responding to my original comment : ).
Fair that what I wrote was condescending. I purposefully wrote it that way, as a second meta-point: to get you to experience what it feels like when people assume negative, and use words like "Ok, no", "Javascript programmer" (negative connotation), "junior"
With that accomplished, moving on to more civil ground.
> I'm not sure what you're objective is because people aren't really reading this thread... it's already buried.
First, as you can now feel, I was pretty annoyed by your presumptuous tone in your initial comment. Second it really did feel like you had depth and love in programming, but from your comments I intuited some traits that lead to lower potential outcomes. Mainly: jumping to conclusions too quickly (harder to learn new things this way, and unless you are almost finished with your career, it can be detrimental).
> Does the guy even know that the class keyword is just sugar for "function" in javascript? ... Not to be insulting but the parent poster likely doesn't have much experience.
Yes, I do know what classes de-sugar to in javascript, I worked with many of the folks who brought classes to the ES spec.
As you most likely know, javascript classes are a bit of a special case, because JS uses prototypical inheritance. Classes in other languages do not de-sugar this way.
For example: you can see a function as a special `class` with only one method `apply`, or you could see a class as a special higher order function.
> Who missed the point?
The point is, that though functions and classes seem distinct, they are less distinct than one would think. In your comments, you seem very attached to the specific distinctions you've set up with classes, procedures, and functions. One question I would ask you is: what is _similar_ about them? Could you express all of these with one abstraction? Is there a difference between choosing `class` as the base abstraction, vs a closure?
>One question I would ask you is: what is _similar_ about them? Could you express all of these with one abstraction? Is there a difference between choosing `class` as the base abstraction, vs a closure?
The answer is yes you can. But you're thinking in the wrong direction.
First let's make things clear. A function is just a one line expression where all values are immutable. There is no concept of time or procedures in a function.
function
def f(x):
return ((x + 1) * 2)/3
procedure:
def f(x):
x = x + 1
x = x * 2
x = x / 3
return x
You are saying that a procedure is isomorphic to an object which is to say you can define an object in terms of a procedure and a procedure in terms of an object. People often mix up the two terms, procedure and function but it's no big deal. The issue is, you used the term "Higher Order" function and the second issue I had was that it's actually quite an obvious thing presented as if it was novel.
Well first off all computers are procedural machines. The underlying machine is just executing machine code which is a series of procedures. So all programming languages on top of this are implemented with procedures.
That means OOP languages are implemented with procedures.
That means FP languages are implemented with procedures.
That means procedural languages are implemented with procedures.
Basically your post is just reiterating how an object is implemented by a compiler.
However the title of your post used "Higher Order Function." This implies you don't know the distinction between procedures and functions as "Higher order" functions are usually reserved for true functions, not procedures.
That was the point of my post, to help you see the distinction because although you can create objects from procedures, you cannot create objects from functions because objects require mutation which is a primitive that a function cannot actually provide. The relationship is surjective or unidirectional.
>harder to learn new things this way, and unless you are almost finished with your career, it can be detrimental
This is the internet. I can communicate without a filter on the internet with little consequence. Filters slow things down as do a lack of filter. Either way I can get to the point quickly without worrying about offending someone.