Get the latest tech news

Should programming languages be safe or powerful?


Should a programming language be powerful and let a programmer do a lot, or should it be safe and protect the programmer from bad mistakes? Contrary to what the title insinuates, these are not diametrically opposed attributes. Nevertheless, this is the mindset that underlies notions such as, “macros, manual memory management, etc. are power tools—they’re not supposed to be safe.” If safety and power are not necessarily opposed, why does this notion persist?

Haskell forces you to express side-effects in the type system, but this lets you know that calling a function with a signature like String → Int won’t do any IO or throw an exception. The evolution of syntax macros in Lisp, Scheme, and Racket provide an interesting real-world instance of how safety and power can start off as a trade-off, but with better language design, become complimentary. The problem with this is that these macros are unhygienic: if I introduce a new variable, as I did with tmp in my-or, that is just a bare symbol that can be inadvertently captured producing unexpected output:

Get the Android app

Or read this on Hacker News

Read more on:

Photo of languages

languages

Related news:

News photo

Cohere’s smallest, fastest R-series model excels at RAG, reasoning in 23 languages

News photo

OpenAI-backed Speak raises $78M at $1B valuation to help users learn languages by talking out loud

News photo

Trivial REST server in various languages to compare