News for hackers. Stuff that matters.
Re:The Java Origins of Angular JS: Angular vs. JSF vs. GWT by waps on Tuesday July 15, 2014 @01:09PM (#8037649)
But the big thing missing is the old javascript pain point : if your frontend is in javascript, and your backend in C++ or java or php or python, you will have translation issues between the two. Things will go wrong. Server and client don't handle the "RPC" quite the same way. This will bite you again and again.

If you have a real one-page (the only way to go responsive) web-app, once you hit a certain level of complexity GWT is the only way to go. Javascript <> Frontend <> middleware <> backend <> database (using the right framework), all statically typechecked. You NEVER get a fieldname wrong. Checking if a call works ? You don't write tests for that, because static typing means it works. Need the same RPC calls to work for an iOS app, an android app, a desktop app, ... ? They can share all the model code (literally, the same lines of code, same bugs, same everything) and only need custom views and controllers (which you'd have to do differently in any language). Backend is simply identical, and java supports secure RPC to all these platforms, all of whom process data in exactly the same way.

Plus : GWT makes dynamically creating user interfaces tolerable, something I still have nightmares of doing in javascript.

But my main complaint is controlling complexity : in javascript, you can forget about it. 500-1k lines of javascript nicely working together really does mean you have a good programmer. You can effectively not load more than 1 javascript library without unwanted interactions (exception being the many Google libraries that do seem to work together, but combine them with jquery and you'll already see surprises). The point where complexity starts exploding is very low. PHP/Perl/Python/C is a little better : you can generally expect a good programmer to be able to get ~10000 lines to work together nicely without very serious problems. Java/C#/C++ allow you to control complexity on a large scale. 100k, 1 mil, 10 million line codebases are possible and (can be) maintainable in those languages. Now keep in mind that sucky programmers suck in any language, I'm talking about good programmers

Yes, angular is really fast to make a tiny form with "standard" functionality. If you think that's going to do anything more than get you a standard app without armies of programmers (like Google has), you're deluding yourself.

Plus let's state the obvious here : people hate javascript for good reason. Good language, considering it was a weekend hack, but horrible language compared to anything else out there. Java, flawed as it is, is massively better than javascript. Also : once GWT frees you from frontend/backend integration and ridiculous testing you won't want to go back, and of course there's the java library ecosystem that is very extensive indeed.

Re:The Java Origins of Angular JS: Angular vs. JSF vs. GWT by nostrademons on Tuesday July 15, 2014 @02:31PM (#8038156)
Considering that most Google Apps (GMail, G+, Docs, Calendar, etc.) are single-page webapps with over a million lines of JS, I'd hardly say "GWT is the only way to go". The programmers I know at Google who worked on complex GWT apps (notably Google Base and Adwords 3) didn't have very many nice things to say about it, besides the Eclipse integration.

The Java/JS integration is handled the same way it's handled in any large distributed system: define a protocol for the server and client to communicate. Only evolve the protocol in backwards-compatible ways. You need to do this anyway if you expect user sessions to survive server upgrades, because you may have an old client talking to a new server. I'm curious how GWT handles this case - if it's autogenerating communication responses, it needs to be aware of both old and new versions to safely upgrade them.

Re:The Java Origins of Angular JS: Angular vs. JSF vs. GWT by skybrian on Tuesday July 15, 2014 @05:27PM (#8039118)
I'm most familiar with GWT-RPC and it doesn't have any backward compatibility built in, so most deploys are a protocol change. (It does at least give you a clear error when there's a protocol mismatch.)

So if you want old user sessions to survive, you'll need to keep the old service available until they reload the page.

There are protobuf/JSON-based alternatives with a better compatibility story.

Re:The Java Origins of Angular JS: Angular vs. JSF vs. GWT by johnyzee on Tuesday July 15, 2014 @06:18PM (#8039451)
It's not true that most deploys are a protocol change - only changes that would also change Java serialization's serial UID will cause GWT-RPC clients to become incompatible.

I routinely deploy a new version while hundreds of users are online and nobody is the wiser.

Re:The Java Origins of Angular JS: Angular vs. JSF vs. GWT by skybrian on Tuesday July 15, 2014 @07:32PM (#8039772)
Well, that's true; it depends on how complex your protocol is and how often you change it. Simplicity is good!

But this can be tricky for large, distributed projects, where the author of a class might not even be aware that it's used with GWT.

Re:The Java Origins of Angular JS: Angular vs. JSF vs. GWT by waps on Tuesday July 15, 2014 @09:25PM (#8040123)
Actually there is backwards compatibility in the same sense as there is binary compatibility. Have a mechanism to force upgrades, ideally conserving state. Leave the old call in place for 1 version.

This is not difficult.

Protobuf/JSON alternatives don't even have frontend-backend compatibility in the same version. Protobuf in java has completely different encoding to normal protobuf, meaning you need TWO protobuf libraries in your backend, and of course javascript protobuf messages don't actually support anywhere near the language set that protobuf itself supports. Those are reasons why calling it protobuf is misleading. The data structures don't mean the same thing in the frontend and the backend.

Re:The Java Origins of Angular JS: Angular vs. JSF vs. GWT by JamesXNelson on Wednesday July 16, 2014 @11:41AM (#8042603)
Funny you mention docs... The new Google Sheets (y'know, that awesome spreadsheet app that lets you write javascript macros with a full in-browser debugger), is written in GWT.
Re:The Java Origins of Angular JS: Angular vs. JSF vs. GWT by waps on Wednesday July 16, 2014 @08:56AM (#8041740)
As I understand it, Google does not write apps in javascript, at all. The language closest to javascript that they do use is closure [1]. Closure is technically a javascript to javascript compiler but it makes the language

1) compiled, not interpreted

2) strongly typed (not optional typing according to the google style guide [2])

So yes, there are large javascript applications. In the same sense that KDE is an extremely large C application, or that the linux kernel is written in assembly. Only not really written in javascript.

[1] https://developers.google.com/closure/

[2] http://google-styleguide.googlecode.com/svn/trunk/javascript...

Re:The Java Origins of Angular JS: Angular vs. JSF vs. GWT by nostrademons on Wednesday July 16, 2014 @04:06PM (#8044226)
(I worked at Google, with Closure, on some of these large JS apps. The Closure tech lead responsible for open-sourcing it is a friend of mine.)

It's true that all of Google's major customer-facing apps use Closure. However, I would not consider it to be a separate language, but rather a large component library and toolchain for developing JS apps at scale. The language is identical to Javascript, and Closure apps can be run uncompiled, they just take up more bytes on the wire and give the programmer weaker error-checking.

It is also very possible to write Closure without the type declarations - I've done it, frequently, for various doodles & easter eggs. They are non-optional according to the styleguide, but that's a style choice mandated for large teams. Typically, type annotations make working with large multi-developer JS apps much easier, but they're unnecessary for smaller one-off projects.

Also, any JS developer off the street can download Closure and use it to write JS apps, since it's open-source. If they want to use Closure Compiler they will probably have to forgo certain language features; I once tried to get JQuery to compile with it and it was basically a total loss. But the language should be completely familiar to anyone accustomed to working with Javascript. (You probably don't want to do this if you just have a small startup, since both the compiler and class library are designed for working with very large-scale apps and pay a large verbosity penalty for keeping things manageable, but it's possible.)

Re:The Java Origins of Angular JS: Angular vs. JSF vs. GWT by waps on Friday July 18, 2014 @02:36AM (#8051945)
And you can implement C as a set of assembler macros and a preprocessor step (which can be part of any C compiler). That does NOT make C and assembly the same language. The same is true for large C++ codebases. Nobody claims they're valid C, even though they're one preprocessing step away from being one.

Specifically C is "smaller". Everything in C can be expressed in assembly, but not every piece of assembly code has a matching C code. One hopes that it's mostly the more insane parts of assembly code that can't be translated.

Nobody will argue that C and "text" assembly are the same language. In the same way, I argue that javascript and closure are very, very different. Generally, assuming google actually demands closure apps compile with the toolchain (I'd be astonished if they didn't), these languages are not the same, despite one being valid in the other.

Javascript further clouds this issue by allowing preprocessing steps in the language itself. If you don't take that into account, you could say python is valid javascript. That's not a reasonable claim.