Dynamic Typing is a property of a programming language where type checks are performed mostly at run time.

learn more… | top users | synonyms

85
votes
16answers
23k views

What functionality does dynamic typing allow?

I've been using python for a few days now and I think I understand the difference between dynamic and static typing. What I don't understand is under what circumstances it would be preferred. It is ...
50
votes
14answers
5k views

Is it a bad idea to return different data types from a single function in a dynamically typed language?

I come from a statically typed language background (Java). In Java, you have to return a single type from every method. For example, you can't have a method that conditionally returns a String or ...
46
votes
6answers
3k views

Dynamically vs Statically typed languages studies

Do there exist studies done on the effectiveness of statically vs dynamically typed languages? In particular: Measurements of programmer productivity Defect Rate Also including the effects of ...
41
votes
21answers
12k views

Is type safety worth the trade-offs?

I began coding in in Python primarily where there is no type safety, then moved to C# and Java where there is. I found that I could work a bit more quickly and with less headaches in Python, but then ...
39
votes
4answers
5k views

Is there a correlation between the scale of the project and the strictness of the language?

Explaining the difference between strictness of languages and paradigms to a colleague of mine, I ended up asserting that: Tolerant languages, such as dynamic and interpreted languages, are used ...
35
votes
8answers
3k views

What is the supposed productivity gain of dynamic typing?

I often heard the claim that dynamically typed languages are more productive than statically typed languages. What are the reasons for this claim? Isn't it just tooling with modern concepts like ...
26
votes
9answers
3k views

Do dynamic typed languages deserve all the criticism? [closed]

I have read a few articles on Internet about programming language choice in the enterprise. Recently many dynamic typed languages have been popular, i.e. Ruby, Python, PHP and Erlang. But many ...
25
votes
3answers
2k views

Is there a real advantage to dynamic languages? [closed]

First I want to say Java is the only language I ever used, so please excuse my ignorance on this subject. Dynamically typed languages allow you to put any value in any variable. So for example you ...
20
votes
4answers
2k views

Architectural differences between dynamic and static languages

