Top Banner
Java, .NET, Ruby and PHP integration Matthias Hryniszak 33rd Degree Conferenc Kraków, 7 April, 2011
51

Matthias Hryniszak 33rd Degree Conference Kraków, 7 April, 2011.

Jan 01, 2016

Download

Documents

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Matthias Hryniszak 33rd Degree Conference Kraków, 7 April, 2011.

Java, .NET, Ruby and PHP integration

Matthias Hryniszak

33rd Degree ConferenceKraków, 7 April, 2011

Page 2: Matthias Hryniszak 33rd Degree Conference Kraków, 7 April, 2011.
Page 3: Matthias Hryniszak 33rd Degree Conference Krakó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.

Page 4: Matthias Hryniszak 33rd Degree Conference Kraków, 7 April, 2011.
Page 5: Matthias Hryniszak 33rd Degree Conference Kraków, 7 April, 2011.

The storyso far…

Page 6: Matthias Hryniszak 33rd Degree Conference Kraków, 7 April, 2011.

X86 asm

Page 7: Matthias Hryniszak 33rd Degree Conference Kraków, 7 April, 2011.

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

Page 8: Matthias Hryniszak 33rd Degree Conference Kraków, 7 April, 2011.

C/C++

Page 9: Matthias Hryniszak 33rd Degree Conference Kraków, 7 April, 2011.

#include <stdio.h>#include <stdlib.h>

int main() {println("Hello, world!");

}

#include <iostream>

int main() { std::cout << "Hello World!" << std::endl;}

Page 10: Matthias Hryniszak 33rd Degree Conference Kraków, 7 April, 2011.

JEE

Page 11: Matthias Hryniszak 33rd Degree Conference Kraków, 7 April, 2011.

│ 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

Page 12: Matthias Hryniszak 33rd Degree Conference Kraków, 7 April, 2011.
Page 13: Matthias Hryniszak 33rd Degree Conference Kraków, 7 April, 2011.

Ruby

Page 14: Matthias Hryniszak 33rd Degree Conference Kraków, 7 April, 2011.

puts 'Hello world'

Page 15: Matthias Hryniszak 33rd Degree Conference Kraków, 7 April, 2011.

PHP

Page 16: Matthias Hryniszak 33rd Degree Conference Kraków, 7 April, 2011.

<?php echo "Hello, World!"; ?>

Page 17: Matthias Hryniszak 33rd Degree Conference Kraków, 7 April, 2011.

C#.NET

Page 18: Matthias Hryniszak 33rd Degree Conference Kraków, 7 April, 2011.

using System;

class Pogram { public static void Main() { Console.WriteLine("Hello, world!"); }}

Page 19: Matthias Hryniszak 33rd Degree Conference Kraków, 7 April, 2011.
Page 20: Matthias Hryniszak 33rd Degree Conference Kraków, 7 April, 2011.

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

整合

Page 21: Matthias Hryniszak 33rd Degree Conference Kraków, 7 April, 2011.

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?

整合

Page 22: Matthias Hryniszak 33rd Degree Conference Kraków, 7 April, 2011.
Page 23: Matthias Hryniszak 33rd Degree Conference Kraków, 7 April, 2011.

TRY THIS BEFORE YOU USE

IT!

Page 24: Matthias Hryniszak 33rd Degree Conference Kraków, 7 April, 2011.

How about…

Java integration

整合

Page 25: Matthias Hryniszak 33rd Degree Conference Kraków, 7 April, 2011.

Wiki in 2 minutes?

整合

Page 26: Matthias Hryniszak 33rd Degree Conference Kraków, 7 April, 2011.

Wiki in 2 minutes!

MediaWiki

整合

Page 27: Matthias Hryniszak 33rd Degree Conference Kraków, 7 April, 2011.

Blog in 2 minutes?

整合

Page 28: Matthias Hryniszak 33rd Degree Conference Kraków, 7 April, 2011.

Blog in 2 minutes!

Wordpress

整合

Page 29: Matthias Hryniszak 33rd Degree Conference Kraków, 7 April, 2011.

Forum in 2 minutes?

整合

Page 30: Matthias Hryniszak 33rd Degree Conference Kraków, 7 April, 2011.

Forum in 2 minutes!

PhpBB

整合

Page 31: Matthias Hryniszak 33rd Degree Conference Kraków, 7 April, 2011.
Page 32: Matthias Hryniszak 33rd Degree Conference Kraków, 7 April, 2011.
Page 33: Matthias Hryniszak 33rd Degree Conference Kraków, 7 April, 2011.

TRY THIS BEFORE YOU USE

IT!

Page 34: Matthias Hryniszak 33rd Degree Conference Kraków, 7 April, 2011.

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

整合

Page 35: Matthias Hryniszak 33rd Degree Conference Kraków, 7 April, 2011.

require 'java'

Calculator = com.aplaline.example.Calculatorcalc = Calculator.newcalc.add(2.0,3.0)

Ruby as a scripting languageJSR 223

整合

Page 36: Matthias Hryniszak 33rd Degree Conference Kraków, 7 April, 2011.

require 'java'

Calculator = com.aplaline.example.Calculatorcalc = Calculator.newcalc.add(2.0,3.0)

Ruby as a scripting languageJSR 223

整合

Page 37: Matthias Hryniszak 33rd Degree Conference Kraków, 7 April, 2011.

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

Page 38: Matthias Hryniszak 33rd Degree Conference Kraków, 7 April, 2011.

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

Page 39: Matthias Hryniszak 33rd Degree Conference Kraków, 7 April, 2011.
Page 40: Matthias Hryniszak 33rd Degree Conference Kraków, 7 April, 2011.
Page 41: Matthias Hryniszak 33rd Degree Conference Kraków, 7 April, 2011.

Don’t shoot the

messenger

Page 42: Matthias Hryniszak 33rd Degree Conference Kraków, 7 April, 2011.

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!

Page 43: Matthias Hryniszak 33rd Degree Conference Kraków, 7 April, 2011.

整合

How would you integrate with it?The old-fasion way…

Page 44: Matthias Hryniszak 33rd Degree Conference Kraków, 7 April, 2011.

整合

How would you integrate with it?The old-fasion way…

Page 45: Matthias Hryniszak 33rd Degree Conference Kraków, 7 April, 2011.

整合

How would you integrate with it?The IKVM-way

IKVM.NET

Page 46: Matthias Hryniszak 33rd Degree Conference Kraków, 7 April, 2011.

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

Page 47: Matthias Hryniszak 33rd Degree Conference Kraków, 7 April, 2011.

Java on .NET ???

DemoGroovy + OSGi

整合

Page 48: Matthias Hryniszak 33rd Degree Conference Kraków, 7 April, 2011.

What runs on IKVM?

Eclipse

整合

Page 49: Matthias Hryniszak 33rd Degree Conference Kraków, 7 April, 2011.

What runs on IKVM?

Apache Tomcat

整合

Page 50: Matthias Hryniszak 33rd Degree Conference Kraków, 7 April, 2011.
Page 51: Matthias Hryniszak 33rd Degree Conference Kraków, 7 April, 2011.

Thanks for watching!

整合

http://padcom13.blogspot.com

http://ikvm.nethttp://resin.orghttp://jruby.org