gosukiwi / Blueberry

A beautiful programming language with clean syntax which compiles to PHP
MIT License
63 stars 10 forks source link

This should probably be written in Blueberry or PHP #10

Closed hikari-no-yume closed 9 years ago

hikari-no-yume commented 10 years ago

If it's written in Blueberry, it means there's a non-trivial program written in the language, and it may force language improvement as it would help discover deficiencies. But even PHP would be better than JavaScript, really.

gosukiwi commented 10 years ago

That's actually an interesting approach! I use Javascript because there are a lot of parsers out there like PEG.js and Jison, if I knew a good PHP parser I could interop with Blueberry then I'd love to try that out.

hikari-no-yume commented 10 years ago

Ah, that makes sense. Unfortunately there doesn't seem to be much available, going by this: http://stackoverflow.com/questions/1003923/flex-bison-like-functionality-within-php

Of those options, LIME seems the best. The version on SourceForge hasn't been worked on since 2008, but 2 years ago someone tried to update it: https://github.com/rvanvelzen/lime

gosukiwi commented 10 years ago

Yeah, as far as I know those are the only options. Javascript also makes it easy to integrate with npm and grunt/gulp if it ever get's out of just beta state, so it seems like a not-so-bad option at the moment.

worksofliam commented 10 years ago

gosukiwi, not sure if I am staying on topic but what are you opinions on me writing a 'compiler' in a different language that uses the same syntax as Blueberry?

gosukiwi commented 10 years ago

I wouldn't mind that, I'd like to see it actually! I'm just wondering what language you'll use to write the compiler and whether or not it will also compile to PHP :stuck_out_tongue:

worksofliam commented 10 years ago

Well, either Java or C# - you can decide actually. :)

The intention is that you write Blueberry, my interpreter then compiles it to PHP.

hikari-no-yume commented 10 years ago

What's the benefit of writing it in Java or C#, though? What's wrong with the existing compiler? I realise you probably just want to write a compiler for something, and that's entirely reasonable, but I suggest choosing something else.

worksofliam commented 10 years ago

Difference being Java and C# is compiled themselves, whereas JavaScript isn't.

There is nothing wrong with what you're doing at all, but writing a interpreter in a scripting language.. some may find is odd due to efficiency, performance, etc. Imagine writing a 'compiler'/interpreter in PHP for JS.. just seems crazy to write something like this in a scripting language.

I was just wondering if writing it in a compiled language is something that @gosukiwi thought about before he decided to write in JS, even though it is quite cool.

hikari-no-yume commented 10 years ago

JavaScript is compiled, just at a later stage in the browser.

Imagine writing a 'compiler'/interpreter in PHP for JS.. just seems crazy to write something like this in a scripting language.

Why? It's not a performance-critical application, and "scripting" languages aren't in any way inferior to "compiled" languages, and they have many advantages over them. Plus, compiled languages aren't necessarily faster in all cases.

gosukiwi commented 10 years ago

Blueberry is a compiler, it compiles Blueberry source code to PHP. The compiler is written in Javascript and uses node. It might be slower than a C/Java/C# compiler, but it gets the job done, it's not like it takes 5 seconds to compile a file, the compile time is actually quite decent. There are a lot of compilers already written in Javascript, like Less, and CoffeeScript (although this might be in Coffeescript by now).

I don't think performance is a relevant point about it beeing in Javascript. One might argue the language itself is weird and hard to mantain, but that's another topic.

If you want to write a compiler which takes Blueberry source code and translates it to PHP feel free to do it, but if your motives are that Javascript is slow you might want to reconsider. If you are just doing it as an exercise then feel free :)

worksofliam commented 10 years ago

JavaScript is compiled

Yes, eventually. The code is ran 'interpreted multiple times' before being compiled in most JS engines.

compiled languages aren't necessarily faster in all cases.

This is also somewhat.. true.. sometimes. But in most cases you'll find that compiled is quicker, for obvious reasons.

I wasn't hear to start an argument about compilers.. I was just hear to ask @gosukiwi's opinion on me writing a compiler/interpreter - not 'take down this and rewrite in a compiled language'

gosukiwi commented 10 years ago

Feel free to write a compiler if you want, I'd like to see it! I was just wondering why, that's all. If all you want is the same compiler but a bit faster, my point was that it might not be worth, but still, it's a very good exercise and you are free to do it if you want to :smile: