Types::string

I have never really understood the argument for strict typing. We store everything away as bits anyway – so why do we have type keepers?

The Raw truth:

Instructions are recognized by the computer in bits, Data are stored in the computer in bytes, which are the smallest addressable memory(8 bits).

Languages have different methods of managing data for safety and efficiency.

The Allure of Dynamic Typing

Developers love dynamic languages like Python as they increase their **expressivity **with its seductive duck typing.
x = "foo" # a string
y = 700 # now an int - no compiler to appease

Static Languages Embracing Dynamism

Even static languages have embraced controlled dynamism over the years:

  • C++ (2017): introduced std::any and std::variant

  • C# (2009): C#4.0 added dynamic and dynamic language runtime (DLR) to handle dynamic typing.

Where are we?

A hybrid approach involves static checks and inference at compile time and dynamic inference at runtime. It’s about abstraction, letting the compiler handle the mundane so we can focus on the big picture.

Modern languages often adopt a hybrid approach: static type checking and inference at compile time for safety, with controlled dynamism at runtime for flexibility. This abstraction lets developers delegate even more task routine checks to the compiler while focusing on higher-level logic

Typing Ends …

When coding, do you:

  • Embrace types fully?
  • Crave the flexibility of dynamic freedom?

原文链接:Types::string

© 版权声明
THE END
喜欢就支持一下吧
点赞8 分享
Judge each day not by the harvest you reap but by the seeds you plant.
不要问自己收获了多少果实,而是要问自己今天播种了多少种子
评论 抢沙发

请登录后发表评论

    暂无评论内容