<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Batajus</title>
    <description>The latest articles on DEV Community by Batajus (@batajus).</description>
    <link>https://dev.to/batajus</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F114465%2F321136dd-8fd9-4df7-b6ba-9c338beebfe6.jpg</url>
      <title>DEV Community: Batajus</title>
      <link>https://dev.to/batajus</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/batajus"/>
    <language>en</language>
    <item>
      <title>Electron - Quick start with Typescript</title>
      <dc:creator>Batajus</dc:creator>
      <pubDate>Mon, 13 Apr 2020 12:48:01 +0000</pubDate>
      <link>https://dev.to/batajus/electron-quick-start-with-typescript-48h8</link>
      <guid>https://dev.to/batajus/electron-quick-start-with-typescript-48h8</guid>
      <description>&lt;p&gt;Due to the rapidly growing internet, web applications are becoming more and more important for our modern society. So nowadays it isn't required anymore to write a Desktop application with a languages like C++, Java, Python, etc. &lt;br&gt;
With the &lt;a href="https://www.electronjs.org/" rel="noopener noreferrer"&gt;Electron&lt;/a&gt; framework we're able to create native Desktop applications with web technologies. &lt;/p&gt;

&lt;p&gt;Electron provides a Chromium-Browser with a full Node.js integration, which loads our web app. &lt;/p&gt;

&lt;p&gt;We can use Electron not only to create new Desktop applications. With it we can  provide native apps for already existing web applications, too. &lt;/p&gt;

&lt;p&gt;In this guide I will explain how to create a simple Electron app with the Electron framework and Typescript.&lt;/p&gt;

&lt;p&gt;Let's start 🙂&lt;/p&gt;
&lt;h1&gt;
  
  
  Getting started
&lt;/h1&gt;

&lt;p&gt;You need to create a new directory, called whatever you like, or e.g. electron-typescript-guide, and initialize it with &lt;code&gt;npm init&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Afterwards we need to install Electron and Typescript:&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm i electron typescript --dev
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;One last thing before we can start to implement our small project. We need to add a &lt;code&gt;tsconfig.json&lt;/code&gt; to out project. You can add it by yourself or by executing the &lt;code&gt;tsc --init&lt;/code&gt; command (I recommend this =D).&lt;/p&gt;

