Jump to content
  • Advertisement
Sign in to follow this  
HalfThere

Give me some ideas for making a programming language

This topic is 2899 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Exactly what the topic title says. Just throw out ideas you think would be neat. Remember:
-This is a one-semester class, the project is towards the end of it. There will be 4-5 people working with me, but our total hours put into the project will still be limited
-I am not a programming whiz, or even close. An idea like "re-implement perl as a functional language" is probably wonderful, but I cannot parse that sentence, let alone program a parser for that language
-Other than the above, no rules

Share this post


Link to post
Share on other sites
Advertisement
Do you have to create a general purpose language or a domain specific language is also acceptable? The latter is easier to design because your goals and constraints are better defined. I think quality, elegance and simplicity is more important than quantity in a project like that. You should define some goals and define your language around few strong ideas.

Share this post


Link to post
Share on other sites
Have you done this before? If not, do something simple. Trust me, even that will entail a *lot* of work and long, sleepless nights.

Something pascal-based would be a good choice (a subset of pascal, e.g. PCL). I'd avoid C and/or OO constructs for a first project and would probably try to add a few optimization passesd for extra credits (but only if everything else worked and I had time to spare!)

Make sure you have a sane build environment and create lots of unit tests. In fact, first write a unit test then make sure it parses and compiles correctly.

Share this post


Link to post
Share on other sites
What is the goal of the project? If this is about compiler construction, you might be expected to implement a lexer, a parser, a type system, compiling it to another language such as C, ... Or is this about programming concepts and being able to implement them, in which case you only need to write an interpreter, and you can settle for an easy syntax such as Forth or Lisp.

If it's about programming concepts, you might try going for a language which deals elegantly with multithreading, it would be quite relevant these days. The interpreter itself doesn't have to be multithreaded, it should just be able to have multiple pieces of code in a list, each of which gets stepped through in turn. This book (also freely available freely online somewhere) discusses the programming language Oz, in which it is very easy to write multithreaded code. The book explains how it all works underneath the hood, so you would already know how to implement it.

Another possibility would be to implement a type system. The first few chapters of TAPL would be a good resource for this. The languages it considers are very small, but you could extend them without too much difficulty so that they can be used to write small applications.

If you're looking for crazy programming language concepts, you could take a look at this book (which is also available for free), it discusses a lot of different languages, some with very weird concepts in them.
(I would give you links to the free books, but sadly the links I saved don't seem to work anymore)

Share this post


Link to post
Share on other sites
The focus of the course is lexical analysis,syntax, typing and parsing; more the basics than anything advanced like hardcore compiling, but we can implement fairly simplistic and domain-specific languages. Past projects have included image processing languages, tower defense languages, and a baseball language.

Share this post


Link to post
Share on other sites
Some suggestions, in no particular order:

  • Don't go crazy with your syntax. Keep it simple, consistent, and clean. It takes a lot of time to develop a good gut instinct for how to parse complex grammars - and even what comprises a complex grammar - so for a short-term project I can't stress highly enough that you want to do something minimalistic. You don't have to go to Lisp extremes (although writing a minimal Lisp is a fantastic learning exercise) but don't go to C++ extremes either. Lexing and parsing C++ style syntax is worse than a nightmare.
  • Don't write a virtual machine or native-code compiler. Do an interpreter if you feel ambitious, or just a cross-compiler that emits C (or whatever) if you don't. Generating efficient bytecode for any machine is a very arcane and complex job, and it'll distract you from the core goals of the project. By contrast, emitting relatively sane C is pretty easy, and you can let existing compilers do the heavy lifting of generating good machine code.
  • Definitely prefer something domain-specific if you have a good idea for it. Sit down with your team and brainstorm a few dozen random things that you'd love to see a computer do, and see if any of them lend themselves to DSLs. Some possibilities include text processing, XML transformation, games, data mining, logic solvers, and so on; all of these are well-trodden areas of computing so you should find ample inspiration there and plenty of guidance.
  • As a counterpoint to the first item, at least try to parse infix notation with operator precedence and associativity rules. It's one of the more complex and subtle things to do in a general-purpose syntax, so it'd be a great learning exercise. See how elegant you can make your parser.
  • Definitely prefer generation of an Abstract Syntax Tree prior to final code output. This makes debugging your parser a lot easier, and can make it easy to automatically unit test as well, with a little care. For instance, consider representing your AST as Lisp-style s-expressions. This means you can do a trivial string compare to see if your generated AST is correct, and as a bonus, you get to peek into the magical realm of Lisp-style code representation. (Hint: if you don't have a startling moment of clarity, enlightenment, and sheer excitement when you "get" AST-to-sexpr transformation, you missed something.)
  • Try to build in some simple type inference. You don't have to go all Hindley-Milner on it, but something like the C# [font="Courier New"]var[/font] keyword would be cool. It's a great introduction to thinking more deeply and richly about type systems.
  • On the flip side of that coin, don't do anything crazy with your type system. Building and proving a type system to be correct are both monumental tasks, and you don't have the time or training to tackle that for a short-term project. Stick to primitive types and maybe simple aggregates with no subtyping.
  • As an alternative, you could explore doing a DSL for dimensional analysis; this would require minimal parsing, rich type semantics, some algebraic manipulation in code, and a little bit of ingenuity. If you keep the scope down, this could be a great learning experience, and certainly a bit of a challenge if you have never written an algebraic reducer/solver before.
  • One last point, which touches on soft skills: language design and implementation is usually far easier when done by a single person; typically you don't want to involve a team until you have a very stable core compiler and/or need to start building libraries. Design-by-committee and multiple chefs in the code kitchen will make things complicated. Do your best to divide the work up into areas of responsibility from day one, and if possible, have one person who is in charge of making final design decisions, if for no other reason than to save time arguing over all the possible options. I don't know how you or your teammates work best, but find a workflow quickly that everyone is at least marginally happy with, and stick to it. Otherwise you risk getting a very disjointed, inconsistent implementation that doesn't work.
    Best of luck with your project, and have fun smile.gif

Share this post


Link to post
Share on other sites
I have very little knowledge in this area, but some time ago I was reading up on what it might take to add JIT support to a certain language. This led me to LLVM and I came across this tutorial:

http://llvm.org/docs/tutorial/

It walks you through the creation of a simple interpreted language with JIT, starting from C++ or OCaml. I have no idea how useful this is or if it even below what you're trying to do (the only data type is double), but it seemed pretty interesting.

Share this post


Link to post
Share on other sites
I concur with ApochPiQ, except for one case:

I would recommend an un-typed language. Adding a type system adds quite a bit of complexity that might be more than you want to chew in one semester.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!