Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

Discussion about a programming language I'm creating (Kava)

kava programming language java c++ c d oop

  • Please log in to reply
27 replies to this topic

#1 Yannbane

Yannbane

    CC Addict

  • Advanced Member
  • PipPipPipPipPip
  • 238 posts
  • Programming Language:C, Java, C++, PHP, Python, JavaScript, PL/SQL, Lisp, Assembly, Bash, Others
  • Learning:Lisp, Scheme

Posted 16 December 2012 - 06:19 AM

I realized that most already available languages don't meet some of my needs, so, I've decided to create a programming language of my own.

I realize that this is a really ambitious, and definitely not an easy task, but, I believe there's much to learn down this road. However, I do want to end up with something usable.

Here are some of the reasons I've rejected some languages:
  • Java
    • Not really free (Oracle suing Google for creating their own implementation)
    • IMO bad package system
  • C
    • Too low-level, I want my programs to run consistently (in a VM)
    • Not OO
    • Platform dependent a lot of times (this can be good, but for some of my needs, it's a bad thing)
  • C++
    • The declaration-implementation split seems poorly executed
    • I don't like #include, nor the preprocessor being a whole different language crammed inside another language
    • (all points except 2nd one in C)
  • D
    • Garbage collection in a C-like language? Yuck
    • Syntax seems a bit weird sometimes, but I could get over that
    • I'm not sure whether it has a compiler for all the platforms I'd like to target
However, I didn't "give up" C/C++, I believe that they're very important languages that will be here virtually forever, and that's why I'm implementing my VM in C++.

I've created this thread for general discussion about the language, feature suggestions, constructive criticism, etc.

I think I have a fairly good idea of what the language will look like, but, I haven't started implementing things seriously, so there's a lot of room for change.

Basic information:
  • Name: Kava
  • Purpose: general, robotics
  • Paradigm: OOP
  • Based off: Java
    • Ran by a VM
    • WORA
    • Platform independent
    • One public class per file
    • However:
    • Free from the start
    • Cleaner syntax
    • No package system, just modules (think: Python)
    • No interfaces, explicit abstract classes, etc, everything is a simple class and everything can be overridden (I'll probably go the D way of making all methods virtual implicitly)
    • Multiple inheritance (yay!)
    • Operator overloading
    • I hope to make references a wee bit more "pointery"
  • Support for the Kava Virtual Machine (KVM) on AVR microcontrollers, and a library for accessing the ports and other parts of the AVR system
I do have some questions:
  • I don't think I can implement JIT all by myself. How fast can VMs get with just interpretation?
  • What would you like to see fixed in Java?
  • Except in syntactic sugar and arithmetic, how much do Java references differ from C++ pointers?
This project has a repo here: github.com/Yannbane/Kava.
Here is a post on my blog about it, but it basically says what has already been said here: yannbane.com/2012/12/kava.html.

I'll post development updates on my blog, and summaries here.

Thanks for reading!

Edited by Yannbane, 01 January 2013 - 02:29 PM.

  • 1

My blog: yannbane.com. I post about programming, game development, and artificial intelligence.


#2 0xDEADBEEF

0xDEADBEEF

    CC Devotee

  • Senior Member
  • PipPipPipPipPipPip
  • 790 posts
  • Programming Language:C, Java, C++, C#, (Visual) Basic, Perl, Transact-SQL, Bash, Prolog, Others
  • Learning:Others

Posted 16 December 2012 - 02:11 PM

Why do you not like the interface/implementation split? It seems logical to me; a largish java class is hard to view the whole interface at once. Infact it'd be interesting to see the data section with the implementation rather than in the interface definition.

In regard to your preprocessor dislike; I can understand it a bit, although having a meta-programming language in the language might be quite useful. What I mean is that somethings can be determined statically at compile time and sometimes you want to be able to write such things in a programming language - to make code more readable (although maybe in a static linked language this is more important).

anyway to your questions:

1) Your probably going to have to write a JIT, at least the linking part. You probably don't have todo any dynamic optimisation in the JIT (its advanced anyway.) Btw be prepared for your language to be slow at first - you have to put work in to get it fast.

2) Java
- id probably make arrays of primitives actually primitive.
- reduce the redundance in creating classes. For instance Foo bar = new Foo(); should just be
Foo bar(); or Foo bar;
- all the methods are overridable - I feel this should be the other way (like C#). You should mark
the functions as virtual if you want to override them. (although the override syntax is rubbish in c#)
this would allow you to do inlining easier.

- properties; get & set is tideous, a specific language properties would allow easy optimision on the
compiler size.

- the ability to control garbage collection times; for certain programs they often follow certain patterns
e.g. wait for work, do some work, finish work. In the finish work stage, we'd want to run the garabage
collection rather than during the 'do some work' time.

- lack of templates, but bad generics.

- multiple inhiretance.

3) Java references are actually handles (pointers to pointers) to allow for the garbage collection, heap compaction etc.
  • 2

Creating SEGFAULTs since 1995.


#3 Yannbane

Yannbane

    CC Addict

  • Advanced Member
  • PipPipPipPipPip
  • 238 posts
  • Programming Language:C, Java, C++, PHP, Python, JavaScript, PL/SQL, Lisp, Assembly, Bash, Others
  • Learning:Lisp, Scheme

Posted 16 December 2012 - 02:44 PM

Thanks for your reply, Evan.

My dislike of the declaration-implementation split stems from some practical reasons... I want modules. Modules are integral. You shouldn't have one part of the module you need to literally stick to your code to make it possible for another part of the module, with the first part of the module already glued, to be compiled with your program.

Having such a split, at least in the way it's implemented in C/C++, means that you need to distribute both the compiled library, and header files (source code) of that library!

I'd rather have a compiled, integral module, that can be loaded dynamically at runtime.


- reduce the redundance in creating classes. For instance Foo bar = new Foo(); should just be
Foo bar(); or Foo bar;


Actually, I believe that Foo bar = new Foo(); is the right way to go. It's clear: Foo bar; creates a new variable that can hold a reference to a Foo object, and new Foo(); returns such a reference.

- the ability to control garbage collection times;


This might be an execution mode of some sort, however, it's too early to start thinking about garbage collection.

- properties; get & set is tideous, a specific language properties would allow easy optimision on the
compiler size.



What do you mean?

1) Your probably going to have to write a JIT, at least the linking part. You probably don't have todo any dynamic optimisation in the JIT (its advanced anyway.) Btw be prepared for your language to be slow at first - you have to put work in to get it fast.


