Which one tells you immediately what it's doing and what the parameters stand for?
With method parameters being (kind of) labeled in Objective-C even complex methods (parameter-wise) can be read kind of like plain english. They differ in capitalization and whitespace, but the wording pretty much reflects english language.
Objective-C is not language specific though (apart from if, do…while, etc). You could easily write the line above as:
and now your code reads somewhat German. Not that you should do that (seriously, don't!), though.
A language that very much resembles the english language would be Applescript. But it's this very feature that makes Applescript such a pain to work with. English (natural languages in general) simply isn't/aren't meant to be used for instructing computers.
I am really sorry for your disappointment. It is not right to compare English (Verbal Language) and Objective-C (Programming Language). But to some extent the syntax of objective-c is more understandable than other programming language for that matter.
On first glimpse for a beginner, he will be able to understand how the code works "Logically" (compared to C or C++, where he is dependent on some documentation)! He would not be able to understand the programming aspects of the code in Objective-C, but its easier to comprehend whats going on.
For example, in C, you will have create methods for initializing a string, and you can name the method like createString(); In objective-C, you can start writing code like how you might feel.
user.text = [NSString stringWithFormat:@"%@ is a %@", string1, string2];
or
html = [html stringByReplacingOccurrencesOfString:
[NSString stringWithFormat:@"%@>", text] withString:@""];
There are so many examples, and you will be happy for this language only if you start comparing with other programming language. I think your professor meant that in a positive way so as to encourage the students to learn.
发布评论
评论(2)
教授的意思是常见的类 C 编程代码之间的区别,例如:
与常见的 Objective-C 编程代码之间的区别,例如:
哪一个可以立即告诉您它在做什么以及参数代表什么?
通过在 Objective-C 中(某种程度上)标记方法参数,即使是复杂的方法(按参数)也可以像简单的英语一样阅读。它们的大小写和空格有所不同,但措辞几乎反映了英语。
Objective-C 并不是特定于语言的(除了
if
、do…while
等)。您可以轻松地将上面的行写为:现在您的代码读起来有点德语。不过,并不是说你应该这样做(说真的,不要这样做!)。
与英语非常相似的语言是 Applescript。但正是这个特性使得 Applescript 使用起来非常痛苦。英语(一般来说是自然语言)根本不是用来指导计算机的。
What the professor meant was the difference between common C-like programming code, such as:
versus common Objective-C programming code, such as:
Which one tells you immediately what it's doing and what the parameters stand for?
With method parameters being (kind of) labeled in Objective-C even complex methods (parameter-wise) can be read kind of like plain english. They differ in capitalization and whitespace, but the wording pretty much reflects english language.
Objective-C is not language specific though (apart from
if
,do…while
, etc). You could easily write the line above as:and now your code reads somewhat German. Not that you should do that (seriously, don't!), though.
A language that very much resembles the english language would be Applescript. But it's this very feature that makes Applescript such a pain to work with. English (natural languages in general) simply isn't/aren't meant to be used for instructing computers.
对于您的失望,我真的很抱歉。 比较英语(口头语言)和 Objective-C(编程语言)是不正确的。但在某种程度上,objective-c 的语法比其他编程语言更容易理解。
对于初学者来说,乍一看,他将能够理解代码如何“逻辑上”工作(与 C 或 C++ 相比,他依赖于一些文档)!他无法理解 Objective-C 代码的编程方面,但更容易理解正在发生的事情。
例如,在 C 中,您将拥有用于初始化字符串的 create 方法,并且您可以将该方法命名为
createString();
在 Objective-C 中,您可以开始编写您可能感觉的代码。或者
有很多例子,只有当你开始与其他编程语言进行比较时,你才会对这种语言感到高兴。我认为你的教授的意思是积极的,以鼓励学生学习。
I am really sorry for your disappointment. It is not right to compare English (Verbal Language) and Objective-C (Programming Language). But to some extent the syntax of objective-c is more understandable than other programming language for that matter.
On first glimpse for a beginner, he will be able to understand how the code works "Logically" (compared to C or C++, where he is dependent on some documentation)! He would not be able to understand the programming aspects of the code in Objective-C, but its easier to comprehend whats going on.
For example, in C, you will have create methods for initializing a string, and you can name the method like
createString();
In objective-C, you can start writing code like how you might feel.or
There are so many examples, and you will be happy for this language only if you start comparing with other programming language. I think your professor meant that in a positive way so as to encourage the students to learn.