Post on 22-Feb-2016
description
Java, .NET, Ruby and PHP integration
Matthias Hryniszak
33rd Degree ConferenceKraków, 7 April, 2011
The following presentation is intended for informational purposes only.
There’s no part of it that you should consider either a guideline, viable option or production-ready set of
instructions that could solve your problem
If you use any concepts of what you see here it is entirely up to you to make sure it works for you.
The storyso far…
X86 asm
section .text global _start ;must be declared for linker (ld)_start: ;tell linker entry point
mov edx,len ;message lengthmov ecx,msg ;message to writemov ebx,1 ;file descriptor (stdout)mov eax,4 ;system call number (sys_write)int 0x80 ;call kernelmov eax,1 ;system call number (sys_exit)int 0x80 ;call kernel
section .datamsg db 'Hello, world!',0xa ;our dear stringlen equ $ - msg ;length of our dear string
C/C++
#include <stdio.h>#include <stdlib.h>
int main() {println("Hello, world!");
}
#include <iostream>
int main() { std::cout << "Hello World!" << std::endl;}
JEE
│ pom.xml│└───src ├───main │ ├───java │ │ └───com │ │ └───aplaline │ │ └───example │ │ │ MyApplicationModule.java │ │ │ ServletConfig.java │ │ │ │ │ ├───components │ │ │ TextLabel.java │ │ │ │ │ └───views │ │ FrontView.java │ │ RootView.java │ │ │ ├───resources │ │ └───com │ │ └───aplaline │ │ └───example │ │ ├───components │ │ │ TextLabel.xsl │ │ │ │ │ └───views │ │ FrontView.xsl │ │ RootView.xsl │ │ │ └───webapp │ │ main.css │ │ │ ├───gfx │ │ pageheader.png │ │ │ ├───scripts │ │ contextfw.js │ │ jquery.js │ │ json.js │ │ │ └───WEB-INF │ web.xml │ └───test └───java └───com └───aplaline └───example WebStart.java
Ruby
puts 'Hello world'
PHP
<?php echo "Hello, World!"; ?>
C#.NET
using System;
class Pogram { public static void Main() { Console.WriteLine("Hello, world!"); }}
AgendaThe no-brainers
PHP – the dynamic language for massesWhy would you even care?How to integrate with PHP code
Ruby – the new waveWhat’s Ruby really good at?How to integrate with Ruby code
整合
AgendaThe evil, but cool side of life
.NET– the evil twin from MicrosoftWhy would you even care?The lame side of integration…How cool kids do it?
整合
TRY THIS BEFORE YOU USE
IT!
How about…
Java integration
整合
Wiki in 2 minutes?
整合
Wiki in 2 minutes!
MediaWiki
整合
Blog in 2 minutes?
整合
Blog in 2 minutes!
Wordpress
整合
Forum in 2 minutes?
整合
Forum in 2 minutes!
PhpBB
整合
TRY THIS BEFORE YOU USE
IT!
ScriptEngineManager sem = new ScriptEngineManager();ScriptEngine se = sem.getEngineByExtension("rb");InputStream is = ClassLoader.getSystemResourceAsStream("hello.rb");InputStreamReader script = new InputStreamReader(is);
try { Object result = se.eval(script); System.out.println("Result: " + result);} catch (Exception e) { System.out.println( "Error while executing script\n" + e.getMessage() );}
Ruby as a scripting languageJSR 223
整合
require 'java'
Calculator = com.aplaline.example.Calculatorcalc = Calculator.newcalc.add(2.0,3.0)
Ruby as a scripting languageJSR 223
整合
require 'java'
Calculator = com.aplaline.example.Calculatorcalc = Calculator.newcalc.add(2.0,3.0)
Ruby as a scripting languageJSR 223
整合
Ruby as a language for testsJtestR - regular
整合
class HashMapTests < Test::Unit::TestCase def setup @map = java.util.HashMap.new end
def test_that_map_is_empty assert @map.isEmpty endend
Ruby as a language for testsJtestR - RSpec
整合
import java.util.HashMap
describe "An empty", HashMap do before :each do @hash_map = HashMap.new end
it "should be able to add an entry to it" do @hash_map.put "foo", "bar" @hash_map.get("foo").should == "bar" endend
Don’t shoot the
messenger
Why even bother?
整合
Learn from other’s mistakesBecome aware that Java is not the only choiceMake sure you understand the risks involvedTo have plenty of fun!
整合
How would you integrate with it?The old-fasion way…
整合
How would you integrate with it?The old-fasion way…
整合
How would you integrate with it?The IKVM-way
IKVM.NET
What’s in the box?
整合
ikvmc.exethe binary compilerjar-to-dll/exe converter
ikvm.exethe JVM implementation on .NET
ikvmstub.exedll-to-jar converter
OpenJDK in assembly form
Java on .NET ???
DemoGroovy + OSGi
整合
What runs on IKVM?
Eclipse
整合
What runs on IKVM?
Apache Tomcat
整合
Thanks for watching!
整合
http://padcom13.blogspot.com
http://ikvm.nethttp://resin.orghttp://jruby.org