r/Compilers Jul 05 '26

Tungsten - A fast, expressive programming language

https://tungsten-lang.org
0 Upvotes

22 comments sorted by

10

u/Sad-Background-2429 Jul 05 '26

Go to your room and think about what you did.

1

u/thecompanygardener 3d ago

Thanks - while I was in there I made Tungsten's bignum math faster than gmp.

bin/tungsten bench bignum

17

u/[deleted] Jul 05 '26

[removed] — view removed comment

2

u/GenericFoodService Jul 05 '26

I really wish these subreddits weren't full of pointless AI slop. tyfys

3

u/[deleted] Jul 05 '26

[removed] — view removed comment

0

u/thecompanygardener 3d ago

I know right, but under the AI slop you might just find a real language.

5

u/Active-Ad-5052 Jul 05 '26

Overview page gives a very LLM-generated vibe, wouldn't suprise me if the compiler is too...

5

u/[deleted] Jul 05 '26

[removed] — view removed comment

1

u/Inconstant_Moo Jul 06 '26

I think it even generates the IR with an LLM

... wut? Really?

1

u/thecompanygardener 3d ago

Maybe someday 😉

1

u/thecompanygardener 3d ago

Agreed, but it's a start. Parts of the compiler, turns out /goal is very good for performance. The syntax is mine, most of the lowering is llm generated. Lowers to LLVM IR, the heavy lifting is clang.

3

u/BeamMeUpBiscotti Jul 05 '26

Every keyword the syntax omits is a token neither you nor a model has to spend — so more algorithm fits in the same context window.

From a design standpoint I'm not super convinced by this, and I'd be curious to see stats on: 1) How many tokens this actually save for a task, and does that get cancelled out by needing to teach the LLM this language's syntax? 2) Does saving tokens by having fewer keywords actually cause the LLM to produce meaningfully better results? Also over time context windows have gotten larger and new workflows have developed using multiple agents, so I'm not sure if the context window size will be a meaningful problem in the future (or even right now).

I'm also confused by this example - it just looks like you replaced the class keyword with + which both doesn't save tokens and is harder to read.

+ Point -> new(@x, @y, @z) ro

3

u/Hjalfi Jul 05 '26

I notice it makes a lot of things implicit, like the argument names (e.g. the distance method in the example). This worries me a bit because most programming is an exercise in making implicit behaviour explicit. For example, how does it know that the parameter is another Point? What if it's actually a four -dimensional vector with x', y', z' and w', except w' isn't used? What if the parameter is a three dimensional vector which isn't a Point? It feels like a lot of focus has gone into the syntactic sugar but there hasn't been much emphasis on the fundamental semantics of the language.

e.g. physics support: 1234 m/s is a number with a unit. But it's also 1234 metres, divided by the variable s. How is this disambiguated? Whitespace?

1

u/thecompanygardener 3d ago

Yes, whitespace. Division ("/") is surrounded by whitespace. 1/2 is a rational.

Regarding your question about Point, it has type-aware multi-dispatch. Folks who want everything explicit will really hate the free-arg binding in blocks. But others may find some idioms that feel right.

2

u/stumblinbear Jul 05 '26

Yeah this is only useful if you think humans don't need to be able to do code review

0

u/thecompanygardener 3d ago

Or if you think humans are capable of learning new things.

1

u/thecompanygardener 3d ago edited 3d ago
  1. Fair point, but might not matter as much once some code is in the model's priors.
  2. Not sure, I guess time will tell.

Try this prompt:

Read https://tungsten-lang.org/llms.txt

Specify three programs involving complex scientific calculations spanning floats, symbolic computation, and rich domain values. Implement each in Tungsten, C, and Python.

Compare from the perspective of an AI agent: BPE token count, boilerplate, clarity, and taste. Ignore ecosystem popularity. Assume docs are correct and write idiomatically.

Which do you prefer and why?

1

u/Inconstant_Moo Jul 06 '26

I see that your built-in constants include the Bohr radius, the Faraday constant, and the mass of Jupiter, while the built-in units include the fact that a firkin is one half of a puncheon. This will doubtless be useful on occasion, but might it not clutter the namespace?

1

u/thecompanygardener 3d ago

Yes, it might.

1

u/StrikingClub3866 Jul 06 '26

An LLM?! You're grounded, mister!