DEV Community

Cover image for Programmers need types or "The Another Billion Dollar Mistake"
Ughur Huseyn
Ughur Huseyn

Posted on

Programmers need types or "The Another Billion Dollar Mistake"

Interpreted languages lack performance for large programs. When created they not meant to be used as today. But they must overcome this issue. For fast execution many alternative JIT implementations and even compilers have been created (V8, PyPy, LuaJIT, Crystal, etc.). But efficient JITter or compiler needs type declarations. Therefore we can see many alternative syntaxes have been created also (Crystal, Cython etc.).
And type declarations also make code readable and editor friendly, they document your code. Scripting languages mainly created for automatic memory managment and productivity. But why did they drop type declaraions completely?!. Today we see almost all of them return type declarations back somehow (Python, PHP, Typescript). Is this "The Another Billion Dollar Mistake"?

Again, We programmers, need types. Not sure?

Javascript -> TypeScript, V8
Python -> Type hints, Cython, PyPy
PHP -> Type declarations, PHP 8 (JIT Compiler)
Ruby -> Crystal
Lua -> LuaJIT

Top comments (6)

Collapse
 
jonrandy profile image
Jon Randy ๐ŸŽ–๏ธ • Edited

Types slow you down hugely and put the brakes on creativity. Working without them is much more enjoyable.

That said, they do have a place when speed and memory are issues

Collapse
 
ricardoslv profile image
ricardoSlv

How do types stop creativity?

Collapse
 
jonrandy profile image
Jon Randy ๐ŸŽ–๏ธ

They don't, but they can slow it down. I'll try and make an analogy with art...

Say you have an idea for a piece - a mixed media piece. You immediately start throwing things together to make your masterpiece - paint, charcoal, coloured pencils, chalk, yoghurt... whatever takes your fancy. Some ideas work, some don't - but you have the full freedom to try them out without worrying about the specifics of the media involved. This is working with a loosely typed language (with features like type coercion etc.)

Now imagine trying to being creative in the same way, and being told every 2 minutes that you can't use this media on this canvas ("You can't use yoghurt here"). This is working with a strictly typed language. It will inevitably slow you down, and restrict the flow of ideas with constant interruptions.

I started learning to code 38 years ago, and have used many different languages. I've come to view coding as a very creative, sometimes even artistic process - and there's nothing better for trying out new ideas than languages that let you play fast and loose with types.

Collapse
 
scottshipp profile image
scottshipp

Types just make everything far easier to reason about and save you from having to write tests that a compiler is good at checking for you anyway. Like anything they aren't perfect and are only a tool.

Collapse
 
mitya8128 profile image
mitya8128

for python I don't think that it's appropriate to compare type hints with Cython or PyPy, but I understand you and, in some approximation, agree.

Collapse
 
ughurh profile image
Ughur Huseyn

I wanted to say Cython have type declarations, and PyPy needs to infer types. I didn't compare type hints with them.