Guest User

Untitled

a guest
Jan 22nd, 2018
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.84 KB | None | 0 0
  1. Opalscript
  2. ==========
  3.  
  4. Opalscript is a ruby => javascript compiler that removes some of rubys' features to make the resulting javascript faster. It is based off, but different, to Opal. This document outlines the differences between opal script and the ruby features.
  5.  
  6. method_missing
  7. --------------
  8.  
  9. Method missing is **not** supported at all in opalscript.
  10.  
  11. Boolean class
  12. -------------
  13.  
  14. There is a single `Boolean` class which `true` and `false` are both instances. There is no `TrueClass` or `FalseClass`. This allows rubys `true` and `false` to be literal javascript natives.
  15.  
  16. Numeric class
  17. -------------
  18.  
  19. All numbers are instances of this single number class, which allows them to map directly to javascript numbers. There is no `Integer` or `Float` classes etc.
  20.  
  21. Strings and Symbols
  22. -------------------
  23.  
  24. There are no symbols. Symbol syntax is maintained, but they compile directly to javascript strings. The speed benefit of ruby symbols cannot be kept in javascript, so they are removed. Also, strings are **all** immutable - no `String#upcase!` for you!.
  25.  
  26. Limited operator overloading
  27. ----------------------------
  28.  
  29. Overloading operators is not efficient for the resulting js as simple math additions etc must be compiled into function calls which is obviously bad for DOM maths etc. For this reason all operators compile to their respective javascript counterparts which means they cannot be overridden. `===` is an exception which compiles into a regular ruby method call as its overrides are useful in case statements. Also, `[]` and `[]=` are also regular method calls as they are useful for `Array`, `Hash`
  30. as well as lots of other classes. They are an acceptable overhead. The full list of restricted operators are: `+`, `-`, `*`, `/`, `==`, `!=`, `<`, `>`, `<=`, `>=`, `!`, `+@` and `-@`. For now bit wise operators can still be overridden, but this is up for debate.
Add Comment
Please, Sign In to add comment