Hacker News new | ask | show | jobs
by skishor 2340 days ago
Learning different programming paradigms. For example, logic programming with Prolog makes you think about solving certain problems quickly and efficiently in a declarative style. Strongly-typed functional languages like SML and OCaml make it easy to use types and pattern matching to reduce errors and shift some cognitive burden from yourself to the compiler. Lisps allow you to quickly prototype functions in the REPL and test them interactively, and thinking about code as data (homoiconicity) is a powerful concept.

In short, learning new programming paradigms completely changed my view of programming and these skills can translate over to more "mainstream" languages, so it is still a worthwhile effort.

4 comments

Yes, learning other paradigms is useful.

For me, introducing immutability of data (functional paradigm) helped clean up many interfaces and made the code feel resilient. I realized I rarely passed the input data back to the caller (it was often a new and different structure). At the end of it all, I was somehow more confident in the 'run time' of the app and reasoning about issues is much easier. Currently I am not using any language features to enforce immutability - I just code the receiving function to not change any input structures (or in rare cases, return a new one). I suspect there are some exceptions lying around but having most of the code behave this way has helped.

Especially when using very general purpose languages often in business, I think what you get from learning completely different styles, structures and concepts in other languages is mental models for approaching problems that can help you write cleaner code, finding simpler solutions. When the choice is so broad (say you want to build a React App, there's 1000s of approaches, many of them only show their nasty side at a point where you now have a huge difficult to maintain app). I think some paradigms do lend themselves to different architecture too, and this helps you to discover more ways to architect code and make informed choices.

I found learning Rust valuable, as it forces you think about (and specify) ownership and mutability. It has exhaustive branch matching enforced by compiler, and it has no Null.

Also ChucK (and other niche languages are often cool). "ChucK is a concurrent, strongly timed audio programming language for real-time synthesis, composition, and performance"

I did a Coursera course on digital music creation in ChucK and it was such a joy, and such an unusual language.

Learning Rust helped me become a stronger Python developer.

I've been working full time with Rust for long enough that I've acquired an intuition about ownership such that a lightweight borrow checker in my mind monitors ownership designs in Python. I use mutability sparingly. I use compositional design. Etc.

>shift some cognitive burden from yourself to the compiler

This is the best way I've seen the advantages of static type checking articulated.

The line I use is: "I'm a very bad programmer, but I'm very good at making the compiler force me to get it right".