Again, what do you mean? I don't see why JIT compilation would be necessary...
  • 1

My blog: yannbane.com. I post about programming, game development, and artificial intelligence.


#4 0xDEADBEEF

0xDEADBEEF

    CC Devotee

  • Senior Member
  • PipPipPipPipPipPip
  • 790 posts
  • Programming Language:C, Java, C++, C#, (Visual) Basic, Perl, Transact-SQL, Bash, Prolog, Others
  • Learning:Others

Posted 16 December 2012 - 03:11 PM

Having the interface in the module is still ok with the split; you're still compiling to a module your just loading more than one file; problem is if your doing the one class one file thing you'd have a lot of files.

I think that in a language where nearly everything is a reference only on way of devlaring is needed; so foo bar; and foo bar() are quite clear to me. But it's only my opinion, since I dislike writing new so much.

The execution model is a bit further down the road but you should think about if it'll be garbage collected or not; it's pretty fundamental.

90% of getters will return just the variable; so a quick form to create these would be useful; like c# has. Although I would say that they should be limited to basicung setting/getting.

Eg
Class x {
    Property int foo [public get;public set]
}

Btw I typos compiler side as compiler size: what I ment was you can avoid a function call when accessing a property.

On JIT I mean you have to translate a module/class/function reference to a handle in your vm. Eg linking it to your vm. You could do it on the fly but you might as well do it on load.


  • 1

Creating SEGFAULTs since 1995.


#5 Yannbane

