JavaScript Brendan Eich on Fixing String Methods on Emoji (2019)
.@BrendanEich can i ask you a js Q? all javascript string methods break when string contains emoji. is there plan to fix this? and how?
I understand workarounds. But the fact remain. All JavaScript string methods doesn't work when string contain emoji.
"๐".length===2"๐".padStart(2,"x")==="๐""๐".slice (0,1)!=="๐"
so no plan in ECMA to fix this?
it's really sad to hear, that #JavaScript has no plan to fix its broken string methods. Users need to write their own string methods or rely on libs, whenever string contain codepointโฅ2^16 I can't imagine it's gonna be forever. All modern lang don't have this problem.
the issue isn't just emoji. Any codepoint โฅ 2^16.
"๐ช".length===2
this is a practical problem. I thought we need
strict 2015;
but seems Brendan and ECMA is against such idea.
the point here is that, forever in the future, when a string contains a character whose codepoint โฅ 2^16, he cannot rely on any string methods. Has to write his own or use external lib. I do not see this as acceptable. But seems, that's what the industry is accepting.
meanwhile, the fancy industry coders talk about new features in JavaScript. Often, i truly, don't understand wtf these hackers are thinking.
someone asked why it's a practical problem. Don't you think a lot strings will contain codepoint beyond 2^16? e.g. twitter, facebook, or any website that allow posts/comments, will have to deal with emoji. So they can't rely on string methods. need to use ext lib or special attention to string.
Sure, such string is perhaps still less than 0.1% of strings. But on the whole, most software will encounter it. Also, programers have to know what's in his string. A high level lang such as JavaScript with this problem is really broken fundamentally.
i think the solution is really a new "use strict 2020".
But i recall asking Brendan, he or the js future team is agaist it for reasons i can't agree.
Reasons like โmaking things more complicatedโ.
i think the real reason is, corporate interests induced perspective.
if you are not sure what's going on in this thread, see JS: Character, Code Unit, Codepoint
String Problem in Java and C#
turns out, same problem happens in Java and C#.
/* package whatever; // don't place package name! */ import java.util.*; import java.lang.*; import java.io.*; /* Name of the class has to be "Main" only if the class is public. */ class Ideone { public static void main (String[] args) throws java.lang.Exception { System.out.println("๐".length() == 2); System.out.println(!"๐".substring(0,1).equals("๐")); } }
using System; public class Test { public static void Main() { Console.WriteLine("๐".Length == 2); Console.WriteLine("๐".Substring(0,1) != "๐"); } }
2019-04-29 thanks to https://x.com/tjcrowder for the Java and C# code.
JavaScript misc. Brendan Eich, etc.
- JavaScript History. Sharp Variable for Circular Reference (via Common Lisp Reader Macro Syntax)
- JavaScript Brendan Eich on Fixing String Methods on Emoji (2019)
- JavaScript. Why not create a directive โuse new jsโ to fix warts? (2019)
- Computer Science, Technical Writing. On Documentation of JavaScript Weakset
- JavaScript/DOM String Hell and Symbolic Languages
- JavaScript, Design Patterns Approach to Computer Language Tutorials (2013)
JavaScript history
- History of JavaScript, 1995 to 2025.
- The Ugly JavaScript. 2010 to 2026
- the History of JavaScript, by Brendan Eich. 2008
- HTML History Timeline. 1993 to 2011
- Netscape Browser Sucks (2002)
- JS: Version History. 1995 to 2025
- JavaScript history, prototype.js (2005 to 2010)
- JS: ECMAScript New Features. 2015 to 2026
- History of the HTML Script Tag (JavaScript) (2011)
- JavaScript History. Sharp Variable for Circular Reference (via Common Lisp Reader Macro Syntax)
- JavaScript the Good Parts, Douglas Crockford. 2008
- JavaScript The Definitive Guide by David Flanagan. 2011, 2020.
- History of Node.js by Ryan Dahl 2011 ๐บ
- Apache vs Node.js vs NGINX ๐บ. (2013 humor)
- History of Angular.js (2018)
- CoffeeScript or JavaScript (2011)
- TypeScript Will Kill CoffeeScript and Dart (2012)
- Microsoft Apple Mozilla Dismiss Dart (2011)
- Stackoverflow dolts on JavaScript Compiler ES2015 to ES5. (Babel.js) (2014)
- JavaScript Brendan Eich on Fixing String Methods on Emoji (2019)
- JavaScript. Why not create a directive โuse new jsโ to fix warts? (2019)
- JS: CommonJS Module System. 2009 to 2026
- JS: AMD Module System and history (2009 to 2016)
- npm Disease (2021)