Hacker News new | ask | show | jobs
by myWindoonn 1735 days ago
Ah, to be reminded of high school, where one could be not popular simply because they are weird.

I think that they've confused functional and declarative?

2 comments

This is about as far from "popular kids make fun of nerds for being weird and nerdy" as you can get. It's more like two different groups of nerds having a nerd-fight about which kind of nerd is the better kind.
I'm curious, what is the difference between a declarative programming language and a functional one?
Declarative languages are characterised by having the programmer specify _what they want_ but not _how to get it_ (i.e to get a sorted list, you would specify that the elements are in increasing order, but not the specific algorithm to use). In contrast, functional languages are characterised by treating functions as first class values (amongst other things, but these are harder to summarise).

Prolog for example is a declarative language, Haskell is a functional language.

Someone can correct me on this, but I've never seen this distinction you're making anywhere else. And, it doesn't make sense to me either. The wikipedia page[0] for FP says that FP is a "declarative programming paradigm". Can you give me an examplel of a "functional" piece of code that is "not declarative"?

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

Prolog is a declarative language but not a functional language. Hence functional languages and declarative languages are not equivalent. Functional languages are not just defined by lacking side effects but also by using functions as first class citizens, meaning that SQL isn't a functional language either.
Thanks!
Python and Scheme are the two classic examples of non-declarative functional languages; they are both instructing low-level VMs to mutate machine state, but also both have functional-programming tools and first-class functions. The Scheme (set!) form is a great example of imperative mutation within a functional paradigm.
Your definitions are pretty much orthogonal. I would consider Haskell functional and mostly declarative.