# High-order Virtual Machine (HVM) - GC가 없는 순수 함수형 런타임

> Clean Markdown view of GeekNews topic #7311. Use the original source for factual precision when an external source URL is present.

## Metadata

- GeekNews HTML: [https://news.hada.io/topic?id=7311](https://news.hada.io/topic?id=7311)
- GeekNews Markdown: [https://news.hada.io/topic/7311.md](https://news.hada.io/topic/7311.md)
- Type: news
- Author: [alstjr7375](https://news.hada.io/@alstjr7375)
- Published: 2022-09-01T19:15:03+09:00
- Updated: 2022-09-01T19:15:03+09:00
- Original source: [github.com/Kindelia](https://github.com/Kindelia/HVM)
- Points: 16
- Comments: 1

## Topic Body

- Turing Machine과 Lambda Calculus를 결합한 Interaction Net이라는 새로운 계산 모델  
- 러스트의 복잡한 차용모델 대신 하스켈의 평가 방식과 비슷한 lazy clone primitive를 사용  
- Lazy하기 때문에 복제 비용이 무료에 가까우며 하스켈과 다르게 람다 내부에서 계산을 공유할 수 있음 (병렬처리에서 이득이 큼)  
- [SIC(Symmetric Interaction Calculus)](https://github.com/VictorTaelin/Symmetric-Interaction-Calculus) 기반 메모리 모델을 선택하여 하스켈등에서 [Graph Reduction](https://en.wikibooks.org/wiki/Haskell/Graph_reduction)이라 일컬었던 방식에서 요구했던 포인터 간접 참조 비용을 상당부분 제거함 (Optimal 을 찾을 수 있을때 이득)  
- 즉, 일반 언어 런타임에 비해 GC가 없고, 병렬과 Optimal처리에 강점이 있음

## Comments



### Comment 12118

- Author: alstjr7375
- Created: 2022-09-01T19:34:32+09:00
- Points: 2

퀵소트 구현입니다.  
Lamda Calculus를 적극적으로 사용해서 그런지 리스프랑 비슷해보이는 군요..?  
  
```  
// QuickSort  
(QSort p s Nil)          = Empty  
(QSort p s (Cons x Nil)) = (Single x)  
(QSort p s (Cons x xs))  =  
  (Split p s (Cons x xs) Nil Nil)  
  
// Splits list in two partitions  
(Split p s Nil min max) =  
  let s   = (>> s 1)  
  let min = (QSort (- p s) s min)  
  let max = (QSort (+ p s) s max)  
  (Concat min max)  
(Split p s (Cons x xs) min max) =  
  (Place p s (< p x) x xs min max)  
  
// Sorts and sums n random numbers  
(Main n) =  
  let list = (Randoms 1 (* 100000 n))  
  (Sum (QSort Pivot Pivot list))  
```
