SlideShare a Scribd company logo
Using FXML on Clojure
(fxml helloworld)
netpyoung@gmail.com
July 2018
#1
Do you have any Questions?
- If you have questions, during presentation.
- message on slack #clojure-sg with page #numer.
- https://clojurians.slack.com/messages/clojure-sg
- ex) #10 - what is blabla?
- I will answer after presentation.(for keep time)
- so, I can polish this slide from your feedbacks.
#2
● EunPyoung Kim
● KOR -> JPN -> SGP-> ???
● Game Client Programmer. (since 2012.04 ~ )
● I like Lisp (not only clojure)
● I’m Lazy
○ because of that I like automatation (code generate also)
○ I like macro (but don't abuse)
● I like Emacs
○ Cursive
○ (Neo)Vim….?
● https://netpyoung.github.io/
#3
What I want & What I did.
● I want editor for future when I making game.
○ Cross platform desktop application
○ GUI designer.
● I didn’t make library.
● I just share other’s approach and my experience.
#4
Wait but why Clojure? (java,scala,kotlin...)
● I'm Game Client Programmer. I prefer typed language rather than dynamic.
● No Clojure? No Problem to me.
● But I just feel fun when I play with REPL.
● I love Lisp not only Clojure.
○ They Also love(?) Lisp.
■ https://www.slideshare.net/naughty_dog/statebased-scripting-in-uncharted-2-among-
thieves
■ https://www.youtube.com/watch?v=Hbexh-Jutvs
● I also like person who love Lisp, they's way of thinking is so flexible and
amazing, like language itself.
● I just choose Clojure compare each other Lisp directs.
#5
Desktop Application
● WPF
○ C#(ClojureCRL)
○ Windows only (but I like XAML. I hope it will be ported on dotnet core)
● JavaFX
○ Java(Clojure)
○ Cross Platform
○ SceneBuilder - GUI Editor
● Electron
○ Javascript(Clojurescript)
○ Cross Platform
○ gui editor??
● qt, wxwidgets, ...
#6
JavaFX
● Sun announces JavaOne 2007
● Open-sourced 2011
○ http://openjdk.java.net/projects/openjfx/
● August 2018
○ JDK 11, Oracle is making JavaFX easier to adopt by making the technology available as a
separate download, decoupled from the JDK.
○ https://blogs.oracle.com/java-platform-group/the-future-of-javafx-and-other-java-client-
roadmap-updates
● I’m not sure JavaFX will be popular or not.
○ If is it possible using WPF on osx - dotnet core, I will choose ClojureCLR.
#7
FXML
fxml
- language
- id
- action
scene builder
controller
#8
FXML
fxml
scene builder
controller
#9
FXML
fxml
scene builder
controller
img: https://www.callicoder.com/javafx-fxml-form-gui-tutorial/
#10
Java - Controller
#11
Java - Controller
#12
I Need Controller
but there are some issue.
● controller - @FXML attribute binding
○ binding Method
○ binding Field
○ binding initialize
● REPL driven developing
○ need to solving AOT problem
#13
#14
I Need Type for Controller
Controller
● regular map
● defrecord
● rerify
● proxy
● gen-class
● deftype
#15
Skip this things
(X) binding
method
(X) binding field
Controller
● regular map
● defrecord
● rerify
● proxy
● gen-class
● deftype
#16
gen-class
#17
binding field(?)
gen-class
● If you want to binding field with gen-class,
○ using .java both…..
● If I incorrect, message to me I will correct that.
#18
Controller
● regular map
● defrecord
● rerify
● proxy
● gen-class
● deftype
#19
#20
deftype
● dirty.. but works….
● I want to check fxml without relaunch application.
#21
● (deftask build []
(comp (aot) (pom) (uber) (jar)))
● aot : Perform AOT compilation of Clojure namespaces
● pom: Create project pom.xml file
● uber: Add jar entries from dependencies to fileset
● jar: Build a jar file for the project
#22
reload
● Okay let’s boost with boot
○ https://github.com/boot-clj/boot
○ https://github.com/boot-clj/boot/pull/692
● danielsz/system
○ https://github.com/danielsz/system
#23
#24
It’s works
● But……. It looks so weird.
● definterface only used one per deftype
● Code structure also Dirty
○ we can avoid this problem using macro… but… Is this really valuable??
#25
What’s the Next
● regular map
● defrecord
● rerify
● proxy
● gen-class
● deftype
#26
FTW! Virtual Dom
● regular map
● defrecord
● rerify
● proxy
● gen-class
● deftype
● Virtual DOM
#27
Virtual DOM
in java
● There is https://github.com/netopyr/reduxfx
#28
in clojure
● fn-fx
○ https://github.com/halgari/fn-fx
○ https://www.youtube.com/watch?v=hJ8GZxhsaVQ
● like redux, single data direction.
● Java 10 Parser and Abstract Syntax Tree for Java – https://javaparser.org
● - https://github.com/javaparser/javaparser : Java source text -> AST
● - https://github.com/forge/roaster : A Java Parser library that allows easy
parsing and formatting of Java source files
● - https://github.com/ronmamo/reflections : Java runtime metadata analysis
#29
#30
Wait…. I want to use FXML
● I’m tired to write UI code……
● I want that take over this task to UI designer.
#31
● regular map
● defrecord
● rerify
● proxy
● gen-class
● deftype
● Virtual DOM
● Custom Type
Controller
#32
Custom Type
How to implement gen-class in Clojure.
https://github.com/clojure/clojure/blob/master/src/clj/clojure/genclass.clj
(defmacro gen-class
(generate-class options-map)
(defn- generate-class [options-map]
(let [cv (clojure.lang.Compiler/classWriter)
#33
How to implement deftype in clojure
https://github.com/clojure/clojure/blob/master/src/clj/clojure/core_deftype.clj
(defmacro deftype
(emit-deftype*
(defn- emit-deftype*
`(deftype*
#34
How to implement deftype in clojure
https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/Compiler.java
static final Symbol DEFTYPE = Symbol.intern("deftype*");
ClassWriter cw
ClassVisiter cv = cw;
#35
What is ClassWriter?
https://github.com/clojure/clojure/blob/master/src/jvm/clojure/asm/ClassWriter.java
ASM
https://github.com/consulo/objectweb-
asm/blob/master/src/main/java/org/jetbrains/org/objectweb/asm/ClassWriter.java
#36
ASM
● https://asm.ow2.io/
● ASM is an all purpose Java bytecode manipulation and analysis framework. It
can be used to modify existing classes or to dynamically generate classes,
directly in binary form.
● It can be used to modify existing classes or to dynamically generate classes,
directly in binary form
● ref:
○ https://www.infoq.com/presentations/asm-cglib-javassist-2
○ https://www.slideshare.net/ashleypuls/bytecode-manipulation
#37
bytecode
● JVM Bytecode for Dummies (and the Rest of Us Too)
○ https://www.youtube.com/watch?v=rPyqB1l4gko
#38
#39
#40
wait! insn
● Functional JVM bytecode generation for Clojure.
● https://github.com/jgpc42/insn
#41
clojurefx
● I found interesting library.
● https://github.com/zilti/clojurefx
#42
(defn load-fxml-with-controller
[filename init-fn]
(generate-controller filename init-fn)
(load-fxml filename))
#43
FXML -> input-stream -> javafx.fxml.FXMLLoader
FXML -> input-stream
-> xml/parse -> tree-seq (for finding id, handler)
-> Do Something
-> ClassLoader
#44
Do Something
cw =org.objectweb.asm.ClassWriter
.visitCode
.visitMethodInsn
.visitEnd
.visitField
.visitAnnotation
.visitEnd
.visitEnd
bytes = cw.toBytesArray
ClassLoader.getSystemClassLoader() // java.lang.ClassLoader
.defineClass(name, bytes, 0, bytes.length)
#45
How about this? defmacro fxml
(defmacro fxml [fxml-name]
….
)
(def fxml-helloworld (fxml helloworld))
#46
How about this? fxml-controller
(defmacro fxml-controller [...]
….
)
(def controller
(fxml-controller [lbl_count]
(onBtnDown [evt] …)
(onBtnUp [evt] …)))
#47
Resources
● github : https://github.com/netpyoung/pt.using-fxml-on-clojure
#48
Questions
ex) #10 - what is blabla?
#49
Thank you
50

More Related Content

What's hot (20)

DOC
Typescript Basics
Manikandan [M M K]
 
PPT
Design Patterns (Examples in .NET)
Aniruddha Chakrabarti
 
PPTX
Fragment
nationalmobileapps
 
PDF
Declarative UIs with Jetpack Compose
Ramon Ribeiro Rabello
 
PDF
Unit-3 event handling
Amol Gaikwad
 
PPTX
Async Programming in C# 5
Pratik Khasnabis
 
PDF
TypeScript와 Flow: 
자바스크립트 개발에 정적 타이핑 도입하기
Heejong Ahn
 
PPTX
Angular modules in depth
Christoffer Noring
 
PDF
Introduction to fragments in android
Prawesh Shrestha
 
PPTX
Data Sharing Between Child and Parent Components in AngularJS
Fibonalabs
 
PDF
Asynchronous JavaScript Programming with Callbacks & Promises
Hùng Nguyễn Huy
 
PDF
프로젝트 기획안
UGOHWANG
 
PPTX
Xslt
Mahara Jothi
 
PPTX
Introduction to React
Rob Quick
 
PDF
Angular
Lilia Sfaxi
 
PDF
Introduction to Java 11
Knoldus Inc.
 
PPTX
Popup boxes
sonal bisla
 
PDF
An introduction-to-tkinter
Jose Hernandez Moya
 
ODP
Spring User Guide
Muthuselvam RS
 
PDF
High-Performance Haskell
Johan Tibell
 
Typescript Basics
Manikandan [M M K]
 
Design Patterns (Examples in .NET)
Aniruddha Chakrabarti
 
Declarative UIs with Jetpack Compose
Ramon Ribeiro Rabello
 
Unit-3 event handling
Amol Gaikwad
 
Async Programming in C# 5
Pratik Khasnabis
 
TypeScript와 Flow: 
자바스크립트 개발에 정적 타이핑 도입하기
Heejong Ahn
 
Angular modules in depth
Christoffer Noring
 
Introduction to fragments in android
Prawesh Shrestha
 
Data Sharing Between Child and Parent Components in AngularJS
Fibonalabs
 
Asynchronous JavaScript Programming with Callbacks & Promises
Hùng Nguyễn Huy
 
프로젝트 기획안
UGOHWANG
 
Introduction to React
Rob Quick
 
Angular
Lilia Sfaxi
 
Introduction to Java 11
Knoldus Inc.
 
Popup boxes
sonal bisla
 
An introduction-to-tkinter
Jose Hernandez Moya
 
Spring User Guide
Muthuselvam RS
 
High-Performance Haskell
Johan Tibell
 

Similar to Using FXML on Clojure (20)

PDF
JavaFX Your Way: Building JavaFX Applications with Alternative Languages
Stephen Chin
 
PPTX
JavaFX Your Way - Devoxx Version
Stephen Chin
 
PPTX
JavaFX 2.0 With Alternative Languages - Groovy, Clojure, Scala, Fantom, and V...
Stephen Chin
 
PPTX
JavaFX 2.0 and Alternative Languages
Stephen Chin
 
PPTX
JavaFX 2.0 With Alternative Languages - Groovy, Clojure, Scala, Fantom, and V...
Stephen Chin
 
PDF
From Swing to JavaFX
Yuichi Sakuraba
 
PDF
Clojure beasts-euroclj-2014
Renzo Borgatti
 
PDF
Clojure & Scala
Diego Pacheco
 
PDF
Clojure - A new Lisp
elliando dias
 
PDF
JavaFX, because you're worth it
Thierry Wasylczenko
 
ODP
Getting started with Clojure
John Stevenson
 
KEY
(map Clojure everyday-tasks)
Jacek Laskowski
 
PPT
Unit 1 informatica en ingles
Marisa Torrecillas
 
PPT
Unit i informatica en ingles
Marisa Torrecillas
 
PPT
6 xml parsing
gauravashq
 
PPTX
JavaFX 2 and Scala - Like Milk and Cookies (33rd Degrees)
Stephen Chin
 
PDF
JavaOne - The JavaFX Community and Ecosystem
Alexander Casall
 
PPTX
JavaFX Presentation
Mochamad Taufik Mulyadi
 
PDF
Javafxpressentation 140524053934-phpapp01 (1)
ssuser4f9de3
 
PDF
Scripting with Java FX - Cédric Tabin - December 2007
JUG Lausanne
 
JavaFX Your Way: Building JavaFX Applications with Alternative Languages
Stephen Chin
 
JavaFX Your Way - Devoxx Version
Stephen Chin
 
JavaFX 2.0 With Alternative Languages - Groovy, Clojure, Scala, Fantom, and V...
Stephen Chin
 
JavaFX 2.0 and Alternative Languages
Stephen Chin
 
JavaFX 2.0 With Alternative Languages - Groovy, Clojure, Scala, Fantom, and V...
Stephen Chin
 
From Swing to JavaFX
Yuichi Sakuraba
 
Clojure beasts-euroclj-2014
Renzo Borgatti
 
Clojure & Scala
Diego Pacheco
 
Clojure - A new Lisp
elliando dias
 
JavaFX, because you're worth it
Thierry Wasylczenko
 
Getting started with Clojure
John Stevenson
 
(map Clojure everyday-tasks)
Jacek Laskowski
 
Unit 1 informatica en ingles
Marisa Torrecillas
 
Unit i informatica en ingles
Marisa Torrecillas
 
6 xml parsing
gauravashq
 
JavaFX 2 and Scala - Like Milk and Cookies (33rd Degrees)
Stephen Chin
 
JavaOne - The JavaFX Community and Ecosystem
Alexander Casall
 
JavaFX Presentation
Mochamad Taufik Mulyadi
 
Javafxpressentation 140524053934-phpapp01 (1)
ssuser4f9de3
 
Scripting with Java FX - Cédric Tabin - December 2007
JUG Lausanne
 
Ad

More from EunPyoung Kim (7)

PPTX
Clojure with panama
EunPyoung Kim
 
PPTX
Interop with c in clojure
EunPyoung Kim
 
PPTX
On lisp ch18
EunPyoung Kim
 
PPTX
On lisp ch09
EunPyoung Kim
 
PPTX
(Lisp)
EunPyoung Kim
 
PPTX
Clojure programming study_00
EunPyoung Kim
 
PPT
Clojure development environment
EunPyoung Kim
 
Clojure with panama
EunPyoung Kim
 
Interop with c in clojure
EunPyoung Kim
 
On lisp ch18
EunPyoung Kim
 
On lisp ch09
EunPyoung Kim
 
Clojure programming study_00
EunPyoung Kim
 
Clojure development environment
EunPyoung Kim
 
Ad

Recently uploaded (20)

PDF
HiHelloHR – Simplify HR Operations for Modern Workplaces
HiHelloHR
 
PDF
Salesforce CRM Services.VALiNTRY360
VALiNTRY360
 
PPT
MergeSortfbsjbjsfk sdfik k
RafishaikIT02044
 
PDF
Understanding the Need for Systemic Change in Open Source Through Intersectio...
Imma Valls Bernaus
 
PPTX
Tally software_Introduction_Presentation
AditiBansal54083
 
PDF
Revenue streams of the Wazirx clone script.pdf
aaronjeffray
 
PPTX
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pptx
Varsha Nayak
 
PPTX
Writing Better Code - Helping Developers make Decisions.pptx
Lorraine Steyn
 
PDF
GridView,Recycler view, API, SQLITE& NetworkRequest.pdf
Nabin Dhakal
 
PDF
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pdf
Varsha Nayak
 
PDF
GetOnCRM Speeds Up Agentforce 3 Deployment for Enterprise AI Wins.pdf
GetOnCRM Solutions
 
PPTX
MailsDaddy Outlook OST to PST converter.pptx
abhishekdutt366
 
PDF
Mobile CMMS Solutions Empowering the Frontline Workforce
CryotosCMMSSoftware
 
PPTX
Tally_Basic_Operations_Presentation.pptx
AditiBansal54083
 
PPTX
How Odoo Became a Game-Changer for an IT Company in Manufacturing ERP
SatishKumar2651
 
PPTX
Revolutionizing Code Modernization with AI
KrzysztofKkol1
 
PPTX
An Introduction to ZAP by Checkmarx - Official Version
Simon Bennetts
 
PPTX
Java Native Memory Leaks: The Hidden Villain Behind JVM Performance Issues
Tier1 app
 
PPTX
Migrating Millions of Users with Debezium, Apache Kafka, and an Acyclic Synch...
MD Sayem Ahmed
 
PDF
Thread In Android-Mastering Concurrency for Responsive Apps.pdf
Nabin Dhakal
 
HiHelloHR – Simplify HR Operations for Modern Workplaces
HiHelloHR
 
Salesforce CRM Services.VALiNTRY360
VALiNTRY360
 
MergeSortfbsjbjsfk sdfik k
RafishaikIT02044
 
Understanding the Need for Systemic Change in Open Source Through Intersectio...
Imma Valls Bernaus
 
Tally software_Introduction_Presentation
AditiBansal54083
 
Revenue streams of the Wazirx clone script.pdf
aaronjeffray
 
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pptx
Varsha Nayak
 
Writing Better Code - Helping Developers make Decisions.pptx
Lorraine Steyn
 
GridView,Recycler view, API, SQLITE& NetworkRequest.pdf
Nabin Dhakal
 
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pdf
Varsha Nayak
 
GetOnCRM Speeds Up Agentforce 3 Deployment for Enterprise AI Wins.pdf
GetOnCRM Solutions
 
MailsDaddy Outlook OST to PST converter.pptx
abhishekdutt366
 
Mobile CMMS Solutions Empowering the Frontline Workforce
CryotosCMMSSoftware
 
Tally_Basic_Operations_Presentation.pptx
AditiBansal54083
 
How Odoo Became a Game-Changer for an IT Company in Manufacturing ERP
SatishKumar2651
 
Revolutionizing Code Modernization with AI
KrzysztofKkol1
 
An Introduction to ZAP by Checkmarx - Official Version
Simon Bennetts
 
Java Native Memory Leaks: The Hidden Villain Behind JVM Performance Issues
Tier1 app
 
Migrating Millions of Users with Debezium, Apache Kafka, and an Acyclic Synch...
MD Sayem Ahmed
 
Thread In Android-Mastering Concurrency for Responsive Apps.pdf
Nabin Dhakal
 

Using FXML on Clojure

  • 1. Using FXML on Clojure (fxml helloworld) [email protected] July 2018 #1
  • 2. Do you have any Questions? - If you have questions, during presentation. - message on slack #clojure-sg with page #numer. - https://clojurians.slack.com/messages/clojure-sg - ex) #10 - what is blabla? - I will answer after presentation.(for keep time) - so, I can polish this slide from your feedbacks. #2
  • 3. ● EunPyoung Kim ● KOR -> JPN -> SGP-> ??? ● Game Client Programmer. (since 2012.04 ~ ) ● I like Lisp (not only clojure) ● I’m Lazy ○ because of that I like automatation (code generate also) ○ I like macro (but don't abuse) ● I like Emacs ○ Cursive ○ (Neo)Vim….? ● https://netpyoung.github.io/ #3
  • 4. What I want & What I did. ● I want editor for future when I making game. ○ Cross platform desktop application ○ GUI designer. ● I didn’t make library. ● I just share other’s approach and my experience. #4
  • 5. Wait but why Clojure? (java,scala,kotlin...) ● I'm Game Client Programmer. I prefer typed language rather than dynamic. ● No Clojure? No Problem to me. ● But I just feel fun when I play with REPL. ● I love Lisp not only Clojure. ○ They Also love(?) Lisp. ■ https://www.slideshare.net/naughty_dog/statebased-scripting-in-uncharted-2-among- thieves ■ https://www.youtube.com/watch?v=Hbexh-Jutvs ● I also like person who love Lisp, they's way of thinking is so flexible and amazing, like language itself. ● I just choose Clojure compare each other Lisp directs. #5
  • 6. Desktop Application ● WPF ○ C#(ClojureCRL) ○ Windows only (but I like XAML. I hope it will be ported on dotnet core) ● JavaFX ○ Java(Clojure) ○ Cross Platform ○ SceneBuilder - GUI Editor ● Electron ○ Javascript(Clojurescript) ○ Cross Platform ○ gui editor?? ● qt, wxwidgets, ... #6
  • 7. JavaFX ● Sun announces JavaOne 2007 ● Open-sourced 2011 ○ http://openjdk.java.net/projects/openjfx/ ● August 2018 ○ JDK 11, Oracle is making JavaFX easier to adopt by making the technology available as a separate download, decoupled from the JDK. ○ https://blogs.oracle.com/java-platform-group/the-future-of-javafx-and-other-java-client- roadmap-updates ● I’m not sure JavaFX will be popular or not. ○ If is it possible using WPF on osx - dotnet core, I will choose ClojureCLR. #7
  • 8. FXML fxml - language - id - action scene builder controller #8
  • 13. I Need Controller but there are some issue. ● controller - @FXML attribute binding ○ binding Method ○ binding Field ○ binding initialize ● REPL driven developing ○ need to solving AOT problem #13
  • 14. #14 I Need Type for Controller
  • 15. Controller ● regular map ● defrecord ● rerify ● proxy ● gen-class ● deftype #15 Skip this things (X) binding method (X) binding field
  • 16. Controller ● regular map ● defrecord ● rerify ● proxy ● gen-class ● deftype #16
  • 18. gen-class ● If you want to binding field with gen-class, ○ using .java both….. ● If I incorrect, message to me I will correct that. #18
  • 19. Controller ● regular map ● defrecord ● rerify ● proxy ● gen-class ● deftype #19
  • 20. #20
  • 21. deftype ● dirty.. but works…. ● I want to check fxml without relaunch application. #21
  • 22. ● (deftask build [] (comp (aot) (pom) (uber) (jar))) ● aot : Perform AOT compilation of Clojure namespaces ● pom: Create project pom.xml file ● uber: Add jar entries from dependencies to fileset ● jar: Build a jar file for the project #22
  • 23. reload ● Okay let’s boost with boot ○ https://github.com/boot-clj/boot ○ https://github.com/boot-clj/boot/pull/692 ● danielsz/system ○ https://github.com/danielsz/system #23
  • 24. #24
  • 25. It’s works ● But……. It looks so weird. ● definterface only used one per deftype ● Code structure also Dirty ○ we can avoid this problem using macro… but… Is this really valuable?? #25
  • 26. What’s the Next ● regular map ● defrecord ● rerify ● proxy ● gen-class ● deftype #26
  • 27. FTW! Virtual Dom ● regular map ● defrecord ● rerify ● proxy ● gen-class ● deftype ● Virtual DOM #27 Virtual DOM
  • 28. in java ● There is https://github.com/netopyr/reduxfx #28
  • 29. in clojure ● fn-fx ○ https://github.com/halgari/fn-fx ○ https://www.youtube.com/watch?v=hJ8GZxhsaVQ ● like redux, single data direction. ● Java 10 Parser and Abstract Syntax Tree for Java – https://javaparser.org ● - https://github.com/javaparser/javaparser : Java source text -> AST ● - https://github.com/forge/roaster : A Java Parser library that allows easy parsing and formatting of Java source files ● - https://github.com/ronmamo/reflections : Java runtime metadata analysis #29
  • 30. #30
  • 31. Wait…. I want to use FXML ● I’m tired to write UI code…… ● I want that take over this task to UI designer. #31
  • 32. ● regular map ● defrecord ● rerify ● proxy ● gen-class ● deftype ● Virtual DOM ● Custom Type Controller #32 Custom Type
  • 33. How to implement gen-class in Clojure. https://github.com/clojure/clojure/blob/master/src/clj/clojure/genclass.clj (defmacro gen-class (generate-class options-map) (defn- generate-class [options-map] (let [cv (clojure.lang.Compiler/classWriter) #33
  • 34. How to implement deftype in clojure https://github.com/clojure/clojure/blob/master/src/clj/clojure/core_deftype.clj (defmacro deftype (emit-deftype* (defn- emit-deftype* `(deftype* #34
  • 35. How to implement deftype in clojure https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/Compiler.java static final Symbol DEFTYPE = Symbol.intern("deftype*"); ClassWriter cw ClassVisiter cv = cw; #35
  • 37. ASM ● https://asm.ow2.io/ ● ASM is an all purpose Java bytecode manipulation and analysis framework. It can be used to modify existing classes or to dynamically generate classes, directly in binary form. ● It can be used to modify existing classes or to dynamically generate classes, directly in binary form ● ref: ○ https://www.infoq.com/presentations/asm-cglib-javassist-2 ○ https://www.slideshare.net/ashleypuls/bytecode-manipulation #37
  • 38. bytecode ● JVM Bytecode for Dummies (and the Rest of Us Too) ○ https://www.youtube.com/watch?v=rPyqB1l4gko #38
  • 39. #39
  • 40. #40
  • 41. wait! insn ● Functional JVM bytecode generation for Clojure. ● https://github.com/jgpc42/insn #41
  • 42. clojurefx ● I found interesting library. ● https://github.com/zilti/clojurefx #42
  • 43. (defn load-fxml-with-controller [filename init-fn] (generate-controller filename init-fn) (load-fxml filename)) #43
  • 44. FXML -> input-stream -> javafx.fxml.FXMLLoader FXML -> input-stream -> xml/parse -> tree-seq (for finding id, handler) -> Do Something -> ClassLoader #44
  • 45. Do Something cw =org.objectweb.asm.ClassWriter .visitCode .visitMethodInsn .visitEnd .visitField .visitAnnotation .visitEnd .visitEnd bytes = cw.toBytesArray ClassLoader.getSystemClassLoader() // java.lang.ClassLoader .defineClass(name, bytes, 0, bytes.length) #45
  • 46. How about this? defmacro fxml (defmacro fxml [fxml-name] …. ) (def fxml-helloworld (fxml helloworld)) #46
  • 47. How about this? fxml-controller (defmacro fxml-controller [...] …. ) (def controller (fxml-controller [lbl_count] (onBtnDown [evt] …) (onBtnUp [evt] …))) #47
  • 48. Resources ● github : https://github.com/netpyoung/pt.using-fxml-on-clojure #48
  • 49. Questions ex) #10 - what is blabla? #49

Editor's Notes

  • #9: println “helloworld” 출력하는거 표시해주자
  • #10: for understanding FXML, U need to learn this 3 kind of things
  • #51: Today is maybe my last day to attend this seminar