23 votes

The Ante programming language

18 comments

  1. [8]
    rndmprsn
    Link
    I have been working on this project for a few years now and would like some feedback towards the direction of the project. Note that the website details the language itself rather than the subset...

    I have been working on this project for a few years now and would like some feedback towards the direction of the project. Note that the website details the language itself rather than the subset that is implemented in the current compiler.

    Ante is a statically and strongly typed, compiled language that compiles to low level code. The most important principle of the language is that it should be, first and foremost, extensible. I have taken inspiration from various lisps (mostly racket) but in my opinion they do not go far enough. You should not have to switch languages just because you want a garbage collector and you should not have to switch if you want an ownership or lexical lifetime system. In fact, I would not be satisfied if there was anything you have to switch languages for.

    Ante's primary feature is its use of compile time execution to also interface with the compiler as a library and allow compiler extensions to be made within the program itself. This allows for programming your own optimization passes, implementing ownership semantics, extending the type system, etc.

    The language itself takes a mostly ML inspired syntax with significant indentation, somewhat similar to f#. The majority of time spent programming is reading code, not writing it, so I wanted it to be easily readable and approachable to new programmers.

    13 votes
    1. [2]
      Comment deleted by author
      Link Parent
      1. rndmprsn
        Link Parent
        One of the advantages of Ante is that it does not need to be a low level language. If you do not want to bother with memory management you can just import GC and get a garbage collector. You are...

        One of the advantages of Ante is that it does not need to be a low level language. If you do not want to bother with memory management you can just import GC and get a garbage collector. You are free to program in a style as high level as python or haskell if you wish.

        This language is a general purpose programming language so the applications made with it can vary like most languages. That being said, because the language itself can go as low or high level as needed it (imo) makes it a good language for game development since you can tightly optimize inner loops while also having other parts of the codebase be written in an easily understood high-level style.

        10 votes
    2. [2]
      panic
      Link Parent
      I think you should put this paragraph right at the top of the page! I wasn't sure what made Ante different from other programming languages just by looking at the site. It would also be cool see...

      Ante's primary feature is its use of compile time execution to also interface with the compiler as a library and allow compiler extensions to be made within the program itself. This allows for programming your own optimization passes, implementing ownership semantics, extending the type system, etc.

      I think you should put this paragraph right at the top of the page! I wasn't sure what made Ante different from other programming languages just by looking at the site. It would also be cool see more examples of this compile-time metaprogramming in action.

      4 votes
      1. rndmprsn
        Link Parent
        Thank you, I guess I tried to make the description at the top of the site a bit too brief. I'll definitely try to merge in that paragraph too. I realized the website does cover a lot of features...

        Thank you, I guess I tried to make the description at the top of the site a bit too brief. I'll definitely try to merge in that paragraph too. I realized the website does cover a lot of features in the language but fails to mention that almost all of them are just library implementations using the compile time api. The module system, build system, and gradual memory management are all built on the API yet are given the same amount of attention in the features list than the "extensible" feature.

        1 vote
    3. [3]
      wervenyt
      Link Parent
      As a pretty green programmer with a bit of a fetish for ML-ish languages, this looks pretty cool to me. My big thing is: why would I use this over Rust? It doesn't have any safety guarantees...

      As a pretty green programmer with a bit of a fetish for ML-ish languages, this looks pretty cool to me. My big thing is: why would I use this over Rust? It doesn't have any safety guarantees beyond those normally found in strongly typed languages, and I don't see any strong examples of its metaprogrammability from a cursory glance of the site. That being said, I want to like it a lot, and I like its design philosophy.

      2 votes
      1. [2]
        rndmprsn
        Link Parent
        Rust is inherently inflexible, like how GC'd languages limit themselves to only be usable with a garbage collector, rust is limited in that it can only be used with its ownership system which is...

        Rust is inherently inflexible, like how GC'd languages limit themselves to only be usable with a garbage collector, rust is limited in that it can only be used with its ownership system which is not always preferable for all types of work. For Ante, you can choose between having a GC, ownership semantics, manual deallocation, etc. If you import Ownership a variety of compile time functions are included that implement ownership guarentees by tracing lifetimes (and defining a way to manually set them when needed).

        If you want a stronger metaprogramming example, there is the example on github where goto is implemented by directly inserting into the LLVM IR:

        //The 'ante' keyword declares compile-time values
        ante
            global mut labels = Map.init Str LLVM.BasicBlock
        
            fun goto: VarNode vn
                let label = labels.lookup vn.name ?
                    None -> Ante.error "Cannot goto undefined label ${vn}"
        
                LLVM.setInsertPoint <| getCallSiteBlock ()
                LLVM.createBr label
        
            fun label: VarNode vn
                let ctxt = Ante.llvm_ctxt
                let callingFn = getParentFn <| getCallSiteBlock ()
                let lbl = LLVM.BasicBlock ctxt callingFn
                labels#vn.name = lbl
        
        //test it out
        label begin
        print "hello!"
        goto begin
        

        If you want further examples there are some at http://antelang.org/docs/compiler-directives/
        but the API is very much still changing.

        5 votes
        1. wervenyt
          Link Parent
          Well, that makes sense. Thanks for explaining! I'll definitely keep tabs on Ante then, and might toy around with it.

          Well, that makes sense. Thanks for explaining! I'll definitely keep tabs on Ante then, and might toy around with it.

    4. joelthelion
      Link Parent
      I think your design goals are really nice. If it existed, I think I would use it. The question is whether you can pull it off :)

      I think your design goals are really nice. If it existed, I think I would use it. The question is whether you can pull it off :)

  2. [2]
    dodger
    Link
    You had me at "integrated build system". Can't wait to try this. Planning to create an official docker image or vscode/other ide plugins?

    You had me at "integrated build system". Can't wait to try this. Planning to create an official docker image or vscode/other ide plugins?

    4 votes
    1. rndmprsn
      Link Parent
      There is already a Dockerfile on the master branch. Ante has sublime text 3 (maybe 2 as well, but I only tested with 3) plugin, as well as a vim plugin. In the future there will be plugins for...

      There is already a Dockerfile on the master branch. Ante has sublime text 3 (maybe 2 as well, but I only tested with 3) plugin, as well as a vim plugin. In the future there will be plugins for other ides/text editors but I prioritized the ones I use atm. As for the integrated build system, its API is mostly stabilized (it is based off of the tup build system) but it is still unimplemented. I originally planned for it to use compile-time features but I'm questioning if that is even needed if you already have a dedicated build.an file. For now, the ante compiler can compile all ante code with a single ante file.an but for multiple languages a traditional build system is still needed.

  3. 666
    Link
    This seems like what Rust tried to be, but with the added bonus of some nice features Haskell has and a garbage collector. My initial reaction (reading the website and build instructions) is that...

    This seems like what Rust tried to be, but with the added bonus of some nice features Haskell has and a garbage collector. My initial reaction (reading the website and build instructions) is that I like it, but I haven't been programming much recently and I'm not sure when I'm going to give it a try.

    1 vote
  4. [3]
    jgb
    Link
    This is really nice. It's got a lot of the sorts of ideas that have gotten me excited about JAI, but the terse and functional flavour is also really nice in its own right. fn is clearly a better...

    This is really nice. It's got a lot of the sorts of ideas that have gotten me excited about JAI, but the terse and functional flavour is also really nice in its own right. fn is clearly a better keyword than fun but that's about my only gripe.

    1 vote
    1. [2]
      rndmprsn
      Link Parent
      My reasoning for fun instead of fn or other keyword is that fun abides by the 3 character rule. ie. if you have an indentation level of 4 then your code will be aligned with the function name...

      My reasoning for fun instead of fn or other keyword is that fun abides by the 3 character rule. ie. if you have an indentation level of 4 then your code will be aligned with the function name after fun:

      fun show_usage:
          print "usage: bf <file>"
          print "     | bf -e <program>"
      

      I also like the idea of more functions = more fun but I can see that being a bit on the nose. fun is originally from OCaml's lambda syntax but Ante just uses it for all functions instead of just lambdas. Why do you prefer fn if I may ask?

      1 vote
      1. jgb
        Link Parent
        No reason - it's purely a matter of taste. I mostly mentioned it as a tongue in cheek way to express how impressed I am by the language!

        Why do you prefer fn if I may ask?

        No reason - it's purely a matter of taste. I mostly mentioned it as a tongue in cheek way to express how impressed I am by the language!

        2 votes
  5. [4]
    moredhel
    Link
    Hi, this is a really interesting language, I really like it. The source code seems pretty minimal too which makes it much more manageable. Are you interested in doing any sort of formal...

    Hi, this is a really interesting language, I really like it. The source code seems pretty minimal too which makes it much more manageable.

    Are you interested in doing any sort of formal verification on the semantics of your language? I haven't looked into how powerful the compiler API is, so it may not allow for this.

    Secondly, have you had a think about dependency management? Have you thought about writing your own tool, or are you going to piggyback on something else?

    Thanks for sharing!

    1 vote
    1. [3]
      rndmprsn
      Link Parent
      I am not the most knowledgeable in formal verification but I think it could be used to prove certain semantics in the base language at least. Once you add in some of the compiler's api being very...

      I am not the most knowledgeable in formal verification but I think it could be used to prove certain semantics in the base language at least. Once you add in some of the compiler's api being very unsafe or unfriendly to verification (changing the type system, inserting directly into LLVM IR, ...), I dont think you would be able to make too many guarentees but again I could be wrong.

      Dependency management in regard to Ante's integrated build system is a "new" api but the actual dependency management is based on the tup build system. In short, each file and command is a node in the DAG. A key feature I like about tup's approach is that it detects the dependencies of a command by examining which files are opened by the process, thus ensuring you never forget a dependency.

      If you are just compiling pure Ante (or Ante & C/C++ headers) you will not need the build system at all as it is taken care of by Ante's module system.

      1 vote
      1. [2]
        moredhel
        Link Parent
        Thanks for the info, I hadn't heard of the tup system before. Yeah, it would be difficult to write code that can be formally verified if one can hook into the compiler. Regarding dependency...

        Thanks for the info, I hadn't heard of the tup system before.

        Yeah, it would be difficult to write code that can be formally verified if one can hook into the compiler.

        Regarding dependency management, I was thinking more along the lines of 3rd-party libraries (similar to pip/npm). Do you have an idea about this, or are you not at that stage yet?

        1. rndmprsn
          Link Parent
          I am not really at that stage yet but package management will hopefully be integrated into the build system as well. For some reason I never like having to use a markup language to list...

          I am not really at that stage yet but package management will hopefully be integrated into the build system as well. For some reason I never like having to use a markup language to list dependencies so it will most likely be an ante library as well, most likely under the name Package. I am also looking in to having an automatic semantic versioning system in the package manager like elm does although nothing is set in stone at this point.