Hacker News new | ask | show | jobs
by sremani 3665 days ago
F# is a functional first language, yes, C# with Func<> can do many things, but functional code in F# is just smooth and easy, unlike C#, where you have to put up with lot of noise.
1 comments

I haven't mentioned or was making any points about F# or C#; I was commenting on what appears to be your definition of a functional language, that is "Functional programming is a broad term that at its core describes languages that allow you to pass functions around as values to other functions".

Even if that meant something in the past, it really isn't a useful definition any more, because pretty much all languages do this. That's why I offered my alternative description. Even if it too has flaws, I think it's a more meaningful description.

> "I haven't mentioned or was making any points about F# or C#; I was commenting on what appears to be your definition of a functional language"

sremani != ZenoArrow (though if you read this sremani, thank you for attempting to clarify).

There are many 'multi-paradigm' languages, and C# is one of them. From the C# Wikipedia page...

https://en.wikipedia.org/wiki/C_Sharp_(programming_language)

"C# (pronounced as see sharp) is a multi-paradigm programming language encompassing strong typing, imperative, declarative, functional, generic, object-oriented (class-based), and component-oriented programming disciplines."

What makes a language 'functional' is first-class functions (i.e. functions that can be treated as values, which is what I was referring to in my earlier post).

As sremani said, F# is 'functional first', in the sense that the language is designed to make functional algorithms straightforward to express. You can write C# in a functional way too, but there's less syntactic sugar for this style of programming.

Hope that clears it up.

> sremani != ZenoArrow

Apologies, my mistake.

> Hope that clears it up.

First paragraph on the Wikipedia page for Functional Programming [1]:

"In computer science, functional programming is a programming paradigm—a style of building the structure and elements of computer programs—that treats computation as the evaluation of mathematical functions and avoids changing-state and mutable data. It is a declarative programming paradigm, which means programming is done with expressions[1] or declarations[2] instead of statements."

I'll stick with my definition.

Hope that clears it up.

[1] https://en.wikipedia.org/wiki/Functional_programming

With your definition, is Lisp a functional language? Is it expression-oriented or statement-oriented?
Pure functions, i.e. that are 1) idempotent 2) have all their arguments passed in 3) cause no side effects as a by product of evaluating the function are fundamental to functional programming.
But not fundamental to the definition of a functional language. F# isn't pure, but most would call it a functional language - so purity is surely not 'fundamental' - in fact most functional languages aren't pure.

That's why I prefer to stick to the 'expression oriented' concept, it seems to be the thing that captures most, if not all, functional languages. But I guess just like there are plenty of people that wouldn't call Java OO (and would prefer the Alan Kay definition), there are plenty that will disagree with any definition of 'functional'

(preparing for the inevitable 'functional first' comment).

Yeah, I could go along with that.
Are there any terms/concepts in math/CS that are related to or similar to "idempotence"?
I think in this case, referential transparency means the same thing. That is, produce the same output given the same input, every time.
Got it, thanks.