Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Perl as a Strong-Type and Dynanmic Programming Language

by bichonfrise74 (Vicar)
on Aug 27, 2010 at 20:50 UTC ( #857765=perlquestion: print w/ replies, xml ) Need Help??
bichonfrise74 has asked for the wisdom of the Perl Monks concerning the following question:

From the wikipedia, the following terms are defined:
  • Strong type language - used to describe those situations where programming languages specify one or more restrictions on how operations involving values having different data types can be intermixed.
  • Dynamic programming language - execute at runtime many common behaviors that other languages might perform during compilation, if at all.

    Based on the above definitions, would you say that:
  • Perl is not a strong type language since we do not need to define the type of the variable?
  • Perl is a dynamic programming language?
  • Comment on Perl as a Strong-Type and Dynanmic Programming Language
    Re: Perl as a Strong-Type and Dynanmic Programming Language
    by Marshall (Prior) on Aug 27, 2010 at 20:59 UTC
      Perl doesn't really have data types in the sense that C or Java does.

      C++ has run time vtables and I think Perl has an equivalent concept for OO. So in that sense it is dynamic (can figure out what exact code to execute for a method call at run time - enables polymorphism among other things.

      In Perl you can actually write a program "on the fly" and then execute it - how much more dynamic could it be?

      Sure that other Monks will have lots to say about all of this.

      Update: So I am basically going to duck 'n cover for now.

    Re: Perl as a Strong-Type and Dynanmic Programming Language
    by ikegami (Pope) on Aug 27, 2010 at 21:44 UTC

      would you say that Perl is not a strong type language since we do not need to define the type of the variable?

      Actually, you must define the type of the variable in Perl by using the right sigil. It's a question of specificity.

      Questions about whether a language is strongly typed or not don't lead to anything productive. It's usually used to apply against preconceptions about code robustness, code size, coding speed, etc. Those are definitely interesting areas of study. Whether a language is strongly typed or not isn't. In short, your question suffers from the XY Problem.

      I recommend that you read the results of Dominus's attempt to define "strongly typed".

      Dynamic programming language - execute at runtime many common behaviors that other languages might perform during compilation

      Given how common dynamic programming languages have become, your definition doesn't match any languages. Your definition is a contradiction.

        Questions about whether a language is strongly typed or not don't lead to anything productive. It's usually used to apply against preconceptions about code robustness, code size, coding speed, etc. Those are definitely interesting areas of study. Whether a language is strongly typed or not isn't. In short, your question suffers from the XY Problem.

        ikegami ++!





        I am trying to improve my English skills, if you see a mistake please feel free to reply or /msg me a correction

    Re: Perl as a Strong-Type and Dynanmic Programming Language
    by davies (Vicar) on Aug 27, 2010 at 22:35 UTC
      I can't really add to this and this.

      Regards,

      John Davies
    Re: Perl as a Strong-Type and Dynanmic Programming Language
    by nikosv (Hermit) on Aug 29, 2010 at 07:36 UTC

      would you say that Perl is not a strong type language since we do not need to define the type of the variable?

      Strong typing has no much to do with variable types, it has to do with conversions from one type to another. Strongly typed languages typically disallow implicit conversions between unrelated types. What you are referring to is static typing

      Questions about whether a language is strongly typed or not don't lead to anything productive.

      I do believe the same but at the same time think that it could get important when you want use more than one language in a project or you want to learn a new language, and can potentially face issues that can arise from the variation in their type systems

      For example if one is accustomed in writing in VB.net and wants to write in C# as well, he could find the transition not so smooth, not because of that they are different languages per se, but because their type systems allow or disallow certain operations which could interfere with existing experience.

      For example in VB.net the Object type behaves dynamic language style(when option strict off is turned off) while in C# the behaviour is purely statical (until lately one would have to use the Reflection services to get dynamic style behaviour) or as far as weak typing goes, the compiler would allow implicit conversions between unrelated types in an expression evaluation i.e treat a string as a number (like VB.net and Perl do) while in C# would not.

      Certainly, one cannot label a language as purely strongly typed or purely weakly typed because even Perl notoriously labeled as weakly typed displays strong typing properties ,in some cases, but I think that if one has a grasp on the principles would enjoy a smoother transition and/or improved production

        can potentially face issues that can arise from the variation in their type systems

        Then talk about the variations. Using a term that both applies and doesn't apply to just about every language doesn't help.

    Re: Perl as a Strong-Type and Dynanmic Programming Language
    by sundialsvc4 (Monsignor) on Aug 29, 2010 at 23:04 UTC

      Based on these definitions, I would generally agree.

      As to the second point, it is worth mentioning that many language implementations today (and language designs today) are far more “dynamic” in nature than many earlier languages literally could afford to be.   Processor speeds and memory sizes are orders of magnitude larger than before, making many strategies practical which could not be considered in earlier times.   Languages quickly followed suit.   So, this distinction, in practical terms today, is just not that useful a distinction anymore.   It has become “academic.”

      Q:   Where do you draw the line?
      A:   Only where the line is useful.

    Re: Perl as a Strong-Type and Dynanmic Programming Language
    by Jenda (Abbot) on Aug 30, 2010 at 21:04 UTC

      You don't need to have to specify the type for the language to be strong typed. Ask Google about "type inference". There are languages that do not expect you to declare the types (most of the time), because they can infer the type and test the consistency of a variable's/function's use. Actually for the most simple cases you no longer have to specify the type even in C# or VB.Net.

      Jenda
      Enoch was right!
      Enjoy the last years of Rome.

        However it should be pointed out that type inference is a compile time afair and not a runtime afair;C# did not turn dynamic because of the use of the 'var' keyword.

        In the most simple cases such as with primitive data types, type inference provides a shortcut instead of explicitly denoting the type of the variable :

        var a=10; #the compiler infers that a is an int

        but its real value comes when having to assign the return value of an expression's evaluation to a variable and is difficult to work out the variable's type so you must cast or re-cast;cases like that occur frequently with Linq queries

    Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Node Status?
    node history
    Node Type: perlquestion [id://857765]
    Approved by GrandFather
    Front-paged by Erez
    help
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others about the Monastery: (4)
    As of 2014-07-26 14:38 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      My favorite superfluous repetitious redundant duplicative phrase is:









      Results (178 votes), past polls