News for hackers. Stuff that matters.
Re:Apple's new Objective-C to Javascript Bridge by jfb on Wednesday May 15, 2013 @02:20PM (#5713771)
Maybe I've just swallowed the Kool-Aid, but I don't see the putative benefits of Apple's switching platforms. I'm also not clear on how many people there are who a) can write non-trivial software and b) can't learn a C derivative language who c) would actually write software for Apple's platforms. It just seems like a pretty small set.

And, if Apple were to switch, why would they pick a language as shitty as Javascript?

Re:Apple's new Objective-C to Javascript Bridge by Arelius on Wednesday May 15, 2013 @02:30PM (#5713853)
I actually like Javascript. Sure it has some warts. But it has an elegance I've really only seen in Javascript, Lua, and Lisp.
Re:Apple's new Objective-C to Javascript Bridge by drtse4 on Wednesday May 15, 2013 @02:41PM (#5713908)
You last sentence is a bit far-fetched.
Re:Apple's new Objective-C to Javascript Bridge by stcredzero on Wednesday May 15, 2013 @03:15PM (#5714103)
The referred sentence is a matter of opinion, so it's a bit far-fetched to say it's a bit far-fetched, IMO. From what I know of Lua, it's fairly tiny, and it has ready access to its own meta-level -- to the point where there can be a blurring of programming and meta-programming. Instead of everything "being an Object," everything is in a table. Just rename "table" to "object" and call it a prototypical day.
Re:Apple's new Objective-C to Javascript Bridge by drtse4 on Wednesday May 15, 2013 @03:44PM (#5714326)
No it's not, jokes aside, implicitly comparing Javascript to Lisp from the point of view of elegance is simply incorrect, for many definitions of "elegance".
Re:Apple's new Objective-C to Javascript Bridge by stcredzero on Wednesday May 15, 2013 @03:49PM (#5714376)
And for how many definitions of "comparable?" Lose a point for careless reading.
Re:Apple's new Objective-C to Javascript Bridge by CodeCube on Wednesday May 15, 2013 @03:41PM (#5714297)
It is an elegant weapon, for a more civilized age
Re:Apple's new Objective-C to Javascript Bridge by mmariani on Wednesday May 15, 2013 @04:28PM (#5714649)
If you want to shoot your own foot sure!
Re:Apple's new Objective-C to Javascript Bridge by yen223 on Wednesday May 15, 2013 @11:07PM (#5716668)
If Javascript had a saner type system, better scoping, and a decent module system, it would easily be the best language out there. Right now, it is a diamond covered in loads of poop.

I still haven't found a language that implements events as elegantly as Javascript.

Re:Apple's new Objective-C to Javascript Bridge by Offler on Thursday May 16, 2013 @04:07AM (#5717462)
Some of those things are improving in ES6 with block scoping and modules.
Re:Apple's new Objective-C to Javascript Bridge by wwweston on Wednesday May 15, 2013 @04:19PM (#5714587)
> a) can write non-trivial software and b) can't learn a C derivative language who c) would actually write software for Apple's platforms. It just seems like a pretty small set.

Funny. I've sometimes similarly speculated in the past that the set of developers who (a) struggle with JavaScript as a tool for in-browser apps and (b) would actually be genuinely productive with some other dynamic scripting language (Ruby, Python, CoffeeScript) in the same context is pretty small too.

But the truth is probably that whether or not someone can develop non-trivial software with any roughly equivalent language is mostly a function of available time to ramp up vs spend on other things. So, sure, Obj C and JS are close enough that anybody who can develop non-trivial software in one can probably do it in the other... but it's still going to be a time investment while you learn how things are done in the language and various associated APIs.

I don't know if Apple particularly cares if they're pulling in more developers. If they do, though, adding another language that many developers already know makes sense. It reduces the friction involved.

> And, if Apple were to switch, why would they pick a language as shitty as Javascript?

On top of the widespread at-least-shallow familiarity, not everyone shares this opinion.

Also, this is unlikely to be a "switch." It's more likely to be a gateway.

Re:Apple's new Objective-C to Javascript Bridge by zackbloom on Wednesday May 15, 2013 @02:30PM (#5713848)
Closures + Lexical Scoping + Prototypical Inheritance makes for a pretty great language IMHO.
Re:Apple's new Objective-C to Javascript Bridge by ldh on Wednesday May 15, 2013 @02:56PM (#5713996)
Those things are indeed nice, but they can't defend against the other insanities that come in the box with them.
Re:Apple's new Objective-C to Javascript Bridge by coldtea on Wednesday May 15, 2013 @05:07PM (#5714913)
All languages have crap.

C? Buffer overflows, manual memory management, header files, severely lacking standard libraries, crap support for most modern idioms, etc etc.

C++? Tons of edge cases, template madness, unbelievable large language spec, etc etc.

Python? Python 2 - 3 dichotomy, crappy concurrency / parallelism support, , strict on whitespace, standard libs in various stages of cruft and abandonment, no proper closures, CPU bound for lots of interesting problems necessitating bilingual development with C extensions or the use of hacks such as Cython etc.

You can find a similar list for everything, from Lisp to Haskell.

Javascript "insanities" are no big deal. People have been creating large apps (including porting stuff like THE WHOLE BLOODY QT TOOLKIT to it) in it with no problems. Once you know them, you can work around them.

A huge install base, huge number of programmers, easy syntax, powering the internet, lispy-flexibility, and the fastest interpreters this side of the JVM are enough benefits to counter some crappy coercion rules and FP only math bizarreness.

Re:Apple's new Objective-C to Javascript Bridge by gcr on Wednesday May 15, 2013 @03:16PM (#5714108)
Only a subset of Javascript is useful, just like how only a subset of C++ is useful, just like how only a subset of Objective-C is useful, just like how only a subset of Haskell is useful, ...
Re:Apple's new Objective-C to Javascript Bridge by yen223 on Wednesday May 15, 2013 @11:08PM (#5716675)
Wasn't there a saying: "90% of everything is crap"?
Re:Apple's new Objective-C to Javascript Bridge by pi18n on Wednesday May 15, 2013 @09:56PM (#5716436)
I think this comment would have been better if you had listed some insanities that make Javascript unusable. It doesn't seem objective at the moment. I, for one, honestly cannot think of what you might be referring to, but I only have a passing knowledge of Javascript so I cannot really decide if you are the GP have made the better point.
Re:Apple's new Objective-C to Javascript Bridge by to3m on Wednesday May 15, 2013 @05:38PM (#5715145)
And the global object nonsense alone is enough to make it suck. Throw in the lack of an integer type, the curious `for each' statement, and the oddities surrounding `this', and it really starts to feel like this is the sort of language that over time is going to cause you a lot of heartache. It makes me sad - seriously, do people not expect better from their tools?

The maddening thing is that Javascript could so easily be vastly better, and it wouldn't take all that much. Remove any kind of implicit binding (and this could easily be optional, like Visual BASIC's option strict, or the similar thing in perl) and you'd be about 75% of the way there, in my view.

It would take a bit more to convince me that this kind of language is suitable for larger-scale projects - this based on my experience with pretty much any language that isn't statically typed - but this would at least remove one obvious type of error without impinging too much on what people appear to see as their freedoms.

Re:Apple's new Objective-C to Javascript Bridge by cheapsteak on Wednesday May 15, 2013 @10:45PM (#5716604)
I was under the impression that javascript's strict mode already does this?
Re:Apple's new Objective-C to Javascript Bridge by to3m on Thursday May 16, 2013 @06:51AM (#5717842)
Yes, it looks like it does. And browser support looks decent enough. Thanks!

I don't recall seeing this mentioned anywhere. Perhaps the still-imperfect browser support puts people off.

Re:Apple's new Objective-C to Javascript Bridge by pornel on Thursday May 16, 2013 @05:12AM (#5717611)
ObjC has closures (blocks) and ObjC runtime (but not the syntax!) supports prototypical inheritance.

