No comments on these ones because I like them:
1. Object Oriented.
2. Lightweight runtime.
3. Strongly typed.
4. No pointers.
14. Restricted classes and methods.
Just a few comments and questions.
- turned into more than a few but hey
5. Exception handling (try/catch/throw).I'm guessing that you mean something like 1 = divide by zero, 2 = null object etc?
My idea is to have a section of the method that handles the exception (similar to your finally block). There is only one handler for each method. It's not as useful, but if you aren't passing any other information to the handler anyway it shouldn't matter as much. It's simpler.
Or/and have a code block after a method call; if an exception occurs while that method is executing, and isn't caught until this method, the code straight afterwards would be called.
object.dangerousMethod(a) { // code to execute if the above method call threw an exception}
These two features would handle all cases that I use exceptions and exception handling for.
6. Primitive types including boolean, char, byte, short, int, and float.I'm a fan of pure object oriented languages, this is just a vote for that direction.
7. Typed Enumerations.In java you can create an enumeration like this (the code may not be correct but hopefully you can get the gist of it):
// an action in rock paper scissorspublic class RCPAction{ static public RCPAction rock = RCPAction(0); static public RCPAction paper = RCPAction(1); static public RCPAction scissors = RCPAction(2); private int enum; // important: the constructor is private private RCPAction(int startEnum) { enum = startEnum; }}
You reference RCPAction.rock to get rock etc.
This is the way I'm planning on doing things.
8. Expressions in switch/case statements.Isn't this the same as having a bunch of if statements? If you are using boolean expressions in the case statements, don't you have to evaluate all of them just to see if they are going to be called? Or are you somehow going to incorporate this with the traditional "jump" method, grouping all the single value case statements into a normal switch statement then your boolean if statements? (I'm talking about implementation here). In any case, it seems that the normal switch method and if statements provide the same functionality and you're just making a new way of writing it. That's cool btw, I think for commonly used commands that making new syntax for it isn't bad, you just need to know where to stop and if the new syntax is worth it in terms of language simplicity.
9. Data structures.I'm mostly with you on this one, but I think it might complicate things and lead to errors. If it was up to me I wouldn't include it. I think that taking the time to nicely wrap and bind it would be more beneficial than having the ability to jump straight in down and dirty.
But then again I'm a believer in a language that almost forces you to code in a particular way, and I don't like more than one way to do something.
10. Support for “finally” code blocks.I'm guessing that this isn't just a compiler thing, that the runtime actually jumps to a bit of code that is executed after it finds a return instruction. Otherwise it would still be good, but you would have to insert the code everytime there is a return statement.
My opinion is that this would make the code confusing to read but I can see where it comes from. I would try to put some sort of restriction on it so it can only be used to clean up objects and other things that are used in the method. Many times I have duplicate code in different if blocks just because I need to clean up whatever object I'm working with before returning.
It's a good feature but for me it's a toss up, it could be abused and lead to very nasty code. Considering what I said earlier (that I like strict languages) I would probably leave it out. Having said that, if I use your language in the future, I would use finally code blocks.
11. Delegates.I read this as two things: function pointers, and delegates.
Function pointers are good, but not often used with object oriented programming (not sure if this is because they often aren't supported in such a language, or some sort of design pattern can do the same thing).
To me delegates looks like it could be implemented with a simple class hierarchy, unless I'm missing something?.
Something like this would do the same (using my pseudo code, hope you get the gist - it's tabbed blocked):
interface MyDelegate void Func1() void Func2() bool Func3(IActor actor)// state1 implements the MyDelegate interfaceclass state1 : MyDelegate void Func1() ... do something ... void Func2() ... do something ... bool Func3(IActor actor) ... do something ...// to use it you goMyDelegate a = new state1()
The only difference I can see is if your delegates can have properties, and that each state acts on these properties. This couldn't be done easily with a class system.
delegate IntegerAction { void action(); int get(); int value = 0;}IntegerAction increment default { void action() { value++; } int get() { return value; }}IntegerAction decrement default { void action() { value--; } int get() { return value; }}IntegerAction half default { void action() { value /= 2; } int get() { return value; }}
Is this how you envisioned it working? If so, that would be cool, very cool.
Also it looks like a state change is global, is this intentional? I think that would be a bad idea, each MyDelegate object should have a different current state.
12. Events.I'm planning on having a callback type system, you register an object's method and trigger conditions, and that method gets called when the event is triggered. You can also tell the event system what parameters to call the method with, they can be static or based on the trigger condition (ie what object was involved with the trigger). Most, if not all of the events won't be polling type ones, they will be related to some other part of the engine (eg the collision system) and so won't effect performance quite as much.
13. Support for intrinsic functions.Good idea.
My plan is to only have one virtual machine and to write it using standard C++ code so it will compile on any ansi compiler. This means that the virtual machine is always going to be the same. No need for intrinsic functions.
15. Type impersonation.I can't believe I've come this far without spouting about Objective-C's class system thing. Basically each class had a 'class' object. I use the quoted class here because things tend to get a bit icky trying to describe it. Basically this object can have methods and properties just like other objects, but there is always only one instance of it. You actually ask it to create new instances of it's class for you. When you define a class methods preceded by a '+' mean that it's a class method, a '-' means that it's an object method.
So to talk to this class object you just use the classes name
Object o = Object.alloc()
The above code creates a new object of type Object (Objective-C doesn't actually use dot notation but you get the picture).
Anyway getting back to Type impersonation. Basically what I would do is replace the object's create methods (the ones that create new objects of that type) to return objects of the type that you want.
I really really like your idea of external grammar handlers, full points for that one.
Multiple grammars I'm not so keen on. I like to be able to look at some code and work out what's happening quickly, if there is more than one dialect of a language I think it would get complicated and messy.
Conditional compilation isn't necessary in my book. Compilation is fast, and being able to subclass almost makes it redundant. As an example, if you want a version of your class that logs everything all the time, just subclass it and make the class object return that instance (or use your impersonate thing).
Templates are good for lists. Even if you don't support creating your own templates I would think it mandatory to build in the common datastructures with them. Don't go the java way and make me cast everything that comes out of my ArrayList even though I'm only ever storing one type of object.
Not sure if you have seen it, but I had a
big discussion a year or so ago about my language and what I wanted to have in it. I think I wasn't too cosher towards one of the guys that posted, so disregard that. But the rest of the thread might be useful to you. Unfortunately it's quite long.