Yannbane

    CC Addict

  • Advanced Member
  • PipPipPipPipPip
  • 238 posts
  • Programming Language:C, Java, C++, PHP, Python, JavaScript, PL/SQL, Lisp, Assembly, Bash, Others
  • Learning:Lisp, Scheme

Posted 16 December 2012 - 04:39 PM

I consider those getters and setters to be completely useless. If you're going to do that, you might as well declare foo as public. Getters and setters are only useful when you need some form of checking done. However, you could use that, and implement the actual methods later, once the rest of your code is complete...

You're correct that I could still separate declaration and implementation, and compile into one file, but I like it better when it's all in one file.
And I'm pretty sure that I will have garbage collection, but I'd rather design and implement some more fundamental parts of the language.

I'm still not sure whether we both have the same definition of JIT compilation. JITC is the process of compiling the platform independent bytecode into platform dependent machine code, in order to achieve high performance, right? And module/class/function references are my own language's constructs, so they don't need to be linked with the VM.

What you're probably referring to is that I'll need a way of calling native functions, for file manipulation, basic I/O, hardware interaction, anything that isn't mere mathematics. You're right about that.

For calling native functions, I'll use dlopen and dlsym to load dynamically linkable libraries, and LibFFI in order to execute code in them. However, LibFFI is not available on AVR's, so sometimes I will need to "bake in" functionality into a specific VM distribution.
  • 0

My blog: yannbane.com. I post about programming, game development, and artificial intelligence.


#6 0xDEADBEEF

0xDEADBEEF

    CC Devotee

  • Senior Member
  • PipPipPipPipPipPip
  • 790 posts
  • Programming Language:C, Java, C++, C#, (Visual) Basic, Perl, Transact-SQL, Bash, Prolog, Others
  • Learning:Others

Posted 17 December 2012 - 12:18 AM

I consider those getters and setters to be completely useless. If you're going to do that, you might as well declare foo as public. Getters and setters are only useful when you need some form of checking done. However, you could use that, and implement the actual methods later, once the rest of your code is complete...


True. I actually like the idea of forcing the data to be protected or private and not allowing any public data. This would nessitate the use of properties or functions. But I understand your point, I think that in the following situation:

Obj o;

o.foo = 3;
o.bar(3);

In the C# way, foo could actually be a very very expensive operation and to the user it just looks like a variable set. Where as at least bar is a function call and you know that might have some cost. This i dislike as its not intuitative code to read.

You're correct that I could still separate declaration and implementation, and compile into one file, but I like it better when it's all in one file.
And I'm pretty sure that I will have garbage collection, but I'd rather design and implement some more fundamental parts of the language.


Cool.

I'm still not sure whether we both have the same definition of JIT compilation. JITC is the process of compiling the platform independent bytecode into platform dependent machine code, in order to achieve high performance, right? And module/class/function references are my own language's constructs, so they don't need to be linked with the VM.

What you're probably referring to is that I'll need a way of calling native functions, for file manipulation, basic I/O, hardware interaction, anything that isn't mere mathematics. You're right about that.

For calling native functions, I'll use dlopen and dlsym to load dynamically linkable libraries, and LibFFI in order to execute code in them. However, LibFFI is not available on AVR's, so sometimes I will need to "bake in" functionality into a specific VM distribution.


Yes, I'm completely wrong on what a JIT was; but I wouldn't worry about it. Its somthing you can easily do later.


On other language features any thoughts about:

1) Lambda functions
2) Inner functions (functions within a function?)
3) Functions that arn't actually in a class (i.e the Util class you always get with Java.)

Anyway sounds like an interesting project.

Edited by Evan, 17 December 2012 - 12:19 AM.

  • 0

Creating SEGFAULTs since 1995.


#7 Yannbane

Yannbane

    CC Addict

  • Advanced Member
  • PipPipPipPipPip
  • 238 posts
  • Programming Language:C, Java, C++, PHP, Python, JavaScript, PL/SQL, Lisp, Assembly, Bash, Others
  • Learning:Lisp, Scheme

Posted 17 December 2012 - 02:10 AM

