Do you struggle with weak typing, and why it was invented?

0 like 0 dislike
116 views
I procedure simply. Writing a project in vue.js. Constantly having to provide data of the same type, because otherwise there is a hard-to-find bugs. As you write code in JS? He's not supposed to be stuffed with parseInt() and !== undefined. How to handle the types?
And most importantly: who came up with weak typing? What are the advantages of it? The only thing that gives weak typing - it makes us constantly check the type.
by | 116 views

7 Answers

0 like 0 dislike
And most importantly: who came up with weak typing?

For starters, get familiar with the classic fallacy, and not to be confused with weak typing and dynamic typing. Now from your question, you might think that this is one and the same.

Dynamic typing was invented in order to make it easier to write generic algorithms and meta-algorithms, in Dean. language to compile the code does not need types of tricks of the generics (TypeScript, C# and much more) or templates/macros (C++). In OO languages are often available and other amenities, for example changing the interface of an object depending on its state (because the decision on the method call/property, the object can make itself).

Weak typing was invented to make people suffer (Yes, I don't know who wants that at all).

As you write code in JS?

We do not write code in JS, we write code in TypeScript. Yes, these are strange times, when the language is statically typed compileda in a dynamic language, because to execute on the client (in the browser) nothing more yet.

He's not supposed to be stuffed with parseInt() and !== undefined.

Don't have to. If you write on bare JS, you can a) use JSDoc annotations on the typesand work types on the level of documentation and agreements; b) to write algorithms in the most generic manner, and claim not to specific data types, and values over which the valid desired operation; C) to cover code with tests, that will save in dynamic languages.

The larger the project, the more important static typing, this is normal. JS is a language which is popular for technical reasons and by coincidence, not because he deserves it (IMHO). Very intelligent uncle and aunt would not have to spend years of your time and a lot of money to develop TypeScript and Flow, if it was unnecessary.
by
0 like 0 dislike
Good architecture reduces the need for casts.
5af00f1b811b0153622827.png
And invented and use dynamic typing because it significantly reduces TTM.
by
0 like 0 dislike
To this end, the projects are using TypeScript or Flow:
const foo = (arg: number) => { /* do something with number type */ };

They are large projects it is better not even to start.

About the advantages of weak typing:
1. The usability of multimodal expressions (e.g. integers, real numbers and strings).
2. Abstracting from typing and focusing on the problem.
3. The brevity of the record.
by
0 like 0 dislike
If you pull any meaning from a document or form, the default data type is string, and if so, then what is there to wonder, Parsis line. If you don't declare any variable, or set a parameter for a function, then again, why wonder, js thoughts can not read? Still have the default settings.
by
0 like 0 dislike
I don't struggle with it, I enjoy it. First, I have very rarely in a variable there are several types - if the variable string, the string it will be. If a variable is a number, it will be the number, plus I will check before using it on the correct number. And secondly, just need to know the basic rules of type conversion which are very simple and clear in JS. Believe it or not, but I have one last error that is associated with weak typing, was three years ago, if not earlier.
by
0 like 0 dislike
You need to learn some materiel in the General theory.
It's dogma like this, those people who can only work within the template...

Alan Kay said


"Until we figure out how to truly need to develop a software solution may be the creation of dynamic systems with extreme late binding in all its manifestations."

"Late binding allows you to implement the ideas in the later stages of development with exponentially less effort than traditional early binding as in C, C++, Java and other similar languages"

"If you use a language with early binding, as most people do, instead of a language with late binding, you will find yourself locked up to have the work done. To restate something that will be too difficult"

"I'm not against types, but I don't know any system types that would not have caused suffering, so I'm still behind dynamic typing"



similarly, people usually do not understand what the PLO:


"I was thinking about objects as living cells or as separate computers on the network that exchange messages... I'm sorry I coined the term "objects" many years ago, because it makes people focus on small ideas. Really great idea — it messages... Object-oriented programming to me means only messaging, local retention and protection and hiding of state-process, and extreme late binding of all"
by
0 like 0 dislike
Weak dynamic typing is useful when we need something to nagovestaj on the knee in a dozen lines without the need for special skills. And with the exception of the last few years, JS was used.
by

Related questions

0 like 0 dislike
7 answers
asked May 12, 2019 by Viktor_Ilukhin
0 like 0 dislike
7 answers
0 like 0 dislike
3 answers
asked May 12, 2019 by logpol32
0 like 0 dislike
6 answers
0 like 0 dislike
6 answers
110,608 questions
257,186 answers
0 comments
32,781 users