The most obvious feature of Dynamic Language is that the behavior/attribute of a class instance can be dynamically modified after the new version is released! I personally think this kind of processing is more in line with the real world than Java/C # (static language.
For example, when a person is born, almost none of the other basic primitive instincts except crying and breastfeeding (primitive instinct can understand the attributes and methods most initially defined in class definitions ), but over time, I learned to read books, walk, and talk... (equivalent to adding a method/attribute), no one can predict in the future. Everything is unknown, so it is unlikely to be like a static language, before running the program, you can write all the attributes/methods in advance. Even if a person forgets what he has learned, it is impossible (for example, he suddenly does not speak, it is equivalent to dynamically deleting the method/attribute of the instance. After being well-managed, you can talk again (re-Add a method ).
Of course, I do not mean that static languages are not bad. I can only say that each has its own characteristics.CodeRight:
class persondef cryputs "Wow... "enddef eatputs", please do not disturb... "enddef showbodyputs" streaking to show your own body "# This method is relatively straightforward. endendaperson = person. new # creates a newborn aperson. cry # I was just born. Of course I have to cry a few times. eat # Eat aperson when you are tired. showbody # For Children, just show me JJ. Class persondef readputs "learned to read books" enddef mongoputs "learned to walk" endendendaperson. walkaperson. readclass personundef read # later, for some reason, I suddenly won't be able to read, maybe it's a strange problem :) end # aperson. read # Here the error "undefined method 'read' for #
(nomethoderror)" class personprivate: showbody # after growing up, of course, you cannot show your body to strangers. End # aperson. showbody # the following error is returned: Private method 'showbody' called for #
(nomethoderror)