Hm, I'd like to have lambda functions, however, I'm not sure whether this whole mode of compilation would allow such a thing. I think this would automatically mean that I must allow the compilation of functions outside of classes, and I'm still not exactly sure this is a good idea.

About inner functions, well, this isn't Javascript, nor a functional language, so I honestly see no benefit in making those available. This would imply that I ought to implement closures or something like that to make it useful, and that would be taking it too far.
  • 0

My blog: yannbane.com. I post about programming, game development, and artificial intelligence.


#8 Yannbane

Yannbane

    CC Addict

  • Advanced Member
  • PipPipPipPipPip
  • 238 posts
  • Programming Language:C, Java, C++, PHP, Python, JavaScript, PL/SQL, Lisp, Assembly, Bash, Others
  • Learning:Lisp, Scheme

Posted 18 December 2012 - 01:56 AM

I'm having second thoughts about having the class be the compilation unit.

I'd maybe go the Python way with modules. This would mean that I would be giving up on forced OOP, and that the possibility of global variables, functions, etc is introduced. However, I think this gives the programmer much more freedom.

I'll have to think this over...
  • 0

My blog: yannbane.com. I post about programming, game development, and artificial intelligence.


#9 wim DC

wim DC

    Roar

  • Expert Member
  • PipPipPipPipPipPipPipPip
  • 2681 posts
  • Programming Language:Java, JavaScript, PL/SQL
  • Learning:Python

Posted 18 December 2012 - 02:30 AM

I like many features of the Scala language.

- Method parameters can have default values if not supplied.

- Allowed to write methods without writing the dot, and braces + no need for line delimiters (semicolon in Java) -- unless multiple statements on 1 line.

car.driveHome();
COULD be
car driveHome
There are some general rules for readability, but written right or wrong it'll work (see http://docs.scala-la...invocation.html)

This has the consequence, that all operators are in fact methods.
a + b
is the same as
a.+( b );
Hence operator overloading is possible.


- Lambda functions

- much much easier to create "final" variables. In MANY java declarations, variables can perfectly be final but often are not because you have to write final.
In scala it's a difference of writing "var" vs "val", which is much better.

- so much more cool stuff

Edited by wim DC, 18 December 2012 - 03:06 AM.

  • 0

#10 WingedPanther73

WingedPanther73

    A spammer's worst nightmare

  • Moderator
  • 17757 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others

Posted 18 December 2012 - 06:24 AM

A thought: for people who write/sell libraries, the declaration/implementation split is going to be very important.
  • 0

Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

My MineCraft server site: http://banishedwings.enjin.com/


#11 Yannbane

Yannbane

    CC Addict

  • Advanced Member
  • PipPipPipPipPip
  • 238 posts
  • Programming Language:C, Java, C++, PHP, Python, JavaScript, PL/SQL, Lisp, Assembly, Bash, Others
  • Learning:Lisp, Scheme

Posted 18 December 2012 - 12:14 PM

A thought: for people who write/sell libraries, the declaration/implementation split is going to be very important.


I don't really agree. I think it's actually more convenient not to have that split, as I've already explained.
  • 0

My blog: yannbane.com. I post about programming, game development, and artificial intelligence.


#12 Yannbane

Yannbane

    CC Addict

  • Advanced Member
  • PipPipPipPipPip
  • 238 posts
  • Programming Language:C, Java, C++, PHP, Python, JavaScript, PL/SQL, Lisp, Assembly, Bash, Others
  • Learning:Lisp, Scheme

Posted 18 December 2012 - 03:31 PM

*** Development news ***

Forgot to post it the day it was published on my blog as I was pretty tired, but, I've created the assembler for Kava, and defined how the bytecode will look like (nothing final yet).

Kava bytecode comes in two versions: human readable and machine code. An assembler is a program which translates the human readable bytecode (assembly code) into an executable that can be loaded and executed by the KVM.

To read more about that, visit my blog: yannbane.com/2012/12/assembler-for-kava-has-been-created.html.
  • 0

My blog: yannbane.com. I post about programming, game development, and artificial intelligence.






Also tagged with one or more of these keywords: kava, programming, language, java, c++, c, d, oop

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download