Live data from Hacker News

Tao: A statically-typed functional language

github.com

51–60 of 98 posts

Re: Tao: A statically-typed functional language

#51

Hey, author here. I definitely didn't expect to see Tao on Hacker News. As is probably obvious, the language is extremely early in its life, and it's not practical to write anything but trivial examples in it yet. Please don't judge!

> A rather dogged and obnoxious opinion of mine is that the 'optimisation ceiling' for statically-typed, total functional programming languages is significantly higher than traditional imperative languages with comparably weak type systems.

Curious about plans for this. When Haskell use exploded I followed a lot of the blogs talking about it someday being faster than C because purity made compiler reasoning easier and stream fusion and other things were going to change the world, but as time went on idiomatic Haskell never came even close to C. Now having a lot of performance experience I think a major factor is that functional languages insist on using lists for everything, which map poorly to hardware. Looking at your screenshots, it looks like it still employs the list paradigm.

Re: Tao: A statically-typed functional language

#52

Earlier quoted context omitted.

How so? I personally find dependant types to be very interesting, but I get that they are a PITA to implement. So, for me, it was simply an observation that there are currently no plans for dependant types. No value judgement intended.

Not to be pendantic, but I think you made a joke without realizing it.

I did? I have now spent like 20 minutes trying to figure it out. But I still don't get it.

Re: Tao: A statically-typed functional language

#53

Earlier quoted context omitted.

Not to be pendantic, but I think you made a joke without realizing it.

I did? I have now spent like 20 minutes trying to figure it out. But I still don't get it.

I'm guessing it has something to do with the keyword "either" and Haskell types, but I'm otherwise clueless. Every time I look at Haskell I run the other way.

Re: Tao: A statically-typed functional language

#56

Hey, author here. I definitely didn't expect to see Tao on Hacker News. As is probably obvious, the language is extremely early in its life, and it's not practical to write anything but trivial examples in it yet. Please don't judge!

> A rather dogged and obnoxious opinion of mine is that the 'optimisation ceiling' for statically-typed, total functional programming languages is significantly higher than traditional imperative languages with comparably weak type systems. Curious about plans for this. When Haskell use exploded I followed a lot of the blogs talking about it someday being faster than C because purity made compiler reasoning easier an…

So... I want to preface this by saying that I'm very, very far from being an expert on this topic. Although Tao's compiler has a MIR optimiser, it only covers the basics (inlining, constant folding + symbolic execution, etc.).

I think one of the main reasons that Haskell failed to solve this is actually the same reason that many lower level languages failed: it places too many requirements on data representation. In the case of C/C++ and even (to a lesser extent) modern languages like Rust and Swift, this is because they make promises about representation to the programmer that allow you to circumvent aspects of the language and still write correct code: be it transmutation, casting, field offsets, etc. In the case of Haskell, lists have an entirely arbitrary length and the language makes no effort to constrain this requirement in the type system, meaning that the compiler can only speculatively optimise a list into an unboxed array. In a language with dependent types, it should be possible to constrain the size of a list with the type system, allowing the optimiser to do its job without need for speculative whole-program analysis.

The other reason Haskell doesn't quite succeed is monomorphisation (or lack thereof). Haskell's support for first-class higher-ranked types means that the language can't feasibly make promises about monomorphisation, and as a result it needs to revert to boxing and dynamic dispatch far more than it really should. Conversely, Tao is designed to monomorphise in all cases from the start.

Rust demonstrates that functional programming (and in particular, programming with higher-order functions) is more than possible to optimise very well, and it does this by promising monomorphisation through the type system, allowing the compiler to aggressively perform static dispatch and inlining.

From what I've seen, GHC also fails to pick a lot of low-hanging fruit. The last time I checked (perhaps this has since changed) GHC often struggles with things like TCO and inlining in relatively simple cases as a byproduct of its design (all functions are dynamically dispatched by default, with inlining being a speculative optimisation).

I need to do a little more writing about exactly what ideas I have for Tao, but other languages of similar ilk demonstrate that Haskell is very far from the pinnacle of what is possible (for example, Koka's Perceus reference reuse: https://koka-lang.github.io/koka/doc/book.html#why-perceus).

Re: Tao: A statically-typed functional language

#57
post #7

Earlier quoted context omitted.

REPLs are often difficult to reconcile with AoT compilation and static analysis, particularly in the context of things like type inference (at least, in a way that preserves semantics). It's on my mental todo list, but not a priority for me.

How fast is the compiler? In many cases a report can just be syntactic sugar for compiling and running an accumulating log of source code lines. It’s not really important how it works under the hood as long as it’s mostly transparent to the user. As a side effect, it might also be a good way to keep your compile times down.

What if one of those lines fires the missiles?

Re: Tao: A statically-typed functional language

#58
post #7

Earlier quoted context omitted.

REPLs are often difficult to reconcile with AoT compilation and static analysis, particularly in the context of things like type inference (at least, in a way that preserves semantics). It's on my mental todo list, but not a priority for me.

How fast is the compiler? In many cases a report can just be syntactic sugar for compiling and running an accumulating log of source code lines. It’s not really important how it works under the hood as long as it’s mostly transparent to the user. As a side effect, it might also be a good way to keep your compile times down.

That's not even close to being adequate for the kinds of things good REPLs are good for.

Re: Tao: A statically-typed functional language

#59
> Totality

Best of luck. Dhall is a current language with totality, but it runs into impossibly high memory requirements as a result. We had CI workers with 16 GB RAM run into out-of-memory issues because of the sheer size of the totally expanded type space (sum types of types which are themselves sum types of types which are themselves sum types etc... Exponential growth is easy).

I appreciate that this is scoped as a hobby project for now, not recommended for production, so like I said, best of luck :)

Re: Tao: A statically-typed functional language

#60
post #7

Hardly ever is "good REPL" one of the features of these new languages. Do they think it's irrelevant or is making such a thing too difficult compared to all these more CSy features?

REPLs are often difficult to reconcile with AoT compilation and static analysis, particularly in the context of things like type inference (at least, in a way that preserves semantics). It's on my mental todo list, but not a priority for me.

Do you suppose that might be an outmoded historical bias? I'm wondering if maybe the advancement of hardware has made it so that the costs of AOT compilation and a type system should no longer stand in the way of delivering a reasonable REPL experience. Swift's "playgrounds" seems to do alright — a real outlier in this regard.
Post reply on HN