Java, .N ET , Ruby and PHP integration

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

description

33rd Degree Conference Kraków, 7 April , 2011. Java, .N ET , Ruby and PHP integration. Matthias Hryniszak. The following presentation is intended for informational purposes only . - PowerPoint PPT Presentation

Transcript of Java, .N ET , Ruby and PHP integration

Page 1: Java, .N ET , Ruby  and PHP integration

Java, .NET, Ruby and PHP integration

Matthias Hryniszak

33rd Degree ConferenceKraków, 7 April, 2011

Page 2: Java, .N ET , Ruby  and PHP integration
Page 3: Java, .N ET , Ruby  and PHP integration

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: Java, .N ET , Ruby  and PHP integration
Page 5: Java, .N ET , Ruby  and PHP integration

The storyso far…

Page 6: Java, .N ET , Ruby  and PHP integration

X86 asm

Page 7: Java, .N ET , Ruby  and PHP integration

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: Java, .N ET , Ruby  and PHP integration

C/C++

Page 9: Java, .N ET , Ruby  and PHP integration

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

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

}

#include <iostream>

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

Page 10: Java, .N ET , Ruby  and PHP integration

JEE

Page 11: Java, .N ET , Ruby  and PHP integration

│ 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: Java, .N ET , Ruby  and PHP integration
Page 13: Java, .N ET , Ruby  and PHP integration

Ruby

Page 14: Java, .N ET , Ruby  and PHP integration

puts 'Hello world'

Page 15: Java, .N ET , Ruby  and PHP integration

PHP

Page 16: Java, .N ET , Ruby  and PHP integration

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

Page 17: Java, .N ET , Ruby  and PHP integration

C#.NET

Page 18: Java, .N ET , Ruby  and PHP integration

using System;

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

Page 19: Java, .N ET , Ruby  and PHP integration
Page 20: Java, .N ET , Ruby  and PHP integration

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: Java, .N ET , Ruby  and PHP integration

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: Java, .N ET , Ruby  and PHP integration
Page 23: Java, .N ET , Ruby  and PHP integration

TRY THIS BEFORE YOU USE

IT!

Page 24: Java, .N ET , Ruby  and PHP integration

How about…

Java integration

整合

Page 25: Java, .N ET , Ruby  and PHP integration

Wiki in 2 minutes?

整合

Page 26: Java, .N ET , Ruby  and PHP integration

Wiki in 2 minutes!

MediaWiki

整合

Page 27: Java, .N ET , Ruby  and PHP integration

Blog in 2 minutes?

整合

Page 28: Java, .N ET , Ruby  and PHP integration

Blog in 2 minutes!

Wordpress

整合

Page 29: Java, .N ET , Ruby  and PHP integration

Forum in 2 minutes?

整合

Page 30: Java, .N ET , Ruby  and PHP integration

Forum in 2 minutes!

PhpBB

整合

Page 31: Java, .N ET , Ruby  and PHP integration
Page 32: Java, .N ET , Ruby  and PHP integration
Page 33: Java, .N ET , Ruby  and PHP integration

TRY THIS BEFORE YOU USE

IT!

Page 34: Java, .N ET , Ruby  and PHP integration

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: Java, .N ET , Ruby  and PHP integration

require 'java'

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

Ruby as a scripting languageJSR 223

整合

Page 36: Java, .N ET , Ruby  and PHP integration

require 'java'

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

Ruby as a scripting languageJSR 223

整合

Page 37: Java, .N ET , Ruby  and PHP integration

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: Java, .N ET , Ruby  and PHP integration

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: Java, .N ET , Ruby  and PHP integration
Page 40: Java, .N ET , Ruby  and PHP integration
Page 41: Java, .N ET , Ruby  and PHP integration

Don’t shoot the

messenger

Page 42: Java, .N ET , Ruby  and PHP integration

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: Java, .N ET , Ruby  and PHP integration

整合

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

Page 44: Java, .N ET , Ruby  and PHP integration

整合

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

Page 45: Java, .N ET , Ruby  and PHP integration

整合

How would you integrate with it?The IKVM-way

IKVM.NET

Page 46: Java, .N ET , Ruby  and PHP integration

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: Java, .N ET , Ruby  and PHP integration

Java on .NET ???

DemoGroovy + OSGi

整合

Page 48: Java, .N ET , Ruby  and PHP integration

What runs on IKVM?

Eclipse

整合

Page 49: Java, .N ET , Ruby  and PHP integration

What runs on IKVM?

Apache Tomcat

整合

Page 50: Java, .N ET , Ruby  and PHP integration
Page 51: Java, .N ET , Ruby  and PHP integration

Thanks for watching!

整合

http://padcom13.blogspot.com

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