{"id":722,"date":"2014-01-27T18:42:19","date_gmt":"2014-01-28T01:42:19","guid":{"rendered":"http:\/\/somethingk.com\/main\/?p=722"},"modified":"2014-01-28T19:20:12","modified_gmt":"2014-01-29T02:20:12","slug":"type-safe-vs-dynamically-typed-programming-languages","status":"publish","type":"post","link":"https:\/\/somethingk.com\/main\/type-safe-vs-dynamically-typed-programming-languages\/","title":{"rendered":"Type-Safe vs Dynamically Typed Programming Languages"},"content":{"rendered":"<p>So a lot of my posts include Python code. <a title=\"Python Programming Language\" href=\"http:\/\/python.org\" target=\"_blank\">Python<\/a> is a powerful, dynamically typed, free application programming language.<\/p>\n<p style=\"text-align: center;\"><a href=\"http:\/\/robotix.in\/blog\/wp-content\/uploads\/2011\/10\/python-vs-java-726367-copy.jpg\"><img fetchpriority=\"high\" decoding=\"async\" class=\"aligncenter\" alt=\"\" src=\"http:\/\/robotix.in\/blog\/wp-content\/uploads\/2011\/10\/python-vs-java-726367-copy.jpg\" width=\"435\" height=\"286\" \/><\/a><\/p>\n<p>Programming languages are either type-safe or dynamically typed. One setting isn&#8217;t necessarily better than the other.\u00a0It all just depends on your project and what you are trying to accomplish.<\/p>\n<p><strong>Type-Safe (Statically typed)<\/strong><\/p>\n<p>A variable type (int, unsigned int, double, float, etc.) must be explicitly stated when a variable is declared.\u00a0The variable is fixed at compile time which allows the compiler then uses this supplied information to\u00a0ensure the right data is used in the right context. Languages such as C, C+ and Java are type-safe.<\/p>\n<p><em>Pros:<\/em><\/p>\n<ul>\n<li>Less bugs (There is no chance of misreading a variable)<\/li>\n<li>Safer programming<\/li>\n<li>Easier to manage complexity in large projects (Everyone is aware of types and their purpose)<\/li>\n<li>More control over types (You state the type, you are in control over exactly how the compiler sees it)<\/li>\n<\/ul>\n<p><em>Cons:<\/em><\/p>\n<ul>\n<li>Decreased flexibility<\/li>\n<li>Not as recyclable (It&#8217;s not as easy to reuse your code for multiple purposes)<\/li>\n<\/ul>\n<p><em><span style=\"line-height: 1.5em;\">\u00a0Good For:<\/span><\/em><\/p>\n<ul>\n<li>Complicated algorithms and data structures which require strict low-level controls<\/li>\n<li>Memory sensitive large dataset manipulation<\/li>\n<li>Well-defined functions that are likely not to change much over time<\/li>\n<li>Large development teams<\/li>\n<\/ul>\n<p><strong>Dynamically Typed<\/strong><\/p>\n<p>Variables are not declared with a given type. Types are basically determined by the compiler. These languages\u00a0normally include extensive run-time checks to prevent most type errors.<\/p>\n<p><em><span style=\"line-height: 1.5em;\">Pros:<\/span><\/em><\/p>\n<ul>\n<li>Very flexible<\/li>\n<li>Easily Recyclable<\/li>\n<li>Quick development speed and turn-around time<\/li>\n<li>Reduces amount of overall code leading to possible reduction in bugs<\/li>\n<\/ul>\n<p><em>Cons:<\/em><\/p>\n<ul>\n<li>Can have some undesirable effects on the code (If the wrong type is understood in a situation, some\u00a0funky things can happen)<\/li>\n<li>More prone to human failures such as typing errors (Say you mistyped a variable, it might be seen as a new variable all together\u00a0in a dynamic setting)<\/li>\n<li>Decreased efficiency due to run-time checks<\/li>\n<\/ul>\n<p><em><span style=\"line-height: 1.5em;\">Good for:<\/span><\/em><\/p>\n<ul>\n<li>Connecting different components or languages together<\/li>\n<li>Creating graphical user interface<\/li>\n<li>Text manipulation (Concatenating, regular expressions, search, etc.)<\/li>\n<li>Ever changing code<\/li>\n<li>Small segments of CPU-time intensive work<\/li>\n<li>Automatic memory administration<\/li>\n<li>Web server communications<\/li>\n<li>Consistent performance across OS platforms (meaning I can run the script the same on Windows, OSX, Linux, Unix etc.)<\/li>\n<\/ul>\n<p style=\"text-align: center;\"><span style=\"line-height: 1.5em;\"><a href=\"http:\/\/blog.smartbear.com\/wp-content\/uploads\/2013\/10\/unix-jurassic-park.jpeg\"><img decoding=\"async\" class=\"aligncenter\" alt=\"\" src=\"http:\/\/blog.smartbear.com\/wp-content\/uploads\/2013\/10\/unix-jurassic-park.jpeg\" width=\"400\" height=\"266\" \/><\/a><\/span><\/p>\n<p><strong>Not to Be Confused With&#8230;\u00a0<\/strong><\/p>\n<p>In addition, there is also something known as weakly and strongly typing (totally different concept from the type-safe\/dynamic stuff). This refers to one type being able to\u00a0be used as another type. A strong language will not let a string all of a sudden act as an integer. A weak language will allow this, mostly\u00a0due to unintentionally loopholes. Languages such as Pearl and C are known for being weakly typed while Python is a strongly typed language.\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<wbr \/><\/p>\n<p>People will argue one over the other, similar to the whole Mac vs PC debate, in reality both benefit and serve\u00a0different programming objective purposes.<\/p>\n<p style=\"text-align: center;\"><a href=\"http:\/\/www.sprinklemassacre.com\/wp-content\/uploads\/2011\/08\/mac-vs-pc-packing-heat.jpg\"><img decoding=\"async\" class=\"aligncenter\" alt=\"\" src=\"http:\/\/www.sprinklemassacre.com\/wp-content\/uploads\/2011\/08\/mac-vs-pc-packing-heat.jpg\" width=\"210\" height=\"254\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>So a lot of my posts include Python code. Python is a powerful, dynamically typed, free application programming language. Programming languages are either type-safe or dynamically typed. One setting isn&#8217;t necessarily better than the other.\u00a0It all just depends on your project and what you are trying to accomplish. Type-Safe (Statically typed) A variable type (int, unsigned int, double, float, etc.) [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[177,72],"tags":[179,183,181,178,184,180,182],"class_list":["post-722","post","type-post","status-publish","format-standard","hentry","category-development","category-python","tag-dynamically-typed","tag-programming-languages","tag-strong","tag-type-safe","tag-type-safe-vs-dynamically-typed","tag-typed","tag-weak"],"_links":{"self":[{"href":"https:\/\/somethingk.com\/main\/wp-json\/wp\/v2\/posts\/722","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/somethingk.com\/main\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/somethingk.com\/main\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/somethingk.com\/main\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/somethingk.com\/main\/wp-json\/wp\/v2\/comments?post=722"}],"version-history":[{"count":4,"href":"https:\/\/somethingk.com\/main\/wp-json\/wp\/v2\/posts\/722\/revisions"}],"predecessor-version":[{"id":732,"href":"https:\/\/somethingk.com\/main\/wp-json\/wp\/v2\/posts\/722\/revisions\/732"}],"wp:attachment":[{"href":"https:\/\/somethingk.com\/main\/wp-json\/wp\/v2\/media?parent=722"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/somethingk.com\/main\/wp-json\/wp\/v2\/categories?post=722"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/somethingk.com\/main\/wp-json\/wp\/v2\/tags?post=722"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}