9 ms·
would it save us from the hell of objective c?
by iamtoby2003 14y ago
would it save us from the hell of objective c?
- kenver 14y agoWhy do you think it's hell? I've been using it for about 2-3 years now and it's really grown on me over that time. I think the most common complaint is that it is too verbose, but that has its advantages too.
- damian2000 14y agowhat's an advantage of being too verbose? extra exercise for your fingers? ;-)
- agos 14y agoit has big advantages in terms of readability and is necessary for self-documenting code
- pjmlp 14y agoYou can always make use of APL if you don't like typing.
- chc 14y agoYou could always make use of enterprise Java if you like verbosity. The extremes are probably not the place to be.
- pjmlp 14y agoVerbosity is good when you need to maintain projects developed with 300+ developers, scattered across the globe with multiple companies working on the project. Why do you think verbose languages are so loved by big enterprise companies? It is a total different scale of development.
- rimantas 14y agoWith autocomplete you don't get much extra exercise anyway. It helps to strain your brain less however when reading the code.
- chc 14y agoI don't think "arrayByAddingObjectsFromArray:" is particularly clearer than "concat" or "+" unless you're just totally unfamiliar with the language. In fact, for many selectors I find the shorter names easier to read because my brain sees them as a single token while I have to mentally parse Cocoa's behemoths every time I run across them. There is some benefit to clarity, but very often Objective-C's glut of information makes it harder to pick out the details you were looking for. Smalltalk was considered quite readable and in fact was the inspiration for Objective-C and Cocoa, but its selectors were more minimal (for example, the equivalent to the above methods is #addAll:). (Just to establish that I'm not completely talking out my rear end: I've been programming Objective-C for ten years, Ruby for five.)
- kennywinker 14y agooh crap, does concat create a new object, or mutate the current one? is it the same as using + or do they handle objects differently....? should I be using << here maybe? I agree with you that the verbosity of ObjC makes it harder to mentally parse fast, but I also think there is a lot of clarity to it when you read it slow. Where I see ObjC fall down is more in terms of command verbosity. For example in Ruby, File.open("readfile.rb", "r") do |infile| while (line = infile.gets) puts "#{line}" end end ...would be ~150 lines of code in ObjC (Dave DeLong: http://stackoverflow.com/a/3711079/196358 http://stackoverflow.com/a/3711079/196358). Which is not really a failing of the language, actually. It's a failing of the libraries that come with the language. Apple chose to give you a couple ways to read a file. The easy way is `stringWithContentsOfFile:encoding:error:error`, but the next level of control is way to low level. Dave DeLong's solution to reading a file line by line exposes an api that looks like this: DDFileReader * reader = [[DDFileReader alloc] initWithFilePath:pathToMyFile]; [reader enumerateLinesUsingBlock:^(NSString * line, BOOL * stop) { NSLog(@"%@", line); }]; Not actually much more complex or verbose than the ruby.