Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add blog post on Functional Programming #85

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

abhayptp
Copy link

No description provided.

@abhayptp
Copy link
Author

@parvmor see if you can add something!

"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."
Didn't get it? No problem! Continue reading and at the end, atleast you will get to know what it is all about.

Actually Functional Programming is much about abstraction and mathematical concepts. And that is what acts as an hindrance for programmers from learning it. But now many people are turning towards it due to many reasons, primarily the easiness of writing thread-safe(concurrent) code in functional languages. With that in mind, I have tried to cover some key ideas in this post, and have listed some resources at the last. Hoping it will help you! :)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The main reason for using functional is to help you write modular and compositional code as modular design is the key to successful programming. (From Hughes paper "Why functional programming matters"). Also try to relate it to how coding jobs require people who write such code.

* [https://www.schoolofhaskell.com/](https://www.schoolofhaskell.com/)
* [book.realworldhaskell.org/read/](book.realworldhaskell.org/read/)

### Scala
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add this blog too: Neophytes Guide to Scala

One can easily verify that no state is being changed in the second example. It also looks familiar(something like recursion), isn't it? In FP, most of the functions are indeed implemented through recursion.

### Getting Started
I would recommend you to first go through ~~scala~~ hashkell tutorials as they are better than scala in getting you started with functional programming. But after all, choice is yours.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo: haskell not hashkell

}
}
```
One can easily verify that no state is being changed in the second example. It also looks familiar(something like recursion), isn't it? In FP, most of the functions are indeed implemented through recursion.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In pure functional there is no loop. So, all functions are implemented with pattern matching and recursion.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also nothing about pattern matching 😢 ?

```scala
def fib2(n: Int): Int = {
n match {
case 0 => 0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use:
case 0 | 1 => n

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also add a tail recursion example as this will overflow for large n

Copy link
Author

@abhayptp abhayptp Aug 16, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I didn't want it to be a long post with any tutorial, only bare introduction. That's why I have not included pattern matching,tail end, currying, etc. But including it won't hurt though. But, will including pattern matching and tail end suffice? Or should include more topics? Thanks anyway for review.. 😄

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At least add that stuff. If you want you can also show some examples on lazy evaluation. Since, you are writing it in scala show the effects of declaring a variable as lazy. Along with that you can also show how sometimes laziness needs to be taken care while IO.

### Getting Started
I would recommend you to first go through ~~scala~~ hashkell tutorials as they are better than scala in getting you started with functional programming. But after all, choice is yours.

### Hashkell
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo again. For some who wants to have a better understanding: Deep insight into functional programming

@shivanshuag
Copy link
Member

shivanshuag commented Aug 16, 2017 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants