Objective Next(nearthespeedoflight.com) |
Objective Next(nearthespeedoflight.com) |
Slower execution is indicative of waste. When it comes to interpreted languages, even those that are very well implemented, any slowness is directly related to energy loss. This is very problematic when it comes to mobile devices, even modern ones, as this energy is generally coming from a rather limited source (the device's battery).
While this may not be a problem if one or two apps are written using a wasteful interpreted language, it can become a much bigger issue when the entire ecosystem is implemented in such a manner. It'd be irresponsible to unnecessarily reduce the battery life of the devices of thousands or even millions of people.
And while many mobile devices today probably are more powerful than desktops from a decade ago, I don't think it's correct to say that those desktops "ran interpreted apps just fine". They didn't. There's a reason why Java has a bad reputation for performance problems, even today: many desktop apps written in Java performed horribly on computers of that era. And Java was perhaps the best-performing of the interpreted or quasi-interpreted languages.
Aside from arguments about the screen perhaps not needing to be used as long when the software completes its operations faster, I think it's probably safe to say that such hardware-specific energy consumption due to the factors you mention would be constant in both the case of compiled applications and the case of interpreted applications.
Because if you start using the CPU all the time, your battery is done.
As long as your Obj-Next doesn't come with superb C++ compatibility you won't get the serious players on board.
See also more thoughts on the essay: http://nearthespeedoflight.com/article/2014_03_20_assorted_f...
Instead of hating on the way things are currently done, show a better way. It will mean a lot more in the end.
Don't mean to be harsh, just saying that there are plenty of us who have questioned all these things and still do not have the answer.
Bluntly: there is a class of programmers and programs that cannot be written without:
* C linkage
* Calling of and calling from C
And a further class of programs where:
* Garbage collection
* Significant runtime
* Safe code
Make acceptable performance impossible. This class of programs includes .NET itself which is entirely written on top of the Win32 C APIs.
If you want a runtime on top of Objective-C, you're welcome to write one yourself. It could offer everything you're requesting without needing to change anything about Objective-C.
Oh wait, there are literally dozens of runtimes on top of Objective-C. Not to mention official bindings to Python and other languages. Sure, none of them are very popular but if you want to write in something else: go ahead.
It is just the historical legacy fact that the majority of modern OS ABI == C ABI that keeps us have to link with it.
https://pythonhosted.org/pyobjc/
Or Xamarin for programming iOS using Mono/C#?
http://docs.xamarin.com/guides/ios/getting_started/hello,_wo...
Or F-Script for programming Mac OS X from a command-line shell?
All three are quite well established and work pretty well for what they do.
@interface MyClass
- (NSDictionary *)createSimpleDictionary;
@end
@implementation MyClass
- (NSDictionary *)createSimpleDictionary
{
return @{
@"keyForNumber": @1,
@"keyForBool": @YES,
@"keyForArrayOfStrings: @[@"one", @"two", @"three"]
};
}
@end
How much cleaner could this be if we dropped C backwards compatibility! We could remove the header file, and get rid of all the *'s and @'s: class MyClass
- (NSDictionary)createSimpleDictionary
{
return {
"keyForNumber": 1,
"keyForBool": YES,
"keyForArrayOfStrings: ["one", "two", "three"]
}
}
end
This new language would get rid of many warts of Objective-C, bringing it up to speed with modern languages, while keeping performance and interoperability with the Cocoa toolchain.There may be some perfect, completely new idea for a programming language out there, but Apple would never go for it. Developer experience is a distant third to the User experience and the Apple experience, and the only thing they will go for is an evolutionary, backward compatibile change such as this.
When will people learn this is an implementation issue?!
There are various characteristics of programming languages that can make it much easier to implement them as interpreted languages rather than compiled languages, and vice versa.
Maybe any difficulties could be overcome given enough resources, but this usually isn't the case. I think this is why the efforts to make compilers for a language like Python have never really been that successful. And the same goes for the attempts to create interpreters for languages like C and C++.
Perhaps the most success has been with the various compilers that compile Java source or bytecode to native code. But even in that case, the end result usually isn't very good. It's usually somewhere in the undesirable middle, giving the worst of both compilation and interpretation.
It is all about convenience and effort one is willing to invest versus return on investment. As any good CS compiler design course will show to their students.
Back in the 70-80's most languages had multiple implementations offering both compilers and interpreters as part of their toolchains.
Only on the early 2000's I started to see this phenomenon of mixing languages with their canonical implementation.
The end result of visual design tools doesn't seem to match the hype. At some point you DO need programmers to make some of the magic happen. I think so far game development has probably done the most to merge the graphic designer, game designer, and programmer workflows into something that is productive for lots of people on the same project.
I really think Apple is the last place you'll see much programming language innovation compared to what you already see in languages compiling to JS or the JVM or even LLVM.
How it would work is you would have something like ActiveRecord that can pull data into the first step, then visual steps for mapping, calculating, etc.. and spitting that data into a HTML view or whatever in the last step. You could design the HTML in a WYSIWYG kind of thing or just as a tempting system. Doesn't matter.
All it would be doing would be replacing a lot of the computation that programmers do with some functional lego block able logic in the middle. Once you had the mechanisms in place for this kind of system, I think you could swap out the data sources from a CSV file to a database to a restful service, and your design bits from HTML to iOS or whatever pretty easily, giving you the ability to work in a pretty general purpose way.
A tool like that could be very interesting, but it's quite a different approach.
The iOS dev environment is the nicest I've ever worked in., in big part to obj-c and all that comes with it.
Seems to be change is being requested for changes sake , rather than trying to address any actual pain points.
The complexity is reality, not something that can be swept under the rug so that naive implementors can use general purpose tools. Isn't that why we have DSLs, anyway?
Heck, many are written in Flash too. Yes, Flash.
I actually consider it a very healthy sign that the people complaining about Objective C are a vocal minority whining about such silly, unfocused, vague things.
It means Objective C is doing quite fine, thank you very much.
mono -aot
So, for example, I have a Customer type and a Customer varibable. Not only can I see that one is a type and the other is not, I can apply a global "tag" to all the Customer instances to mark it as "Client-Side" and see visually the difference between a Customer class server side and client side.
Or have a style to mark when a function have side-effect, or if it trhow a exception. Make it part of the syntax:
[CAN-KILL]openFile:(customer:[CLIENT]Customer)
But the coder just write: openFile:(customer:Customer)
How could be to use code as a word document?
Please note though this is not at all what I’m describing in my essay. A REPL is hardly a graphical, direct manipulation drawing tool for creating software.
But it was fun to dip my toes in more dynamic waters.
>We think we know what we want from an Objective C replacement. We want Garbage Collection, we want better concurrency, we don’t want pointers. We want better networking, better data base, better syncing functionality. We want a better, real runtime. We don’t want header files or import statements.
We don't want Garbage Collection to the contrary we want reference counting. Reference counting is the best compromise between handling memory manually and using GC ala Java. I would argue that the mental strain for the programmer is equal for reference counting(at least with ARC) to that of GC. However Reference Counting is extremely lightweight.
Regarding concurrency it should be mentioned that I don't have a huge amount of experience with different languages. I've done concurrency in Erlang, Java/JR, C++ and Objective-C. I'd say that GDC from Objective-C and possibly Erlang were the easiest to use.
Why wouldn't we want pointers? Most modern languages use pointers under the surface, there are significant benefits in not obscuring and hiding this as is done in Java.
We do want header files and imports because they provide a bunch of benefits namely separation of interface and implementation, distribution of compiled implementations with interfaces in header files. With the @import option compile time is significantly faster as well.
I'll deliberately skip the last points, suffice to say I don't feel strongly about them. I do agree on the data base point though.
My own revised list of things that Objective-C needs are. Proper static typing(no id), templates and namespaces.
EDIT: The point about requiring a programer to change a color is interesting, all though I would argue that the same holds true for web. I have rarely worked with designers who are proficient enough in git and css to make such changes. In the case that the designer is proficient enough to handle git, a css like json file can be used to specify the look of the app and thus changing colour would only involve editing a json file which is comparable to editing a css file
"What do we want? We don't know! When do we want it? Now!"
Couldn't a simple compiler take in .m files and output compiled code + .h files?
I used to think that, until I started to spend more time on modern GC platforms like Java and .NET. It's impressive how performant a good generational garbage collector can be. For many business applications (i.e., not the kinds of workloads you'll see being simulated by popular benchmarks) a good generational GC can even improve performance thanks to improved locality of reference. I think a lot of us don't fully appreciate the cost of a cache miss.
Speaking of, I'm not sure a lot of us fully appreciate the cost of synchronization, either. It's one big reason why I'm not convinced that reference counting is particularly well-suited to concurrent programming, since it turns a really commonplace operation (retaining a reference to an object) into a synchronization point in the program. There's a non-trivial cost associated with that. You could avoid repeatedly stalling the CPU by being very careful about not sharing objects among threads, but I don't think most developers can reasonably be expected to make a habit of that in practice.
This is actually a problem for both. Simple implementations of AGC have to stop the world to scan at least the roots, and probably even a bit more than that, because there are significant ABA problems. There are ways around this, but as far as I know the only environment to use any of the really good ones is the JVM, because it's hellishly complex. I don't know that there is anything that doesn't stop the world for at least a couple of ns, though.
There are also solutions to it for reference counting. They involve using thread local reference counts and briefly stopping the world to reconcile the counts. I believe [1] describes this algorithm.
And once you get there, and start dealing with cycle detection, the difference between the two approaches starts to look a lot smaller. There's a paper on this too. [2]
[1] http://www.cs.technion.ac.il/~erez/Papers/refcount.pdf
[2] http://www.cs.virginia.edu/~cs415/reading/bacon-garbage.pdf
The point is that we may be wasting time talking about a negligible amount of the total battery assumption.
I'm a professional PL designer also, though working under the pretext of a researcher. Those of us who are disgruntled are trying to start a support group :)
Exposing internals is still bad design.
I do agree with you on that any platform should have a staticly typed language as a first class citizen.
By simply glancing over a header file one can achieve a quick idea of the interface without consulting the documentation. It's self documenting, reading a Java file in the same way is impossible.
Forward declaration in header files and imports in implementation is also a huge benefit in compilation speed and complexity.
When I last used C#, I remember Visual Studio would extract and display such public overviews directly from compiled .NET assemblies.
Even if no IDE is involved, something could just auto-generate a text file for distribution. It could even be adorned with a .h file extension for faux-retro appearance!
- Object Pascal
- Delphi
- Modula-2
- Modula-3
- Oberon
- Active Oberon
- Component Pascal
- OCaml
- Haskell
- D
- Ada
- Eiffel
- ...
All languages with native code compiler available, where the header files can bot the manually or automatically generated from the implementation.
Many of them have, or used to have, code browsers and auto complete by reading the metadata stored in the binaries.
C based toolchains are still at stone age, in terms of modular programming support.
In fact Objective-C already includes pretty much everything necessary in the binary already, as you can see by using class-dump. Perhaps additional work would be required to support exposing absolutely everything that might be required, but there's no obvious reason why the language couldn't be extended to allow direct use of compiled code, with no need for a .h file.