Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I've finally begun to understand the complexity behind creating an interpreter and a compiler. I've built several versions of TinyBasic, 1964 (Dartmouth) Basic, and my own expansions on those languages before getting to this point. The most recent project is one I call Open Source Basic... because I could think of no other features of the language that would interest people. To be able to open up the source of the language and understand how some complex things are done (how scanning, parsing, interpreting, and compiling are done)

Open Source Basic is first interpreted into a stack based language. That stack based language is then interpreted and executed immediately or turned into a CLR executable.

My questions all boil down to this:

  • What are the basic features/constructs of a Basic-based language? I have these basic constructs already: Assignments, Expressions, Variables, some functions (Random, ToUpper, ToLower), Looping (for and do-while/until), If (block and single-line) Else decisions, console based input (Input) and output (Print), and sub-routines (with no parameters, yet).
  • When I'm 'done' adding the basic constructs onto my language - how should I branch out? Into what domain(s)? In other words, what direction(s) should my open source basic language take once I've got all the generic constructs working?

Thank you for your time,


share|improve this question
I've always wanted a langauge that had built-in, syntax-supported AOP functionality. –  FrustratedWithFormsDesigner Jun 13 '11 at 13:40
@Dominick: How about LINQ functionality? –  Predator Jun 13 '11 at 16:21
@Frustrated... AOP - Aspect Oriented Programming functionality? Could you give an example? –  Dominick Jun 14 '11 at 1:17
You should not start inventing a domain specific language from basic imperative features. Formalise your domain first, turn this knowledge into a language, and only then add basic features, if they're necessary at all. Likely you'd even end up with a perfect DSL which is not Turing-complete, and it is one of the best properties of the DSLs. –  SK-logic Jun 15 '11 at 21:39
Surely "goto" is a mandatory feature of any BASIC? –  Perry Jul 11 '11 at 22:59

5 Answers 5

My experience with early BASIC on the Commodore [Vic-20,C-64] gave me the impression that line numbers were a core "feature" of BASIC. It seems like they are no longer used in modern implementations, which to me is something of a detriment since my primary view of BASIC is as a learning language from which to springboard onto something else.

share|improve this answer

Definitely a noble endeavor, but I think that you've got your priorities reversed.

Your first concern should be the "domain" problems that your language is targeted to address. That's why it is called a "Domain Specific Language" in the first place. A DSL is tolerable only when it is small, simple and very narrowly focused to solve particular set of problems like a knife through butter.

After you've identified the domain and how your language will work in the domain, you can lay down specific constructs or features.

Finally, it might be helpful to consider whether you want an internal or external DSL.

share|improve this answer

I have been developing a scripting language for a CAE/FEA application and some features that I found useful for end users are: Local and global variables Matrices with dynamic allocation and expansion Functions with arguments and by reference passing Structures (user defined types) Along with the features you mentioned yourself should make a quite powerful language to begin with. Then you will develop according to user request.

share|improve this answer
That's an interesting and very domain specific language (Computer Aided Engineering/Finite Element Analysis). I can see why you should need matrices. All your suggestions are pretty good ones and I will keep them in mind. Thanks. –  Dominick Jun 14 '11 at 1:25

There are several features that can be added or extended if already exists, but...

...Basic-like programming languages, are very similar to script languages, and a feature that many missed or included later, was namespace or modules.

C, C++, PHP, Visual Basic, started without modules / namespaces, and where added later.

The next could be subroutines (procedures or functions that doesn't return a value), and functions (subroutines that return an special value).

share|improve this answer

understand how some complex things are done (how scanning, parsing, interpreting, and compiling are done)

There is a nice question over on the Stack Overflow site on resources for understanding compilers. You can also have a look at my Compilers class page.

When I'm 'done' adding the basic constructs onto my language - how should I branch out?

Given the features you've already built, I suggest adding three data types: int, string, boolean. You'll need to do three things, each a little harder than the prior:

  1. Modify the grammar so that you can parse those key words. Test.
  2. Create (or add to your existing) symbol table so that you can include the data type along with the variable name and other properties. Then make a debug switch so you can test this and see the symbol table.
  3. Check for compatible types before code generation to MsIL or during interpretation. Test both error and non-error cases in each execution mode for all types.

If that goes well, then I suggest working on scope (local in sub-routines vs. global). Let me know if you'd like some advice on that.

Good luck. And enjoy!

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.