dynamic-languages

Programming language for self-modifying code?

杀马特。学长 韩版系。学妹 提交于 2019-11-29 21:03:30
I am recently thinking about writing self-modifying programs , I think it may be powerful and fun. So I am currently looking for a language that allows modifying a program's own code easily. I read about C# (as a way around) and the ability to compile and execute code in runtime, but that is too hurting. I am also thinking about assembly . It is easier there to change running code but it is not very powerful (very raw). Can you suggest a powerful language or feature that supports modifying code in runtime? Example That what I mean by modifying code in runtime: Start: a=10,b=20,c=0; label1: c=a

What makes Ruby slow? [closed]

别说谁变了你拦得住时间么 提交于 2019-11-29 19:42:14
Ruby is slow at certain things. But what parts of it are the most problematic? How much does the garbage collector affect performance? I know I've had times when running the garbage collector alone took several seconds, especially when working with OpenGL libraries. I've used matrix math libraries with Ruby that were particularly slow. Is there an issue with how ruby implements basic math? Are there any dynamic features in Ruby that simply cannot be implemented efficiently? If so, how do other languages like Lua and Python solve these problems? Has there been recent work that has significantly

Simulating duck typing in Java

[亡魂溺海] 提交于 2019-11-29 12:48:12
问题 The problem: I'd like to be able to generically access in Java any property/field on a Java ojbect similarly to how a dynamic language (think Groovy, JavaScript) would. I won't know at the time I'm writing this plumbing code what type of object it is or what the property/field name will be. But I will know the property/field name when I go to use it. My current solution: So far I've written a simple wrapper class that uses java.beans.Introspector to grab the properties of a Bean/POJO and

Are dynamic languages slower than static languages? [closed]

不羁的心 提交于 2019-11-29 02:06:24
Are dynamic languages slower than static languages because, for example, the run-time has to check the type consistently? All other things being equal, usually, yes. No. Dynamic languages are not slower than static languages. In fact, it is impossible for any language, dynamic or not, to be slower than another language (or faster, for that matter), simply because a language is just a bunch of abstract mathematical rules. You cannot execute a bunch of abstract mathematical rules, therefore they cannot ever be slow(er) or fast(er). The statement that "dynamic languages are slower than static

Any way to determine which object called a method?

人走茶凉 提交于 2019-11-28 23:11:53
I'm hoping that Ruby's message-passing infrastructure means there might be some clever trick for this. How do I determine the calling object -- which object called the method I'm currently in? As an option, there is a binding_of_caller gem that allows you to execute code in context of any caller on the call stack (caller, caller's caller and so on). It's useful for inspecting (read do anything at any position on the call stack ) call stack in development, as used in better_errors . Objects of class Binding encapsulate the execution context at some particular place in the code and retain this

Is there any point for interfaces in dynamic languages?

梦想的初衷 提交于 2019-11-28 22:26:45
问题 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

Programming language for self-modifying code?

青春壹個敷衍的年華 提交于 2019-11-28 16:29:12
问题 I am recently thinking about writing self-modifying programs , I think it may be powerful and fun. So I am currently looking for a language that allows modifying a program's own code easily. I read about C# (as a way around) and the ability to compile and execute code in runtime, but that is too hurting. I am also thinking about assembly . It is easier there to change running code but it is not very powerful (very raw). Can you suggest a powerful language or feature that supports modifying

Why are IOC containers unnecessary with dynamic languages

本秂侑毒 提交于 2019-11-27 17:42:09
Someone on the Herding Code podcast No. 68, http://herdingcode.com/herding-code-68-new-year-shenanigans/ , stated that IOC containers had no place with Python or Javascript, or words to that effect. I'm assuming this is conventional wisdom and that it applies to all dynamic languages. Why? What is it about dynamic languages that makes IOC containers unnecessary? Nigel Thorne IoC provides a mechanism to break the coupling you get when an object calls 'new' on another class. This coupling ties the calling object with the instantiated implementation of whatever interface it implements. In static

Are dynamic languages slower than static languages? [closed]

时光总嘲笑我的痴心妄想 提交于 2019-11-27 16:25:07
问题 Are dynamic languages slower than static languages because, for example, the run-time has to check the type consistently? 回答1: All other things being equal, usually, yes. 回答2: No. Dynamic languages are not slower than static languages. In fact, it is impossible for any language, dynamic or not, to be slower than another language (or faster, for that matter), simply because a language is just a bunch of abstract mathematical rules. You cannot execute a bunch of abstract mathematical rules,

dynamic object construction in javascript?

試著忘記壹切 提交于 2019-11-27 13:15:14
When I want to call a function in javascript with arguments supplied from elsewhere I can use the apply method of the function like: array = ["arg1", 5, "arg3"] ... someFunc.apply(null, array); but what if I need to call a constructor in a similar fashion? This does not seem to work: array = ["arg1", 5, "arg3"] ... someConstructor.apply({}, array); at least not as I am attempting: template = ['string1', string2, 'etc']; var resultTpl = Ext.XTemplate.apply({}, template); this does not work wither: Ext.XTemplate.prototype.constructor.apply({}, template); Any way to make that one work? (In this