Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
Latest commit
34 lines (32 loc) · 11.6 KB
/
Copy pathindex.html
File metadata and controls
34 lines (32 loc) · 11.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<!DOCTYPE html><htmllang="en"><head><metacharset="utf-8"><title>Running Java from Node.js</title><metaname="description" content="Evaluating different methods to run Java code from Node.js."><metaname="author" content="Christian Dittrich"><metaname="apple-mobile-web-app-capable" content="yes"><metaname="apple-mobile-web-app-status-bar-style" content="black-translucent"><metaname="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"><linkrel="stylesheet" href="css/reveal.css"><linkid="theme" rel="stylesheet" href="css/theme/black.css"><!-- Code syntax highlighting--><linkrel="stylesheet" href="lib/css/zenburn.css"><!-- Printing and PDF exports--><script>varlink=document.createElement('link');
link.rel='stylesheet';
link.type='text/css';
link.href=window.location.search.match(/print-pdf/gi) ? 'css/print/pdf.css' : 'css/print/paper.css';
document.getElementsByTagName('head')[0].appendChild(link);</script><!--if lt IE 9script(src='lib/js/html5shiv.js')--></head><body><divclass="reveal"><!-- Any section element inside of this container is displayed as a slide--><divclass="slides"><section><h1>Running Java from Node.js</h1><h2><ahref="mailto:christian.dittrich@creatale.de?subject=Dein%20Vortrag%20beim%206.%20WebDev%20BBQ">Christian Dittrich</a></h2><h3><ahref="http://creatale.de">creatale GmbH</a></h3><p>WebDev BBQ, 15.09.2015</p></section><section><h1>Use Case</h1><h2><ahref="https://github.com/creatale/node-dv">node-dv</a></h2><ulclass="fragment"><li>image manipulation: <ahref="http://www.leptonica.com">Leptonica</a> and <ahref="http://opencv.org">OpenCV</a></li><li>OCR: <ahref="http://code.google.com/p/tesseract-ocr/">Tesseract</a></li><li>OMR: custom</li><li>barcode reader: <ahref="https://github.com/zxing/zxing">ZXing</a></li></ul></section><section><h1>ZXing in Node.js</h1><ul><li>native module using <ahref="https://github.com/zxing/zxing/tree/00f634024ceeee591f54e6984ea7dd666fab22ae/cpp">official C++ port</a></li><liclass="drawback">discontinued since 2013</li></ul></section><section><h1>What now?</h1><h1class="fragment">DIY?</h1></section><section><h1>Requirements</h1><ul><liclass="fragment">easy to keep up to date (automatically?)</li><liclass="fragment">platform "independent" (at least Windows and Linux)</li><liclass="fragment">easy to use API (has to work with buffers, not just files)</li><liclass="fragment">performant</li></ul></section><section><h1>1. Execute Java</h1><ulclass="fragment"><li>childProcess.spawn</li><li><ahref="https://github.com/YaroslavGaponov/node-jvm">node-jvm</a></li><li>client + server (aka service)</li><divclass="fragment"><liclass="drawback">not capable of working directly with buffers (only <code>public static void main(String[] args)</code> entry points)</li><liclass="drawback">usually extra processes</li></div></ul></section><section><h1>2. Java to C/C++</h1></section><section><h1>j2c</h1><ul><li><ahref="https://bitbucket.org/arnetheduck/j2c">https://bitbucket.org/arnetheduck/j2c</a></li><li>Eclipse Plugin by Google</li><li>supports Java 1.6</li><divclass="fragment"><liclass="drawback">errors when compiling ZXing</li><liclass="drawback">no Java class library implementation provided</li></div></ul></section><section><h1>XMLVM</h1><ul><li><ahref="http://xmlvm.org/overview/">http://xmlvm.org/overview/</a></li><li>cross platform mobile development</li><divclass="fragment"><liclass="drawback">problems with some java.nio classes ZXing uses (Paths, Files, DirectoryStream)</li></div></ul></section><section><h1>Tangible</h1><ul><li><ahref="http://www.tangiblesoftwaresolutions.com/Product_Details/CPlusPlus_to_Java_Converter_Details.html">http://www.tangiblesoftwaresolutions.com/Product_Details/CPlusPlus_to_Java_Converter_Details.html</a></li><liclass="drawback">costs money</li><liclass="drawback">free version limited to 100 lines of code at once</li></ul></section><section><h1>Java2C</h1><ul><li><ahref="http://sourceforge.net/projects/java2c/">http://sourceforge.net/projects/java2c/</a></li><li>Java to C for embedded projects</li><divclass="fragment"><liclass="drawback">only limited subset of Java supported (no generics, ZXing needs generics)</li><liclass="drawback">last updated in 2011</li></div></ul></section><section><h1>JCGO</h1><ul><li><ahref="http://www.ivmaisoft.com/jcgo/">http://www.ivmaisoft.com/jcgo/</a></li><liclass="drawback">supports only Java 1.4 (ZXing needs generics)</li></ul></section><section><h1>GCJ</h1><ul><li><ahref="http://gcc.gnu.org/java/">http://gcc.gnu.org/java/</a></li><li>GNU</li><divclass="fragment"><liclass="drawback">supports only Java 1.4 + some 1.5 features</li><liclass="drawback">last updated in 2009</li><liclass="drawback">java.nio missing (ZXing uses nio)</li></div></ul></section><section><h1>Toba</h1><ul><li><ahref="http://www.cs.arizona.edu/projects/sumatra/toba/">http://www.cs.arizona.edu/projects/sumatra/toba/</a></li><liclass="drawback">supports only Java 1.2</li><liclass="drawback">last updated in 1999</li></ul></section><section><h1>XES</h1><ul><li><ahref="http://www.euclideanspace.com/software/language/xes/userGuide/convert/javaToCpp/index.htm">http://www.euclideanspace.com/software/language/xes/userGuide/convert/javaToCpp/index.htm</a></li><liclass="drawback">manual translation of symbol table necessary (e.g. java.io to System)</li></ul></section><section><h1>3. JNI</h1><ulclass="fragment"><li><ahref="https://github.com/joeferner/node-java">'java' node module</a></li><li>ok-ish API<pre><codedata-trimclass="javascript">var list = java.newInstanceSync("java.util.ArrayList");</code></pre></li><divclass="fragment"><liclass="drawback">has problems with memory management (frequent out of memory exceptions), waiting for GC kills performance</li></div></ul></section><section><h1>4. Java to JavaScript</h1></section><section><h1>XMLVM</h1><ul><li><ahref="http://xmlvm.org/overview/">http://xmlvm.org/overview/</a></li><li>cross platform mobile development</li><liclass="drawback">uses Qooxdoo, client side only module</li></ul></section><section><h1>Java2Script</h1><ul><li><ahref="https://code.google.com/p/java2script/">https://code.google.com/p/java2script/</a></li><li>Eclipse Plugin</li><divclass="fragment"><liclass="drawback">compiled code contains errors</li><liclass="drawback">when compiling ZXing, some java.nio stuff missing</li></div></ul></section><section><h1>GWT</h1><ul><li><a href="http://www.gwtproject.org">http://www.gwtproject.org</a></li><li>by Google</li><li>for Web Applications</li><div class="fragment"><li class="drawback">needs explicit support by project (has to be packaged into a GWT module)</li></div></ul></section><section><h1>GWT Exporter</h1><ul><li><a href="https://code.google.com/p/gwt-exporter/">https://code.google.com/p/gwt-exporter/</a></li><li>built on GWT, does not need an GWT Application to work</li><div class="fragment"><li class="drawback">needs annotation of source code with <code>@Export()</code> and <code>implements Exportable</code></li></div></ul></section><section><h1>Kotlin</h1><ul><li><a href="http://kotlinlang.org">http://kotlinlang.org</a></li><li>a JVM language by JetBrains</li><li>compiles to JavaScript</li><li>Java can be automatically translated to Kotlin</li><div class="fragment"><li class="drawback">errors when compiling ZXing to JavaScript</li></div></ul></section><section><h1>Recap</h1><ol style="width:50%"><li style="visibility: visible;" class="fragment strike">Execute Java</li><li style="visibility: visible;" class="fragment strike">Java to C/C++</li><li style="visibility: visible;" class="fragment strike">JNI</li><li style="visibility: visible;" class="fragment strike">Java to JavaScript</li></ol></section><section><h1>5. <span class="fragment">Java to C# + 'edge' node module</span></h1></section><section><h1>What is edge?</h1><ul class="fragment"><li><a href="https://github.com/tjanczuk/edge">https://github.com/tjanczuk/edge</a></li><li>in process .NET code execution for Node.js and vice versa</li></ul><pre class="fragment"><code data-trim class="javascript">var edge = require('edge');
var helloWorld = edge.func(function () {/*
async (input) => {
return ".NET Welcomes " + input.ToString();
}
*/});
helloWorld('JavaScript', function (error, result) {
if (error) throw error;
console.log(result);
});
</code></pre></section><section><h1>sharpen</h1><ul><li><ahref="https://github.com/mono/sharpen">https://github.com/mono/sharpen</a></li><liclass="drawback">does not support multi dimensional arrays</li></ul></section><section><h1>Tangible</h1><ul><li><ahref="http://www.tangiblesoftwaresolutions.com/Product_Details/Java_to_CSharp_Converter.html">http://www.tangiblesoftwaresolutions.com/Product_Details/Java_to_CSharp_Converter.html</a></li><liclass="drawback">costs money</li><liclass="drawback">free version limited to 100 lines of code at once</li></ul></section><section><h1>XES</h1><ul><li><ahref="http://www.euclideanspace.com/software/language/xes/userGuide/convert/javaToCSharp/index.htm">http://www.euclideanspace.com/software/language/xes/userGuide/convert/javaToCSharp/index.htm</a></li><liclass="drawback">manual translation of symbol table necessary (e.g. java.io to stdio.h)</li></ul></section><section><h1>Octopus</h1><ul><li><ahref="http://www.remotesoft.com/octopus/">http://www.remotesoft.com/octopus/</a></li><liclass="drawback">costs money</li><liclass="drawback">online demo does not compile ZXing file</li></ul></section><section><h1>Java Language Conversion Assistant 2.0</h1><ul><li><ahref="http://www.microsoft.com/en-us/download/details.aspx?id=14349">http://www.microsoft.com/en-us/download/details.aspx?id=14349</a></li><li>by Microsoft</li><liclass="drawback">no longer available :(</li></ul></section><section><h1>VaryCode</h1><ul><li><ahref="https://www.varycode.com">https://www.varycode.com</a></li><liclass="drawback">costs money</li><liclass="drawback">free version limited to 2048 characters at once</li></ul></section><section><h1>Finally: The Solution</h1></section><section><h1>XMLVM</h1><p><ahref="http://xmlvm.org/overview/">http://xmlvm.org/overview/</a></p><olclass="fragment"><li>build JAR</li><li>compile to .NET-DLL via XMLVM</li><li>use 'edge' node module and <ahref="http://www.ikvm.net">IKVM</a> to run in-process on Node.js</li></ol><ulclass="fragment"><li>easy to keep up to date</li><li>platform independent (Mono)</li><li>usable API (same classes and methods for every object in C# + litte JavaScript boilerplate)</li><li>about 10% performance loss for ZXing, compared to original Java code</li></ul></section><section><h1>Example</h1></section><section><h1>Coming soon to <ahref="https://github.com/creatale">GitHub</a></h1><h2>'zxing-edge' node module</h2></section></div></div><scriptsrc="lib/js/head.min.js"></script><scriptsrc="js/reveal.js"></script><script>// Full list of configuration options available at:
// https://github.com/hakimel/reveal.js#configuration
Reveal.initialize({
controls: true,
progress: true,
history: true,
center: true,
transition: 'slide',// none/fade/slide/convex/concave/zoom
// Optional reveal.js plugins
dependencies: [
{src: 'lib/js/classList.js',condition: function(){return!document.body.classList;}},
{src: 'plugin/markdown/marked.js',condition: function(){return!!document.querySelector('[data-markdown]');}},
{src: 'plugin/markdown/markdown.js',condition: function(){return!!document.querySelector('[data-markdown]');}},
{src: 'plugin/highlight/highlight.js',async: true,condition: function(){return!!document.querySelector('pre code');},callback: function(){hljs.initHighlightingOnLoad();}},
{src: 'plugin/zoom-js/zoom.js',async: true},
{src: 'plugin/notes/notes.js',async: true}
]
});</script></body></html>