dynamic-typing

Using Variables for Class Names in Python?

I want to know how to use variables for objects and function names in Python. In PHP, you can do this: $className = "MyClass"; $newObject = new $className(); How do you do this sort of thing in Python? Or, am I totally not appreciating some fundamental difference with Python, and if so, what is it? ...

Can someone tell me what Strong typing and weak typing means and which one is better?

Can someone tell me what Strong typing and weak typing means and which one is better? ...

What is the preferred way to type-check variables in Python?

I have a Python function that takes a numeric argument that must be an integer in order for it behave correctly. What is the preferred way of verifying this in Python? My first reaction is to do something like this: def isInteger(n): return int(n) == n But I can't help thinking that this is 1) expensive 2) ugly and 3) subject to ...

Is it defined behavior to change an Objective-C object's isa?

In Objective-C, you can change an object's dynamic type at runtime by assigning to it's isa member variable: id object = ...; object->isa = [SomeClass class]; Is this undefined behavior? I'm currently doing this as a kludge for something else, and it appears to be working, but I feel so dirty doing it this way. The new class I'm set...

Python Programming - Rules/Advice for developing enterprise-level software in Python?

I'm a somewhat advanced C++/Java Developer who recently became interested in Python and I enjoy its dynamic typing and efficient coding style very much. I currently use it on my small programming needs like solving programming riddles and scripting, but I'm curious if anyone out there has successfully used Python in an enterprise-quality...

When is sqlite's manifest typing useful?

sqlite uses something that the authors call "Manifest Typing", which basically means that sqlite is dynamically typed: You can store a varchar value in a "int" column if you want to. This is an interesting design decision, but whenever I've used sqlite, I've used it like a standard RDMS and treated the types as if they were static. Inde...

Cast an object with Type T to Type T<System.Guid>

I inherited a project with a Windows mobile part. To make a long story short, my problem is this: [DBPropertyUpdate("CustomerId")] [DBPropertyRetrieve("CustomerId")] public CustomerBase<T> Customer { get { return _customer; } set { _customer = SetProperty(_customer, value); } } throws an exception. In a watch window I have th...

How does a virtual machine work?

I've been looking into how programming languages work, and some of them have a so-called virtual machines. I understand that this is some form of emulation of the programming language within another programming language, and that it works like how a compiled language would be executed, with a stack. Did I get that right? With the provis...

Dynamic typing in C#

I know this does not work, however does anyone have a way of making it work? object obj = new object(); MyType typObj = new MyType(); obj = typObj; Type objType = typObj.GetType(); List<objType> list = new List<objType>(); list.add((objType) obj); EDIT: Here is the current code: http://github.com/vimae/Nisme/blob/4aa18943214a7fd4ec65...

Is there a dream language that merges the benefits of dynamic and strong typing?

I would be interested to learn a language that handles objects internally as hashtables (like JavaScript) but could wrap them with strong types to offer the benefits of code completion/intellisense in design time. Here is how I wish this dream language to work: public class Lion { public void Roar() { Console.WriteLine("Aaarrgghh");} ...

Dynamic typing and return values in Objective-C

Hello! I have run into a very strange behaviour I can’t make sense of. I have a Texture class with contentWidth property of type int. This class is wrapped in a Image class that has a width property of type int. The width of an Image is computed simply as the contentWidth of the underlying texture: - (int) width { return texture.co...

Why do COM libraries used from C# 4.0 require such heavy use of dynamic types?

In the C# 4.0 demos, I'm seeing lots of code that uses the dynamic type. For example, the following code sets the value of an Excel cell: excel.Cells[1, 1].Value = ... However, you can also access the cell in an early bound manner with a cast: ((Range)excel.Cells[1, 1]).Value = ...; Why don't the Excel COM library just describe the C...

Why Is Dynamic Typing So Often Associated with Interpreted Languages?

Simple question folks: I do a lot of programming (professionally and personally) in compiled languages like C++/Java and in interpreted languages like Python/Javascript. I personally find that my code is almost always more robust when I program in statically typed languages. However, almost every interpreted language I encounter uses dyn...

Which out of Python, Ruby, F# is better for learning as first programming language with dynamic type system?

I am thinking to learn programming language with dynamic type system. Which one should I learn first? Criteria: I can learn and start programming in a day or two Easy, Concise In few days I should be able to write small scripts for some batch jobs with file systems. To mention, I am normally a quick learner. ...

type of object references in ruby

Hello, I am new to Ruby and currently trying a few examples from the Ruby book I am using as a guide: class Account attr_accessor :balance def initialize(balance) @balance = balance end end class Transaction def initialize(account_a, account_b) @account_a = account_a @account_b = account_b end def debit(account,amount) a...

What is the difference between statically typed and dynamically typed languages?

Hi, I hear a lot that new programming languages are dynamically typed but what does it actually mean when we say a language is dynamically typed vs. statically typed? Thanks ...

How can I create an instance of type dynamically in Java

Hello. In my Java application I have method public <T extends Transaction> boolean appendTransaction(T transaction) { ... } and inside of this method I need to create an instance of object T which extends Transaction Is it correct to do it in this way T newTransaction = (T) transaction.getClass().newInstance(); ...

Different approaches to dynamic typing in the CLR and JVM

.NET 4.0 introduces new support for dispatching invocations on dynamically typed objects. As far as I can make out, this involves: no change to the CLR new types in the BCL new compilers that convert new syntax into usages of the new types In the Java space, folks are discussing adding a new dynamicinvoke bytecode to the JVM such th...

Statically typed languages vs. dynamically typed languages

How is the association of type and parameter different in a dynamically typed language than a statically typed language? ...

Is there a citation available for 'a growing rebellion' against strict typing systems?

The FAQ for the new Go language explicitly makes this claim: There is a growing rebellion against cumbersome type systems like those of Java and C++, pushing people towards dynamically typed languages such as Python and JavaScript. Is there (non-anecdotal) data to actually support such a claim? I've always found dynamic typing slo...