R
R
Roman2019-05-04 11:02:20
Programming
Roman, 2019-05-04 11:02:20

Why so much enthusiasm around typing? I think it's much easier without it, no?

Hello.
I am a simple web developer and frankly do not understand why there is so much noise around "strong typing" and all that stuff.
Personally, the need to prescribe the data type everywhere would have put me on the contrary.
In my opinion, the ability to not do this in PHP and JS is just the same advantage.
So right?

Answer the question

In order to leave comments, you need to log in

5 answer(s)
A
Alexander, 2019-05-04
@procode

I will supplement all other answers that you should not confuse strong typing with static typing .
Typehints in the same php make it much easier to understand and develop code, leaving it still a weakly typed language.

E
Evgeny Romashkan, 2019-05-04
@EvgeniiR

It's not normal to write code and not know what types you're working with.
This leads to errors, complicates code understanding, and greatly complicates static analysis.
Therefore, in php there is vimeo psalm, phpdocs with types and type hints from version 7, and in js typescript (any other kotlin native by the way)

K
koperagen, 2019-05-04
@koperagen

Knowing the type of the variable, the development environment can suggest:
In some languages, such as Kotlin, the type system allows you to keep track of null values ​​and handle them in your code.
Moreover, most statically typed languages ​​have the ability to infer a type from an expression. Those. you can write a type only where it is really necessary. The difference from JS is that types are still tracked at compile time and you can't assign a value of another type to a variable.
The entry of the form is
equivalent to the entry
This will result in an error:

val a = 2 + 3
a = "Hello"

All this helps to move entire categories of errors from runtime to compilation stage (For an IDE, the coding stage at all)

U
Urukhayy, 2019-05-04
@Urukhayy

If there are types and compilation, then more than half of the bugs are caught by the compiler.

B
BorLaze, 2019-05-05
@BorLaze

Here , as ordered - a great example of why variable declarations, typing and other "excesses that limit the programmer" are needed :-)))

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question