Are there any major architectural differences when designing applications that will be built on static languages (such as C# or Java) and dynamic languages (such as Ruby or Python)? Which are the ...
18
votes
3answers
602 views

Are there any empirical studies on the effect of different languages on software quality?

The proponents of functional programming languages assert that functional programming makes it easier to reason about code. Those in favor of statically typed languages say that their compilers catch ...
13
votes
9answers
2k views

Dynamic vs Statically typed languages for websites [closed]

This statement suggests that statically typed languages are not ideal for web sites: I’ll contrast that with building a website. When rendering web pages, often you have very many components ...
13
votes
3answers
1k views

How do you navigate and refactor code written in a dynamic language?

I love that writing Python, Ruby or Javascript requires so little boilerplate. I love simple functional constructs. I love the clean and simple syntax. However, there are three things I'm really bad ...
12
votes
10answers
1k views

Why dynamically typed languages do not let the developer specify the type?

The dynamically typed languages I know never let the developers specify the types of variables, or at least have a very limited support for that. JavaScript, for example, doesn't provide any ...
11
votes
10answers
2k views

Is dynamic language always interpreted?

Looking at most (if not all) dynamic languages [i.e Python, PHP, Perl and Ruby], they are all interpreted. Correct me if I'm wrong. Is there any example of dynamic language that goes through ...
11
votes
2answers
862 views

What is the relationship between the Dynamic Language Runtime and C# 4.0?

Let's say I wanted to create a dynamic language compiler/interpreter, a Scheme interpreter perhaps, on the .NET platform as it exists today. Would I be better off using the Dynamic Language Runtime ...
9
votes
4answers
1k views

How does thinking on design patterns and OOP practices change in dynamic and weakly-typed languages?

There is a fairly helpful question already along these lines ("Non-OOP Design Patterns?"), but I am more curious about a transitional point of view for someone just getting started with dynamic and ...
9
votes
2answers
368 views

Developing a dynamic language

I have created several hand written compilers for very simple languages but now I want to try my hand at developing a dynamic language, similar to a simplified Python or Ruby. However, it was easy ...
8
votes
5answers
1k views

Are dynamic languages at disadvantage for agile development?

From what I've read agile development often involves refactoring or reverse engineering code into diagrams. Of course there is much more than that, but if we consider the practices that rely on these ...
8
votes
6answers
914 views

What is better for prototyping: a statically-typed language, or a dynamically-typed one? [closed]

When working out the design for a new system, is it better to start with a statically-typed language (like Haskell), or a dynamically-typed language (like Ruby)? Arguments I can think of: With a ...
7
votes
13answers
4k views

Would a statically typed alternative to JavaScript on webpages be practical?

Preference for dynamic and static typing is largely a matter of taste, and different people find them more or less suitable in different situations. My question is, would it be technically possible ...
7
votes
2answers
570 views

Why build data models in a dynamic language?

Background This question stems out of an architectural discussion we had at work. For the current project we are using Python and an object oriented database. There are input services that we ...
6
votes
3answers
370 views

Is changing the type of a variable partway through a procedure in a dynamically typed language bad style?

In Python (and occasionally PHP) where variables do not have fixed types, I'll frequently perform 'type transformations' on a variable part-way through my code's logic. I'm not (necessarily) talking ...
6
votes
4answers
841 views

How does one learn to program (and think) the Ruby way? [closed]

Why I Ask this Question: I've just starting to learn Ruby (and by extension IronRuby since I work in the Microsoft world). I picked up IronRuby Unleased to teach me the basic syntax of Ruby, and any ...
6
votes
3answers
463 views

How should I program with dynamic typing language even no type is noted on documentation?

I lived long time on static typed language world. All types were explicitly noted on each variables and arguments. Now I have to use some kind of dynamic typing language. (Smalltalk) The problem is ...
6
votes
3answers
332 views

Dynamic typing function arguments - how to keep readability high?

Dynamic typing newbie here, hoping for some wizened words of wisdom. I'm curious if there is a set of best practices out there for dealing with function arguments (and let's be honest, variables in ...
5
votes
5answers
755 views

Gradual Typing: “Almost every language with a static type system also has a dynamic type system”

This claim by Aleks Bromfield states: Almost every language with a static type system also has a dynamic type system. Aside from C, I can't think of an exception Is this a valid claim? I ...
5
votes
5answers
342 views

Type-clarifying comments and type checking in dynamic languages

I often feel that there's something wrong when I code blocks such as: function foo (arg){ // arg: a SomeClass object ... } or function foo (arg){ if (Object.prototype.toString.apply(arg) ...
5
votes
4answers
866 views

Can static and dynamically typed languages be seen as different tools for different types of jobs?

Yes, similar questions have been asked but always with the aim of finding out 'which one is better.' I'm asking because I came up as a dev primarily in JavaScript and don't really have any extensive ...
5
votes
5answers
2k views

When and why should one create classes at runtime?

I have read many articles on the creation of dynamic types and classes at run time. For example, the TypeBuilder class in C# lets one create dynamic types. Python has this type function by which one ...
5
votes
3answers
333 views

Dynamic typing across the whole technology stack - where to enforce data validity?

Over the past year or two, I've been playing with newer technologies in my side projects. As a web developer, I've gone from the following (and still the following, at work): The 'classic' technology ...
5
votes
3answers
438 views

C# Dynamic types

I just read a chapter in a programming book about Dynamic types. Although they are quite neat I cant think of a single real world example where I would use them. Does anyone here actually use them and ...
5
votes
3answers
3k views

What can I use instead of Interfaces in Ruby (or any other dynamic language)?

My goal is to define contracts between classes. I like duck typing and all but I'd like also to define an interface between different layers of my application to clearly define which are the method ...
4
votes
5answers
652 views

How can a statically typed language support duck typing?

I understand what dynamic and static type systems are, and what duck typing is. But I don't understand how you can have a static language that supports duck typing. To my understanding only a ...
4
votes
5answers
1k views

Are design patterns independent of programming languages?

I have been recently working on Objective C and came across use of Delegate pattern. I had seen most of the common patterns theoretically in Java, thanks to the Head First book. But at times looking ...
4
votes
1answer
162 views

How are atomic operations are a dynamic language feature?

I was told that atomic operations are a dynamic language feature. I was too afraid to ask in that context what this actually means because I didn't want my coworkers to think I'm stupid. But I ...
4
votes
3answers
260 views

Classes in OOP , methods and attributes memory internals [closed]

I would assume that instances of the same class would actually share their methods, and just have save different attributes in their namespace. How often do you arbitrary add methods to a single ...
4
votes
5answers
1k views

Learning to implement dynamically typed language compiler [closed]

I'm interested in learning how to create a compiler for a dynamically typed language. Most compiler books, college courses and articles/tutorials I've come across are specifically for statically typed ...
4
votes
2answers
341 views

Is using static-typing the solution to domain-driven design and decreasing the number of errors?

We are using PHP (a dynamically-typed language) in our project. However, I have found my colleagues asking questions such as ...
4
votes
0answers
81 views

How significant is the impact of the type system (static/dynamic) on the overall design of programs? [duplicate]

Coming from Java, I've never used a language with dynamic typing. I'm very used to the static-typing way of thinking. My question is, how much does the use of dynamic typing as opposed to static ...
3
votes
6answers
758 views

In Java, would you sacrifice type safety for a nicer programming interface

When and why would you generally sacrifice typesafety for a nicer programming interface? Let me give you an example: if you had the choice between two event aggregators, which one would you prefer ...
3
votes
5answers
380 views

What are the types of dynamically typed languages arrays?

For example, in JavaScript, I can do such things: var arr = [1, "two", /three/, [4]]; There is no way to do such a thing in C! Except by using a void*, which is not an efficient/safe way. Is this ...
3
votes
4answers
560 views

Higher coding standards for dynamic languages?

Due to the inherent risks associated with using dynamic languages (e.g. Python, Ruby) carelessly, what (if any) standards should be imposed on production code written in these languages?
3
votes
1answer
121 views

A question about static types

How would you statically type the following JavaScript program function c(str) { c = eval(str); return c(str); } I'm not trying to start a flame war but I'm genuinely curious. I've always ...
3
votes
2answers
699 views

Are all scripting languages dynamically typed? [closed]

Are all scripting languages dynamically typed? I am using TCL. It is a scripting language and it does not enforce or allow type delaration of variables. It is instead a dynamically-typed language ...
3
votes
2answers
206 views

In javascript and other languages which lack a compiler, is unit testing a good method to ensure correct syntax and variable naming?

I've been working on a medium sized web application that makes very heavy use of javascript. I tend to introduce common errors per 10 lines of code with either an unknown variable name or function ...
2
votes
6answers
808 views

Why is PHP's method of comparing different types bad?

I'm working on designing a new programming language and trying to decide how I will do variable comparisons. Along with many different types of languages, I've used PHP for years and personally had ...
2
votes
3answers
94 views

How do statically typed languages handle test discovery? [closed]

I come from a Python background, so I'm used to pretty automatic test discovery. For example, the py.test library automatically locates any files which begin with test, finds classes whose names start ...
2
votes
2answers
267 views

New insights I can learn from the Groovy language

I realize that, for a programmer coming from the Java world, Groovy contains a lot of new ideas and cool tricks. My situation is different, as I am learning Groovy coming from a dynamic background, ...
2
votes
2answers
152 views

unit testing variable state explicit tests in dynamically typed languages

I have heard that a desirable quality of unit tests is that they test for each scenario independently. I realised whilst writing tests today that when you compare a variable with another value in a ...
2
votes
0answers
111 views

How to restructure Python frameworks [duplicate]

I just joined a group of five developers (non-professionals) working on a medium sized Python framework (> 50 modules, > 10.000 lines of code). The project has no documentation whatsoever and there ...