Skip to content

Commit

Permalink
Merge pull request #1 from kleidemos/thinking-functionally
Browse files Browse the repository at this point in the history
[WIP] Thinking functionally
  • Loading branch information
Neftedollar authored Aug 29, 2019
2 parents 2f00879 + 04bfbbd commit 2982514
Show file tree
Hide file tree
Showing 14 changed files with 2,577 additions and 1,337 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ _book
# eBook build output
*.epub
*.mobi
*.pdf
*.pdf
/.vs
368 changes: 230 additions & 138 deletions posts/currying.md

Large diffs are not rendered by default.

500 changes: 332 additions & 168 deletions posts/defining-functions.md

Large diffs are not rendered by default.

216 changes: 153 additions & 63 deletions posts/function-composition.md

Large diffs are not rendered by default.

119 changes: 76 additions & 43 deletions posts/function-signatures.md

Large diffs are not rendered by default.

177 changes: 128 additions & 49 deletions posts/function-values-and-simple-values.md

Large diffs are not rendered by default.

378 changes: 265 additions & 113 deletions posts/how-types-work-with-functions.md

Large diffs are not rendered by default.

183 changes: 131 additions & 52 deletions posts/mathematical-functions.md

Large diffs are not rendered by default.

529 changes: 332 additions & 197 deletions posts/organizing-functions.md

Large diffs are not rendered by default.

288 changes: 181 additions & 107 deletions posts/partial-application.md

Large diffs are not rendered by default.

499 changes: 336 additions & 163 deletions posts/stack-based-calculator.md

Large diffs are not rendered by default.

43 changes: 30 additions & 13 deletions posts/thinking-functionally-intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,38 @@ seriesId: "Thinking functionally"
seriesOrder: 1
---

Now that you have seen some of the power of F# in the ["why use F#"](../series/why-use-fsharp.md) series, we're going to step back and look at the fundamentals of functional programming -- what does it really mean to "program functionally", and how this approach is different from object oriented or imperative programming.
> Now that you have seen some of the power of F# in the ["why use F#"](../series/why-use-fsharp.md) series, we're going to step back and look at the fundamentals of functional programming -- what does it really mean to "program functionally", and how this approach is different from object oriented or imperative programming.
### Changing the way you think ###
Теперь, когда читатель увидел некоторые из причин, по которым стоит использовать F#, в серии ["why use F#"](../series/why-use-fsharp.md), сделаем шаг назад и обсудим основы функционального программирования. Что в действительности означает "программировать функционально", и чем этот подход отличается от объектно-ориентированного или императивного программирования?

It is important to understand that functional programming is not just a stylistic difference; it is a completely different way of thinking about programming, in the way that truly object-oriented programming (in Smalltalk say) is also a different way of thinking from a traditional imperative language such as C.
### Changing the way you think | Смена образа мышления ###

F# does allow non-functional styles, and it is tempting to retain the habits you already are familiar with. You could just use F# in a non-functional way without really changing your mindset, and not realize what you are missing. To get the most out of F#, and to be fluent and comfortable with functional programming in general, it is critical that you think functionally, not imperatively.
And that is the goal of this series: to help you understand functional programming in a deep way, and help to change the way you think.
> It is important to understand that functional programming is not just a stylistic difference; it is a completely different way of thinking about programming, in the way that truly object-oriented programming (in Smalltalk say) is also a different way of thinking from a traditional imperative language such as C.
This will be a quite abstract series, although I will use lots of short code examples to demonstrate the points. We will cover the following points:
Важно понимать, что функциональное программирование - это не просто отдельный стиль программирования. Это совсем другой способ мышления в программировании, который отличается от "традиционного" подхода так же значительно, как настоящее ООП (в стиле Smalltalk) отличается от традиционного императивного языка - такого, как C.

* **Mathematical functions**. The first post introduces the mathematical ideas behind functional languages, and the benefits that come from this approach.
* **Functions and values**. The next post introduces functions and values, showing how "values" are different from variables, and why there are similarities between function and simple values.
* **Types**. Then we move on to the basic types that work with functions: primitive types such as string and int; the unit type, function types, and generic types.
* **Functions with multiple parameters**. Next, I explain the concepts of "currying" and "partial application". This is where your brain can start to hurt, if you are coming from an imperative background!
* **Defining functions**. Then some posts devoted to the many different ways to define and combine functions.
* **Function signatures**. Then a important post on the critical topic of function signatures: what they mean and how to use them as an aid to understanding.
* **Organizing functions**. Once you know how to create functions, how can you organize them to make them available to the rest of your code?
> F# does allow non-functional styles, and it is tempting to retain the habits you already are familiar with. You could just use F# in a non-functional way without really changing your mindset, and not realize what you are missing. To get the most out of F#, and to be fluent and comfortable with functional programming in general, it is critical that you think functionally, not imperatively.
> And that is the goal of this series: to help you understand functional programming in a deep way, and help to change the way you think.
F# позволяет использовать нефункциональные стили кодирования, и это искушает программиста сохранить его существующие привычки. На F# вы можете программировать так, как привыкли, не меняя радикально мировоззрения, и даже не представляя, что при этом упускаете. Однако, чтобы получить от F# максимальную отдачу, а также научиться уверенно программировать в функциональном стиле вообще, очень важно научиться мыслить функционально, а не императивно.
Цель данной серии - помочь читателю понять подоплёку функционального программирования и изменить его способ мышления.

> This will be a quite abstract series, although I will use lots of short code examples to demonstrate the points. We will cover the following points:
Это будет довольно абстрактная серия, хотя я буду использовать множество коротких примеров кода для демонстрации некоторых моментов. Мы рассмотрим следующие темы:

> * **Mathematical functions**. The first post introduces the mathematical ideas behind functional languages, and the benefits that come from this approach.
> * **Functions and values**. The next post introduces functions and values, showing how "values" are different from variables, and why there are similarities between function and simple values.
> * **Types**. Then we move on to the basic types that work with functions: primitive types such as string and int; the unit type, function types, and generic types.
> * **Functions with multiple parameters**. Next, I explain the concepts of "currying" and "partial application". This is where your brain can start to hurt, if you are coming from an imperative background!
> * **Defining functions**. Then some posts devoted to the many different ways to define and combine functions.
> * **Function signatures**. Then a important post on the critical topic of function signatures: what they mean and how to use them as an aid to understanding.
> * **Organizing functions**. Once you know how to create functions, how can you organize them to make them available to the rest of your code?
* **Математические функции**. Первая статья знакомит с математическими представлениями, лежащими в основе функциональных языков и преимуществами, которые приносит данный подход.
* **Функции и значения**. Следующая знакомит с функциями и значениями, объясняет чем "значения" отличаются от переменных, и какие есть сходства между функциями и простыми значениями.
* **Типы**. Затем мы перейдем к основным типам, которые работают с функциями: примитивные типы, такие как string и int, тип unit, функциональные типы, и обобщённые типы (generic).
* **Функции с несколькими параметрами**. Далее я объясню понятия "каррирования" и "частичного применения". В этом месте чьим-то мозгам будет больно, особенно если у этих мозгов только императивное прошлое.
* **Определение функций**. Затем несколько постов будут посвящены множеству различных способов определения и комбинирования функций.
* **Сигнатуры функций**. Далее будет важный пост о критическом значении сигнатур функций, что они значат, и как использовать сигнатуры для понимания содержимого функций.
* **Организация функций**. Когда станет понятно, как создавать функции, возникнет вопрос: как можно их организовать, чтобы сделать доступными для остальной части кода?
Loading

0 comments on commit 2982514

Please sign in to comment.