1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Statically Typed Versus Dynamically Typed Languages

Discussion in 'Programming' started by serialentre, Sep 14, 2015.

  1. #1
    Hi all,

    Is there an advantage of Statically Typed over Dynamically Typed, and vice versa?

    Came across this article recently - http://fsharpforfunandprofit.com/posts/ten-reasons-not-to-use-a-functional-programming-language/
     
    serialentre, Sep 14, 2015 IP
  2. mmerlinn

    mmerlinn Prominent Member

    Messages:
    3,197
    Likes Received:
    818
    Best Answers:
    7
    Trophy Points:
    320
    #2
    I read that article and it leaves me totally confused.

    I started programming 31 years ago with Apple Basic. All variable names were statically typed, for example the names of all strings ended in $, like Title$ = "The Mouse". Title$ could never be anything except a string, never logical, never numeric.

    Today, I do most of my programming in FoxPro, which uses dynamic typing depending on what is assigned to the variable. For example, by doing Title = "The Mouse", Title is dynamically designated as a string. If I later say, Title = 1, we now have Title defined as a number. Basically, any variable name can be any type at any time only depending on what is assigned to it.

    Now if that is what the article was dancing around and if your question is about the advantages/disadvantages of each, then here is my take.

    Static typing (#1 above) - Very rigid. Makes for easy assimilation of exactly what kind of variables we are working with. Very easy to debug when I had 'Mismatched type' errors. A pain in the butt to always remember to add the correct type symbol to every variable name. Impossible to assign a number to any other type of variable, for example.

    Dynamic typing (#2 above) - Extremely hard to find 'Mismatched type' errors without stepping through the code. No way of preventing any variable name from being assigned to any type anywhere in the code. Same variable name could be logical, string, number, integer, and so on at any time. Requires extreme consciousness while coding to avoid using the same variable name for different types of variables.

    My preference? Dynamic. When I first switched I had many problems keeping things straight in the code. Nowadays, after 20 years of using FoxPro, I seldom have variable mismatch problems that I can't solve in a few minutes. And I don't need the code bloat of $, %, etc to keep things straight.
     
    mmerlinn, Sep 14, 2015 IP
  3. serialentre

    serialentre Member

    Messages:
    123
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    30
    #3
    Thanks mmerlinn!

    Can I say that the crux is that it's not so much a case of which type is better for creating and writing software. Rather, it is a function of the times where the language was created?
     
    serialentre, Sep 14, 2015 IP
  4. mmerlinn

    mmerlinn Prominent Member

    Messages:
    3,197
    Likes Received:
    818
    Best Answers:
    7
    Trophy Points:
    320
    #4
    If you base that conclusion on only the two examples I gave, then you could, otherwise you shouldn't as there are probably modern languages I know nothing about that use static typing.

    As far as getting the job done, static and dynamic typing of variable names is really a non-issue. They both will do the job and they both have their own pluses and minuses.

    As far as that article is concerned, the writer is a selfish thief. He thinks that getting paid by the number of lines he codes that it gives him liberty to stuff his code with all kinds of crap creating code bloat, impossible code for others to debug, slow code, and so on. I NEVER believe a thief, so to me his whole article is nothing more than pure unadulterated crappy NONSENSE.
     
    mmerlinn, Sep 15, 2015 IP
  5. serialentre

    serialentre Member

    Messages:
    123
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    30
    #5
    Cool cool. Thanks for your insight.

    The author is merely using tonnes of sarcasm I think. :)
     
    serialentre, Sep 15, 2015 IP
    deathshadow likes this.