Blog
Os 4 grandes paradigmas além de OOP. Haskell puro, Clojure (Lisp moderno), Elixir/OTP (BEAM), Prolog (lógico), reativo (RxJS), data-oriented design. Por que você precisa mudar de paradigma — não de linguagem.
IMPERATIVO: "faça assim" (C, Bash). OOP: "objetos trocam mensagens" (Java, Smalltalk). FUNCIONAL: "valor é tudo, sem side-effect" (Haskell, Elm). LÓGICO: "declare regras, peça o que quer" (Prolog, Datalog). 80% das linguagens modernas são MULTI-PARADIGMA (Python, Rust, Scala).
IMPERATIVO: você instrui PASSO A PASSO (for, while, mutate variable). DECLARATIVO: você descreve O RESULTADO (SQL, HTML, React JSX, Terraform). Declarativo é mais lento? Não — compilador otimiza. Mais legível? Sim. Por que SQL > pra dados, React JSX > pra UI.
Alan Kay inventou OOP em Smalltalk: "objetos trocam mensagens, late binding". Java/C#/C++ pegaram a CASCA (classes, herança, polimorfismo) mas perderam a alma. Erlang/Elixir herdaram o ESPÍRITO (actor model). "I invented OOP and I don't mean C++" — Alan Kay.
Haskell força PUREZA: função sem side-effect, valores imutáveis. IO encapsulado em MONADS (Maybe, IO, State, Either). Type inference Hindley-Milner. Lazy evaluation default (gera fold direita infinito). Por que Haskell é "ML for math" e Elm é "Haskell pra frontend".
Em Lisp, CÓDIGO É LISTA. (defn fib [n] ...) é uma lista. Você manipula código como dado (macros). Lisp dialects: Common Lisp (Lisp clássico, ANSI), Scheme (minimalista, MIT SICP), Racket (educacional), Clojure (JVM, immutable, atom/ref/agent). Por que Paul Graham fez fortuna com Lisp.
Erlang nasceu na Ericsson pros switches telefônicos (9 nines uptime). Modelo: PROCESSOS LEVES (milhões por máquina) trocando MENSAGENS. Supervisor trees ("let it crash"). OTP é o framework. Elixir é Ruby por cima do BEAM. Discord, WhatsApp, Pinterest rodam BEAM. Phoenix LiveView é mágico.
Você declara FATOS e REGRAS. Prolog responde queries via unificação e backtracking. parent(tom, bob). parent(bob, alice). grandparent(X, Y) :- parent(X, Z), parent(Z, Y). Datalog é Prolog sem recursão (Souffle, Datomic). Watson (IBM) usou Prolog. Domínio: AI, expert systems, NLP parsing.
Você define COMO valores fluem ao longo do tempo. Click stream → debounce → map(filter) → http request → render. RxJS (Observables), ReactiveX (Java/Swift/.NET), Server-Sent Events, WebSockets, Akka Streams (JVM). FRP puro: Elm, Reflex (Haskell). Domínio: UI complexa, real-time.
OOP encoraja Array of Structs (AoS): cada Person tem name+age+email juntos. Mas se você quer só nomes, traz tudo. DOD prefere Struct of Arrays (SoA): names[], ages[], emails[]. CACHE-FRIENDLY. Mike Acton (Insomniac Games) trouxe esse paradigma de games pra C++/Rust modernos. ECS (Entity Component System).
Não existe "melhor paradigma" — existe "melhor pra esse problema". UI complexa? Reativo. Dados em massa? Declarativo (SQL/funcional). Sistemas distribuídos fault-tolerant? Actor model. Game engine? DOD. CRUD simples? Imperativo + OOP leve. Stop arguing about paradigms — start matching problem to tool.
Carregando…