4 ms·
I hope you understood the very fundamental reason why Objective-C syntax has to be the way it is. It does not need to be like this in a statically typed langua
by mattmanser 15y ago
I hope you understood the very fundamental reason why Objective-C syntax has to be the way it is.
It does not need to be like this in a statically typed language. Most statically typed languages don't require you to pass the parameter name. Some have this optionally so you can mix and match or have default values (C# for example http://msdn.microsoft.com/en-us/library/dd264739.aspx http://msdn.microsoft.com/en-us/library/dd264739.aspx).
If you'd written other statically typed language the Obj-C syntax would probably still be surprising to you.
Brilliant design by Apple it is not, it's the nature of statically typed languages. For example your comment:
Now, which one is the recipient? What is the subject?
Shows a lack of experience with statically typed languages. IDEs will tell you if you hover over the method with your mouse as well as when you're creating the method (including all the variations).
On the other hand it's quite fun to see someone naturally find out some of the reasons why some people prefer statically typed languages.
- masklinn 15y agoI'm sorry, but all of your comment is nonsense. 1. Static typing does not help with writability when you're passing 4 strings to a method (now that can be made into a debate over good usage of types, language cultures and many other things, point is when your arguments are "untyped" having a stricter type checking of nothing will not help you) 2. Static typing does not help with readability when you end up with do_send_mail("some@email.com", "another@email.com", "Hello!", "hi!") anyway, there are many cases where keyword arguments significantly enhance the reading experience 3. IDEs are perfectly able to "tell you if you hover over the method with your mouse as well as when you're creating the method" for dynamically languages. The only thing a statically typed language will help you with TFA's example is if you have extraneous or missing arguments, and there even a good IDE will do it in a dynamically typed language (Jetbrains's IDEs do, for instance).
- mattmanser 15y agoDid you read the article? The author claims it has to be this way in Obj-C. Not that's it's a nice thing. It doesn't at all. The Objective-C function’s name is designed to include the parameters’ names. This is not the case with most web programming languages. Why does it have to be this way? The obvious reason is Objective-C is a compiled language, once you get it wrong, it cannot even be compiled. The whole premise of the article is fundamentally flawed. I was just trying to tell him in a nice way. All his 'reasons' are bunk when you look at what a static language provides you in terms of explicitness. I'll leave with this: When I was still coding in PHP, I found myself constantly having another file open just see the declaration of a function I wrote before that That never happens in a static language. It does in dynamic. Or perhaps he just doesn't use IDEs and that's the actual revelation?
- nknight 15y ago> That never happens in a static language. It does in dynamic. Er, says you? > Or perhaps he just doesn't use IDEs and that's the actual revelation? I'm guessing you're either relatively new to the industry, or have lived in the Microsoft and/or Java worlds during most of your career. Use of IDEs outside of those contexts is much rarer, and for much of history, even well into the 2000s, bordered on nonexistent. To this day, many of us do not use what you would consider an "IDE" at all for any language in our normal routine.
- mattmanser 15y agoFFS, which way is it? Do dynamic languages have extensive intellisense support or not? Do you need to give it hints or not? I'm not new to the industry, the day job's MS, but my personal stuff isn't. If you're sitting there without an IDE in 2012 and looking up or memorising the syntax for every single method call you make it's time to grow up and realise there's a better world out there. Even my bloody text editor has basic intellisense.
- nknight 15y ago> looking up or memorising the syntax for every single method call you make As programmers have done for generations? I've never seen an autocomplete functionality that was substantively faster than either actually knowing the platform I'm developing on (what a shocking concept), or having a browser window open alongside my editor. > it's time to grow up PKB. When you do, you'll realize not everyone who disagrees with you is an idiot. > and realise there's a better world out there. "Better" is highly subjective. IDEs inevitably lower my productivity dramatically with their bloated, buggy, slow, and brittle nature. > Even my bloody text editor has basic intellisense. No, it has an autocomplete function. IntelliSense is a Microsoft implementation of the general autocomplete concept. And if you're only worried about autocomplete, why are you so shocked people might not be using a full-blown IDE?
- xyzzyz 15y ago3. IDEs are perfectly able to "tell you if you hover over the method with your mouse as well as when you're creating the method" for dynamically languages. Which IDEs and for which languages? The best I've seen so far was Emacs+Semantic for Python, and it's still totally uncomparable to what Eclipse, or MSVS, or Emacs+Semantic for C or Java offers.
- masklinn 15y ago> Which IDEs and for which languages? Jetbrains's IDEs do it for most of the languages they support, I've had it for Python, Javascript and Ruby. I'm not saying the static analysis is as good as a statically typed language, but basic features like listing arguments are not a problem.
- xyzzyz 15y agoDoes it work for situations like: x = someObject.someMethod() # does IDE know here what the type of `x' is? x.otherMethod(...) # will IDE list arguments of otherMethod? If it does not, then it's hardly useful, and it's unfair to compare intellisense for Java/C#/C with this.