Strongly typed languages
What are the main pros and cons of strongly typed programming languages?
Now that this thread comes to life, I think I could use some more concrete clarification of what defines strong & weak typed languages, having found my understanding of the subject was a total mess : ) And despite how interesting the definitions be, let's not to forget what the main topic was, the pros & cons of strongly typed languages. I'm going to learn a lot from this 😁
Sonic That is also what I understand about strongly typed languages. In Python we can declare variables without a strict need to first define their types, and later on we can assign a different type of data into those variables and things will be just fine. In C, C++ or Java this is not possible AFAIK. But I'm no expert either and also still learning all this stuffs.
From the top of my head: Strongly typed languages (like Python) have more safety because violations will give you Errors. On the other hand they also need more overhead than weakly typed languages (like C++) and are less flexible when it comes to optimizations at compile time. And now I'm excited to read what answers the pros around here will give to this interesting question . :-)
(Also only reading to you from a book I'm reading now: ;-)) Sonic yes, the implicit conversions seem to be a reason for calling it weakly typed. To me it seems a bit 'unfair' since you could also just rely on safe tools... but you have the freedom to deal with it whichever way (the compiler has it too). Having to declare and stick to the types of variables or not makes the difference between 'dynamically and statically typed' which is another thing.
Thanks a million to all for your replies, you're very helpful! ;) Apart from the integer-string combination example, can anyone provide more scenarios in which the typing could be relevant in terms of chosing a programming language for a project? Thanks again.
Ion Elberdin Navarro I can't really imagine a situation when strong / weak typing should be a main decision factor for choosing a particular programming language. It is just a given characteristics of the language. There are ways to handle type issues in both worlds, you just need to be aware of the impact and possible solutions.
I have a little experience with C# which is by definition "strongly typed". It means that you have to explicit the type during variable declaration and that you must always make a proper conversion of type to do what you want to do. In the beginning this can be annoying, but in the end, it cause you to pay attention to "what is" and "what it will turn to be" (adding a "control layer" in the code writing). Plus, if there are type coherence mistakes, then compiler won't compile and you have to debug. Annoying in the beginning (also for the quantity of code that you have to write) but paying and satisfying in the long run (when the quality of code is higher).
They prevent you from shooting yourself in the leg. They bind variables to a specific type making it easier to follow along how your code works i.e. what is making what do what unlike weakly typed ones.
Tibor Santa I agree with you, nevertheless it's a factor that could be included in a trade-off analysis.
strongly -typed languages generally appeal to me. I feel like they protect me from myself. More than that, they force me to think through what I'm doing. A lot off code works in spite of us. Java makes us stay aware of the nature of our objects. It compliments sophisticated OOP, using static classes and interfaces.
Then Python (dynamicly & strongly tipped) C/C++ (staticly & strongly tipped)
Given three integer matrices A(m*n),B(m*n) and C(m*n) . Print the one with more zero elements. beside code
sizeof funtion with a loop in c!
1. Write a program that asks the user for their name and how many times to print it. The program should print out the user’s nam