NSString *myString = @"Hello";
NSString *second = [myString stringByAppendingString:@" World"];
[1]: https://stackoverflow.com/questions/510269/shortcuts-in-obje... NSString *myString = @"Hello";
NSString *second = [myString stringByAppendingString:@" World"];
[1]: https://stackoverflow.com/questions/510269/shortcuts-in-obje...Is both elegant and very powerful as it is has the perfect balance between a static and a dynamic language.
Swift on the other had is a language where wonks decided to throw every silly feature they thought off to the point that is becoming more complex than even Scala.
I wished Swift was just a modernized Objective-C with a normal non bracket syntax and some extra facilities that it was missing.
It is such a wasted opportunity
https://blog.metaobject.com/2019/12/the-4-stages-of-objectiv...
What features in particular do you think represent unjustified complexity?
Swift is not my favorite, but I wouldn’t consider it to be a “kitchen-sink” language, and it’s certainly less complicated than Scala.
The developer not being made to do so, and just embedding conditions within conditions, is how the pyramids of doom are constructed to begin with.
NSString* result = [NSString stringWithFormat:@"%@ %@", @"Hello", @"World"];Compare with
"Hello " + "world"
or if you hate operator overloading "{} {}".format("hello", "world")
f"{foo} {bar}"It's hard to control once you want anything more interesting than + and it's not localizable. Complaining that a function call's name is too long doesn't matter at all.
ObjC itself is not responsible, it's NeXT and Apple's fault for perpetuating that abominable naming convention for much too long.
As for localisation, only a tiny fraction of strings in a software program are user visible. I don't think we should be designing language syntax around that edge case.
ObjC is one of the most readable languages around. That's mostly because of the param:value syntax, which is much better than C-like syntax because you can see the parameter names. But the long method names aren't a problem once you have autocompletion. They also make it clearer what the best name for a method is - if you call something fmt() you start needing to make up equally clever short names for everything else, and it becomes less principled.
For algorithmic string building, I'm not sure how often you want + (aka appendString:), appendFormat: or componentsJoinedByString: are more flexible.
Not necessary. There's a very sensible "huffmanization" principle created within Perl/Raku community which says that the need for a name/token to be overly descriptive is inversely proportional to frequency of its usage. So you can have short names and they still be human-parseable just because they are used often, and your brain used to register it. FWIW they will be easier human-parseable, because longer words take longer to read. With this approach one can has both fmt, and formatSomethingSomewhereSomeday
https://github.com/SerenityOS/jakt
Notable differences:
1. param:value is used, but convention is param:value not the gratuitous Engrish verbingParamProposition:value ObjC inherited from Smalltalk.
2. param: is optional if the variable holding value in the calling function is named "param" at compile time. This pushes you to name your params "param" everywhere that makes sense.
Jakt's popularity is limited, obviously, but it's a compile-to-C++ language, so you could use it many places.
Smalltalk does not have this convention.
Also, I've never heard of any serious iOS/macOS dev complaining about this.
ObjC is very simple (often confused with archaic), but also wildly complex. Once you wrap your head around the ObjC way of doing things, everything makes sense, is very consistent, and you could develop very effectively.
NSString *foo = [@"foo" stringByAppendingString:@"bar"];
It's not that bad. "foo" + "bar" const char *s = "foo" "bar";The Add operation has a whole bunch of properties and this not only isn't most of them, it's arguably not any of them, the main argument for + as a string concatenate operator is "Well, people seem to like it". Which, I guess I/O streams doesn't even have that going for it, but it's a pretty terrible rationale.
Look, just grow string interpolate and write f"{foo}{bar}" or whatever as much as you like don't abuse unrelated operators.
id foo = [@"foo" cat:@"bar"];
I have a category method added to NSString: - (id)cat:(id)arg { return [self stringByAppendingString:arg]; }And, don’t forget to release your alloc’d objects (or use an auto release memory pool). There was no automatic memory management then!