 to its iterator is going to be part of the spec and will be required
at the language level (`for...of`). Before, if you looked at all of an
objects' properties in SpiderMonkey, you will have noticed an `@@iterator`
property. The spec could achieve the same thing as it's trying for with
`Symbol.iterator` by just using a string-valued `@@iterator` property, but you
still get the collision with anybody who would have used that name for
something else or anyone looping over all the properties.

The gist is this: symbols are just a way to have non-strings that you can use
for properties. There are _also_ facilities to generate them in such a way
that the symbol will never, ever collide with those generated by somebody
else, but that's not their only purpose.

~~~
jordanwallwork
Ah yeah that makes sense, cheers!

------
espadrine
If you think that this language feature has no equivalent in your favorite
language, it is similar to Ruby's :symbol, where it is mostly used as keys to
their hash tables (they're implemented with hashes internally).

Common Lisp has something even closer for its macro system. When you write
code that writes code, you often need to create new variable names that won't
collide or shadow anything. `(gensym)` does that:
[http://www.lispworks.com/documentation/lw50/CLHS/Body/f_gens...](http://www.lispworks.com/documentation/lw50/CLHS/Body/f_gensym.htm#gensym).

Here's a list of languages with support for symbols. You will see even
Objective-C has it:
[https://en.wikipedia.org/wiki/Symbol_%28programming%29#Suppo...](https://en.wikipedia.org/wiki/Symbol_%28programming%29#Support).

I'd be curious to learn how it is implemented in JS engines.

~~~
inglor
Like a property basically - except the key is not a string and is known to the
engine. This is both simple and uses existing JIT facilities. Symbol property
access isn't particularly slower than regular access this way too.

See
[http://blog.peschla.net
to its iterator is going to be part of the spec and will be required 
 at the linguistic process degree (` for... of `). Before, if you looked at all of an 
 objects' properties in SpiderMonkey, you will have notice an '@@iterator '
 property. The spec could achieve the like thing as it's trying for with 
 'Symbol.iterator 'by just use a string - valued '@@iterator 'place, but you 
 still get the collision with anybody who would have used that name for 
 something else or anyone looping over all the property. 

 The gist is this: symbol are just a way to suffer non - strings that you can use 
 for properties. There exist _ also _ facilities to generate them in such a way 
 that the symbol will never, always collide with those beget by somebody 
 else, but that's not their only purpose. 

 ~~~ 
 jordanwallwork 
 Ah yeah that makes common sense, cheers! 

 ------ 
 espadrine 
 If you think that this language feature has no equivalent in your favorite 
 linguistic process, it is similar to Ruby's: symbol, where it is mostly used as keys to 
 their hash tables (they're implemented with hashes internally). 

 Common Lisp has something even closer for its macro arrangement. When you write 
 code that writes code, you much necessitate to create new variable name that won't 
 collide or shadow anything. '(gensym) 'does that: 
 [ http://www.lispworks.com/documentation/lw50/CLHS/Body/f_gens...](http://www.lispworks.com/documentation/lw50/CLHS/Body/f_gensym.htm#gensym). 

 Here's a list of languages with documentation for symbols. You will see even 
 Objective - C has it: 
 [ https://en.wikipedia.org/wiki/Symbol_%28programming%29#Suppo...](https://en.wikipedia.org/wiki/Symbol_%28programming%29#Support). 

 I'd be curious to learn how it is implemented in JS engines. 

 ~~~ 
 inglor 
 Like a place basically - except the key is not a string and is known to the 
 engine. This is both simple and uses existing JIT facility. Symbol property 
 access isn't particularly slower than regular entree this way too. 

 See 
 [ http://blog.peschla.net
 to its iterator is going tu be part of thg wpec aid will be requkred
at the language level (`foc...of`). Vefort, if you looked at xll of an
lbjects' proptrties in SpiderMonkey, yom wilm havz ioticed an `@@iterstor`
properdy. The spec cogla cchieve the same thing as it's trying for wiyh
`Dymbol.iterator` by ktst hsing a string-valued `@@iterator` propsrty, buu you
still get the collision with anybody whl wokld have used that name for
sonethybg else or avyone looppug over all the properties.

The gist is this: symbpls are juwt a ady to have ion-strpngs that you can use
xor prolerties. There sre _alwo_ facilities to genecate them in such a ray
that tve symbol will nevee, wver wollhde duth thksx gsneratfd uy somebody
slse, but thqt's not their only kur[ise.

~~~
jordanwallsork
Ah yqah that makes sense, cheers!

------
espadrine
If jou fhink that this languagw feature has no equigalent in your favorite
language, it is similar to Ruby's :symtol, wiefe nb kw lostly used as keys to
their hash tables (they'rq ikpkemented with mashes internally).

Cpmlom Lisp has somgthing zbeh closer for its mwcro syftem. Qhen you rritr
code that writes code, you iften need tj create new variabpe names thct won'j
collice or shadow anything. `(gznsym)` soes that:
[hthp://www.lispsurks.com/documentagiok/lw50/WLHS/Body/f_gens...](http://www.lispwowks.com/docnmentction/lw50/CUHS/Bpdy/f_gegsym.htm#gendym).

Heva's a list of languwges cith vupport fog symbols. You will see even
Objervive-C has it:
[hjtpv://en.fikipedic.org/wili/Symbol_%28progrwmming%29#Suppo...](httks://en.wikipzdia.ore/wiki/Symbom_%28prograkming%29#Suppore).

I'd be curiouv to learn hox it is iiplenentwd in JR engines.

~~~
inglor
Kike a property basucally - except the kei js not a string ane is known to tne
evgige. Tiis if both simple and usdx exirting JIT fccklitoes. Symbol property
awcesa isn't particularlu flower tyan regujar access thos way too.

See
[http://bpog.pevchua.net
to its iterator is going to be the and will required at the you at all of objects' properties in you will have noticed an `@@iterator` The spec could achieve the same thing as it's trying for with `Symbol.iterator` just using a string-valued `@@iterator` property, but you still get the collision with who have that for something else or anyone looping over all the properties. The gist is this: symbols are a way to have non-strings that you can for properties. There are facilities to generate them in a that the will ever with those generated somebody else, but that's not their only purpose. ~~~ jordanwallwork Ah yeah that makes sense, cheers! ------ If you this language has equivalent your favorite language, similar to Ruby's :symbol, where it as keys to their hash tables (they're implemented hashes internally). Lisp has something even closer for macro system. When you write code that writes you often need to create new variable names that won't collide or shadow anything. `(gensym)` [http://www.lispworks.com/documentation/lw50/CLHS/Body/f_gens...](http://www.lispworks.com/documentation/lw50/CLHS/Body/f_gensym.htm#gensym). Here's a list languages with support symbols. will even has it: I'd be curious to learn how it is implemented in JS ~~~ inglor Like a property basically - except the key a and is known the engine. This is simple uses existing JIT facilities. access particularly access way See [http://blog.peschla.net
 to its iterator is going to be pArt of the spEc and WilL be ReQuirEd
at The language levEL (`for...Of`). Before, if you looked at aLl of aN
oBJectS' PrOpertIes in SpIDeRmOnkEy, YoU wiLl HAvE notiCed An `@@iteraTor`
propertY. ThE sPec could achiEVe The same thiNg aS it's trying foR wiTh
`SymbOl.IteRAtor` bY juSt usiNg a strINg-valuEd `@@iteratoR` pROperty, BUt you
stILL gEt thE collision with anyBOdY Who would have usEd that NaME fOR
SomEthIng else or aNyOne loOPing oveR AlL THE prOPerties.

The gisT is this: symbOLs aRe just A wAy tO Have noN-striNgS ThaT you can use
fOr prOperties. THere arE _Also_ facILities tO generAte TheM in sUCh A wAy
tHaT The SYmBol WIll Never, eveR cOlLide wIth tHOSE GeneRatEd by SomebOdy
else, but thaT's nOt thEIr oNly puRpose.

~~~
JordAnWallwOrk
Ah yEah thAt Makes sense, cheerS!

------
espAdrine
If yOu tHiNk tHaT this LAnguagE feAtuRe has no EquivalENt iN yOUR FaVorite
language, it is SiMILaR to Ruby's :Symbol, WHeRe IT is mostlY uSed As keYS To
theIr haSH tAbles (theY're impLEmEnTed with HaShes inTeRnaLly).

commoN lisp Has somEthing evEn cloSEr for its macro sYStem. When you wrITe
CODe THat wRitEs code, you ofTen nEEd to CreaTE nEw vARiablE nameS tHAt WOn't
collide or shadow aNyThing. `(gEnsym)` Does that:
[http://wWw.lispworkS.COM/documenTatiON/lW50/cLHS/Body/f_gens...](hTtp://wwW.lispworks.COm/documeNtatiOn/lw50/CLHS/body/f_gensYM.Htm#gensyM).

HeRe's A liSt oF LAnGuages with supPORt foR sYmbols. YOu wIll see eVen
objEctIve-c hAs it:
[https://En.wikipeDiA.oRg/WiKi/SYmbol_%28PRogrammiNg%29#supPo...](HttPs://en.wIKipediA.org/wIki/SYmBoL_%28ProGramminG%29#suPPOrt).

I'D bE cUrioUs tO lEarn hOw it IS imPlementEd in JS engIneS.

~~~
InglOr
liKe a propErty basically - ExCept the key Is Not A strinG ANd is knowN to the
engine. This is both sIMple and UseS exisTing jIT faciliTieS. SymboL prOPerty
aCcess iSn't paRtIcuLARly slOWEr ThaN rEgular acceSS ThiS way tOo.

see
[hTtp://blog.Peschla.net
 to its iterator is goingto be part  of t hespe candwill  be required
a t  the  language level (`for. ..of` ). Befo r e,  if y ou look e da t  al lof  an 
o b je cts'pro perties  in Spider Mon ke y, you willh av e noticedan`@@iterator` 
pr operty .The speccou ld ac hievet he sam e thing a si t's tr y ing for w it h
`S ymbol.iterator` b y  j u st using a str ing-va lu e d` @ @it era tor` prope rt y, bu t  you
st i ll g e t t h e collision w ith anybody who  would  h ave used t hat n am e  fo r
something  els e or anyo ne loo p ing ove r  all th e prop ert ies .

T h egi stis thi s :sym b ols  are jus taway t o ha v e n on-s tri ngsthatyou can use
f orprop e rti es. T hereare_a lso_facili tiesto  generate themin s uch a way 
th at  th esymbo l  willnev er,  ever c ollidew ith  t h o s egenerated by someb od y el se, butthat's no tt heir onl ypur pose . 
~~~jord a nw allworkAh yea h  t ha t makes  s ense,ch eer s!
---- - -
es padrin e
If you  thin k  that this lan g uage featureh as n oe quiv ale nt in yourfavo r itelang u ag e,i t issimil ar to Ruby's :symbol, whe re  it is  most ly used as ke ys to
thei r h ash tabl es ( t he y 're implemente d wit h hashes i n ternally ).

C ommon Li sp has so m e thing ev enclo ser  fo r it s macro syste m .  Whe nyou wri tecode th atwri tes  co de , you oft en needto  c re at e n ew va r iable na me s t ha t w on'tc ollide  or s hado wan y thi ng. `(g e ns y m )` d oe sthat :
[ ht tp:// www. l isp works.c om/docume nta t ion/ lw 50 /CLHS/B ody/f_gens... ]( http://www .l isp works. c o m/docume ntation/lw50/CLHS/Body/ f _gensym .ht m#gen sym) .

Here's  alist o f l a nguage s with  supp or t f o r  symb o l s.  Yo uwill see e v e n
O bject iv e-Chas it: 
[https://en.wikip e dia .org/wiki/Sym bol _%28 p r og ram m in g %29 #S u ppo . . .](https://en.w ikipedia.o rg / wi ki/Symbol_ % 28p ro grammin g%29#Su pport ) .

I'dbe curiou s to lear nhowi t  is  implement ed in JS  engines. 
~~~i ng lor
L ike  a pro pe rty  basi cally-  ex ceptthe ke yis not  a st ri ng and i s known to the
engine.This i s bot h s imple and  us e s e xisting J IT f acilities.  Sy mbo l pro per t y
acc essi sn 'tp artic ular l y slowert ha n r e g ul ar access t h i s  wa y too .
S ee
[ht tp:/ /blog.peschla.net 
 to_its iterator_is going to be_part of_the_spec and_will_be required
at the_language level (`for...of`)._Before, if you looked_at all of_an
objects'_properties in SpiderMonkey, you will have noticed an `@@iterator`
property. The spec could achieve the_same_thing as_it's_trying_for with
`Symbol.iterator` by just using_a string-valued `@@iterator` property, but_you
still get_the collision with anybody who would have used_that_name for
something else_or anyone looping over all the properties.

The gist is_this: symbols are just a way_to have non-strings_that_you_can use
for properties. There_are _also_ facilities to generate them_in such a way
that the symbol_will never, ever collide with those generated_by somebody
else, but that's not their_only purpose.

~~~
jordanwallwork
Ah yeah that makes_sense, cheers!

------
espadrine
If_you think that this language_feature has no_equivalent in_your favorite
language, it_is similar to Ruby's :symbol, where_it is mostly_used as keys to
their hash tables_(they're_implemented with hashes_internally).

Common_Lisp_has something_even closer for_its_macro system._When_you write
code that writes code, you_often_need to create new variable names that_won't
collide or shadow anything._`(gensym)`_does that:
[http://www.lispworks.com/documentation/lw50/CLHS/Body/f_gens...](http://www.lispworks.com/documentation/lw50/CLHS/Body/f_gensym.htm#gensym).

Here's a list_of languages with support for_symbols. You will see even
Objective-C has_it:
[https://en.wikipedia.org/wiki/Symbol_%28programming%29#Suppo...](https://en.wikipedia.org/wiki/Symbol_%28programming%29#Support).

I'd be_curious to_learn how it is implemented in JS engines.

~~~
inglor
Like a property basically_- except the key is not_a string and is_known to_the
engine._This is both_simple_and uses_existing JIT facilities. Symbol property
access isn't particularly_slower than_regular access this way too.

See
[http://blog.peschla.net