DEV Community

Adam Crockett 🌀
Adam Crockett 🌀

Posted on • Edited on

If you made a subset of your favourite language, what would you keep.

If you had to use just one language for the rest of your life and that was nearly a reduced version of your primary language, what 3 features would you simply not be able to live without?

For me it would be JavaScript with:

  • WebAssembly
  • Promises
  • spread and destructure

WebAssembly because then I would use another language.

Top comments (5)

Collapse
 
mateiadrielrafael profile image
Matei Adriel

So the rules are pretty unclear to me, but I'll assume you don't need to explicitly choose prinitives and operators, but not structures like if, for loops, switch, function definitions and objects.

So to be able to recreate objects we need functions (see nr 2#), arrays (for multiple returns) and decision making. For taking decisions we can use the ternary operator so my 1# will be arrays (maybe not object based, just the most dummy arrays ww can get)

You can implement promises yourself if you have higher order functions, so my 2# would be higher order arrow functions

Since we have functions, taill call optimization is essential for implementing looping over stuff, so that would be my 3#

Collapse
 
ssimontis profile image
Scott Simontis

F#: higher order functions, pattern matching, and easy interoperability with .NET.

Okay, that last one has never existed but damn it would be nice 🙃

Collapse
 
adam_cyclones profile image
Adam Crockett 🌀

I was going to say, beacuse I'm interested in F#, and interop would make this language more prevalent. unfortunately I am in interested in most languages and there is a queue of things to try forming. I like pattern matching too, but as js doesn't have it I couldn't say that.

Collapse
 
mateiadrielrafael profile image
Matei Adriel

What about computational expressions?

Collapse
 
ssimontis profile image
Scott Simontis

TBH I haven't totally mastered them and thus learned to appreciate their power. Thanks for reminding me to add that to my todo list!