2022-12-24-TIL

Today I Learned

함수형 프로그래밍

함수형 프로그래밍을 잘 하려면 재귀함수에 익숙해져야 한다.

반복문 -> 재귀 -> 꼬리함수 최적화의 과정을 반복 숙달해야한다.

func concate(Strintg s) {
    val leftPart = s.subString(0, 10);
    val rightPart = s.subString(11, 20);
    return concat(leftPart, rightPart);
}

위와 같은 코드가 있다고 가정하자. 이때 굳이 지역 변수를 사용해서 가독성을 높여야하는가? 지역변수를 사용하는 것의 최대 단점은 로직이 복잡해지고 다른 사람이 코드를 수정하게 되면, 변수의 선언 사이에 로직이 들어갈 여지가 생긴다는 점이다. 그렇게 되면 원자적인 단위의 연산으로 정의한 함수가 더 이상 원자성을 보장하지 못한다. 즉, 변수 선언과 결과를 리턴하는 코드 사이에 다른 로직이 들어갈 여지가 있다는 점에서 이미 원자적인 단위의 연산이 아니게 된다.

극단적인 방법으로는 코틀린에서 .let으로 리팩토링이 안되면 코드를 지운다.

.also의 존재이유도 납득이 간다.

이렇게 로직을 원자화하여 다른 로직이 중간에 파고들어서 원자성을 훼손시키지 못 하도록 하는 것이 하나의 방법이다.

  • https://m.blog.naver.com/jhc9639/221486916086
  • https://www.geeksforgeeks.org/functional-programming-paradigm/

Type Casting

하나의 파이프를 지나면 타입의 변형이 발생하는데, 낭비가 아닌지? -> data class 를 사용하는 이유, data class면 map으로 사용가능 아니면 concat으로 user + post 타입을 사용

Pipe(
    getUserId()(userId, postId) (User, Post)
    getPost() (Post)
)

Type construct 모나드

코틀린 꼬리 재귀 함수

  • https://www.roach-dev.com/kotlin_tailrec/?fbclid=IwAR1Pf8PDDz4wQJ81KwW-Gno-TEjSOu98ZmKozomeio-yzuIvWj1PNNDTksc

Tactic Programming

  • https://en.wikipedia.org/wiki/Tacit_programming

Shadow Stack

  • https://en.wikipedia.org/wiki/Shadow_stack

Vector Instruction

  • https://www.sciencedirect.com/topics/computer-science/vector-instruction

Pipeline Hazard

  • https://needjarvis.tistory.com/675

Handler and Multiplexer

  • https://dejavuqa.tistory.com/314

Out-of-order Execution

  • https://en.wikipedia.org/wiki/Out-of-order_execution

Finite State Machines

  • http://www.cs.utoronto.ca/~sengels/csc258/lectures/FSM_4up.pdf

Kotlin reduce() and fold()

  • https://blog.leocat.kr/notes/2020/03/09/kotlin-reduce-and-fold

Type Inference

  • https://joshua1988.github.io/ts/guide/type-inference.html

Functional Programming with Kotlin

코틀린도 엘릭서와 마찬가지로 함수의 파이프라이닝이 가능한가? 언어에서 직접 제공하지는 않지만 별도의 구현으로 가능할 듯

  • https://juan-medina.com/2017/05/23/why-functional-programming-kotlin/
  • https://www.gojek.io/blog/how-to-use-declarative-pipelines-in-kotlin
  • https://subscription.packtpub.com/book/application-development/9781788476485/12/ch12lvl1sec90/pipes
  • https://medium.com/@krpiotrek/kotlin-pipeline-syntax-191b59429c38
  • https://discuss.kotlinlang.org/t/pipe-forward-operator/2098

Monard

  • https://teamdable.github.io/techblog/Moand-and-Functional-Architecture

Object Strage

  • https://www.ibm.com/kr-ko/cloud/learn/what-is-object-storage
  • https://aws.amazon.com/ko/what-is/object-storage/
  • https://www.ncloud.com/product/storage/objectStorage
  • https://cloudian.com/blog/object-storage-vs-block-storage/

Can Race Condition happen in Single Thread

레이스 컨디션은 2개 이상의 스레드로 동작할 때만 발생한다.

  • https://en.wikipedia.org/wiki/Race_condition
  • https://www.quora.com/How-does-race-condition-happen-on-a-single-core-machinej
  • https://www.techtarget.com/searchstorage/definition/race-condition
  • https://www.baeldung.com/cs/race-conditions
  • https://softwareengineering.stackexchange.com/questions/377816/is-there-a-race-condition-for-multiple-threads-on-multiple-cores-trying-to-lock
  • https://stackoverflow.com/questions/46556478/can-single-processor-environment-prevent-race-condition
  • https://stackoverflow.com/questions/21463377/can-we-have-race-conditions-in-a-single-thread-program

What is Middleware

  • https://psyhm.tistory.com/8
  • https://lakelouise.tistory.com/211

DI Framework in Golang

  • https://syntaxsugar.tistory.com/entry/Golang-Dependency-Injection
  • https://stackoverflow.com/questions/41900053/is-there-a-better-dependency-injection-pattern-in-golang
  • https://medium.com/avenue-tech/dependency-injection-in-go-35293ef7b6
  • https://github.com/sarulabs/di

Kotlin mono

  • https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-reactor/
  • https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-reactor/kotlinx.coroutines.reactor/mono.html

Spring MVC and WebFlux

  • https://pearlluck.tistory.com/726
  • https://techblog.woowahan.com/7349/

Coroutines in Kotlin

  • https://www.baeldung.com/kotlin/threads-coroutines

Composition and Pipeline

  • https://kkangil.github.io/2020/09/13/%EC%BB%B4%ED%8F%AC%EC%A7%80%EC%85%98%EA%B3%BC-%ED%8C%8C%EC%9D%B4%ED%94%84%EB%9D%BC%EC%9D%B8/

Today's Book

  • http://www.yes24.com/Product/Goods/64586851
  • https://www.manning.com/books/grokking-simplicity
  • http://www.yes24.com/Product/Goods/108748841
  • http://www.yes24.com/Product/Goods/44020344
  • http://www.yes24.com/Product/Goods/84899008
  • http://www.yes24.com/Product/Goods/73293439