zlacker

Which programming languages are most token-efficient?

submitted by tehnub+(OP) on 2026-01-12 01:36:26 | 115 points 91 comments
[view article] [source] [go to bottom]

NOTE: showing posts with links only show all posts
1. btbyte+J5[view] [source] 2026-01-12 02:13:14
>>tehnub+(OP)
Not surprisingly, it is J [1], an APL dialect.

[1] https://www.jsoftware.com/

6. bri-ho+ga[view] [source] 2026-01-12 02:46:55
>>tehnub+(OP)
I suspect DB queries will also benefit from token-efficient query languages as RAG queries grow exponentially. I've been working on one such language that is emitted in a token-efficient IR and compiles to SQL. https://memelang.net/
◧◩
7. Curiou+tc[view] [source] [discussion] 2026-01-12 03:02:40
>>HarHar+C8
The approaches used by Claude Code and Cursor are inefficient. It's possible to calculate a covering set for a piece of code and provide that to an agent directly via a tool, and it turns out that this can reduce context usage in SWE-bench style tasks by >90% over RAG and grep/read.

If you're interested in learning more, https://github.com/sibyllinesoft/scribe

38. kozika+Zx[view] [source] 2026-01-12 06:33:24
>>tehnub+(OP)
Someone has made a programming language called Sui, which is said to be designed for LLMs. However, using index-based variable names in order to "avoid typo bugs" makes it more difficult than general-purpose languages, and it also has poor token efficiency :(

https://github.com/TakatoHonda/sui-lang

◧◩◪
51. tikhon+DJ[view] [source] [discussion] 2026-01-12 08:19:27
>>eru+bl
From what I've heard—and in my own very limited experiments—LLMs are much better at less popular languages than I would have expected. I've had good results with OCaml, and I've talked to people who've had good results with Haskell and even Unison.

I've also seen multiple startups that have had some pretty impressive performance with Lean and Rocq.

My current theory is that as long as the LLM has sufficiently good baseline performance in a language, the kind of scaffolding and tooling you can build around the pure code generation will have an outsize effect, and languages with expressive type systems have a pretty direct advantage there: types can constrain and give immediate feedback to your system, letting you iterate the LLM generation faster and at a higher level than you could otherwise.

I recently saw a paper[1] about using types to directly constrain LLM output. The paper used TypeScript, but it seems like the same approach would work well with other typed languages as well. Approaches like that make generating typed code with LLMs even more promising.

Abstract:

> Language models (LMs) can generate code but cannot guarantee its correctness often producing outputs that violate type safety, program invariants, or other semantic properties. Constrained decoding offers a solution by restricting generation to only produce programs that satisfy user-defined properties. However, existing methods are either limited to syntactic constraints or rely on brittle, ad hoc encodings of semantic properties over token sequences rather than program structure.

> We present ChopChop, the first programmable framework for constraining the output of LMs with respect to semantic properties. ChopChop introduces a principled way to construct constrained decoders based on analyzing the space of programs a prefix represents. It formulates this analysis as a realizability problem which is solved via coinduction, connecting token-level generation with structural reasoning over programs. We demonstrate ChopChop's generality by using it to enforce (1) equivalence to a reference program and (2) type safety. Across a range of models and tasks, ChopChop improves success rates while maintaining practical decoding latency.

[1]: https://arxiv.org/abs/2509.00360

55. aleph_+CO[view] [source] 2026-01-12 09:00:20
>>tehnub+(OP)
Relevant:

On https://danuker.go.ro/programming-languages.html you can find charts of popularity (TIOBE) vs code density for various programming languages together with which programming languages are Pareto-optimal regarding these two criteria.

68. thw_9a+U01[view] [source] 2026-01-12 10:39:55
>>tehnub+(OP)
There is one class of languages missing in the comparison: Programming golf languages: E.g. Japt [1], Pyth [2] or Jelly [3].

Update: I noticed that the author mentions that "APL's famous terseness isn't a plus for LLMs." Isn't that just a design limitation of the LLM tokenizers?

[1]: https://github.com/ETHproductions/japt

[2]: https://github.com/isaacg1/pyth

[3]: https://github.com/DennisMitchell/jellylanguage

◧◩◪
70. johnis+rc1[view] [source] [discussion] 2026-01-12 12:08:15
>>Bootvi+1P
See >>46586312 .

I cannot speak much for C#, but you may be right. Claude's Opus is really good.

◧◩◪◨⬒
77. solomo+FZ1[view] [source] [discussion] 2026-01-12 16:11:15
>>torgin+lT
I write Haskell professionally and I can tell you that Opus 4.5 can do a great writing industrial Haskell code consistent with an existing code base.

I don't think it is capable of writing galaxy brain Haskell libraries, it absolutely missed the forest for the trees, but if you have an existing code base with consistent patterns it can emulate then it can do a surprisingly good job.

Here is an example side project I have done extremely heavily with Claude: https://github.com/solomon-b/kpbj.fm

I built a library (without Claude) that wraps in an opinionated way Servant and a handful of other common libraries used to build Haskell web-apps and then have let Claude use that to build this site. There is absolutely some hairy code and I have done a ton of manual refactors on what Claude produces, but claude has been highly effective for me here.

[go to top]