
Show HN: PuffinBASIC – A cross-platform modern BASIC interpreter written in Java - srivastm
GitHub: <a href="https:&#x2F;&#x2F;github.com&#x2F;mayuropensource&#x2F;PuffinBASIC" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;mayuropensource&#x2F;PuffinBASIC</a><p>BASIC (Beginners&#x27; All-purpose Symbolic Instruction Code) is a general-purpose high-level language from the 1960s. PuffinBASIC is an implementation of the BASIC language specification. PuffinBASIC conforms most closely to GWBASIC.<p>The purpose of this implementation is to learn how to write interpreters and resurrect an old programming language to work in modern ecosystem.<p>The interpreter is evolving fast and in near future, I wish to apply modern interpreter building techniques to it.<p>How it works?
1. PuffinBASIC&#x27;s grammar is defined using antlr4.
2. At runtime, the user source code is parsed using antlr4 lexer+parser.
3. After parsing, an intermediate representation (IR) of the source code is generated. A symbol table keeps track of variables, scalars, arrays, etc. objects.
4. A runtime, processes the IR instructions and executes them.<p>Performance
PuffinBASIC is an interpreter, and it should not be expected to have very good performance characteristics. Certain operations such as PRINT USING, INPUT, etc. are not optimized for performance. I have not benchmarked PuffinBASIC primitives. That being said, we have written games with graphics in PuffinBASIC is work very well.<p>TESSEL - A 2D Tile Game written in PuffinBASIC
Source: <a href="https:&#x2F;&#x2F;github.com&#x2F;mayuropensource&#x2F;PuffinBASIC&#x2F;blob&#x2F;master&#x2F;samples&#x2F;tessel&#x2F;tessel.bas" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;mayuropensource&#x2F;PuffinBASIC&#x2F;blob&#x2F;master&#x2F;s...</a>
Link to YouTube video demo: <a href="https:&#x2F;&#x2F;youtu.be&#x2F;L8xkM-g3Zms" rel="nofollow">https:&#x2F;&#x2F;youtu.be&#x2F;L8xkM-g3Zms</a><p>Memory
PuffinBASIC runs within a JVM and can use as much memory as available for the JVM process.<p>Compatibility
PuffinBASIC is mostly compatible with Microsoft&#x27;s GWBASIC. Graphics is supported using Java 2D graphics. PuffinBASIC will not support assembly instructions.<p>Data Types
PuffinBASIC has extended BASIC types and supports Int32, Int4, Float32, Float64, and String.<p>Reference: <a href="https:&#x2F;&#x2F;github.com&#x2F;mayuropensource&#x2F;PuffinBASIC" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;mayuropensource&#x2F;PuffinBASIC</a>
======
pavlov
I'm curious why you chose to extend GW-BASIC specifically? Out of the
Microsoft BASIC dialects, QBasic would probably be familiar to a much larger
audience, and is a substantially more modern language.

~~~
srivastm
I learned gwbasic as my first programming language in 90s. After that I
switched to C. So, I never made the transition to qbasic. The main reasons for
this choice are love and familiarity. Now, that I look back at the language, I
would clearly make a lots of changes to it. May be, the next language I
implement will be much more modern!

~~~
pavlov
_" The main reasons for this choice are love and familiarity."_

That is indeed a fundamentally great reason to embark on a project. Congrats
and best of luck!

------
jcadam
Cool. Now we just need LOGO on the JVM and I can fully relive my childhood
coding days.

~~~
srivastm
LOGO is very easy to implement. My son loves secret coders books and they are
full of turtle graphics code. I myself never used logo. If I get more spare
time, I will go for it.

------
earthboundkid
I don't think BASIC is good as teaching language, and it's certainly no good
as a practical language, so who is this for? Hobbyists, maybe, but then why
not use PICO8 or something similar?

~~~
jrm4
Could be because I'm old and it's what I started with, but I can't see how
BASIC _isn 't_ a great beginner language -- especially with regard to going
from "0 to working code."

10 PRINT "John is awesome"

20 GOTO 10

..and now you've shown a child the power of complete control as well as the
concept of infinity. I have not seen a _remotely_ comparable demonstration for
getting someone excited about programming in any other language.

~~~
earthboundkid
I started in BASIC in the 80s. The olden days sucked!

\- No good manuals! I lived in the sticks and had little access to the
library. All I could do was flip through the GW-BASIC reference book. It
sucked!

\- Teaches bad habits. It took me years before I realized I was a bad
programmer and was doing everything wrong!

\- Not as powerful as a modern system. Modern stuff lets you easily sprites on
the screen. That's 99.9% of what kids want to do! You can do a lot more, a lot
more quickly with modern educational languages.

There are still big issues with distribution, but all things equal, it's way
better to be a kid learning a modern language today than a kid learning BASIC
in the 80s.

~~~
srivastm
I worked on gwbasic in early 90s and I turned lack of Docs/resources to my
advantage. I used to spend time thinking about different ways to solve a
problem. Basic does teach some bad habits, but it also teaches basic control
structures, debugging skills and problem solving. Later, when I switched to
C/Java/C++, the old programming habits changed quickly. In modern times, I
would recommend Python as a beginner’s language.

------
tjalfi
Have you considered submitting this to Show HN instead of Ask?

You can email hn@ycombinator.com and ask dang to change the title.

~~~
srivastm
I wasn’t aware if this. I will do. Thanks!

------
tuatoru
> Data Types PuffinBASIC has extended BASIC types and supports Int32, Int4,
> Float32, Float64, and String.

That's hardly "extended". Where are decimals, arbitrary precision numbers,
dates, datetimes, lists/sets/stacks, dictionaries, structured types,
enumerated types? Let alone advanced types.

~~~
srivastm
I am comparing with gwbasic types which was limited to in16, float, double and
string. The only type from gwbasic I did not implement is decimal. This is an
active project and I plan to add dict/set types soon. I may also add decimal
type. Stay tuned. I don’t plan to add complex types in PuffinBASIC. If I do
another language, then I might add these.

~~~
srivastm
Btw, I totally agree with you. I should have said a minor improvement to
gwbasic data types. Your comments made me also think about adding a few data
types, specially decimal, dict and set.

