Re:BaCon – BASIC to C converter
by marktangotango on Sunday January 29, 2017 @10:45AM
(#13514583)
I was curious to see what 'type' of BASIC this project translates, turns out it implements it's own version of BASIC similar to qbasic. It's essentially a thin veneer over C with arrays, records, and dictionaries. It allow dynamic memory allocation. I've often pondered what the minimal BASIC would consist of, and this implementation hits all the things I'd expect: subroutines, functions, records, arrays, dictionaries.
I didn't see anything in the documentation about garbage collection and reference counting. The language has the ability to return arrays from functions, but the arrays are required to declared static. How is this different from just declaring a global array? How does the language prevent memory leaks with strings and arrays?
Re:BaCon – BASIC to C converter
by nothrabannosir on Sunday January 29, 2017 @09:56AM
(#13514357)
Wow that alone is perhaps even more impressive than what the program actually does... I thought I knew bash but just wow. Compatible with 5 different shells, too. This is some next level enlightened zen master stuff.
Re:BaCon – BASIC to C converter
by chx on Sunday January 29, 2017 @01:23PM
(#13515697)
Don't get too carried away, it's written for ksh and relies on bash and zsh to be compatible with ksh. You can see in the beginning it does a tiny bit of setup and never cares again which shell it runs on. For zsh, it literally says "emulate ksh" which is something zsh provides.
Re:BaCon – BASIC to C converter
by lf-non on Sunday January 29, 2017 @12:36PM
(#13515347)
I am very curious what is the target audience for this project ?
Given its long history (dating back to 2011) it does not look like just an experiment or hobby project. I would have assumed it to be a solution for porting legacy programs but it implements a custom basic dialect so that is largely out of question.
Is it intended to be a solution for rapidly prototyping performant systems applications ?
Re:BaCon – BASIC to C converter
by versteegen on Tuesday January 31, 2017 @03:53AM
(#13528872)
I've seen a lot of BASIC-to-C converters, inspected the source code for a number of them (the transpilers, not the output), and almost universally been disappointed at their poor quality, which I decided I couldn't trust for a real project. This one however, looks like real software engineering went into it (see eg http://basic-converter.org/String_optimization.html), even if the code is... well, it's shell script which looks an awful lot like perl, real arcane magic.
I didn't see anything in the documentation about garbage collection and reference counting. The language has the ability to return arrays from functions, but the arrays are required to declared static. How is this different from just declaring a global array? How does the language prevent memory leaks with strings and arrays?
[0] https://github.com/kanaka/mal/tree/master/bash