【转】Objective-C for Java Programmers

设计java的灵感源自于Objective-C(简Obj-C), 但是很多学过java的朋友却难以掌握Objective-C。在这个系列的第一部分,David Chisnall(程序开发人员手册的作者),从语言学分析和比较这两种编程语言的相似之处。

  Objective-C 创立于 1986, 但是当时很小众。最主要的支持者是 NeXT公司, 一个十年间仅卖出5万台电脑的公司。这很大程度限制了Obj-C的发展。 苹果公司收购NeXT后, 一切开始改变. Objective-C 变为Mac开发的主要语言, 使其占有5%至10%的桌面应用开发市场。giving it somewhere up toaround 5-10 percent of the desktop application development market share. 尽管Objective-C并不是MAC OS X开发的唯一语言,很多开发者使用他们熟悉的语言,但是iPhone,只允许使用Obj-C开发第三方应用。

如果你是从某个java平台转移而来,你会看到惧怕。Obj-C看起来比java复杂得多。幸运的是,只要你看看语法,就会发现熟悉的东西,你会发现十分容易。

  一部分的java开发者有过Objective-C的开发经验, 包括一些在NeXT 工作过的朋友. 很多Java 概念是从Objective-C转变而来的, 或者来自于Smalltalk。但并不是说与 Objective-C相同. 有一些重要的不同我将在下一篇文章中说明。


语言哲学

Objective-C 被设计为具有封装的支持,像Smalltalk之于C一般,设计者称其为混血语言,方括号代表了 C 语言到面向对象的语言的进化。




Java的目标是大众化的语言,这结合了类似Smalltalk 的语义和C++ 语法,C++主要是从市场考虑的. C++ 有巨大的市场(且仍然有,虽然原因不明。。。), 而且看似想尽的语法使得人们觉得简单。


不幸的是,这也是java程序员转变为其他程序员的屏障。 Java 看起来像C++, 但是行为像Objective-C. Java 和 Objective-C 都有Smalltalk-like 语义, 与此同时C++ 从C中添加了与Simula 相似的语义。Java 和C++ 分别代表着Smalltalk 和Simula 不同的语义,但是又具有相同的语法.


从C++ 到Objective-C 是简单的,语义变化伴随着语法变化.。从Objective-C到Java是困惑的. 有巨大的语法变化,但是语义却是相似的。


目标的不同很明显. Java 目的在于 C-like 和对于 C 或 C++ 程序员的简单易学, 但是不介意破坏C的方式.;而Objective-C 是一个纯粹的C的超集。 每一个C 程序就是一个Objective-C 程序.。Objective-C 的目的在于创造一个语言封装C到易于重用的组件中。




Objective-C 原本没有很多标准库。而推荐使用C库。 Sun and NeXT的OpenStepAPI, 现在是Objective-C 的标准库, 它的实现例如 Cocoa 或者GNUstep 适用于多数平台. Java 并没有使原有的代码重用变得简单, 所以它需要自己的库。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Book Description Written for the moderately experienced Java programmer, this book builds on readers¿ existing knowledge of object-oriented programming and covers all important aspects of Standard C++—emphasizing more lower-level C-style details later in the presentation. Chapter topics include philosophy of C++, simplest C++, pointers and reference variables, object-based programming: classes, operator overloading, object-oriented programming: inheritance, templates, abnormal control flow, input and output, collections: the standard template library, primitive arrays and strings, C-style C++, and using Java and C++: the JNI. For new C++ programmers converted from Java. For experienced Java programmers and students who require the skills of C++ programming, best-selling author Mark Allen Weiss bridges the gap. He efficiently presents the complex C++ language in this well-designed tutorial/reference that both students and seasoned programmers will appreciate. The book is ideal as a primary text for intermediate C++ courses, as a supplemental no-nonsense reference for other courses, or for independent learning by professionals. C++ for Java Programmers is a concise, well-written text that provides authoritative and up-to-date coverage of key features and details of C++, with a special focus on how C++ compares to Java. The book's approach shows knowledgeable students or professionals how to grasp the complexities of C++ and harness its power by mutually addressing the benefits and the pitfalls of the two languages. By highlighting the features and comparative elements of each language, and building on the reader's existing knowledge of object-oriented programming, C++ for Java Programmers enables users to master the essentials of C++ quickly and thoroughly. Key Features Includes insightful comparisons of the two programming languages throughout the text and points out the subtleties of C++ Succinctly covers the pertinent highlights of STL (Standard Template Library) and the most effective use of templates Explains the use of the powerful JNI (Java Native Interface) for combining Java and C++ Includes a summary of key C++ features and issues with each chapter Provides extensive treatment of C details the programmer is likely to encounter in C++ Companion Website for complete online source code at: http://www.prenhall.com/weiss Available Instructors Resource CD-ROM Product Details Paperback: 304 pages Publisher: Prentice Hall; 1 edition (November 7, 2003) Language: English ISBN-10: 013919424X ISBN-13: 978-0139194245 Product Dimensions: 9.5 x 6.8 x 0.6 inches
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值