Hacker News new | past | comments | ask | show | jobs | submit login

I'm a little confused by the first point. How is Objective-C not a dynamic language? Is he talking about something other than dynamic dispatch? Is there some reason other than time that prevents an implementation of Python to mirror what was done with Objective-C?



Python is interpreted, but Objective-C is compiled. That is, a Python program is executed through the Python interpreter, yet an Objective-C program runs natively.

Although he may indeed be confused about "dynamic," since dynamic dispatch has nothing to do with the above, and is supported by all OO languages.


Python is interpreted, but Objective-C is compiled.

There are plenty of lisp compilers out there, but people still consider lisp a dynamic language.


Again, the author's use of "dynamic" is, I think, confused. I tried to suss out what difference he was actually thinking about, and interpreted versus compiled was the biggest one to me.


Compilation does not necessarily need to remove the dynamism. Objective-C is generally considered a dynamic language, though I get the feeling that many think it is just another C++ with different syntax, which muddies the waters, so to speak.

A quote from Apple themselves:

"Compared to other object-oriented languages based on C, Objective-C is very dynamic. The compiler preserves a great deal of information about the objects themselves for use at runtime. Decisions that otherwise might be made at compile time can be postponed until the program is running. Dynamism gives Objective-C programs unusual flexibility and power."

https://developer.apple.com/library/mac/documentation/Cocoa/...


This is where I'm really not clear. What makes Python harder to compile than Smalltalk (which had some native compilers - Smalltalk/X) or Objective-C?


Well nobody said it would be harder to compile. However the fact is that there is not a compiler for Python, so unless someone writes one that is a downside. Also, the semantics of Python would likely not lead to efficient compiled code anyway, when compared to something like C, Java, or even Haskell - static languages.


The corners of the language make it difficult to benefit from compilation. Per the language, things like the internals of an instance of a class can be manipulated at runtime, so the compiled output ends up needing to support the entire dynamic runtime.

Cython and Nuitka (among others) do this to varying degrees.


Didn't Smalltalk basically invent the idea of being able to open up objects at runtime? Even Objective-C, with its strong Smalltalk ties, allows for runtime modification.


Any language with eval is probably going to, by default, be interpreted. You can compile a language with eval, but it means you'll need to stick the compiler into every binary with a program that calls eval.


Common Lisp allows all sorts of internal runtime manipulation and is usually compiled to machine code. :-)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: