Language Size (was Re: [TLUG]: ECMAScript ("Javascript") Version 4 -FALSE ALARM)

Lars Hansen lhansen at adobe.com
Wed Oct 31 03:43:11 PDT 2007


> -----Original Message-----
> From: es4-discuss-bounces at mozilla.org On Behalf Of Maciej Stachowiak
> Sent: 30. oktober 2007 21:23
> 
> By the way, I think the discussions about language size could 
> benefit from some quantitative data. I think the following 
> comparisons would be interesting:

...

> 2) Size of the ES4 standard library by count of classes, 
> methods and properties.

Below is a breakdown of classes (C), interfaces (I), types (T),
functions (F), methods (M), properties (P), variables/constants (V); *
means new in ES4, + means it replaces something else in ES3 (typically a
"primitive value").  "s" means "static", "p" means prototype.  Based on
current understanding; expect some minor adjustment over time.

Do not count lines uncritically.  Where ES3 had prototype methods, ES4
has intrinsic methods in addition and sometimes generic static methods
as well (Array, String, Function), but in almost all cases, only one of
the set has a nontrivial body and the others delegate to it.
Furthermore, many "String" methods delegate to "string" methods, and
there are shared prototypes (String and String; byte, int, uint, double,
decimal, and Number; boolean and Boolean).  As a consequence, the
footprint for the library is probably substantially smaller than it
would appear at first glance.  (Note also that [[Construct]] and
[[Call]] have new names but are not new.)

--lars


* V __ECMASCRIPT_OBJECT__                        [version number]
* V __ES4__                                      [reserved namespace
constant]
* V __ES4__::intrinsic                           [reserved namespace
constant]
* V __ES4__::meta                                [reserved namespace
constant]
* V __ES4__::reflect                             [reserved namespace
constant]

  C Object
  Ms  Object
  Ms  meta::invoke
  Vs  length
  Vs  prototype
  Mp  toString
  Mp  toLocaleString
* Mp  toJSONString
  Mp  hasOwnProperty
  Mp  isPrototypeOf
  Mp  propertyIsEnumerable
* M   intrinsic::toString
* M   intrinsic::toLocaleString
* M   intrinsic::toJSONString
* M   intrinsic::hasOwnProperty
* M   intrinsic::isPrototypeOf
* M   intrinsic::propertyIsEnumerable

  C Function
  Ms  Function
  Ms  meta::invoke
  Vs  length
  Vs  prototype
* Ms  apply
* Ms  call
  M   meta::invoke
  V   length
  V   prototype
  Mp  toString
  Mp  apply
  Mp  call
* M   intrinsic::toString
* M   intrinsic::apply
* M   intrinsic::call

* C __ES4__::GenericFunction                     [proposed, not fully
spec'd]

  C Array
  Ms  Array
  Ms  meta::invoke
  Vs  length
* Ms  concat
* Ms  every
* Ms  filter
* Ms  forEach
* Ms  indexOf
* Ms  join
* Ms  lastIndexOf
* Ms  map
* Ms  pop
* Ms  push
* Ms  reverse
* Ms  shift
* Ms  slice
* Ms  some
* Ms  sort
* Ms  splice
* Ms  unshift
  Mp  concat
  Mp  every
  Mp  filter
  Mp  forEach
  Mp  indexOf
  Mp  join
  Mp  lastIndexOf
  Mp  map
  Mp  pop
  Mp  push
  Mp  reverse
  Mp  shift
  Mp  slice
  Mp  some
  Mp  sort
  Mp  splice
  Mp  unshift
  M   get length
  M   set length
* M   intrinsic::concat
* M   intrinsic::every
* M   intrinsic::filter
* M   intrinsic::forEach
* M   intrinsic::indexOf
* M   intrinsic::join
* M   intrinsic::lastIndexOf
* M   intrinsic::map
* M   intrinsic::pop
* M   intrinsic::push
* M   intrinsic::reverse
* M   intrinsic::shift
* M   intrinsic::slice
* M   intrinsic::some
* M   intrinsic::sort
* M   intrinsic::splice
* M   intrinsic::unshift

  C String
  Ms  String
  Ms  meta::invoke
  Vs  length
  Ms  fromCharCode
* Ms  charAt
* Ms  charCodeAt
* Ms  concat
* Ms  indexOf
* Ms  lastIndexOf
* Ms  localeCompare
* Ms  match
* Ms  parseJSON
* Ms  replace
* Ms  search
* Ms  slice
* Ms  split
* Ms  substring
* Ms  toLowerCase
* Ms  toLocaleLowerCase
* Ms  toUpperCase
* Ms  toLocaleUpperCase
* Ms  trim
  Mp  charAt
  Mp  charCodeAt
  Mp  concat
  Mp  indexOf
  Mp  lastIndexOf
  Mp  localeCompare
  Mp  match
  Mp  parseJSON
  Mp  replace
  Mp  search
  Mp  slice
  Mp  split
  Mp  substring
  Mp  toLowerCase
  Mp  toLocaleLowerCase
  Mp  toUpperCase
  Mp  toLocaleUpperCase
  Mp  trim
  M   get length
* M   get
* M   intrinsic::charAt
* M   intrinsic::charCodeAt
* M   intrinsic::concat
* M   intrinsic::indexOf
* M   intrinsic::lastIndexOf
* M   intrinsic::localeCompare
* M   intrinsic::match
* M   intrinsic::parseJSON
* M   intrinsic::replace
* M   intrinsic::search
* M   intrinsic::slice
* M   intrinsic::split
* M   intrinsic::substring
* M   intrinsic::toLowerCase
* M   intrinsic::toLocaleLowerCase
* M   intrinsic::toUpperCase
* M   intrinsic::toLocaleUpperCase
* M   intrinsic::trim

+ C __ES4__::string
* Ms  string
* Ms  meta::invoke
* Vs  length
* Ms  fromCharCode
* Ms  charAt
* Ms  charCodeAt
* Ms  concat
* Ms  indexOf
* Ms  lastIndexOf
* Ms  localeCompare
* Ms  match
* Ms  parseJSON
* Ms  replace
* Ms  search
* Ms  slice
* Ms  split
* Ms  substring
* Ms  toLowerCase
* Ms  toLocaleLowerCase
* Ms  toUpperCase
* Ms  toLocaleUpperCase
* Ms  trim
* M   get length
* M   get
* M   intrinsic::charAt
* M   intrinsic::charCodeAt
* M   intrinsic::concat
* M   intrinsic::indexOf
* M   intrinsic::lastIndexOf
* M   intrinsic::localeCompare
* M   intrinsic::match
* M   intrinsic::parseJSON
* M   intrinsic::replace
* M   intrinsic::search
* M   intrinsic::slice
* M   intrinsic::split
* M   intrinsic::substring
* M   intrinsic::toLowerCase
* M   intrinsic::toLocaleLowerCase
* M   intrinsic::toUpperCase
* M   intrinsic::toLocaleUpperCase
* M   intrinsic::trim

  C Boolean
  Ms  Boolean
  Ms  meta::invoke
  Vs  length
  Mp  toString
* Mp  toJSONString
  Mp  valueOf
* M   intrinsic::toString
* M   intrinsic::toJSONString
* M   intrinsic::valueOf

+ C __ES4__::boolean
* Ms  boolean
* Ms  meta::invoke
* Vs  length
* M   intrinsic::toString
* M   intrinsic::toJSONString
* M   intrinsic::valueOf

  C Number
  Ms  Number
  Ms  meta::invoke
  Vs  length
  Vs  MAX_VALUE
  Vs  MIN_VALUE
  Vs  NaN
  Vs  NEGATIVE_INFINITY
  Vs  POSITIVE_INFINITY
  Mp  toString
  Mp  toLocaleString
* Mp  toJSONString
  Mp  valueOf
  Mp  toFixed
  Mp  toExponential
  Mp  toPrecision
  M   intrinsic::toString
  M   intrinsic::toLocaleString
* M   intrinsic::toJSONString
  M   intrinsic::valueOf
  M   intrinsic::toFixed
  M   intrinsic::toExponential
  M   intrinsic::toPrecision

* C __ES4__::byte
  Ms  meta::invoke
  Vs  length
  Vs  MAX_VALUE
  Vs  MIN_VALUE

* C __ES4__::int
* Ms  int
* Ms  meta::invoke
* Vs  length
* Vs  MAX_VALUE
* Vs  MIN_VALUE
* M   intrinsic::toString
* M   intrinsic::toLocaleString
* M   intrinsic::toJSONString
* M   intrinsic::valueOf
* M   intrinsic::toFixed
* M   intrinsic::toExponential
* M   intrinsic::toPrecision

* C __ES4__::uint
* Ms  uint
* Ms  meta::invoke
* Vs  length
* Vs  MAX_VALUE
* Vs  MIN_VALUE
* M   intrinsic::toString
* M   intrinsic::toLocaleString
* M   intrinsic::toJSONString
* M   intrinsic::valueOf
* M   intrinsic::toFixed
* M   intrinsic::toExponential
* M   intrinsic::toPrecision

+ C __ES4__::double
* Ms  double
* Ms  meta::invoke
* Vs  length
* Vs  MAX_VALUE
* Vs  MIN_VALUE
* Vs  NaN
* Vs  NEGATIVE_INFINITY
* Vs  POSITIVE_INFINITY
* Vs  E
* Vs  LN10
* Vs  LN2
* Vs  LOG2E
* Vs  LOG10E
* Vs  PI
* Vs  SQRT1_2
* Vs  SQRT2
* M   intrinsic::toString
* M   intrinsic::toLocaleString
* M   intrinsic::toJSONString
* M   intrinsic::valueOf
* M   intrinsic::toFixed
* M   intrinsic::toExponential
* M   intrinsic::toPrecision

* C __ES4__::decimal
* Ms  int
* Ms  meta::invoke
* Vs  length
* Vs  MAX_VALUE
* Vs  MIN_VALUE
* Vs  NaN
* Vs  NEGATIVE_INFINITY
* Vs  POSITIVE_INFINITY
* Vs  E
* Vs  LN10
* Vs  LN2
* Vs  LOG2E
* Vs  LOG10E
* Vs  PI
* Vs  SQRT1_2
* Vs  SQRT2
* M   intrinsic::toString
* M   intrinsic::toLocaleString
* M   intrinsic::toJSONString
* M   intrinsic::valueOf
* M   intrinsic::toFixed
* M   intrinsic::toExponential
* M   intrinsic::toPrecision

  C Date
  Ms  Date
  Ms  meta::invoke
* Ms  intrinsic::parse
* Ms  intrinsic::UTC
  Ms  now
  Vs  parse
  Vs  UTC
  Vs  length
  Mp  toString
  Mp  toDateString
  Mp  toTimeString
  Mp  toLocaleString
  Mp  toLocaleDateString
  Mp  toLocaleTimeString
  Mp  toUTCString
* Mp  toISOString
* Mp  toJSONString
  Mp  valueOf
  Mp  nanoAge
  Mp  getTime
  Mp  getFullYear
  Mp  getUTCFullYear
  Mp  getMonth
  Mp  getUTCMonth
  Mp  getDate
  Mp  getUTCDate
  Mp  getDay
  Mp  getUTCDay
  Mp  getHours
  Mp  getUTCHours
  Mp  getMinutes
  Mp  getUTCMinutes
  Mp  getSeconds
  Mp  getUTCSeconds
  Mp  getMilliseconds
  Mp  getUTCMilliseconds
  Mp  getTimezoneOffset
  Mp  setTime
  Mp  setMilliseconds
  Mp  setUTCMilliseconds
  Mp  setSeconds
  Mp  setUTCSeconds
  Mp  setMinutes
  Mp  setUTCMinutes
  Mp  setHours
  Mp  setUTCHours
  Mp  setDate
  Mp  setUTCDate
  Mp  setMonth
  Mp  setUTCMonth
  Mp  setFullYear
  Mp  setUTCFullYear
* M   intrinsic::nanoAge
* M   intrinsic::toString
* M   intrinsic::toDateString
* M   intrinsic::toTimeString
* M   intrinsic::toLocaleString
* M   intrinsic::toLocaleDateString
* M   intrinsic::toLocaleTimeString
* M   intrinsic::toUTCString
* M   intrinsic::toISOString
* M   intrinsic::toJSONString
* M   intrinsic::valueOf
* M   intrinsic::getTime
* M   intrinsic::getFullYear
* M   intrinsic::getUTCFullYear
* M   intrinsic::getMonth
* M   intrinsic::getUTCMonth
* M   intrinsic::getDate
* M   intrinsic::getUTCDate
* M   intrinsic::getDay
* M   intrinsic::getUTCDay
* M   intrinsic::getHours
* M   intrinsic::getUTCHours
* M   intrinsic::getMinutes
* M   intrinsic::getUTCMinutes
* M   intrinsic::getSeconds
* M   intrinsic::getUTCSeconds
* M   intrinsic::getMilliseconds
* M   intrinsic::getUTCMilliseconds
* M   intrinsic::getTimezoneOffset
* M   intrinsic::setTime
* M   intrinsic::setMilliseconds
* M   intrinsic::setUTCMilliseconds
* M   intrinsic::setSeconds
* M   intrinsic::setUTCSeconds
* M   intrinsic::setMinutes
* M   intrinsic::setUTCMinutes
* M   intrinsic::setHours
* M   intrinsic::setUTCHours
* M   intrinsic::setDate
* M   intrinsic::setUTCDate
* M   intrinsic::setMonth
* M   intrinsic::setUTCMonth
* M   intrinsic::setFullYear
* M   intrinsic::setUTCFullYear
* M   get time
* M   get year
* M   get month
* M   get UTCMonth
* M   get date
* M   get UTCDate
* M   get day
* M   get UTCDay
* M   get hours
* M   get UTCHours
* M   get minutes
* M   get UTCMinutes
* M   get seconds
* M   get UTCSeconds
* M   get milliseconds
* M   get UTCMilliseconds
* M   set time
* M   set year
* M   set fullYear
* M   set UTCFullYear
* M   set month
* M   set UTCMonth
* M   set date
* M   set UTCDate
* M   set hours
* M   set UTCHours
* M   set minutes
* M   set UTCMinutes
* M   set seconds
* M   set UTCSeconds
* M   set milliseconds
* M   set UTCMilliseconds

  C RegExp
  Ms  RegExp
  Ms  meta::invoke
  Vs  length
  Mp  toString
  Mp  exec
  Mp  test
* M   meta::invoke
* M   intrinsic::toString
* M   intrinsic::exec
* M   intrinsic::test
  V   source
  V   global
  V   ignoreCase
  V   multiline
* V   extended
* V   sticky
  V   lastIndex

  C Error
  Ms  Error
  Ms  meta::invoke
  Vs  length
  V   name
  V   message

  C EvalError extends Error
  Ms  EvalError
  Ms  meta::invoke
  Vs  length

  C RangeError extends Error
  Ms  RangeError
  Ms  meta::invoke
  Vs  length

  C ReferenceError extends Error
  Ms  ReferenceError
  Ms  meta::invoke
  Vs  length

  C SyntaxError extends Error
  Ms  SyntaxError
  Ms  meta::invoke
  Vs  length

  C TypeError extends Error
  Ms  TypeError
  Ms  meta::invoke
  Vs  length

  C URIError extends Error
  Ms  URIError
  Ms  meta::invoke
  Vs  length

* C __ES4__::EncodingError extends Error         [for JSON]
* Ms  EncodingError
* Ms  meta::invoke
* Vs  length

* C __ES4__::Name
* Ms  Name
* Ms  meta::invoke
* Mp  toString
* Mp  valueOf
* M   intrinsic::toString
* M   intrinsic::ValueOf
* V   qualifier
* V   identifier

* C __ES4__::Namespace
* Mp  toString
* M   intrinsic::toString

* C __ES4__::NamespaceSet                        [TBD -- small class]

* C __ES4__::NamespaceSetList                    [TBD -- small class]

* C __ES4__::Map.<K,V>
* Ms  Map
* M   intrinsic::size
* M   intrinsic::get
* M   intrinsic::put
* M   intrinsic::has
* M   intrinsic::remove
* Mp  size
* Mp  get
* Mp  put
* M   phas
* Mp  remove
* M   iterator::get
* M   iterator::getKeys
* M   iterator::getValues
* M   iterator::getItems

* C __ES4__::Vector.<T>
* Ms  Vector
* Ms  meta::invoke
* Vs  length
* Mp  concat
* Mp  every
* Mp  filter
* Mp  forEach
* Mp  indexOf
* Mp  join
* Mp  lastIndexOf
* Mp  map
* Mp  pop
* Mp  push
* Mp  reverse
* Mp  shift
* Mp  slice
* Mp  some
* Mp  sort
* Mp  splice
* Mp  unshift
* M   get length
* M   set length
* V   fixed
* M   meta::get
* M   meta::set
* M   intrinsic::concat
* M   intrinsic::every
* M   intrinsic::filter
* M   intrinsic::forEach
* M   intrinsic::indexOf
* M   intrinsic::join
* M   intrinsic::lastIndexOf
* M   intrinsic::map
* M   intrinsic::pop
* M   intrinsic::push
* M   intrinsic::reverse
* M   intrinsic::shift
* M   intrinsic::slice
* M   intrinsic::some
* M   intrinsic::sort
* M   intrinsic::splice
* M   intrinsic::unshift
* M   iterator::get
* M   iterator::getKeys
* M   iterator::getValues
* M   iterator::getItems

* C intrinsic::ControlInspector.<T>              [may end up in
reflect::]
* Ms  ControlInspector
* M   annotate
* M   getCurrentAnnotation
* M   getAnnotation

* T __ES4__::AnyNumber

* T __ES4__::AnyString

* T __ES4__::AnyBoolean

* T __ES4__::EnumerableId

* I reflect::Type
* M   canConvertTo
* M   isSubtypeOf

* I reflect::NominalType
* M   name
* M   superTypes
* M   [a few more here, TBD]

* I reflect::InterfaceType
* M   implementedBy

* I reflect::ClassType
* M   construct

* I reflect::AnyType

* I reflect::NullType

* I reflect::UndefinedType

* I reflect::UnionType
* M   fields
* M   members

* I reflect::RecordType
* M   construct

* I reflect::FunctionType
* M   boundThid
* M   argTypes
* M   defaultValues
* M   hasRestType
* M   returnType

* I reflect::ArrayType
* M   fields
* M   members

* I reflect::ParameterizedType

* I reflect::Field
* M   name
* M   type

* I reflect::FieldValue
* M   name
* M   value

  F eval
  F parseInt
  F parseFloat
  F isNaN
  F isFinite
  F decodeURI
  F decodeURIComponent
  F encodeURI
  F encodeURIComponent

  V Math
  V   E
  V   LN10
  V   LN2
  V   LOG2E
  V   LOG10E
  V   PI
  V   SQRT1_2
  V   SQRT2
  M   acos
  M   atan
  M   atan2
  M   ceil
  M   cos
  M   exp
  M   floor
  M   log
  M   max
  M   min
  M   pow
  M   random
  M   round
  M   sin
  M   sqrt
  M   tan
* M   intrinsic::acos
* M   intrinsic::atan
* M   intrinsic::atan2
* M   intrinsic::ceil
* M   intrinsic::cos
* M   intrinsic::exp
* M   intrinsic::floor
* M   intrinsic::log
* M   intrinsic::max
* M   intrinsic::min
* M   intrinsic::pow
* M   intrinsic::random
* M   intrinsic::round
* M   intrinsic::sin
* M   intrinsic::sqrt
* M   intrinsic::tan

  V NaN
  V Infinity
  V undefined
* F intrinsic::eval
* F intrinsic::parseInt
* F intrinsic::parseFloat
* F intrinsic::isNaN
* F intrinsic::isFinite
* F intrinsic::decodeURI
* F intrinsic::decodeURIComponent
* F intrinsic::encodeURI
* F intrinsic::encodeURIComponent
* V intrinsic::global
* F reflect::typeOf


> 
> I am willing to run the number on these if someone can help 
> me find the grammar and some sort of standard library index 
> in the spec.
> 
> Regards,
> Maciej
> 
> _______________________________________________
> Es4-discuss mailing list
> Es4-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es4-discuss
> 



More information about the Es4-discuss mailing list