What does your dream language look like?

Back when I was in school, I was bored in class so I started drafting something I called my dream language. I liked features of C++, but hated the amount you had to type for it. I love the style, speed, and formatting of Java. I am also a Lua fanboy who wants to store functions inside their own variables.

So for C++, I liked how I could assign overloads for operators. Object + Object2.
I also like how you could use a struct to dynamically allocate bytes for an object.
From python, comes efficient imports that don’t have a lot of unused text. It’s a nightmare for me manually importing java packages from libraries, especially when using ctrl-space.
C++ has pointers. Pointers are awesome, and so is dynamic memory management - something Java should have. I have had times using XMI file format where I want to take Image object’s array of pixel bytes and free it.
I don’t like how types force that you can’t subtract doubles from ints. The trailing bytes should be lost, or even some overhead would be nice for small-very seldom called-operations that would allow (byte)(0b1 - 1d) which is 0.
C# has get and sets to their fields. I love it. Especially when combined with lambda.
C++ has them mad destructors which are great.

As far as drafting out including other files, inheritance, and strings go I haven’t sat down to think about that. I just wanted to share this cool thing I came up with. To be honest, header files could be reinvented to include everything above struct Example {}. I don’t even have access modifiers.

As far as errors go, I don’t like error handling. There has to be a much better way. This goes with smart pointers and C++. Smart pointers manage the memory in a way where data isn’t leaked. In cases of sandwiching deallocations of memory with allocations, it makes sense to use them because when an error is thrown or a return reaches, its dead code. In the case of returns, you could just flag memory to be deleted on stack on function exit and don’t be a retard and return that memory being deallocated.

http://pastebin.java-gaming.org/47d3366694f19

What does your dream language look like? What stuff are you looking for to be different?

(note that my dream language doesn’t have to be possible)

My dream language would have the following:

From C++:
Pretty much everything.
I like how the memory management is given to the programmer to work with rather than Java’s garbage collector.
Pointers
Compiler directives and macros
I dislike the “include” system (although i know that it functions that way because of the way the preprocessor works)
User defined data types using ‘typedef’

From Java:
Easy cross-compatibility
JRE style default library for cross-platform windowing, graphics and UI
“import” system that avoids the C++ issue of double inclusion

Archive,
Thats basically what I said about my dream language. It doesn’t have to be possible.
I love how you added “import” system that avoids the C++ issue of double inclusion.

That is another thing that I hate. If define, define, end. It should be like java and just flat out or not. Could you expand on JRE style default library for cross-platform windowing, graphics and UI? Is it the UI you like, or just not having to make a complex window in C++ with message handling and crap?

typedef is another good huge one. If you look at my paste, that is basically what the head of the file was. Although, typedef should definitely be able to mask classes and primitives… maybe in a per-file way. Dunno.

I’d start with Java and make a few tweaks here and there. Some to increase readability, some to increase performance. Oddly enough most of what I want is scheduled for Java 9 and 10.

Cas :slight_smile:

If you have time at some point play around with something different. Java and C++ are more or less the same from a high-level viewpoint. A real meta-programming or functional language is a different viewpoint.

I’d take Java 8, and add value types and operator overloading to it. And I will add a way to encrypt the jar files to prevent from decompiling. That’s basically enough for me.

SHC, Well if you were to have encryption on the jar I don’t think that would fit the purpose of being a bundle. Jars aren’t just source and class files. Although it’s not the jar’s fault, it’s the actually the class files. Encryption is not the answer, but something similar to C++
Setup where it’ s tedious to decompile.

Roquen,
I’ve looked at a bunch of languages over the past forever. I can write in at least 15 different languages at least somewhat well. 4 of which I can actually write good code. I haven’t looked at anything gross such as Ruby.

princec,
Already found your dream language huh?

I meant encrypting everything other than classes. User should be able to store the resource files in a container that only the JVM can decode.

I don’t usually look for problems if an acceptable solution already exists :wink:

