What Would Your Perfect Programming Language Look Like?
buphmin

buphmin @buphmin

About: I do things, usually involving buttons. All the while listening to power metal. Oh, and I like cats.

Joined:
Sep 11, 2018

What Would Your Perfect Programming Language Look Like?

Publish Date: Nov 14 '19
9 7

So throughout my career I have learned a number of languages and all have their pros and cons. PHP has some weird choices, Python's OOP seems meh, Go is verbose, and JS can be confusing. This has got me thinking: what features and syntax could I combine to create the "perfect" language for me.

I'll share my thoughts first and I hope to hear from you all on what would be perfect for you!

Starting off I like OOP, so my fictional language would have OOP components. I also like having the flexibility to just write functions. So a mix like Python and PHP. I like static typing and performance, so pre-compiled and optimized it is. I don't write drivers, games, or OSes so I will forgo explicit memory management for convenience at the cost of performance. I like Go's and typescripts type inference so lets keep that, but with the option of explicit declaration. Go's multiple return types is kind of magical, so lets keep that. But let us keep exceptions and try/catch because that cuts down verbosity. Let's also take another page from Go and keep the language fairly simple. It is 2019 so multithreading/coroutines must be easy to use. Oh and JS has these effortless awesome maps called objects, lets keep as much of that as we can with static typing.

So what could my smashed together language look like? Well lets take a peak...

Classes


//hmm interfaces can define properties too like typescript...
//also imports are simple directories relative to the src folder or vendor folder.
//with the exception of the standard library
import AnimalInterface from App/Animals

class Dog implements AnimalInterface
{
  protected sound = "woof!"; //infers string
  public hasFur: boolean;

  //I'm torn as to whether I want the word function, func, fn or nothing...
  public func makeNoise(): void {
    print(this.sound);
  }

  public func getDetails(): (boolean, string) {
    return this.hasFur, this.sound;
  }
}
Enter fullscreen mode Exit fullscreen mode

Looping

numbers = [1, 2, 3, 4];
map = {
 "dog": "bark",
 "cat": "meow"
}; //string => string map

//hmm do i like the map type syntax from go?
anotherMap: map[string]string = {}

for number in numbers {
  print(number);
}

for i = 0; i < 3; i++ {
 number = numbers[i];
 print(number);
}
Enter fullscreen mode Exit fullscreen mode

This is hardly everything in a language, but hey it is a start! Now it is your turn.

Comments 7 total

  • Jean-Michel 🕵🏻‍♂️ Fayard
    Jean-Michel 🕵🏻‍♂️ FayardNov 14, 2019

    Static typing and type inference?
    Mix of OOP and functional programming?
    Safe and concise?
    Coroutines?
    No explicit memory management?
    Less ugly try catch?

    Add "great tooling", "pragmatic" and "leverage an existing huge ecosystem" and you have pretty much described what I like about Kotlin

    kotlinlang.org/docs/reference/

  • kostoglotov
    kostoglotovNov 14, 2019

    LISP... Now get off my lawn

  • Dumb Down Demistifying Dev
    Dumb Down Demistifying DevNov 14, 2019

    Dart.

    • buphmin
      buphminNov 14, 2019

      Dart has changed a lot in it's usage over the years huh? If I recall correctly it used to just be a JS substitute. Now it has its own JIT and is used in flutter. Other than that I know very little about it.

Add comment