DEV Community

Discussion on: Sometimes, the elegant implementation is just a function

Collapse
 
mortoray profile image
edA‑qa mort‑ora‑y

I agree that multi-paradigm languages are definitely the preferred approach. I think it's essential that people can write in all paradigms and learn to use the right one.

To followup from your other comment here as well, I think it's helpful when a language gives multiple ways to define operations on data. Either as standalone functions, or as member functions of a type, preferably allowing both. Some functions just work better as globals, some work better as member functions.

Collapse
 
kungtotte profile image
Thomas Landin • Edited

I agree completely. Languages should enable the programmer, not hamper them. This is one of the reasons why my new favourite language is Nim. It lets you do pretty much whatever you want and with its Unified Function Call Syntax you can mix freely between OOP-style code and functional-style code without changing your coding style.

Example:

# These two are equivalent and will result in 
# some_procedure being called with arg1 and arg2
# as the first and second argument respectively
# 
# This works for independent procedures and class
# methods alike.
some_procedure(arg1, arg2)
arg1.some_procedure(arg2)