HACKER Q&A
📣 ilrwbwrkhv

Most Succinct Programming Language


Hi HN,

I have some free time and wanted to learn a new language.

I was interested in off beat, not as popular as well as mainstream languages which focus on lines of code reduction as one of their key features.

What would be your recommendations?


  👤 pfortuny Accepted Answer ✓
In that vein I’d suggest J (or APL but J has ascii symbols). It will blow your mind and you will learn a lot of different ways of thinking about composition.

👤 jdlshore
You'll probably enjoy this video about implementing Conway's Game of Life in APL:

https://www.youtube.com/watch?v=a9xAKttWgP4


👤 pturing
You might try the keyword "expressiveness" and see how well that maps to what you are talking about.

Definitely see Paul Graham's essay "Beating the Averages" http://www.paulgraham.com/avg.html

People have tried to define and measure this and related ideas in different ways, and I'm not sold on any of them in particular. I can however suggest some languages that stand out in some of these explorations that you might consider.

+ Lisp dialects. In particular, take a look at Clojure, Shen, and Racket.

+ Smalltalk. Try Pharo. Check out some YouTube videos with Alan Kay.

This is also worth a read https://medium.com/smalltalk-talk/lisp-smalltalk-and-the-pow...

If you're interested in math and data science stuff, also check out Julia.


👤 silisili
I'd probably vote Python for most succinct.

If you want something less popular, perhaps give Nim a try.


👤 kazinator
TXR Lisp values terseness, though not above everything else or to ridiculous degrees where we write catenative code using single international characters denoting functions.

TXR is a native program, with its own run-time, and has very low dependencies. There is a capable, expressive FFI.

Here is an example: ger2err: a complete, stand-alone program with command line parsing, which connects to Gerrit servers to extract changeset comments, turning them into compiler error format you can use in your IDE.

https://www.kylheku.com/cgit/ger2err/tree/ger2err

This is a good sample of what ordinary TXR Lisp looks like where effort hasn't been put into "golfing" the code.

Here is code for Advent of Code 2021, Day 8 (https://adventofcode.com/2021/day/8):

https://www.kylheku.com/cgit/advent/tree/2021/08


👤 FrankWilhoit
Fewest lines of code, or fewest expressions? Suppose you open/read/process/writeback/close on one "line": in principle that is five expressions, and it is supported by a vast volume of code in the lower layers, which shows that it is all a matter of complexity management, particularly as expressed in the definitions of the interfaces between layers.

Also, legibility is a crucially important aspect of complexity.


👤 ohiovr
BASH is the most terse. You can develop a whole application in less than 100 lines. But if you want to read it 100 days from now, python is easier to read. I like python's handling of arrays and strings. I sometimes mix shell into python scripts.

👤 eternityforest
FORTH seems to be most famous for what you can do in minimal lines of code.

I can't exactly say I recommend it for practical use though, it's everything I think a language shouldn't be, but it sure does attract some devoted fans.


👤 karmakaze
For something almost mainstream, give F# or OCaml a look.

👤 _448
IO language is good: https://iolanguage.org

👤 bjourne
Try Factor. It's like Lisp/Scheme except even more homo-iconic and succinct.

👤 supernikita
I think pg suggested lisp, more syntax tree tokens per chars or lines.

👤 nivertech
TL;DR: time-to-solution is much more important than "code reduction"/typing time.

--

PLs from the APL family are probably most succint, then come Forth-like languages.

But most succint doesn't mean they're fastest to solve problems with, correct, or reable/easier to maintain.

When writing code in APL/J/K/Q you write one-liners in the REPL and iterate (refactor?) on them until you're getting the desired result. It might be that a little bit more verbose language will give you a solution faster, even if it will require a little bit more typing, but less iterations in the REPL.

The possibility of making a mistake or getting the wrong result is much higher for the APL family of languages.

The idiomatic style makes them almost write-only and hard to maintain.


👤 Koshkin
Haskell, of course.

👤 fyzix
I would say F# and kotlin as a close second.

👤 easytiger
Q/J