DEV Community

buphmin
buphmin

Posted on

What Would Your Perfect Programming Language Look Like?

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.

Top comments (7)

Collapse
 
jmfayard profile image
Jean-Michel 🕵🏻‍♂️ Fayard • Edited

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/

Collapse
 
tholander profile image
Théo Holander

Add "great pattern matching" and you have what I like about Scala ;)

Collapse
 
jmfayard profile image
Jean-Michel 🕵🏻‍♂️ Fayard

Fair enough :)

Collapse
 
buphmin profile image
buphmin

Haha, I will have to take a look.

Collapse
 
stephenhannam profile image
kostoglotov

LISP... Now get off my lawn

Collapse
 
henryong92 profile image
Dumb Down Demistifying Dev

Dart.

Collapse
 
buphmin profile image
buphmin

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.