Opa: A new language aiming to make web programming transparent
lambda-the-ultimate.org
lambda-the-ultimate.org
Only a few obvious downsides/open questions to me:
* License prohibits making closed-source things in it.
* How efficient is the generated client-side code? Language mismatch is a major cause of slow generated code (see GWT). In Opa's case, having no arrays (only linked lists) sounds like a disaster for compiling to JS.
* I've never seen the model work before where you "don't even need to think about what's running on the client or server." I like features like sharing code (same language) and easy transport (serializable data structures), but frameworks that blur the client/server distinction usually download all of your code, or none of it, or little snippets on demand, or some other strategy that's worse than a manual distinction.
* What's development like? Do you really have to recompile your app after every change? My favorite frameworks just let you change the code and reload the web page.
* I've seen many, and even written one, tutorial that goes: "Making a chat room in a web browser is hard. But here's a demo that does it in 20 lines!" With all the frameworks and libraries out there these days, it's not that hard.
* Tons of dependencies (a personal gripe). Coming from the Java world, where lots of things like reading images are built-in, it's comical to see that Opa requires Java, AND libjpeg and a dozen other things (it doesn't actually run on the JVM I don't think).
The JS code is not as optimized as what you can write manually, although a lot of work was put in making it work "fast enough" (thanks Mathieu). However, we have many ideas on how to reach native performance. Look for instance at how Java got sometimes even faster than C!
There are hints @server and @client to specify a side for running a bit of your code. Since, as you say, there are things you know and the machine doesn't.
Opa being a compiler, updated projects have to be recompiled. You gain a lot in quality, consistency with this (especially associated to the very advanced type system of Opa). And as we know that compilers are annoying, we made our best to make the compile time short. You probably won't have to take a coffee, sorry.
The chat example does not rely on predefined libraries -- that's the difference. You can also look at bigger chat applications like https://github.com/hbbio/OpaChat and compare with https://github.com/ry/node_chat.
Opa requires Java for building from source - if the package does, that's something you can report at https://github.com/mlstate/opalang/issues?sort=created&d...
I don't think browsers are going to let you build a hot-spot compiler in Javascript. Nor do I think that an online, optimizing interpreter in javascript stands much of a chance of improving performance.
And then, if NaCl/NativeClient becomes mainstream, that's yet another avenue worth exploring.
For example, in Google Web Toolkit, which compiles Java to JavaScript, theoretically the static type information should be a huge boon to optimization. And indeed, the compiler does some fancy stuff, including static inlining, and segmenting the code so that chunk 2 is only downloaded when a method call crosses the boundary of chunk 1.
However, consider something like a HashMap. A JavaScript programmer might use a single JS object as a hash, whereas the GWT programmer has the luxury of using a java.util.HashMap, which is theoretically compiled down to something efficient, maybe just as efficient. In practice, this is hard or impossible for the compiler, and HashMaps are compiled to a system of objects that's much more complex. There are great reasons for this -- primarily, HashMaps can have any object as a key, not just a string; also the nature of the HashMap API and behavior under subclassing -- but the result is if you want something fast, you need to use a FastStringMap or some such class, backed by a "native" JS object. But in general, when you're not worrying about performance, you might find yourself using many HashMaps, even parsing JSON into nested HashMaps! So now each JS object is represented by a bunch of JS objects needed to make the mechanics of the HashMap abstraction work.
I worry that not having arrays leads to a similar problem. In magic happy land, a call like List.pop that removes the last element of a list would be implemented as a tail-recursive operation on heads and tails, which the compile would then recognize and turn back into a call to Array.pop! In practice, this kind of thing is unlikely. As with HashMaps, the programmer is forced (or told) to use heavyweight data structures to simulate lightweight ones, with the hope that the compiler will recognize that this is a case where the lightweight structure applies and transform it back!
As for "online" compilation, I guess this is easier on the JVM. Clojure, Rhino, Scala, and Java are all compiled and can be set up to recompile on the fly after every change to the program. Node.js too. Having developed this way, I don't think I could go back to having to do anything after changing the code besides reloading the page.
Good point. We have actually been working on this specific problem of lists vs. arrays. The results have not been put on code yet, but we hope that the problem can be solved in many cases.
> Having developed this way, I don't think I could go back to having to do anything after changing the code besides reloading the page.
We have also been working on that. Future versions of Opa might offer something along these lines.
There are two things here. For prototyping, Opa will automatically decide what goes to the client and what goes to the server. We are very much aware that this may not yield the best performance. So, when you move from prototyping to optimization, using your knowledge of the application security policy, you can add security hints that the compiler will use to optimize client-server placement, knowing that this does not break the policy. And finally, if you want even better control, you can annotate any piece of code to instruct the compiler to place it on the client, or on the server, or both. In any case, the compiler will inform you if the set of constraints you put has no solution.
Tons of dependencies (a personal gripe). Coming from the Java world, where lots of things like reading images are built-in, it's comical to see that Opa requires Java, AND libjpeg and a dozen other things (it doesn't actually run on the JVM I don't think).
I concur that the dependencies are a (minor) annoyance. Just one point: Java is used only to build Opa from source. More precisely, during Opa compilation, we run the (very nice) Java-based Google Closure Compiler as a measure of the quality of our JavaScript libraries. If I recall correctly, that build step is optional, too.
There is a lot of transparency in web programming if you are willing to learn. Roy Fielding's dissertation comes to mind as well as the book "RESTful Web Services", RFC 2068, RFC 2616 and ECMA-262. In the end it's "some server stuff" -- HTTP -- "some client stuff" where "some client stuff" is mostly Javascript.
Off topic: Does Blizzard's World of Warcraft client count as web development or is web development limited to the way Joel Spolsky describes it? [1]
PS: This comment is based solely on the introductory paragraph of OPA's home page.
[1] https://plus.google.com/117114202722218150209/posts/KhMRNmgG...
Note: I'm part of the Opa team.
And given that the language is statically typed (with inference in most cases, so it's easy for the programmer) with first-class web values, the whole point of Opa is that the compiler knows quite a lot about your application when generating the binaries. The typing system determines wether part of the code will run on the client side, on the server side (or both) for instance. This mechanism is very different from Ruby on Rails for instance, although both approaches share the goal of making the programmer's life easy.
Building RESTful services is exactly where Opa excels. Have a look at http://doc.opalang.org/index.html#_hello_web_services and the following chapter.
Also, I may be wrong, but I don't think that the code run by a GPLed interpreter has to conform to the license. Native libraries linked to the runtime would have to, though.
Note: I'm part of the Opa team.
Good choice on the license!
(However if you encounter problems with adoption/funding, it might be time to start thinking about paid dual-licensing heh)
AGPL is a non-starter.
EDIT: There is a non-AGPL license that can be purchased. Non-starter has passed start. :)
Ur/Web syntax seems closer to OCaml syntax, so it might be a bit easier to learn. However, Opa documentation seems more polished and complete so it might even the odds.
Nice work, and thanks for bringing static guarantees to web development. It is much needed.
However, if you wish to make your code open-source with a different license, don't hesitate to contact Mathieu.Baudet@mlstate.com, he'll certainly be happy to arrange something.
"way for your users to download the sources of the application. In fact Opa facilitates that by automatically enriching the server (in release mode) to serve the source code of the application at a special /_internal_/src_code URL."
1. When you go through the pains of integrating everything else, why not go for gold and exclude x/html and css as well? These are as "glue, antagonistic" as the other bits that make up the current webapp quagmire.
2. When ideas like PaaS are emerging, wouldnt it be better to bundle everything that makes up the app separate from everything that makes up the platform? I know that this sounds like the antithesis of your "one executable" idea - and I love single executables where appropriate - but it seems like webapp deployment could do with some economies of scale on the underlying container in the sense that the difference between App A and App B is primarily in the functionality, not in the way those functions are accessed, used, etc.
Actually, the x/html and (most of the) css that you see in our examples is syntactic sugar for higher-level constructions.
> 2. When ideas like PaaS are emerging, wouldnt it be better to bundle everything that makes up the app separate from everything that makes up the platform? [...]
Certainly feasible, but I'm not sure what would be gained, and it would make deployment a little harder.
Guess what? We like them :)
Automation: by default, you do not have to give the compiler any hint as to whether code should be compiled towards the client, the server, the database, etc. The compiler solves all of this automatically, inserting whichever Ajax/Comet calls wherever needed. You can, however, provide annotations for optimization and/or security purposes.
Concurrency/distribution: at its heart, Opa is based on an actor model (although you do not need to use actors for simple applications). This actor model lets you connect easily clients, servers, etc. or subsystems through a very simple paradigm.
Security: every Ajax/Comet call inserted is checked for a number of criteria. In particular, the structure of messages is checked automatically, entry points generated dynamically for one single client can only be used by that client, etc.
Note: I'm one of the authors of Opa.
I have quit java/j2ee to avoid recompiling/redeploying all the time ! So the compiling part is a no go for me !
I play the trombone.
Opa opa opa-pa opa-pa opa-pa
Opa opa opa-pa opa opa-pa