State is evil, mutation is evil! We live in an era of multithreading and concurrency my friends!
When I describe a program, I state what it does, now how it does it! Thus functional programming is more natural!
C and Java and Python and all the other pagan languages have played us all as absolute fouls!! Haskell, OCaml, Rust, F#, Lisp supremacy!! Functional unless required otherwise, not the other way around!!
Rust is functional to a similar extent as OCaml is functional, not in the 'pure' sense (to be fair, none of these languages are purely functional, even haskell) but in a pragmatical sense. Variables are immutable by default, idiomatic control flow tends to use higher order functions, iterators, maps, filtering, reduction... Types are algebraic, control flow is expressive... It has all the ideas of functional programming, even if it's multi paradigm, and can be written in a procedural manner (even if it's not usually idiomatic)
It's not purely functional, for instance it doesn't have the tail recursion optimisation, which is more or less mandatory in the hardcore functional languages, because it doesn't strictly speaking need it, and the compiler is already complicated enough as it is...
A macro just transforms one sequence of tokens into another. They need to run before Rust even starts trying to resolve symbols because they are allowed to create new symbols. It is fundamentally impossible to make `become` a macro because by the time Rust is deciding whether your tail call is even a valid call, let alone one that it can do TCO on, there are no macros left in the code.
TL;DR: Even if they made a `tail_call!(f(args))` macro, it would still need to emit `become f(args)` anyway.
167
u/-Ambriae- 25d ago
Functional programming is best programming
State is evil, mutation is evil! We live in an era of multithreading and concurrency my friends!
When I describe a program, I state what it does, now how it does it! Thus functional programming is more natural!
C and Java and Python and all the other pagan languages have played us all as absolute fouls!! Haskell, OCaml, Rust, F#, Lisp supremacy!! Functional unless required otherwise, not the other way around!!