Actually the ObjC runtime is amazingly powerful and dynamic, as if it was made for a better language (e.g. can handle dynamism of Ruby http://macruby.org/)

Re:Apple's new Objective-C to Javascript Bridge by wamatt on Thursday May 16, 2013 @05:12AM (#5717612)
>And, if Apple were to switch, why would they pick a language as shitty as Javascript?

That seems to be a fairly popular dismissal for a language designed in 10 days, and perhaps rightly so. JavaScript probably classifies as mediocre language compared to the wealth of sanely designed choices we have available today.

That said, have you taken a recent look at the next generation of JavaScript aka ES6/Harmony?[1]

- Modules? Yup

- Maps and Sets? You bet.

- Tail call optimizations? Sure

- Classes? Finally!

etc

That's not to suggest that a single iteration will magically fix all of its quirks and shortcomings. However, one possibility could be that Apple picked JS, not on it's checkered history, or the fact that it is popular amongst web developers today, but where it is headed tomorrow and how it could be adopted and adapted.

[1] https://wiki.mozilla.org/ES6_plans*

Re:Apple's new Objective-C to Javascript Bridge by caycep on Wednesday May 15, 2013 @02:24PM (#5713808)
But it has Good Parts(tm)!
Re:Apple's new Objective-C to Javascript Bridge by jfb on Wednesday May 15, 2013 @02:25PM (#5713815)
I remain skeptical.
Re:Apple's new Objective-C to Javascript Bridge by u2328 on Wednesday May 15, 2013 @02:40PM (#5713902)
Have you ever written any significant amount of JavaScript?
Re:Apple's new Objective-C to Javascript Bridge by jfb on Wednesday May 15, 2013 @02:48PM (#5713950)
Enough to not want to do any more.
Re:Apple's new Objective-C to Javascript Bridge by u2328 on Wednesday May 15, 2013 @07:09PM (#5715723)
I take that as a "no."

I grew up as a programmer through C++ and Java, and the first time I ever worked on a JavaScript project, I hated it, and I said the same thing about JavaScript as you did. That's because I was thinking like a Java programmer, and not just a programmer. As I worked more and more with JavaScript, I've grown to love. It has it's pitfalls, sure, but there's just so much flexibility in JavaScript than languages like Java or C++. Nowadays, I prefer it to Java or C++. Even for server-side programming. I get the feeling that you don't really know enough to know what you're missing.

Re:Apple's new Objective-C to Javascript Bridge by bobwaycott on Wednesday May 15, 2013 @11:12PM (#5716686)
It is advisable to taboo your practice of taking any thing X that differs from your viewpoint as a "no".

It is also advisable to taboo projecting your own experience/thoughts onto another, as if that is his/her experience/thoughts, as well.

That you love JavaScript, even for server-side programming, has absolutely zero significance in evaluating whether jfb (or anyone else, for that matter) knows enough to know what s/he is missing.

Re:Apple's new Objective-C to Javascript Bridge by u2328 on Wednesday May 15, 2013 @11:39PM (#5716770)
> It is advisable to taboo your practice of taking any thing X that differs from your viewpoint as a "no".

> It is also advisable to taboo projecting your own experience/thoughts onto another, as if that is his/her experience/thoughts, as well.

I disagree with that take. Personal experiences can lend themselves to evaluating context. Humans do it all the time.

If one is going to make an argument that something is "silly", and provides barley more than nil context to that argument ("enough to know"), then a context vacuum exists. If the OP isn't going to provide it, then someone else will.

Re:Apple's new Objective-C to Javascript Bridge by jfb on Wednesday May 15, 2013 @11:12PM (#5716682)
I don't write Java or C++.
Re:Apple's new Objective-C to Javascript Bridge by marknutter on Wednesday May 15, 2013 @03:18PM (#5714126)
No, your language is shitty!
Re:Apple's new Objective-C to Javascript Bridge by reeses on Wednesday May 15, 2013 @02:48PM (#5713952)
Wait, don't you remember Steve's original announcement about the great development opportunities on iPhone, where you could use HTML and Javascript?

You won't be able to use undocumented APIs because you won't be able to get to them.

Re:Apple's new Objective-C to Javascript Bridge by jfb on Wednesday May 15, 2013 @02:55PM (#5713989)
I was working on software for the phone at the time, so, yeah.
Re:Apple's new Objective-C to Javascript Bridge by reeses on Wednesday May 15, 2013 @03:57PM (#5714436)
whoosh.
Re:Apple's new Objective-C to Javascript Bridge by ojr on Wednesday May 15, 2013 @04:09PM (#5714516)
last time I check a) javascript is a c derivative language and b) it is used for "non-trivial software" c) there will be developers believe it or not that would be able to create maintainable apps that maybe won't be good enough to your standards but I have a small feeling the average consumer will not care, my advice: http://alwaysbetonjs.com/ Apple's on board
Re:Apple's new Objective-C to Javascript Bridge by phawk on Wednesday May 15, 2013 @02:53PM (#5713983)
I think it's less a specific shift to JS, but more a shift to HTML5 and CSS3. That would probably be a better reason to allow people to write JS apps.
Re:Apple's new Objective-C to Javascript Bridge by jfb on Wednesday May 15, 2013 @02:55PM (#5713994)
That's even less explicable.