[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: How am I supposed to use yaci library?(Yet Another Class Implementation)
- From: Sean Conner <sean@...>
- Date: Thu, 27 Feb 2014 12:29:43 -0500
It was thus said that the Great Journeyer J. Joh once stated:
> Hi Javier Guerra Giraldez,
>
> I must say I am sorry. I didn't intent to make you write this much writings
> to me.
> And I understand what you and Steve and Sean trying to say now.
>
> So far I tried not to face a need to learn functional programming.
The concepts of functional programming are (I think) rather easy to
understand. It's wrapping your brain around the concepts to get certain
classes of programs written that's hard.
For instance, the following list is about 80% of what functional
programming is all about:
1. no global variables
2. functions can only use the data given to it via parameters
#1 is pretty easy to understand---there are no global variables. It might be
harder to adapt to this, although not impossible (even in C I try to avoid
the use of globals as much as possible).
#2 is also easy to understand (and follows from #1). Without global
variables, a function can only use what it is given. These two rules make
it easier to reason about code, test the functions in isolation, and are
relatively easy to do in non-functional languages. The next item is harder
to understand though:
3. variables are immutable (that is---once set, they can't change)
This is where functional programming starts to get "hard," conceptually.
Once a variable is assigned, it can't be modified. Because of this,
functions in functional languages tend to be short and rely upon recursion
(the only way to do loops without modifying a variable) and thus, functional
langauges also tend to support tail call optimizations (which is useful even
in imperative languages).
But for insight into functional programming, you can't do worse than start
here:
http://prog21.dadgum.com/23.html
(summary: He attempts to design Pac-Man in a functional style)
-spc (No, really, the first two items will get you most of the way
to functional programming)
- References:
- Re: How am I supposed to use yaci library?(Yet Another Class Implementation), Journeyer J. Joh
- Re: How am I supposed to use yaci library?(Yet Another Class Implementation), Journeyer J. Joh
- Re: How am I supposed to use yaci library?(Yet Another Class Implementation), Andrew Starks
- Re: How am I supposed to use yaci library?(Yet Another Class Implementation), steve donovan
- Re: How am I supposed to use yaci library?(Yet Another Class Implementation), Journeyer J. Joh
- Re: How am I supposed to use yaci library?(Yet Another Class Implementation), steve donovan
- Re: How am I supposed to use yaci library?(Yet Another Class Implementation), Journeyer J. Joh
- Re: How am I supposed to use yaci library?(Yet Another Class Implementation), Journeyer J. Joh
- Re: How am I supposed to use yaci library?(Yet Another Class Implementation), Javier Guerra Giraldez
- Re: How am I supposed to use yaci library?(Yet Another Class Implementation), Journeyer J. Joh