1. CASSIS

    Tantek Çelik tantek.com@t

  2. 2008

  3. Bulletproof AJAX

    bookcover of Bulletproof AJAX
  4. more responsive =
    better UX

  5. href="#"
    breaks the web

  6. href="?p=jeremy"
    + Unobtrusive JavaScript

  7. "Hijax"
    Unobtrusive AJAX

  8. writing code twice:
    JavaScript & PHP

  9. DRY principle
    (Don't Repeat Yourself)

  10. tired of rewriting in different languages

  11. can we pick a winner?

  12. has JavaScript (JS) won?
    (yet)

  13. most # of programmers

  14. most # of companies optimizing it

  15. JS on client & server
    = write logic once

  16. JS subset that works
    on client & server?

  17. CASSIS conceived

  18. avoid unintentionally enabling SkyNet

    SkyNet monitoring screen
  19. JS on the server
    not supported by default

  20. but all web hosts run PHP

  21. intersection of JS & PHP?

  22. 2009

  23. falsy values research

  24. false 0 "0" "00"

  25. falsy value testing

    tweet of falsy value tests
  26. function js() { 
     return ("00"==false); 
    }

  27. runtime switching good
    need a parsetime switch

  28. 2001
    voice-family:"\"}\"";

  29. 2002
    Semantic Scripting

  30. principle of separation of script and markup

  31. hypertext script docs
    external JS with HTML

  32. 
    <!-- /*--> 
     markup ... 
    <!--*/ //-->
     script
    //<!--
    /*--> 
     more markup 
    <!--*/ //-->
    

  33. but for JS and PHP files

  34. back to 2009

  35. CASSIS v0 code

    tweet of CASSIS v0 code
  36. 
    <!-- <?php // -->
    
    /* cassis.js v0 code */
    /* valid JS and PHP  */
    
    // ?> -->
    

  37. <!-- HTML -->
    <script src="cassis.js">

  38. /* php */
    ob_start(); 
    include 'cassis.js'; 
    ob_end_clean();
    

  39. challenge: variable names

  40. jQuery popularized $ in JS

  41. CASSIS convention:
    $ variables e.g. $x

  42. challenge: string concat
    'a'+'b' vs 'a'.'b'

  43. common function instead

  44. 
    function strcat($s1,$s2) {
     if (js()) { 
       return $s1 + $s2; 
     }
     else { 
       return $s1 . $s2; 
     }
    }
    

  45. challenge: PHP-only code
    date_default_timezone_set("UTC");

  46. need a PHP-only block

  47. 
    /* <!-- <?php // -->
      echo 'PHP only';
    // */
      /* both JS and PHP */
    // ?> -->
    

  48. challenge: JS-only code
    e.g. PHP function equivalents

  49. 
    function strlen(s) {
     return s.length;
    }
    
    function ord(s) {
     return s.charCodeAt(0);
    }
    

  50. need JS and/or PHP

  51. /*/
    comment inverter

  52. /**/
    stateless comment closer

  53. 
    /* <!-- <?php // -->
      echo 'PHP only';
    /*/
      alert("JS only");
    /**/
      /* both JS and PHP */
    // ?> -->
    

  54. What's CASSIS good for?

  55. ASIN.cc

  56. I'm using CASSIS:

  57. 2011

  58. CASSIS is open source:
    github.com/tantek/cassis

  59. JS: present and future
    of web programming

  60. Until JS is ubiquitous,
    CASSIS is a step forward.

  61. Thank you.

    Tantek Çelik

    tantek.com@t

    cassisproject.com@cassisjs