Download Java, .Net, Ruby and PHP integration

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
33rd Degree Conference
Kraków, 7 April, 2011
Matthias Hryniszak
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 story
so far…
X86 asm
section .text
global _start
;must be declared for linker (ld)
_start:
;tell linker entry point
mov edx,len ;message length
mov ecx,msg ;message to write
mov ebx,1
;file descriptor (stdout)
mov eax,4
;system call number (sys_write)
int 0x80 ;call kernel
mov eax,1
;system call number (sys_exit)
int 0x80 ;call kernel
section .data
msg db 'Hello, world!',0xa ;our dear string
len 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!");
}
}
The no-brainers
PHP – the dynamic language for masses
Why would you even care?
How to integrate with PHP code
Ruby – the new wave
What’s Ruby really good at?
How to integrate with Ruby code
整合
The evil, but cool side of life
.NET– the evil twin from Microsoft
Why would you even care?
The lame side of integration…
How cool kids do it?
整合
TRY THIS
BEFORE
YOU USE IT!
整合
整合
整合
整合
整合
整合
整合
TRY THIS
BEFORE
YOU USE IT!
JSR 223
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()
);
}
整合
JSR 223
require 'java'
Calculator = com.aplaline.example.Calculator
calc = Calculator.new
calc.add(2.0,3.0)
整合
JSR 223
require 'java'
Calculator = com.aplaline.example.Calculator
calc = Calculator.new
calc.add(2.0,3.0)
整合
JtestR - regular
class HashMapTests < Test::Unit::TestCase
def setup
@map = java.util.HashMap.new
end
def test_that_map_is_empty
assert @map.isEmpty
end
end
整合
JtestR - 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"
end
end
整合
Don’t
shoot the
messenger
Learn from other’s mistakes
Become aware that Java is not the only choice
Make sure you understand the risks involved
To have plenty of fun!
整合
The old-fasion way…
整合
The old-fasion way…
整合
The IKVM-way
整合
ikvmc.exe
the binary compiler
jar-to-dll/exe converter
ikvm.exe
the JVM implementation on .NET
ikvmstub.exe
dll-to-jar converter
OpenJDK in assembly form
整合
整合
整合
整合
http://padcom13.blogspot.com
http://ikvm.net
http://resin.org
http://jruby.org
整合