<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/css" href="http://wiki.apidesign.org/skins/common/feed.css?116"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
	<channel>
		<title>Builtins - Revision history</title>
		<link>http://wiki.apidesign.org/index.php?title=Builtins&amp;action=history</link>
		<description>Revision history for this page on the wiki</description>
		<language>en</language>
		<generator>MediaWiki 1.12.0rc1</generator>
		<lastBuildDate>Tue, 26 May 2026 02:21:04 GMT</lastBuildDate>
		<item>
			<title>JaroslavTulach: New page: When writing a language like JavaScript or Enso one necessarily ends up writing builtins - basic language operations that cannot be expressed in the language itself...</title>
			<link>http://wiki.apidesign.org/index.php?title=Builtins&amp;diff=10692&amp;oldid=prev</link>
			<description>&lt;p&gt;New page: When writing a &lt;a href=&quot;/wiki/Language&quot; title=&quot;Language&quot;&gt;language&lt;/a&gt; like &lt;a href=&quot;/wiki/JavaScript&quot; title=&quot;JavaScript&quot;&gt;JavaScript&lt;/a&gt; or &lt;a href=&quot;/wiki/Enso&quot; title=&quot;Enso&quot;&gt;Enso&lt;/a&gt; one necessarily ends up writing &lt;a href=&quot;/wiki/Builtins&quot; title=&quot;Builtins&quot;&gt;builtins&lt;/a&gt; - basic &lt;a href=&quot;/wiki/Language&quot; title=&quot;Language&quot;&gt;language&lt;/a&gt; operations that cannot be expressed in the &lt;a href=&quot;/wiki/Language&quot; title=&quot;Language&quot;&gt;language&lt;/a&gt; itself...&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;When writing a [[language]] like [[JavaScript]] or [[Enso]] one necessarily ends up writing [[builtins]] - basic [[language]] operations that cannot be expressed in the [[language]] itself, but need to be built into the interpreter/compiler of the [[language]]. &lt;br /&gt;
&lt;br /&gt;
== Granularity ==&lt;br /&gt;
&lt;br /&gt;
All languages have concept of [[builtins]], however the different is the '''granularity'''. &lt;br /&gt;
In general the [[builtins]] internals should ''not be visible'' in the stack trace. &lt;br /&gt;
Not only it makes the stack traces needlessly long, &lt;br /&gt;
but it also complicates [[debugging]] as one has to step thru all these ''builtin levels''.&lt;br /&gt;
&lt;br /&gt;
For example [[Java]] and [[JavaScript]] do the same thing quite differently. In [[JavaScript]] all the [[builtins]] are written in other language than [[JavaScript]]. As such the ''stacktraces are sane'':&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12].filter (x =&amp;gt; { &lt;br /&gt;
  if (x == 5) throw &amp;quot;Error:&amp;quot;+x; &lt;br /&gt;
})&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
yields (when executed by [[GraalVM]].js, but also any other engine):&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ graalvm-17/bin/js f.js &lt;br /&gt;
Error:5&lt;br /&gt;
        at &amp;lt;js&amp;gt; :=&amp;gt;(f.js:2:70-77)&lt;br /&gt;
        at &amp;lt;js&amp;gt; :program(f.js:1-3:0-81)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
However compare the same example written in [[Java]]:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
class F {&lt;br /&gt;
  public static void main(String... args) {&lt;br /&gt;
    java.util.List.of(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12).stream().filter(x -&amp;gt; {&lt;br /&gt;
      if (x == 5) throw new RuntimeException(&amp;quot;Error:&amp;quot; + x);&lt;br /&gt;
      return true;&lt;br /&gt;
    }).toList();&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
and such an example yields:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ graalvm-17/bin/java F.java&lt;br /&gt;
Exception in thread &amp;quot;main&amp;quot; java.lang.RuntimeException: Error:5&lt;br /&gt;
        at F.lambda$main$0(F.java:4)&lt;br /&gt;
        at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:178)&lt;br /&gt;
        at java.base/java.util.AbstractList$RandomAccessSpliterator.forEachRemaining(AbstractList.java:720)&lt;br /&gt;
        at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)&lt;br /&gt;
        at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)&lt;br /&gt;
        at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:575)&lt;br /&gt;
        at java.base/java.util.stream.AbstractPipeline.evaluateToArrayNode(AbstractPipeline.java:260)&lt;br /&gt;
        at java.base/java.util.stream.ReferencePipeline.toArray(ReferencePipeline.java:616)&lt;br /&gt;
        at java.base/java.util.stream.ReferencePipeline.toArray(ReferencePipeline.java:622)&lt;br /&gt;
        at java.base/java.util.stream.ReferencePipeline.toList(ReferencePipeline.java:627)&lt;br /&gt;
        at F.main(F.java:6)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Eleven stacktraces lines instead of two! A lot of boiler plate output instead of two important lines that matter. Who cares there is some ''AbstractPipeline''? Or ''ReferencePipeline''? &lt;br /&gt;
&lt;br /&gt;
Moreover everything gets really complicated when it comes to [[debugging]]. In [[Java]] the debugger has to step thru all these intermediate stacktraces. That's not the case of [[JavaScript]] - in [[JavaScript]] the ''Step Next'' action goes directly from main code to the body of the lambda function and back. [[JVM]]'s decision to implement basic operations like ''filter'' in [[Java]] itself and not as builtin complicates this all. Some [[IDE]]s are even sad to had to design a special ''stream debugger'' exactly for these purposes.&lt;br /&gt;
&lt;br /&gt;
==== Implications for [[Enso]] Language Designers ====&lt;br /&gt;
&lt;br /&gt;
Thus, when designing [[Enso]] we should ask: Do we want [[Enso]] to be like [[JavaScript]] or like [[Java]]?&lt;/div&gt;</description>
			<pubDate>Fri, 10 Jan 2025 10:34:09 GMT</pubDate>			<dc:creator>JaroslavTulach</dc:creator>			<comments>http://wiki.apidesign.org/wiki/Talk:Builtins</comments>		</item>
	</channel>
</rss>