What is the difference between object-oriented lan

2020-05-19 21:22发布

I have been hearing about how C is a non-object-oriented language and how java is an object-oriented language. I was wondering what the difference was?

标签: java c oop
11条回答
\"骚年 ilove
2楼-- · 2020-05-19 22:02

Object-Oriented Language is where you think in terms of objects. However, this takes lot of skills. You cannot take some C-code and stuff it into an object and call it OOP. Key concepts of OOP are inheritance, encapsulation and dynamic binding.

查看更多
爷的心禁止访问
3楼-- · 2020-05-19 22:02

A program can be conceptually organised in two ways,around its code or data. The first approach is called as process-oriented model.The second approach is called as object oriented model.

查看更多
别忘想泡老子
4楼-- · 2020-05-19 22:04

I'll give you the most simple and intuitive answer you can get.

(Considering Java is an object-oriented language and C is a procedural language)

Object-Oriented Language

  • core concept is objects (consider a car)
  • objects have properties that define them, they can be constant or changing (a car is red, 2004 model, and has cruise control. It also currently has 100K on the odometer and 3/4 tank fuel)
  • objects can be sent messages which affect it (a car can be driven from A to B, a car can be refueled)

Procedural Language

  • core concept is process (consider placing on online order)
  • for a process to complete it must go through several steps (an order must be (1) sent to warehouse, (2) boxed, and (3) shipped)
  • one of the steps might be a process by itself, or it can be atomic
查看更多
看我几分像从前
5楼-- · 2020-05-19 22:08

OOP makes it easier to break down one big problem into smaller self contained parts. You can then create something more complex by combining these parts.

查看更多
我只想做你的唯一
6楼-- · 2020-05-19 22:11

The object-oriented programming paradigm tells you to encapsulate state variables in entities called 'objects' which communicate via message passing, most often implemented as functions with a 'special' this or self argument.

An object-oriented programming language is a language designed to make using the oo paradigm easy. Its semantics and syntax are geared towards this goal. Inheritance (either class-based or prototypal) and subtype polymorphism are important techniques which make the abstract concept of oo feasible in practice.

查看更多
Deceive 欺骗
7楼-- · 2020-05-19 22:11

Apart from trying to characterize a language as having a particular paradigm at its core, you might find this paper from William R. Cook useful: On understanding data abstraction, revisited. There's a draft version available. It explores the difference between abstract data types and objects -- a distinction that, after years of absorption in various programming languages, I could no longer see.

I found the paper by way of Guy Steele's recent essay, Why Object-Oriented Languages Need Tail Calls.

查看更多
登录 后发表回答