Java has 8 pain points for me:

  1. Difficulty targeting consoles / iOS
  2. No value types / structs, rendering rather a lot of algorithms to be very slow compared to their C implementations or consume vast amounts of memory
  3. I don’t want operator overloading but I would rather like to define methods as being infix/prefix/suffix operators
  4. A few tiny syntactic sugars like being able to write byte or short literals without the huge ugly cast
  5. Fast foreign function interface implementation. Boy am I sick of JNI.
  6. No proper multi-dimensional arrays
  7. No way to alias (“import blah.bleh.StupidClassWithReallyLongName as ShortName”)
  8. I really miss C# extension methods but I have a feeling I’m doing something immoral or naughty so the jury’s out on that one :wink:

It does more or less everything else perfectly well for every use I’ve so far put it to.

Cas :slight_smile:

I never really liked aliases, because they often confuse the reader.

Regarding iOS, I heard that oracle is working on OpenJDK mobile with version 9. If it is true, I’d be the most happiest person, until Java 10 is announced I guess…

I don’t understand what’s wrong with multidimensional arrays though, could you please kindly explain that to me?

Aliases are a natural extension of import static, and we’ve survived import static without becoming confused. I think that as aliases are only locally used within a single file there’s very little scope for confusion without deliberate attempts to confuse, and plenty of scope for reducing confusion by aliasing by giving things locally meaningful names.

Oracle have been working on a version of OpenJDK for iOS for the last 10 years and nothing has ever come of it, nor probably ever will. Don’t hold your breath!

Multidimensional arrays: int[,] is conceptually different from int[][]. One is a single array object; the other is an array of arrays. Right now if we want to simulate multidimensional arrays we have to do difficult-for-the-compiler-to-optimise and prone-to-calculation-errors code like this:


a[x + y * width + z * width * height] = ...

when we should in fact be letting the compiler figure all that out for us, doing correct bounds checking, and optimising away the checks where possible:


a[x, y, z] ...

Especially useful for matrix math which basically uses tons of small 2D arrays of various sizes.

Cas :slight_smile:

Is there already a language that allows this syntax? I really like the concept but have not seen it before…

What features of Java9/10 are you looking forward to?

The syntax is only different necessarily to distinguish it from Java’s arrays-of-arrays style, which still has perfectly valid uses not to mention the fact it is a completely different implementation and concept under the hood in the JVM… otherwise the basic behaviour is the same as normal C multidimensional arrays, which confusingly use Java’s [][] syntax…

The thing I’m absolutely most looking forward to is value types, coming hopefully in Java 10.

Cas :slight_smile:

This 8)

Just for the heck of it, this is how my dream language looks like:
https://gist.github.com/Longor1996/f0580723bdce9821c8c3bbd0c36cde48

I’d start with Java as a base and make a few changes:

  1. Higher-level variant of tagged unions, like enums in Rust.
  2. Native memory allocation that is not automatically garbage collected.
  3. Unsigned numbers, and doing stuff with signed and unsigned numbers together requires an explicit cast.

Things that are interesting that I don’t know if I’d actually like or not:

  1. Interfaces that function similar to Rust’s traits. The interface is implemented and declared to be implemented apart from the type definition.
  2. Null checking operators, like ?. and ?: from Groovy.
  3. First class functions/methods:
int(int) transform = (x) -> x*x/5; assert transform(6) == 7;

I want to write a little programming language of my own at some point, just for the fun of it. But I can’t think of any features I really need that Java doesn’t give me already, and there’s no way a hobby language is going to have anything to offer in comparison to the maturity and depth of libraries Java offers. So my dream language has to be some kind of specialized DSL that does one specific thing insanely well, but is no competition for Java for general programming. But I’m still waiting for the spark of inspiration…

I do think there is a case for a DSL for my AIs in Vangard but I can’t crystallize the ideas yet.

Maybe some idea to get you started :), is to build a small Prolog interpreter/compiler to express Vangard’s AI rules/states using first-order predicates, like so:


% facts:
has(player, spear).
canKillWith(spear, bear).
distance(player, bear, 8).
% rules:
sees(X, Y) :- distance(X, Y, D) , D < 10.
shouldAttack(X, Y) :- sees(X, Y) , canKillWith(W, Y) , has(X, W).

You could constantly evaluate these predicates and add knowledge/facts to bring an AI player into a certain state:


?- shouldAttack(X, Y).
X = player
Y = bear

It looks like I can go completely declarative, but that doesn’t feel language-ey enough.

That actually sounds a lot like Dlang :slight_smile: