What’s the benefit of having everything as an object in dynamically typed programming language? [closed]

modern dynamic programming languages like Python, Ruby and Javascript all take the approach of treating everything as an object, what’s the benefit of this approach, and what’s the curse of it?

Benefit I can think of: first class functions, duck typing.

Drawbacks:performance issue, especially performance of primitive types like integer etc.

12

It’s not entirely clear whether you are talking about the semantics or the pragmatics here. Your question reads more about semantics, but in the comments you say you are asking about pragmatics. I’m going to answer about both.

Semantics

  • Pros: simplicity. Why have two concepts when one will do?
  • Cons: none.

Pragmatics

  • Pros: simplicity. Again.
  • Cons: Performance.

The Real World

The way this is used in the real world is that you have pure object-oriented languages whose implementations use primitives without ever exposing them to the programmer. So, the only people who need to deal with the complexities of having two different “things” (objects and non-object primitives) are the compiler/interpreter implementors. Language users simply use objects.

So, in other words, use semantics without primitives, but implement them with primitives. YARV, Rubinius, MRuby, MacRuby, pretty much all Lisp and Smalltalk (and derivatives such as Self and Newspeak) implementations, some ECMAScript implementations, and probably many others do this.

The techniques for doing this have been known since (at least) the 80s. Like many other useful things, the designers of the Java platform seem to have forgotten them when they designed the Java platform, and are now fighting a decades long uphill battle against backwards compatibility constraints to remove primitives again. (They are rumored to be gone by Java 10, but then again, this rumor has been going around for 15 years now.)

13

Performance doesn’t matter. Or rather: compared to providing developers the best tool with which they can express and model what they want the computer to do, performance is the easier problem to solve.

Types, classes, objects, functions, lambdas – all those concepts help organize your thoughts and your code. At this point, they’re all quite unrelated to how the processor is going to actually execute your code. The ‘curse’, if there is one, is when your language of choice forces you into a particular model (classes vs object, of object vs functional) when you’d like to use another for a particular problem.

Regarding actual implementation, I don’t know enough to comment about it. However consistency is valuable: having everything appear as an object to the developer might make implementing the language slightly harder, but makes using it much easier. It doesn’t matter (in most cases) wether internally it has special treatment because it’s an int or not.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật