Small Programs and Languages

Hacker News by 5 min read 506x views
Small Programs and Languages

Share Post

Small programs are interesting. But I’m additionally curious in small programming languages.

Generally speaking, the smaller the language, the small expressive it is.

One of the most well-known, smallest expressive languages is assembly.

Assembly languages are very syntactically and conceptually simple. There’s not much tongue at all: it’s mostly a rigid sequence of opcode mnemonics. Even alongside macros, penning in gathering is mostly concerning understanding the puzzle of a particular CPU’s education set architecture, or ISA. (You can demonstrate this by comparing the syntax of gathering for CISC and RISC processors. The puzzle is totally different, during the tongue remains practically unchanged.)

An honest citation must be made current for SNOBOL, which is kind of akin gathering tongue the two for the rigid syntactic reasons listed complete and also since it presents a akin authority stream challenge. Like a CPU, it only understands jumps and call/return. (In all another way, SNOBOL is wildly different, being a cord matching and replacing language. It’s weird and fun and extremely effective.)

Moving on to syntactically small "high-level" languages, these three are brilliant:

  • Forths win fair concerning any "smallness" contest. The lone syntactical construct is the area character. Forths are mind-bendingly elastic and mighty in a way that is downright disturbing.

  • Lisps, (especially Scheme?), have small center languages alongside extremely uncomplicated syntax and enormous expressive power and flexibility.

  • Tcl deserves to be mentioned alongside Forth and Lisp. Tcl is untamed since everything is a cord in a way that is difficult to value at first. You can build your own tongue in Tcl fair as you can alongside Forth or Lisp.

Forth, Lisp, and Tcl lone necessitate you to comprehend a few center ideas and give you limitless power in return. You could fit the syntactic center of these languages on an indicator cardstock or less.

And yet, to wield these tools efficiently requires a enormous change in thinking if you’re used to "normal" Algol-like procedural languages.

So how concerning item that is the two small and uncomplicated and doesn’t necessitate a blood sacrifice?

I think the Lua programming tongue fits the bill. Check out how small the core tongue is:

I’ve got the printed publish type of this document and it’s a lean book! The Lua tongue is covered in the commencement and it is fair 27 pages. 27 pages! I have equivalent manuals longer than that.

The C tongue is beautiful small. I don’t think it’s excellent uncomplicated to program effectively and safely alongside C, but there’s no denying it’s compact and pretty expressive for its size.

Newcomer Zig is C-like. But I think it’s really fairly ample and you need to know a lot of it to use it effectively. (I’m additionally a fan of Zig and think it’s totally value it. The size is there for a reason.)

JavaScript has a center tongue that is fairly small. Probably on par alongside Lua, actually. Functions, arrays, and objects (used as dictionaries) are beautiful much all the JS I use and I akin it that way!

As alongside the natural individual languages, the trade-off alongside a bigger programming language is, hopefully, greater expressivity.

Small or expressive. Which way should you lean?

In a fantastic conversation by David Ungar (wikipedia.org) titled Self and Self: Whys and Wherefores, he laments the mistake of Self’s multiple inheritance:

"It’s far improved to create a scheme a small too uncomplicated so a individual has to compose additional stuff, equal compose it twice alongside a comment that says, 'Look complete here,' than to have a scheme that acts in different ways and nobody can comprehend why. So, simplicity trumps expressiveness."

Got that? Here’s the projectile from the glide to assistance you remember:

snippet of a glide that says Simplicity trumps expressiveness

I think small languages can also be fairly expressive, but lone alongside very, very careful design. Recall Forth, Lisp, and Tcl.

Microworlds: The idea of small, self-contained, learnable programming environments also has a David Ungar association I discovered during watching his talk. See "ARK" on my Microworlds card. (Smith and Ungar co-created the Self language (selflanguage.org), which is a notable milestone in programming and motionless under energetic development to this day.)

Languages which arrive alongside full-featured interactive IDEs are obvious potential microworlds.

But I additionally think that traditional content file-based programming can provision you the microworld cognition as well. For that, a tongue needs elevated quality documentation that installs alongside the compiler/interpreter. And it should strive to have error output that can be understood by beginners, including explanations of what went incorrect and hints for how to fix it or or anywhere to find more information.

Libraries: Another effortlessly overlooked aspect of a programming language’s apparent size is its "standard library" of functions, data structures, and methods.

I think function libraries are topic to the exact identical size versus expressiveness challenge.

For example, learning the Ramda (ramdajs.com) functional programming archive for JavaScript was extremely much akin learning a new programming tongue and I never managed to study all of it. The composability of Ramda and the consistency of its curried functions was extremely eye-opening to me. My advice: A small bit of Ramda goes a lengthy way!

The feels: Concision in our tools has a certain norm that goes beyond utility. Little things fair spark joy, you know?

Why are small things so delightful?

Other Article Hacker News
↑
Close Right Ads
Close Left Ads