Live data from Hacker News

Ante: A low-level functional language

antelang.org

211–220 of 226 posts

Re: Ante: A low-level functional language

#211

Earlier quoted context omitted.

> (f x) and f(x) have the same number of parenthesis. That's the joke

I have heard that if you count { and ( as parens, a Java program for example has just as many parens as. lisp one. A lisp paren can do both jobs: expression and scopes.

That's obviously nonsense.

Java, one pair of parens:

    int x = 1;
    int y = x + 1;
    System.out.println(y);

Clojure, six pairs of brackets:

    (let [x 1 y (+ x 1)] ((. (. System out) println) y))

Re: Ante: A low-level functional language

#212
post #211

Earlier quoted context omitted.

I have heard that if you count { and ( as parens, a Java program for example has just as many parens as. lisp one. A lisp paren can do both jobs: expression and scopes.

That's obviously nonsense. Java, one pair of parens: int x = 1; int y = x + 1; System.out.println(y); Clojure, six pairs of brackets: (let [x 1 y (+ x 1)] ((. (. System out) println) y))

[deleted]

Re: Ante: A low-level functional language

#213

Earlier quoted context omitted.

Very neat project! I noticed that Ante doesn’t have explicit region type declarations. As I recall, existing algorithms implemented for ML can sometimes infer very large regions which causes memory usage to balloon. It looks like smart pointers are part of the plan to address that possibility, but I’d love to hear more about your thoughts on memory management.

Correct, a key goal is to have no explicit region/lifetime annotations. There have been several papers on region inference after the originals by Tofte & Taplin, all attempting to refine the original analysis by inferring shorter lifetimes. First by analyzing when a region can be safely emptied and re-used, then by abandoning the stack discipline, etc. Unfortunately, none of these are viable in a real program in my o…

I maintain a JIT compiler for a very high performance Haskell like functional programming language. The compiler automatically generates the minimum malloc/free calls, mirroring the hand written code of an experienced C programmer. It works really well and the generated machine code was shown to be faster than hand-written optimised C++ code that people had been maintaining for years. The compiler code is unfortunately closed source and I have zero interest in writing academic papers so I wont elaborate further. Just telling you to hint hint perhaps try something like that :) The execution flow analyser was a b** to get right but worth it. I also recommend checking out some of the recent LEAN 4 papers. Some of those papers are moving in the right direction.

Re: Ante: A low-level functional language

#214

Functional is always at odds with low level programming because of heap allocation. You can't control it because of immutability. Just a simple map operation does a heap allocation. How does Ante avoid this problem and give the user control of the heap? The mechanism should be made clear in the introduction as browsing the documentation doesn't make it clear to me.

The plan is to give users control through the Allocate effect which can be handled in any way desired as long as it returns some memory. It is similar, but easier to use since it is an effect, to zig's approach of "pass the allocator everywhere." I say easier to use since effects are automatically passed around where necessary and propagated via function signatures and can be inferred. The specific design is still in…

Here the `Allocate` effect is just a syntactically-lightweight way of doing dependency injection, right? Similar to a Haskell type class. I don't see why you'd need to make it an algebraic effect, as it does not need to mess with control flow AFAIK.

Re: Ante: A low-level functional language

#216
post #180

Earlier quoted context omitted.

The generally accepted definition of a low level language is a language that provides little or no abstraction from a computer's instruction set architecture. In actuality, C is a lower level functional programming language than Ante, because C functions are first-class citizens. I like the lack of GC! What is the method for always incremental compilation? The benefits are obvious, but isn't it problematic to have tw…

Eh, isn't it a bit of a stretch to claim you can program functionally in C? You can mimic it, but without easy closures you can't follow _any_ functional programming patterns that are built on composing functions into new ones in expressions (e.g. binding the operation argument to a fold) C is great, and it would be cool to see something that is similarly close to the instruction set but has functions as values

There is a book about it [0], you can download it here [1]. It uses SML to teach FP. I did the exercises on the train in Termux and Vim.

[0] https://www.semanticscholar.org/paper/Functional-C-Hartel-Mu...

[1] https://ris.utwente.nl/ws/portalfiles/portal/5128727/book.pd...

(edit) add download link and background.

Re: Ante: A low-level functional language

#217

Earlier quoted context omitted.

There is a group of programming language enthusiasts that would be interested in all sorts of languages. Then there are people who will criticize just about anything for the sake of doing it. Just ignore those people and make a day more interesting for the people who share your passions.

That is the argument that has been made by my few friends who are interested in PLT as well. The other option I’ve considered if starting a blog or similar (although my son keeps suggesting a YouTube channel) and doing a longer series of posts concerning the language, type theory, and category theory inspirations present in the semantics of the language. I would love to imagine I could be the next Andrew Kelly (creat…

> I don’t know that I can actually be a language founder.

You will only know if you try. Things that are worth it take courage me thinks.

Re: Ante: A low-level functional language

#218

Earlier quoted context omitted.

If fn 1 is an allowed function call syntax then fn (1) should be synonymous because 1 is expected to be the same as (1) except for a slightly different parse tree; but there might be good reasons to make fn 1 not a function call (for example, the implicit operator in a sequence of two expression without parentheses could be string concatenation rather than function application).

> the implicit operator in a sequence of two expression without parentheses could be string concatenation rather than function application You can design a language which uses `e1 e2` to represent any binary operation you like, but I'd argue that function application is more common than string concatenation, so it's more deserving of that syntax. Plus, it plays nicely with currying.

I’ve sometimes thought that a reasonable alternate choice would be:

  f g = composition of f then g
  x.f = f applied to x
  x.f g h = in regular notation h(g(f(x))
Though slightly different precedence rules may be preferable.

I think the k in awk considered juxtaposition-as-string-concatenation to have been a mistake by the way.

Some other reasonable choices may be:

- disallowed syntax

- multiplication (which, for matrices, is a special case of function composition and application)

- inner join which can be seen a bit like function composition but for relations instead of functions

- sequencing (ie instead of ‘;’)

Re: Ante: A low-level functional language

#219

Earlier quoted context omitted.

> the implicit operator in a sequence of two expression without parentheses could be string concatenation rather than function application You can design a language which uses `e1 e2` to represent any binary operation you like, but I'd argue that function application is more common than string concatenation, so it's more deserving of that syntax. Plus, it plays nicely with currying.

I’ve sometimes thought that a reasonable alternate choice would be: f g = composition of f then g x.f = f applied to x x.f g h = in regular notation h(g(f(x)) Though slightly different precedence rules may be preferable. I think the k in awk considered juxtaposition-as-string-concatenation to have been a mistake by the way. Some other reasonable choices may be: - disallowed syntax - multiplication (which, for matrice…

That's an interesting idea, but how does it work for functions of multiple arguments?

If functions are curried, then I suppose the syntax for `f x y` would be `y.(x.f)`, which maybe you could write as `y.x.f` if the associativity worked as such. But that means you have to provide your arguments in reverse order?

If functions are not curried, do you write `(x, y).f`?

Re: Ante: A low-level functional language

#220
post #204

Earlier quoted context omitted.

There seems little value in "exposing" crap we would be better off not building in the first place. The more expressive your language is, the less the runtime and hardware needs to guess about.

So what are the $%^&* semantics we're supposed to build into the language to avoid the need for speculation via OOO exec and branch prediction. Because as a guy interested in languages you might have something to teach me, assuming you have any idea what you're talking about.

Language design is hard.
Post reply on HN