Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
The ideal module system ...
… and the harsh reality

Adam Warski
SoftwareMill

#DV13 #modules
Wednesday 13 November 13

@a...
New languages
Are we focusing on the wrong problem?

#DV13 #modules
Wednesday 13 November 13

@adamwarski
About me

• During the day: coding @ SoftwareMill
• SoftwareMill: a great software house!
• Afternoon: playgrounds, Duplo,...
Plan for the next 50 minutes

• Ideal module system
• Veripacks
• Ceylon

#DV13 #modules
Wednesday 13 November 13

@adamwa...
What is a module?
• OSGi bundle?
• Jigsaw-something?
• Maven build module?
• Guice module?
• Ruby module?
#DV13 #modules
W...
What is a module?

Source: http://www.merriam-webster.com/dictionary/module

#DV13 #modules
Wednesday 13 November 13

@ada...
The Modularity Continuum

#DV13 #modules
Wednesday 13 November 13

@adamwarski
The Modularity Continuum
Classes

Single responsibility principle
#DV13 #modules
Wednesday 13 November 13

@adamwarski
The Modularity Continuum
Classes

#DV13 #modules
Wednesday 13 November 13

Packages

@adamwarski
The Modularity Continuum
Classes

Packages

Build modules

#DV13 #modules
Wednesday 13 November 13

@adamwarski
The Modularity Continuum
Classes

Packages

Build modules

#DV13 #modules
Wednesday 13 November 13

Projects

@adamwarski
The Modularity Continuum
Classes

Packages

Build modules

Projects

Systems
#DV13 #modules
Wednesday 13 November 13

@ada...
Ideal module
system
#DV13 #modules
Wednesday 13 November 13

@adamwarski
Group code

• Comprehensible chunks of
•
•
•

code
Specific (single)
responsibility
Isolation
Namespacing

#DV13 #modules
W...
Reusable

• Across one system
• Across multiple systems
• Industry standards

#DV13 #modules
Wednesday 13 November 13

@ad...
Abstraction

• Hide implementation
•
•

details
Decide what is accessible
to who
Not only what, but also
how (wiring)

Was...
Interfaces

• Multiple implementations
• A way to define the

interface & data structures

#DV13 #modules
Wednesday 13 Nove...
Composability

• Create big modules from
•
•

smaller ones
Hierarchical
Scalable

#DV13 #modules
Wednesday 13 November 13
...
Replaceable

• Swap implementations
• Run time/load time/build
time

#DV13 #modules
Wednesday 13 November 13

@adamwarski
Meta

• Dependencies
• Versioning
• Specify & verify

#DV13 #modules
Wednesday 13 November 13

@adamwarski
Requirements

• Group code
• Reusable
• Abstraction
• Interfaces
• Composability
• Replaceable
• Meta
#DV13 #modules
Wedne...
Requirements

• So ... what now?
• Let’s create a new

revolutionary language™!

#DV13 #modules
Wednesday 13 November 13

...
Packages &
Veripacks
#DV13 #modules
Wednesday 13 November 13

@adamwarski
Packages
Classes

Packages

Build modules

Projects

Systems
#DV13 #modules
Wednesday 13 November 13

@adamwarski
Packages

• Namespacing
• Simple string identifiers
• Parent-child relations?

• com.company.myapp.finance
• com.company.my...
All classes are equal?

• “By default” classes are public
• Which class is the main one?
• What’s the responsibility of th...
One public class per package

• Make only one class public
• Other: package-protected
• Clearly visible:
•
•

what is the ...
Growing the concept

• Support from JVM/Java ends here
• What if the functionality is big?
•
•

extract a sub-package
now ...
Enter Veripacks

• Specify which classes are exported from a package
•
•

