What would be your ideal programming language?

It depends a bit on what I'm trying to do. If I'm trying to go close to the machine, then I want a language which doesn't have a garbage collector. I can get somewhat fancy with the memory I allocate, but I also like to know where every single byte of memory is. I can't say I'm much a fan of ownership stuff. I just want memory here, some over there, and that over in that corner. But I do see the value of what Rust offers.

If I'm doing something interpreted where speed doesn't matter that much, then I'm happy with Python. If I want something compiled but with fancy generics, then Scala it is.

Now...I've been working on a language for about four years now. I've built something that takes a bunch of parts from different languages and tries to merge them into a coherent whole. I think it's a fine language in both what's present and what's possible. The general list of what I want (and have) is:

  • No variable or class member should be able to not have a value. If you want something like that, there's abstract data types. You know, that Option thing that's in vogue right now. There's no such thing as "You forgot to initialize that".

  • A static typing system. I like my types. But I like my types to be inferred where possible. I also want to have to declare variables before being able to use them. var v: list[hash[string, string]] = []. The language can infer that, in this case, [] should be an empty list of the right type. Types should be there to make sure you've got the right thing, but not exist to be annoying. No optional typing, either. Oh, and type errors should be something that's a syntax error, not a runtime error.

  • Importing. None of that header file stuff. Python has a fine idea for importing: import x looks for x.py in a bunch of different scopes. Now you have this x scope where everything in x.py lives. I don't want the stuff in one package mucking with another. Also, it's nice as an accessor.

  • I like c++'s :: accessor for package based stuff and classes.

  • Class members that use Ruby's @ sigil in front. Also, no self.x access. Just use @x. This removes the whole bikeshed thing about "we use _ before names, but they want m_ and those other guys want this".

  • Single-inheritance. It's simple and it's easy to implement. Classes are really just a tuple of a given size, and the members are just slots in a tuple.

  • Exceptions from the ground up. If the standard library and built-in operations use exceptions, then library makers get used to the idea of using exceptions. But...no checked exceptions, please. Those just make me want to make a junk try+except block to make the compiler shut up. A compiler might be able to force me to make a try+except around something, but it can't make me do the right thing.

  • Functions are values.

  • Optional values for arguments are nice. But...make sure they're constrained to literals. None of that fancy 'the default value to this is some wacky function call'.

  • I'd like to easily get the full call trace to know where I am and how I got there. Sometimes that's nifty. But...also something where I can show the value of any variable. And...I kinda mean anything. Functions? Sure, why not. Show a function defined in code and it tells you the opcodes of it. Sorta like dis.dis of Python. It's nifty for those curious about how the interpreter is operating.

  • Most importantly, all features should be built to interact with each other. Type inference works with generics. Lambdas can use type inference on their inputs.

Granted, what I have isn't complete. The whole purpose of what I've built is to allow for dynamic page generation. There are some things from more dynamically-typed languages that I'm envious of (like being able to make lists of varying types). But I like what I've made. Is it ideal for everything? Absolutely not. But then, nothing is.

But, it's something that I can look back on and say "I made this" and smile in satisfaction. That, to me, is what's most important. :)

/r/programming Thread Link - codetree.net