What have you found for these years?

2011-03-20

random thoughts on imperative/functional

Yesterday I found a blog that has some interesting posts on it.
One of them is What is a functional language?
I have a hard time to define "functional programming",
though I guess most of things are also very hard to define.
It is really that first we do this, do that, and start giving it a
name to label it, then we won't be troubled to explain a lot of
things times over times. Just mention the "name", except blah
blah blah, but blah blah blah, and blah blah blah. That's a lot
easier to communicate if people already heard/knew what
does that "name" stand for.

But in reality, not all people understand things the same way.
Sometimes it's just hard to give definition for various reasons.
In "computer science", there's a ton of terms that have this
definition problems. The author of the post said:

For as readers of this blog surely know, there is no better
imperative language than a functional language! In fact I
often say that Haskell is the world’s best imperative
programming language; I’m only half (if that much) joking

I am not sure what does the author imply, but I have some
feeling about imperative programming versus functional
programming while reading Language Implementation Patterns.
I feel, we can define imperative programming is built on top of
functional programming, but also the other way around.
I am not sure which one might be better, or it's just not important.

The codes in the book: Language Implementation Patterns is
very structural, so it's suitable for code (parser) generator to
produce those structural code. But, it's also very suitable for
monads to do that. It's definitely a kind of imperative style to
do those things, but it could either be written in an imperative
language, or a purely functional language with monads, easily?
I think it should be natural, though I might not be familiar enough
with monads.

So we could think about, an imperative language, could be viewed
as a domain specific language. It could be translated into a purely
functional programming language wrapped with monads. Just get
the types right no matter what might the author think! So we can
program freely in an imperative environment without struggling with
types and semantics. On the contrary, directly programming in the
pure world requires us to manage those semantics things. We need
to "speak" clearly without stupidity.

After I came to this, I started wondering, which should be considered
lower level? Who implements who? If restriction on the machine
is the consideration of low/high level, we might have this:

assembly -> imperative -> functional

But follow the path that imperative language is a domain specific
language, it might be viewed as functional -> imperative.

I think I need more exercises on monads to explore more.

0 retries:

Post a Comment

Note: Only a member of this blog may post a comment.



All texts are licensed under CC Attribution 3.0