dynamic-languages

What is a dynamic language, and why doesn't C# qualify?

亡梦爱人 提交于 2019-12-03 03:35:51
问题 Listening to a podcast, I heard that C# is not dynamic language while Ruby is. What is a "dynamic language"? Does the existence of dynamic languages imply that there are static languages? Why is C# a dynamic language and what other languages are dynamic? If C# is not dynamic, why is Microsoft pushing it strongly to the market? As well why most of .NET programmers are going crazy over it and leaving other languages and moving to C#? Why is Ruby "the language of the future"? 回答1: What is a

Are Interfaces in JavaScript necessary?

坚强是说给别人听的谎言 提交于 2019-12-02 23:54:35
I suppose this could apply to any dynamic language, but the one I'm using is JavaScript. We have a situation where we're writing a couple of controls in JavaScript that need to expose a Send() function which is then called by the page that hosts the JavaScript. We have an array of objects that have this Send function defined so we iterate through the collection and call Send() on each of the objects. In an OO language, if you wanted to do something similar, you'd have an IControl interface that has a Send() function that must be implemented by each control and then you'd have a collection of

Using Groovy MetaClass to overwrite Methods

喜夏-厌秋 提交于 2019-12-02 19:25:28
I have a POJO that uses a service to do something: public class PlainOldJavaObject { private IService service; public String publicMethod(String x) { return doCallService(x); } public String doCallService(String x) { if(service == null) { throw new RuntimeException("Service must not be null"); } return service.callX(x); } public interface IService { String callX(Object o); } } And I have a Groovy test case: class GTest extends GroovyTestCase { def testInjectedMockIFace() { def pojo = new PlainOldJavaObject( service: { callX: "very groovy" } as IService ) assert "very groovy" == pojo

How do you program differently in dynamic languages?

吃可爱长大的小学妹 提交于 2019-12-02 19:06:00
How would someone who really knows how to take advantage of dynamic programming languages approach programming differently than someone working in a static language? I'm familiar with the whole debate over static versus dynamic typing, but that's not what I'm getting at. I'd like to discuss problem solving techniques that are practical in dynamic languages but not in static languages. Most of the code I've seen written in dynamic programming languages isn't very different than code written in static programming languages. As the saying goes, you can write FORTRAN in any language, and many

What is a dynamic language, and why doesn't C# qualify?

℡╲_俬逩灬. 提交于 2019-12-02 17:05:44
Listening to a podcast, I heard that C# is not dynamic language while Ruby is. What is a "dynamic language"? Does the existence of dynamic languages imply that there are static languages? Why is C# a dynamic language and what other languages are dynamic? If C# is not dynamic, why is Microsoft pushing it strongly to the market? As well why most of .NET programmers are going crazy over it and leaving other languages and moving to C#? Why is Ruby "the language of the future"? What is a dynamic language? Whether or not a language is dynamic typically refers to the type of binding the compiler does

Short description of the scoping rules?

落爺英雄遲暮 提交于 2019-12-02 09:02:16
What exactly are the Python scoping rules? If I have some code: code1 class Foo: code2 def spam..... code3 for code4..: code5 x() Where is x found? Some possible choices include the list below: In the enclosing source file In the class namespace In the function definition In the for loop index variable Inside the for loop Also there is the context during execution, when the function spam is passed somewhere else. And maybe lambda functions pass a bit differently? There must be a simple reference or algorithm somewhere. It's a confusing world for intermediate Python programmers. Rizwan Kassim

How programs written in interpreted languages are executed if they are never translated into machine language?

久未见 提交于 2019-12-01 18:59:19
Computers can only understand machine language. Then how come interepreters execute a program directly without translating it into machine language? For example: <?php echo "Hello, World!" ; It's a simple Hello World program written in PHP. How does it execute in machine while the machine has no idea what echo is? How does it output what's expected, in this case, the string Hello, World!? Many interpreters, including the official PHP interpreter, actually translate the code to a byte code format before executing it for performance (and I suppose flexibility) reasons, but at its simplest, an

Why don't we require interfaces in dynamic languages?

此生再无相见时 提交于 2019-11-30 17:17:25
Is it just because of dynamic typing we don't require a concept of interfaces(like in Java and C#) in python? OscarRyz The interface as a keyword and artifact was introduced by Java 1 ( and C# took it from there ) to describe what the contract an object must adhere was. But, interface has always been a key part of Object Oriented Paradigm and basically it represents the methods an object has to respond. Java just enforces this mechanism to provide statically type checking. So, dynamic ( OO ) programming languages do use interfaces, even thought they don't statically check them. Just like other

Is there any point for interfaces in dynamic languages?

五迷三道 提交于 2019-11-30 01:37:16
In static languages like Java you need interfaces because otherwise the type system just won't let you do certain things. But in dynamic languages like PHP and Python you just take advantage of duck-typing . PHP supports interfaces. Ruby and Python don't have them. So you can clearly live happily without them. I've been mostly doing my work in PHP and have never really made use of the ability to define interfaces. When I need a set of classes to implement certain common interface, then I just describe it in documentation. So, what do you think? Aren't you better off without using interfaces in

Why don't we require interfaces in dynamic languages?

拟墨画扇 提交于 2019-11-30 00:56:59
问题 Is it just because of dynamic typing we don't require a concept of interfaces(like in Java and C#) in python? 回答1: The interface as a keyword and artifact was introduced by Java 1 ( and C# took it from there ) to describe what the contract an object must adhere was. But, interface has always been a key part of Object Oriented Paradigm and basically it represents the methods an object has to respond. Java just enforces this mechanism to provide statically type checking. So, dynamic ( OO )