<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Eqela - Medium]]></title>
        <description><![CDATA[Develop The Impossible - Medium]]></description>
        <link>https://medium.com/eqela?source=rss----4bc1059d788f---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Eqela - Medium</title>
            <link>https://medium.com/eqela?source=rss----4bc1059d788f---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 05:59:02 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/eqela" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Write less code: Try the trycatch keyword]]></title>
            <link>https://medium.com/eqela/write-less-code-try-the-trycatch-keyword-b73e275a25e5?source=rss----4bc1059d788f---4</link>
            <guid isPermaLink="false">https://medium.com/p/b73e275a25e5</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[sling]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[csharp]]></category>
            <dc:creator><![CDATA[Markku Kero]]></dc:creator>
            <pubDate>Thu, 10 May 2018 18:07:18 GMT</pubDate>
            <atom:updated>2018-05-10T18:07:18.461Z</atom:updated>
            <content:encoded><![CDATA[<p>One of the main objectives of <a href="http://eqdn.tech/sling/">the Sling language</a> has always been to try and make life simpler and to reduce the need for typing, and to reduce the overall amount of source code needed to do something. And one of the <em>most annoying</em> repetitive things that I personally as a programmer have spent a lot of time and keystrokes on, is the try-catch statement. You know, it’s the classic, you want to read a file (nothing complicated, no big deal)..</p><pre>data = Files.readAllBytes(path);</pre><p>And as all Java programmers already know, if you try that, a great disappointment will follow…</p><pre>error: unreported exception IOException; must be caught or declared to be thrown</pre><p>So from what was just a simple line of code, you’ll now have to take a deep breath and start typing. You’ll work your way towards this monster..</p><pre>try {<br>    data = Files.readAllBytes(path);<br>}<br>catch(Exception e) {<br>    e.printStackTrace();<br>}</pre><p>(And this monster is already greatly simplified by using “Exception” instead of “IOException” and then adding yet more lines of code in a different place in the file to import the IOException..)</p><p>So from what was a simple one-liner, the programming language here forced us to turn it into a 6-liner with three times the amount of typing. And of course this is not a one-time incident. Over the lifespan of a programmer, one will do this countless times, over and over each day. Obviously from time to time you get tired and “lazy” and don’t want to type that printStackTrace because “that wouldn’t happen anyway”, and over time important errors go missing, and terrible things happen to our bank accounts and insurances (not kidding).</p><p>Of course that was not Sling. That was Java. But we do have the same construct, the classic try-catch statement, also in Sling:</p><pre>try {<br>    doSomething()<br>}<br>catch(e as exception) {<br>}</pre><p>(As of slingc r305, the language now has a new built-in data type “exception”, which maps to “System.Exception” for C#, “java.lang.Throwable” on Java and a regular object on JavaScript.)</p><p>As we started to think of ways to improve this, one of the first things we did was to make that exception parameter declaration optional. So the previous snippet can be also expressed like this:</p><pre>try {<br>    doSomething()<br>}<br>catch {<br>}</pre><p>(If no parameter is given to catch, the “e as exception” is automatically assumed)</p><p>Although better, that’s still not so very convenient, and the error still goes missing. And doing the “print stack trace” in a cross-language fashion is not at all a one-liner (on Java you’ll do “e.printStackTrace()”, on C# “Console.WriteLine(e.ToString())”, on JavaScript maybe “console.log(e)”), so there’s a lot of typing left there. Of course you can do a utility function for it, which would be helpful.. But for the common case of just catching the exception and spitting it out, we came up with something new:</p><p><strong>The <em>trycatch</em> keyword</strong></p><p>It works like this:</p><pre>trycatch {<br>    doSomething()<br>}</pre><p>And of course like always in Sling, a one-liner block can be shortened:</p><pre>trycatch:<br>    doSomething()</pre><p>And as a particular case of the <em>trycatch</em> keyword, a one-liner block can also be turned into a single statement:</p><pre>trycatch doSomething()</pre><p>These would all now translate to this kind of Java code:</p><pre>try {<br>    doSomething();<br>}<br>catch(Exception e) {<br>    e.printStackTrace();<br>}</pre><p>Or this kind of C# code:</p><pre>try {<br>    doSomething();<br>}<br>catch(System.Exception e) {<br>    System.Console.WriteLine(e.ToString());<br>}</pre><p>Or this kind of JavaScript code:</p><pre>try {<br>    doSomething();<br>}<br>catch(e) {<br>    console.log(e);<br>}</pre><p>That’s a lot of typing removed.</p><p><em>But wait, there’s more!</em></p><p>The trycatch keyword can also be used as an expression. The <em>trycatch expression</em> evaluates to true if the block executed without exceptions, or false if exceptions were encountered. So you can do stuff like this:</p><pre>if not trycatch doSomething() {<br>    PRINT &quot;Error took place&quot;<br>    return false<br>}</pre><p>But of course the <em>assert statement</em> is meant to make that one shorter:</p><pre>assert trycatch doSomething():<br>    PRINT &quot;Error took place&quot;</pre><p>This ends up being a really rich statement packed into a small space. It is equivalent to the following C# code:</p><pre>if (!((System.Func&lt;bool&gt;)(() =&gt;<br>{<br>    try<br>    {<br>        doSomething();<br>    }<br>    catch (<strong>System</strong>.<strong>Exception</strong> e)<br>    {<br>        System.Console.WriteLine (e.ToString());<br>        return (false);<br>    }<br>    return (true);<br>}))())<br>{<br>    System.Console.WriteLine (&quot;Error took place&quot;);<br>    return (false);<br>}</pre><p>Or the following in Java:</p><pre>if(!(new Object() {<br>    <em>public</em> <strong>boolean</strong> execute() {<br>        try {<br>            doSomething();<br>        }<br>        catch(java.lang.<strong>Throwable</strong> e) {<br>            e.printStackTrace();<br>            return false;<br>        }<br>        return true;<br>    }<br>}.execute())) {<br>    System.out.println(&quot;Error took place&quot;);<br>    return(false);<br>}</pre><p>Or something very similar in JavaScript.</p><p>The trycatch keyword, along with the exception data type, is now available in slingc r305 and newer. Just use the <a href="http://eqdn.tech/eqela-cli/">Eqela command line interface</a> to build and update your build.qx file with:</p><pre>use eqela:sling:r305</pre><p>Happy hacking.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b73e275a25e5" width="1" height="1" alt=""><hr><p><a href="https://medium.com/eqela/write-less-code-try-the-trycatch-keyword-b73e275a25e5">Write less code: Try the trycatch keyword</a> was originally published in <a href="https://medium.com/eqela">Eqela</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introducing the Eqela Command Line Interface (eqela-cli)]]></title>
            <link>https://medium.com/eqela/introducing-the-eqela-command-line-interface-eqela-cli-c0a6758c81bc?source=rss----4bc1059d788f---4</link>
            <guid isPermaLink="false">https://medium.com/p/c0a6758c81bc</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[sling]]></category>
            <dc:creator><![CDATA[Markku Kero]]></dc:creator>
            <pubDate>Thu, 12 Apr 2018 21:48:04 GMT</pubDate>
            <atom:updated>2018-04-12T21:48:03.823Z</atom:updated>
            <content:encoded><![CDATA[<p>Ever since the <a href="http://eqdn.tech/sling">Sling programming language</a> was first introduced, Sling programs have been compiled with the “slingc” compiler, using the <a href="https://github.com/eqela/jkop">Jkop framework</a> as the standard library. This has worked well, and continues to be the best way to make Sling programs. However, some amounts of challenges have been observed in version management, particularly when new versions of the compiler and the Jkop framework have been released.</p><p>To address those challenges and more, we decided to create a new command line interface named the “Eqela Command Line Interface” (eqela-cli). This in itself is of course written in Sling, and is <a href="https://github.com/eqela/eqela-cli">available on GitHub</a>. Precompiled .NET executables (which can be used with Mono also on Linux and Mac OS X) are available for direct download on <a href="http://qx.eqela.com/">qx.eqela.com</a>. The “eqela” tool provided by eqela-cli normally executes build scripts named “build.qx” (which you will find in all modern Sling projects). Inside the build.qx file, the developer of the software module can then also define the versions of the compiler and libraries used, along with other definitions for how to build the software. The Eqela CLI tool will then download, install and use the appropriate versions of the compilers and libraries for each project. Consider it as the NPM, Maven, Ant and/or Make of Sling development.</p><p>To install the Eqela CLI tools, simply download the latest ZIP file for eqela-cli from the above link on <a href="http://qx.eqela.com/">qx.eqela.com</a>, and unzip the file. Then the syntax of compiling something with the tool is as simple as:</p><pre>&lt;path-to-unzipped-directory&gt;/eqela.exe build.qx</pre><p>If you are on Linux or Mac OS X (using Mono), then prefix the above command with “mono”.</p><p>This is of course assuming you have a build.qx file available. This is something you would create as a developer, but these are also frequently shipped with existing Sling projects. As a sample, you can download the eqela-samples package from the Eqela Github (this is assuming you have a the git tools installed):</p><pre>git clone <a href="https://github.com/eqela/eqela-samples.git">https://github.com/eqela/eqela-samples.git</a></pre><p>After doing so, you can use your Eqela tool to compile the samples:</p><pre>&lt;path-to-eqela-cli&gt;/eqela.exe eqela-samples/build.qx html</pre><p>If all is well, this would produce a number of “index.html” files in subdirectories of the “build” directory in your eqela-samples. Those can be opened in your web browser.</p><p>For sample build.qx files and for authoring your own, do go through the existing ones found inside the projects under the <a href="https://github.com/eqela">Eqela GitHub account</a>.</p><p>(For those of you who were fast enough to use the “qx” tool, eqela-cli now fully and completely replaces qx)</p><p>Happy hacking!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c0a6758c81bc" width="1" height="1" alt=""><hr><p><a href="https://medium.com/eqela/introducing-the-eqela-command-line-interface-eqela-cli-c0a6758c81bc">Introducing the Eqela Command Line Interface (eqela-cli)</a> was originally published in <a href="https://medium.com/eqela">Eqela</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>