&lt;p&gt;Also we define an output directory to the &lt;code&gt;tsconfig.json&lt;/code&gt; for the transpiled Typescript files:&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"outDir": "./build"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;Now your &lt;code&gt;tsconfig.json&lt;/code&gt; should look like this (with a lot of additional comments):&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
    "compilerOptions": {
        "target": "es5",         
        "module": "commonjs",    
        "strict": true,          
        "esModuleInterop": true,    
        "outDir": "./build"
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;Now we're ready to implement our first Electron app 🎉&lt;/p&gt;
&lt;h1&gt;
  
  
  Actual Coding of your Electron app 😊
&lt;/h1&gt;

&lt;p&gt;Let's start with our implementation.&lt;/p&gt;

&lt;p&gt;First of all we create a &lt;code&gt;index.html&lt;/code&gt;, which we're loading in our app. You can add any content to it. &lt;/p&gt;

&lt;p&gt;The &lt;code&gt;index.html&lt;/code&gt; can, for example, look like this:&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;!DOCTYPE html&amp;gt;
  &amp;lt;head&amp;gt;
    &amp;lt;title&amp;gt;Electron Project&amp;lt;/title&amp;gt;
  &amp;lt;/head&amp;gt;
  &amp;lt;body&amp;gt;
    &amp;lt;h1&amp;gt;Electron Typescript Beginner's Guide =)&amp;lt;/h1&amp;gt;
  &amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;In the next step we create our &lt;code&gt;index.ts&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;At first we subscribe us to the &lt;code&gt;ready&lt;/code&gt; event of our application, which is emitted as soon as the initialization has finished.&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { app } from 'electron';

app.on('ready', () =&amp;gt; {
  console.log('App is ready');
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;After the initialization we will create our browser window. To do so, we create a &lt;code&gt;BrowserWindow&lt;/code&gt; in our event callback.&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const win = new BrowserWindow({
  width: 600,
  height: 400
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;The created window will have a width of 600px and height of 400px.&lt;br&gt;
For more details about the &lt;code&gt;BrowserWindow&lt;/code&gt; options you should take a look into the &lt;a href="https://www.electronjs.org/docs/api/browser-window#class-browserwindow" rel="noopener noreferrer"&gt;docs&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;If we would start our application now only a white window will be shown. Now we will load our &lt;code&gt;index.html&lt;/code&gt; into our browser window.&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const indexHTML = path.join(__dirname + '/index.html');
win.loadFile(indexHTML).then(() =&amp;gt; {
    // IMPLEMENT FANCY STUFF HERE
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;And now, we're almost finished with our Electron app 🥳&lt;/p&gt;
&lt;h1&gt;
  
  
  Starting of our Electron Application
&lt;/h1&gt;

&lt;p&gt;So before we can start our application we need to transpile our Typescript code into JavaScript. &lt;/p&gt;

&lt;p&gt;For this we extend the &lt;code&gt;scripts&lt;/code&gt; object in our &lt;code&gt;package.json&lt;/code&gt;, so it is easier for us 😉&lt;/p&gt;

&lt;p&gt;We add a script to transpile our code and copy our &lt;code&gt;index.html&lt;/code&gt; into the created build directory:&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"compile": "tsc &amp;amp;&amp;amp; copyfiles -f src/index.html build"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;We transpile our code with &lt;code&gt;tsc&lt;/code&gt; and the second part of the command creates a copy of our &lt;code&gt;index.html&lt;/code&gt; in the build directory, which was created by the &lt;code&gt;tsc&lt;/code&gt; command.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Note: &lt;br&gt;
copyfiles is a npm package, which copies files from one directory to another and works on every OS. We can install it with &lt;code&gt;npm i copyfiles --dev&lt;/code&gt;. &lt;br&gt;
If you're using Linux or MacOS you can also use &lt;code&gt;cp index.html build/&lt;/code&gt; instead.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Next we add a start script:&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"start": "npm run compile &amp;amp;&amp;amp; electron"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;Now every time we run &lt;code&gt;npm start&lt;/code&gt; we transpile our Typescript code and start our Electron app.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;One last thing&lt;/strong&gt; before we can start our application we need to change the path to our &lt;code&gt;index.js&lt;/code&gt; our &lt;code&gt;package.json&lt;/code&gt;:&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"main": "build/index.js"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;Now we can run &lt;code&gt;npm start&lt;/code&gt; and see our app starting 😊&lt;/p&gt;
&lt;h1&gt;
  
  
  Conclusion
&lt;/h1&gt;

&lt;p&gt;So this was my first post ever 😊&lt;br&gt;
I hope you enjoyed reading it and if you've any suggestions please leave a comment😊&lt;/p&gt;

&lt;p&gt;You can find the complete source code at GitHub:&lt;/p&gt;


&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev.to%2Fassets%2Fgithub-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/Batajus" rel="noopener noreferrer"&gt;
        Batajus
      &lt;/a&gt; / &lt;a href="https://github.com/Batajus/electron-typescript-guide" rel="noopener noreferrer"&gt;
        electron-typescript-guide
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      A simple project to introduce into Electron with Typescript
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;div class="markdown-heading"&gt;
&lt;h1 class="heading-element"&gt;electron-typescript-guide&lt;/h1&gt;

&lt;/div&gt;
&lt;p&gt;A sample project to introduce you to Electron in combination with Typescript.&lt;/p&gt;
&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;How to start&lt;/h2&gt;

&lt;/div&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Install all packages&lt;/p&gt;
&lt;div class="snippet-clipboard-content notranslate position-relative overflow-auto"&gt;&lt;pre class="notranslate"&gt;&lt;code&gt; npm install
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Run the electron application&lt;/p&gt;
&lt;div class="snippet-clipboard-content notranslate position-relative overflow-auto"&gt;&lt;pre class="notranslate"&gt;&lt;code&gt; npm start
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;



&lt;/div&gt;
&lt;br&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/Batajus/electron-typescript-guide" rel="noopener noreferrer"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;br&gt;
&lt;/div&gt;
&lt;br&gt;


&lt;p&gt;More posts about Electron are coming soon, so stay tuned 🎉&lt;/p&gt;

</description>
      <category>electron</category>
      <category>typescript</category>
    </item>
    <item>
      <title>What benefits does a M. Sc. in Computer Science have?</title>
      <dc:creator>Batajus</dc:creator>
      <pubDate>Tue, 15 Jan 2019 22:17:27 +0000</pubDate>
      <link>https://dev.to/batajus/what-benefits-does-a-m-sc-in-computer-science-have-2b8h</link>
      <guid>https://dev.to/batajus/what-benefits-does-a-m-sc-in-computer-science-have-2b8h</guid>
      <description>&lt;p&gt;Hey guys,&lt;/p&gt;

&lt;p&gt;currently I'm working full-time as front-end developer for an international software company.  Next to my job I'm doing my M.Sc. in Computer Science.&lt;br&gt;
So the problem is that I'm struggling a bit with the topics of some required lectures, because they're very theoretically :-(&lt;/p&gt;

&lt;p&gt;So I'm regular facing the question: Is a M.Sc in Computer Science really worth the whole effort? &lt;/p&gt;

&lt;p&gt;Thank you very much for your experience/opinions :-)&lt;/p&gt;

</description>
      <category>career</category>
      <category>discuss</category>
    </item>
  </channel>
</rss>
