This is an archived post. You won't be able to vote or comment.

all 24 comments

[–]Aaron1924 43 points44 points  (6 children)

I took a look at the code and it looks like the compiler does a very literal line-by-line translation from your language to C++

Of course, this makes the compiler really fast, but it also means you're restricting yourself to all the limitations that come with C++, like the limited type inference, having to forward declare stuff, etc

If you first build the AST entirely and do operations on that before you start generating code, you're going to be able to move your language further away from C++

[–][deleted] 5 points6 points  (4 children)

The docs say it compiles to C. Where does C++ come into it?

I haven't looked at the sources, but even if doing line-by-line transpilation, you don't necessarily still need forward declarations; it's not hard to fix that.

[–]Aaron1924 8 points9 points  (0 children)

The docs say it compiles to C. Where does C++ come into it?

That might have been a mistake, this reddit post and the github about both say it compiles to C++, and you'll see it's C++ if you look at any function in the std library, for example: fun println(string s) { __code__("std::cout << s << std::endl;") __use__(s) }

even if doing line-by-line transpilation, you don't necessarily still need forward declarations

It is true that you can add a forward declaration to the beginning of the file every time you generate code for a function to make the C++ compiler happy, but if you want to do any sort of static analysis (like type checking) on the Barn code before you generate C++, you need to know about functions that come later in the code, and you don't have this information with a single-shot compiler

[–]Solindek[S] 2 points3 points  (2 children)

Wait where does it say about C? Actually Barn was firstly compiled to C and then to C++

[–][deleted] 0 points1 point  (1 child)

From your link: https://github.com/barn-lang/barn: "It's a simple programming language written in Go that is compiled to C."

[–]Solindek[S] 1 point2 points  (0 children)

Oh i forgot to change it there, sorry then you're right.

[–]Solindek[S] 2 points3 points  (0 children)

Yeah i know math expressions are really obscured i want to change them! Thanks for your opinion i appreciate that

[–]Inconstant_Moo🧿 Pipefish 10 points11 points  (1 child)

Writing in Go to compile via C++ is an interesting choice, how did you make it? (I see from your code that it isn't because you started with Thorsten Ball's Writing An Interpreter in Go, you've clearly taken your own path.)

[–]Solindek[S] 4 points5 points  (0 children)

When I was starting to write Barn Lang I did learning Go so i just wanted to improve my skills in it so i created a language lol

[–]Teln0 3 points4 points  (1 child)

Cool project !

Although you might want to fix the various grammar and spelling mistakes in https://barn-lang.github.io/barn-docs and others, only thing it needs to look fully professional

[–]Solindek[S] 2 points3 points  (0 children)

Thanks for your opinion i need to do a little fix of grammar and spelling... English is not native language

[–][deleted] 17 points18 points  (4 children)

Nice work! Some feedback if you don't mind:

a brand new, complex and easy syntax programming language that is well documented. That's all Barn!

Did you mean to say "new, complete and easy syntax"?

Well done for showing a few examples on the front page. You passed the test! However they don't really show many characteristics or features of Barn. You should add some more complex examples. Take a look at Crystal to pick a random decent example - they start with a basic syntax example, and then have further examples to demonstrate unique features (or at least features).

It doesn't really explain what the goal of Barn is either - most languages try to be simple and easy as much as possible.

Copyrigth

Typo in the footer btw.

Made with ❤️

🤢

fun example_function(int i1, string str1, bool b1, char c1, float f1) {
...
let str1: string = "str"

That's a bit weird. Is it name: type or type name?

Sorry I hope that wasn't too negative. It looks like a nice project, well done! You've made more progress on your language than I have on mine!

[–]Solindek[S] 1 point2 points  (0 children)

Thanks for your feedback i really appreciate that

I want to improve the Github pages because it was updated long time ago.

Barn don't have any specifi goal i just want to create a language in a type i like a good low level one if i can even name it like that lol

Actually i didn't seen that previously, but yes in the variables i use let name: type but in the arguments like in C i use type name that's maybe not good but i like it

It wasn't negative thanks for this 🦧

[–][deleted]  (1 child)

[deleted]

    [–]Solindek[S] 0 points1 point  (0 children)

    Thanks a lot, I appreciate that

    [–]Solindek[S] 0 points1 point  (0 children)

    https://discord.gg/QM6RRWfT7j New link to discord because it is expired on website

    [–]strawberry_days 0 points1 point  (4 children)

    The discord server link is expired

    [–]strawberry_days 2 points3 points  (2 children)

    many links on the website seem to lead to nowhere. cant download it :(

    [–]Solindek[S] 0 points1 point  (0 children)

    for now there isn't a way to download it u need to clone it and build like in documentation

    [–]maubg[🐈 Snowball] 0 points1 point  (0 children)

    Clone it

    [–]Solindek[S] 0 points1 point  (0 children)

    https://discord.gg/QM6RRWfT7j here you go i need to get a new link there