hierarchy
Respect package parent-child relations...
Enter Veripacks
package	
  foo.bar.p1	
  {
	
  	
  @Export
	
  	
  class	
  A	
  {	
  ...	
  }

package	
  foo.bar.p2	
  {...
Veripacks: exporting

• By default: export all
• Export a class
• Export a child package
• ... or any mix
• Transitive!
#D...
Running Veripacks

public	
  void	
  testPackageSpecifications()	
  {
	
  	
  	
  VeripacksBuilder
	
  	
  	
  	
  .build(...
Veripacks: importing

• Also transitive
•

to sub-packages

• Specify that a package needs to be imported
•
•

@Import
@Re...
3rd party library import example
//	
  src/main/scala/org/veripacks/reader/package-­‐info.java
@Import("org.objectweb")
pa...
Replacing build modules?

• Why do we create build modules?
•
•
•
•
•

isolate parts of code
api/impl split
adding a 3rd p...
Build modules are heavy

• Maven: elaborate xml
• Separate directory structure
• Hard to extract a common part
• Additiona...
#DV13 #modules
Wednesday 13 November 13

@adamwarski
Other benefits

• No need to think when functionality is “big enough” to create
•
•

a module
Test code sharing
Refactorin...
Packages+Veripacks as modules?

• Group code
• Partially reusable
• Abstraction: yes (@Export)
• Interfaces: no
• Composab...
Ceylon

#DV13 #modules
Wednesday 13 November 13

@adamwarski
What is Ceylon?

• “A language for writing large programs in teams”
• Cross-platform (Java/JS)
• Statically typed (union, ...
Ceylon modules
Classes

• Moving a level higher
• A bit similar to OSGi,
•

Build modules

Projects

Jigsaw
But part of th...
Sharing

• In Ceylon things can be shared, or not
• Things:
•
•

program elements (classes, class members)
packages

#DV13...
Modularity concepts in Ceylon
•

•

3 basic concepts:
modules
packages
classes

•
•
•

Classes mostly similar as in Java
(...
Packages in Ceylon

• Separate file with
•

meta-data
Annotations

•
•

sharing
comments

#DV13 #modules
Wednesday 13 Novem...
Modules in Ceylon

• Bundles a set of packages into a .car archive
• Package names: prefix of the module name
• Import othe...
There’s more!

• Runnable modules
• Local/remote repositories
used:

#DV13 #modules
Wednesday 13 November 13

‣ during the...
There’s more!

• Run-time component
•
•

isolated class-loaders
based on JBoss Modules

#DV13 #modules
Wednesday 13 Novemb...
Modules in Ceylon

• Group code
• Reusable: yes
• Abstraction: yes (shared)
• Interfaces: no
• Composability: partial
• Re...
Summing up

• Modules come in different flavors & sizes
• How many explicit module types do we want?
•
•
•

scalability
sma...
Links

• http://github.com/adamw/veripacks
• http://ceylon-lang.org
• http://warski.org

#DV13 #modules
Wednesday 13 Novem...
Thank you; Come & get a sticker

http://codebrag.com/devoxx/
#DV13 #modules
Wednesday 13 November 13

@adamwarski
Party!

#DV13 #modules
Wednesday 13 November 13

@adamwarski
Upcoming SlideShare
Loading in …5
×

The ideal module system and the harsh reality

1,926 views

Published on

Published in: Technology, Education
  • Be the first to comment

The ideal module system and the harsh reality

  1. 1. The ideal module system ... … and the harsh reality Adam Warski SoftwareMill #DV13 #modules Wednesday 13 November 13 @adamwarski
  2. 2. New languages Are we focusing on the wrong problem? #DV13 #modules Wednesday 13 November 13 @adamwarski
  3. 3. About me • During the day: coding @ SoftwareMill • SoftwareMill: a great software house! • Afternoon: playgrounds, Duplo, etc. • Evening: blogging, open-source • • • Original author of Hibernate Envers ElasticMQ, Veripacks, MacWire http://www.warski.org #DV13 #modules Wednesday 13 November 13 @adamwarski
  4. 4. Plan for the next 50 minutes • Ideal module system • Veripacks • Ceylon #DV13 #modules Wednesday 13 November 13 @adamwarski
  5. 5. What is a module? • OSGi bundle? • Jigsaw-something? • Maven build module? • Guice module? • Ruby module? #DV13 #modules Wednesday 13 November 13 @adamwarski
  6. 6. What is a module? Source: http://www.merriam-webster.com/dictionary/module #DV13 #modules Wednesday 13 November 13 @adamwarski
  7. 7. The Modularity Continuum #DV13 #modules Wednesday 13 November 13 @adamwarski
  8. 8. The Modularity Continuum Classes Single responsibility principle #DV13 #modules Wednesday 13 November 13 @adamwarski
  9. 9. The Modularity Continuum Classes #DV13 #modules Wednesday 13 November 13 Packages @adamwarski
  10. 10. The Modularity Continuum Classes Packages Build modules #DV13 #modules Wednesday 13 November 13 @adamwarski
  11. 11. The Modularity Continuum Classes Packages Build modules #DV13 #modules Wednesday 13 November 13 Projects @adamwarski
  12. 12. The Modularity Continuum Classes Packages Build modules Projects Systems #DV13 #modules Wednesday 13 November 13 @adamwarski
  13. 13. Ideal module system #DV13 #modules Wednesday 13 November 13 @adamwarski
  14. 14. Group code • Comprehensible chunks of • • • code Specific (single) responsibility Isolation Namespacing #DV13 #modules Wednesday 13 November 13 @adamwarski
  15. 15. Reusable • Across one system • Across multiple systems • Industry standards #DV13 #modules Wednesday 13 November 13 @adamwarski
  16. 16. Abstraction • Hide implementation • • details Decide what is accessible to who Not only what, but also how (wiring) Wassily Kandinsky, Accent on Rose, 1926 #DV13 #modules Wednesday 13 November 13 @adamwarski
  17. 17. Interfaces • Multiple implementations • A way to define the interface & data structures #DV13 #modules Wednesday 13 November 13 @adamwarski
  18. 18. Composability • Create big modules from • • smaller ones Hierarchical Scalable #DV13 #modules Wednesday 13 November 13 @adamwarski
  19. 19. Replaceable • Swap implementations • Run time/load time/build time #DV13 #modules Wednesday 13 November 13 @adamwarski
  20. 20. Meta • Dependencies • Versioning • Specify & verify #DV13 #modules Wednesday 13 November 13 @adamwarski
  21. 21. Requirements • Group code • Reusable • Abstraction • Interfaces • Composability • Replaceable • Meta #DV13 #modules Wednesday 13 November 13 @adamwarski
  22. 22. Requirements • So ... what now? • Let’s create a new revolutionary language™! #DV13 #modules Wednesday 13 November 13 @adamwarski
  23. 23. Packages & Veripacks #DV13 #modules Wednesday 13 November 13 @adamwarski
  24. 24. Packages Classes Packages Build modules Projects Systems #DV13 #modules Wednesday 13 November 13 @adamwarski
  25. 25. Packages • Namespacing • Simple string identifiers • Parent-child relations? • com.company.myapp.finance • com.company.myapp.finance.invoicing #DV13 #modules Wednesday 13 November 13 @adamwarski
  26. 26. All classes are equal? • “By default” classes are public • Which class is the main one? • What’s the responsibility of the package? #DV13 #modules Wednesday 13 November 13 @adamwarski
  27. 27. One public class per package • Make only one class public • Other: package-protected • Clearly visible: • • what is the responsibility of the package what’s the main entry point #DV13 #modules Wednesday 13 November 13 @adamwarski
  28. 28. Growing the concept • Support from JVM/Java ends here • What if the functionality is big? • • extract a sub-package now the classes in the sub-package must be public #DV13 #modules Wednesday 13 November 13 @adamwarski
  29. 29. Enter Veripacks • Specify which classes are exported from a package • • hierarchy Respect package parent-child relationships Allow exporting classes & child packages • Using annotations • Verify Package Specifications #DV13 #modules Wednesday 13 November 13 @adamwarski
  30. 30. Enter Veripacks package  foo.bar.p1  {    @Export    class  A  {  ...  } package  foo.bar.p2  {    class  Test  {        //  ok        new  A()    class  B  {  ...  } }        //  illegal        new  B() package  foo.bar.p1.sub_p1  {    class  C  {  ...  } }        //  illegal        new  C()    } } #DV13 #modules Wednesday 13 November 13 @adamwarski
  31. 31. Veripacks: exporting • By default: export all • Export a class • Export a child package • ... or any mix • Transitive! #DV13 #modules Wednesday 13 November 13 @adamwarski
  32. 32. Running Veripacks public  void  testPackageSpecifications()  {      VeripacksBuilder        .build() .verify(“foo.bar”)  //  root  package  to  check .throwIfNotOk() } #DV13 #modules Wednesday 13 November 13 @adamwarski
  33. 33. Veripacks: importing • Also transitive • to sub-packages • Specify that a package needs to be imported • • @Import @RequiresImport • Importing 3rd party libraries #DV13 #modules Wednesday 13 November 13 @adamwarski
  34. 34. 3rd party library import example //  src/main/scala/org/veripacks/reader/package-­‐info.java @Import("org.objectweb") package  org.veripacks.reader; import  org.veripacks.Import; VeripacksBuilder      .requireImportOf("org.objectweb")      .build      .verify("org.veripacks")      .throwIfNotOk() #DV13 #modules Wednesday 13 November 13 @adamwarski
  35. 35. Replacing build modules? • Why do we create build modules? • • • • • isolate parts of code api/impl split adding a 3rd party lib to a part of code group code with similar functionality statically check inter-module dependencies #DV13 #modules Wednesday 13 November 13 @adamwarski
  36. 36. Build modules are heavy • Maven: elaborate xml • Separate directory structure • Hard to extract a common part • Additional thing to name #DV13 #modules Wednesday 13 November 13 @adamwarski
  37. 37. #DV13 #modules Wednesday 13 November 13 @adamwarski
  38. 38. Other benefits • No need to think when functionality is “big enough” to create • • a module Test code sharing Refactoring, easy to: • • • introduce a module remove a module rename a module #DV13 #modules Wednesday 13 November 13 @adamwarski
  39. 39. Packages+Veripacks as modules? • Group code • Partially reusable • Abstraction: yes (@Export) • Interfaces: no • Composability: partial (transitivity) • Replaceable: no • Meta: dependencies yes (@Import), versioning no #DV13 #modules Wednesday 13 November 13 @adamwarski
  40. 40. Ceylon #DV13 #modules Wednesday 13 November 13 @adamwarski
  41. 41. What is Ceylon? • “A language for writing large programs in teams” • Cross-platform (Java/JS) • Statically typed (union, intersection types, ...) • OO/FP mix • Typesafe metaprogramming • 1.0 with an IDE available: http://ceylon-lang.org/ • ... and modularity #DV13 #modules Wednesday 13 November 13 @adamwarski
  42. 42. Ceylon modules Classes • Moving a level higher • A bit similar to OSGi, • Build modules Projects Jigsaw But part of the language #DV13 #modules Wednesday 13 November 13 Packages Systems @adamwarski
  43. 43. Sharing • In Ceylon things can be shared, or not • Things: • • program elements (classes, class members) packages #DV13 #modules Wednesday 13 November 13 @adamwarski
  44. 44. Modularity concepts in Ceylon • • 3 basic concepts: modules packages classes • • • Classes mostly similar as in Java (from the modularity perspective) • #DV13 #modules Wednesday 13 November 13 @adamwarski
  45. 45. Packages in Ceylon • Separate file with • meta-data Annotations • • sharing comments #DV13 #modules Wednesday 13 November 13 @adamwarski
  46. 46. Modules in Ceylon • Bundles a set of packages into a .car archive • Package names: prefix of the module name • Import other modules #DV13 #modules Wednesday 13 November 13 @adamwarski
  47. 47. There’s more! • Runnable modules • Local/remote repositories used: #DV13 #modules Wednesday 13 November 13 ‣ during the build ‣ when running @adamwarski
  48. 48. There’s more! • Run-time component • • isolated class-loaders based on JBoss Modules #DV13 #modules Wednesday 13 November 13 @adamwarski
  49. 49. Modules in Ceylon • Group code • Reusable: yes • Abstraction: yes (shared) • Interfaces: no • Composability: partial • Replaceable: partial • Meta: yes (both for packages and modules) • Run-time #DV13 #modules Wednesday 13 November 13 @adamwarski
  50. 50. Summing up • Modules come in different flavors & sizes • How many explicit module types do we want? • • • scalability small, but specialized? from very big to very small, general? • Which requirements should which types meet? • Challenge for the Next Big Language? #DV13 #modules Wednesday 13 November 13 @adamwarski
  51. 51. Links • http://github.com/adamw/veripacks • http://ceylon-lang.org • http://warski.org #DV13 #modules Wednesday 13 November 13 @adamwarski
  52. 52. Thank you; Come & get a sticker http://codebrag.com/devoxx/ #DV13 #modules Wednesday 13 November 13 @adamwarski
  53. 53. Party! #DV13 #modules Wednesday 13 November 13 @adamwarski

×