<?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: Alec V</title>
    <description>The latest articles on DEV Community by Alec V (@alecv).</description>
    <link>https://dev.to/alecv</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%2F1141083%2F1502b8d9-4d66-4caa-b97a-beb38899c897.jpg</url>
      <title>DEV Community: Alec V</title>
      <link>https://dev.to/alecv</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/alecv"/>
    <language>en</language>
    <item>
      <title>Task Running</title>
      <dc:creator>Alec V</dc:creator>
      <pubDate>Fri, 05 Jan 2024 14:52:07 +0000</pubDate>
      <link>https://dev.to/alecv/task-running-4jp8</link>
      <guid>https://dev.to/alecv/task-running-4jp8</guid>
      <description>&lt;p&gt;Task runners help software developers by performing repetitive and time-consuming tasks for the developers so they can focus on coding. Task runners are used to automate repetitive tasks, lint and format code, compile code, run tests, manage browsers, automate deployment, and manage workflow. Task runners have large libraries and are very customizable to the task at hand. &lt;/p&gt;

&lt;h2&gt;
  
  
  Grunt
&lt;/h2&gt;

&lt;p&gt;Grunt was one of the first task runners in the JavaScript ecosystem and remains one of the most commonly used today. It can minify files, compile files, transpile, concatenate files, and more. It is controlled by a simple configuration file that runs developer scripts sequentially in the order specified in the configuration file. Grunt is straightforward and easy to use, but can become verbose for larger projects with numerous complex tasks. &lt;/p&gt;

&lt;h2&gt;
  
  
  Gulp
&lt;/h2&gt;

&lt;p&gt;In contrast to Grunt, Gulp emphasizes code over configuration. It can be used to efficiently minify, optimize images, control browsers, and preprocess CSS. Gulp uses Node.js streams to manage tasks like minification, image optimization, browser control, CSS pre-processing efficiently. Gulp is often more efficient than Grunt because it streamlines the development process through code. Unlike Grunt, Gulp can run tasks simultaneously. Gulp’s emphasis on code allows it to be more customizable, which makes it ideal for projects with custom task sequences. &lt;/p&gt;

&lt;h2&gt;
  
  
  Broccoli
&lt;/h2&gt;

&lt;p&gt;Broccoli is a less commonly used  task runner that, in contrast to Gulp and Grunt, is optimized for the asset pipeline. Rather than focusing on task automation, Broccoli is more about optimization for the handling of assets. Broccoli builds in a tree-based structure in which each transformation creates a new tree, which makes it very efficient for incremental builds because it tracks changes and will only rebuild the parts that have changed, which allows it to build very quickly. It is good for larger projects where that efficiency is an important consideration. &lt;/p&gt;

&lt;p&gt;Brunch&lt;br&gt;
Brunch is used to assemble HTML5 applications. It is optimized to compile modern Javascript and CSS pre-processing. Brunch also concatenates files and allows for hot module replacement. Brunch emphasizes ease of use. Only a very minimal configuration is required. It achieves this by using a convention over configuration style. &lt;/p&gt;

&lt;p&gt;Bundlers That Run Tasks&lt;/p&gt;

&lt;h2&gt;
  
  
  Webpack
&lt;/h2&gt;

&lt;p&gt;Webpack is a module bundler that has task runner capabilities. It is highly configurable and widely used. It is primarily used for bundling JavaScript modules, but it can also transpile and minify code. It is versatile and has a large plugin system that allows it to handle a wide array of tasks.&lt;/p&gt;

&lt;h2&gt;
  
  
  Parcel
&lt;/h2&gt;

&lt;p&gt;Parcel is another bundler with task running capabilities. Unlike webpack, it has almost no configuration setup. It is designed for efficiency and ease of use. It automates tasks like code splitting, and does hot module replacement and rapid bundling. Parcel’s easy setup attracts developers who want to minimize initial configuration.  &lt;/p&gt;

&lt;p&gt;By automating repetitive tasks, task runners and bundlers enhance developer efficiency, reduce errors, and improve consistency. &lt;/p&gt;

</description>
    </item>
    <item>
      <title>Open AI's API</title>
      <dc:creator>Alec V</dc:creator>
      <pubDate>Tue, 19 Dec 2023 03:55:32 +0000</pubDate>
      <link>https://dev.to/alecv/open-ais-api-b8a</link>
      <guid>https://dev.to/alecv/open-ais-api-b8a</guid>
      <description>&lt;p&gt;In the rapidly evolving realm of artificial intelligence and machine learning, OpenAI is making a wide range of useful API services that can augment and enhance applications. The api uses OpenAI’s chat GPT 3.5, 4 and 4 Turbo for chat completions, a text to speech engine called TTS to convert text to natural sounding speech, Whisper to convert speech to text, an embeddings engine that converts text into a numerical form, a fine tuning model that trains the AI,  a moderation model that can detect sensitive text, and DALL-E for image generation.&lt;/p&gt;

&lt;p&gt;The audio endpoint supports text to speech, speech to text, and creating translations. The text to speech endpoint request accepts a model, an input, a voice, a response format, and a speed and returns audio in the specified format. The model determines what the information is processed with, currently there is tts-1 and tts-1-hd. The input is a string of text with a maximum length of 4096 characters. The voice determines what voice the response is in, currently there are six options. The response format determines what kind of audio file is sent back, currently mp3, opus, aac, and flac are supported. The speed can return the audio at anywhere from .25 to 4x natural spoken speed. &lt;/p&gt;

&lt;p&gt;The speech to text endpoint request takes an audio  file, a model, a language, a prompt, a response_format, and a temperature. The only currently supported model is whisper-1. The language parameter is optional and specifies the language of the input, which can increase accuracy. The prompt parameter is optional and can include the correct spellings of unusual words like brand names that appear in the audio and may be mistranslated. The transcription will use the capitalization and spelling provided in the prompt. The response can be formatted into json, text, srt, verbose_json, or vtt. The temperature is a number between 0 and 1 where 0 is the most accurate possible and 1 will create more random responses. It returns the transcribed text. The create translation also takes an audio file, a model, a prompt, a response_format, and a temperature. It returns the audio translated into English and transcribed to text. It also uses the whisper-1 model.&lt;/p&gt;

&lt;p&gt;An example of a text to speech request:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;post&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/text-to-speech-openai&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;async&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;text&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;body&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;text&lt;/span&gt;
  &lt;span class="k"&gt;try&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
   &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;openai&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;audio&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;speech&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;create&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
      &lt;span class="na"&gt;model&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;tts-1&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
      &lt;span class="na"&gt;input&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;text&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
      &lt;span class="na"&gt;voice&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;fable&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
    &lt;span class="p"&gt;})&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;buffer&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;Buffer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;from&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;arrayBuffer&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
    &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;status&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;send&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;buffer&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="k"&gt;catch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;error in text to speech: &lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;status&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;500&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;send&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Error synthesizing speech from open AI&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The chat completion request takes a messages array, a model, frequency_penalty, logit_bias, max tokens, n, the presence_penalty, the response_format, the seed, the stop, the stream, temperature, top_p, tools, tool_choice, user, function_call, and functions. It returns a chat completion object processed by the selected model. The messages array contains objects which establish the role of the AI and the past user messages and AI responses. The create image model takes a prompt, a model, a number, the image quality, the desired response format, the style the image should be rendered in and the user. &lt;/p&gt;

&lt;p&gt;An example of a chat completion request:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;  &lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;post&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/openAIGetResponse&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;async &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;messages&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;body&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;request&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="na"&gt;model&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;gpt-3.5-turbo&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;messages&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;messages&lt;/span&gt;
    &lt;span class="p"&gt;};&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;headers&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Content-Type&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;application/json&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Authorization&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;`Bearer &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;OPENAI_API_KEY&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;
    &lt;span class="p"&gt;};&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;airesp&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;axios&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;post&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;https://api.openai.com/v1/chat/completions&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
&lt;span class="nx"&gt;request&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;headers&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;headers&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;responseText&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;airesp&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;choices&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nx"&gt;message&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;content&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;status&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;send&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;response&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;responseText&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;catch &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;status&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;500&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;send&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Internal Server Error&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Embeddings is used to by the AI to convert text to numerical values that the AI uses to process language more quickly. The fine-tuning model allows the user to train the AI on specific bodies of texts to inform its responses. The create moderation model detects speech that goes against a speech policy. &lt;/p&gt;

&lt;p&gt;These API services provide many tools that will be useful to enterprises and smaller developers alike. The capabilities offered by AI are expanding rapidly and will redefine what is possible in our digital world. &lt;/p&gt;

&lt;h6&gt;
  
  
  Source: OpenAI Platform, platform.openai.com/docs/api-reference. Accessed 19 Dec. 2023.
&lt;/h6&gt;

</description>
    </item>
    <item>
      <title>Introduction to Kotlin</title>
      <dc:creator>Alec V</dc:creator>
      <pubDate>Mon, 27 Nov 2023 13:53:50 +0000</pubDate>
      <link>https://dev.to/alecv/introduction-to-kotlin-5d9e</link>
      <guid>https://dev.to/alecv/introduction-to-kotlin-5d9e</guid>
      <description>&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvwo7q4njnu6itdxwmilx.png" class="article-body-image-wrapper"&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-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvwo7q4njnu6itdxwmilx.png" alt="Kotlin Mascot"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Kotlin is a free language released as an open source project in 2012 by JetBrains, a Czech software development company. The first stable release of Kotlin 1.0 was in February of 2016. In 2017 Google announced first-class support for Kotlin on android. In 2016 Kotlin began officially supporting sharing code between JVM and JavaScript platforms. In 2019 Google announced that Kotlin was the preferred language for Android app developers. &lt;/p&gt;

&lt;p&gt;Kotlin is a statically typed general-purpose high-level programming language with type inference. Kotlin uses smart casting which casts a variable to a type in a block where a type check has been performed on the variable. Kotlin was created to have the functionality of Scala, with a while being concise, powerful, and compiling quickly. It supports both object oriented and functional programming. &lt;/p&gt;

&lt;p&gt;Kotlin is fully interoperable with Java and accepts existing Java libraries. This means that Java developers can start using Kotlin without rewriting all of their existing Java code.  Kotlin/JS is compatible with JavaScript and can use many of JavaScript’s modules, including react. Kotlin typically transpiles to Java and Kotlin/JS compiles to JavaScript. Kotlin/Native is intended to compile directly to machine code. Kotlin Multiplatform, which was announced as stable in November of 2023,  allows developers to use Kotlin with the Java Virtual Machine (JVM), Kotlin/JS, and Kotlin Native in a single codebase allowing for efficient and intuitive cross-platform development. &lt;/p&gt;

&lt;p&gt;Kotlin handles asynchronous code using Coroutines, which are built on top of threads and communicate with each other using channels. Coroutines offer an elegant and concise way to handle asynchronous code. They are non-blocking by default, but can be explicitly set to be blocking. Coroutines have built in cancellation.&lt;/p&gt;

&lt;p&gt;Kotlin has strong null safety: if a type or class may have a null value, the developer must explicitly declare this by putting a “?” after the data type in the declaration. Kotlin has an immutable data class that is intended to store data that will not change. Kotlin’s null safety and data class make code more robust and guard against errors. &lt;/p&gt;

&lt;p&gt;Kotlin has many data types that will be familiar to programmers, and also offers a wide variety of collections including lists, sets, maps, and ranges. Lists are an ordered collection that can be accessed by an index property and can contain duplicates. Sets are an unordered collection that does not allow duplicates. Maps are an unordered collection of key-value pairs. These collections can have a mutable property which allows them to be modified. &lt;/p&gt;

&lt;p&gt;Kotlin is a broad, powerful, and multi-purpose language. It is increasing in popularity and is Google’s language of choice for android app development. It is an ideal language for large projects because it is robust and for cross-platform development because of its interoperability and multiplatform capability. &lt;/p&gt;

</description>
    </item>
    <item>
      <title>Procedural Generation</title>
      <dc:creator>Alec V</dc:creator>
      <pubDate>Mon, 16 Oct 2023 13:53:08 +0000</pubDate>
      <link>https://dev.to/alecv/procedural-generation-4pd9</link>
      <guid>https://dev.to/alecv/procedural-generation-4pd9</guid>
      <description>&lt;p&gt;Procedural generation is a method of creating data algorithmically through a combination of rules iterated through with a degree of randomness. It is used in computer graphics to create textures and models. It is used in movie computer-generated imagery to produce large landscapes and simulated crowds. Music can be generated algorithmically, either to avoid repetition or to allow it to change in real-time based on predefined stimuli. Procedural generation can create large amounts of content that adheres to specific rules. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--qux42e8j--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9bh7j32pkk1ozaa2oznz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--qux42e8j--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9bh7j32pkk1ozaa2oznz.png" alt="Procedurally generated trees using L-systems" width="800" height="574"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Procedural generation made its way from dice roll generated dungeons in Dungeons and Dragons into early video games like Maze Craze(1978), Apple Manor (1978), and Rogue (1980). Rogue used procedural generation to create unique dungeons so that every playthrough was different. Rogue gave rise to a host of similar games known as rogue-likes, which is a popular buzzword in today’s computer game industry. Procedural generation allowed these early games to create large amounts of content while using only a small amount of memory. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--qgiFJs0e--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wivf2fonbfttnsbbi3ax.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--qgiFJs0e--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wivf2fonbfttnsbbi3ax.png" alt="A Procedurally Generated Dungeon in Rogue" width="484" height="316"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In modern games procedural generation is used to create content like terrain using techniques like Perlin noise, Simplex noise, fractal noise, and cellular automata, or creating variations from an example using deep neural networks trained on real terrain data. These processes generate unique maps for games and build worlds with unpredictable weather patterns, ecosystems, climate, and geological processes. Physics-based procedural generation creates landscapes by simulating the process of erosion. The three-dimensional worlds are colored by textures which can also be procedurally generated so that no two objects look exactly the same. Developers of these systems must balance the processing power required to produce these landscapes with realism. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--QTZPpqWp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fo3y6rsxm1e7o2e7u8u0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--QTZPpqWp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fo3y6rsxm1e7o2e7u8u0.png" alt="A procedural landscape rendered in Terragen" width="800" height="600"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Perlin and Simplex are gradient noises that were developed by Ken Perlin in 1983 and 2001, respectively. They are used to generate terrain and textures procedurally in 1 or more dimensions that are more aesthetically pleasing but more computationally demanding than value noise, which generates random values between grid points and then a smooth gradient between them. Simplex noise is an improvement on Perlin noise. Simplex noise is more computationally efficient than Perlin noise and can scale to more dimensions efficiently. Simplex noise generates more aesthetically pleasing results with fewer artifacts. Perlin and simplex noise can be layered into fractal noise to increase realism and control the variations. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--FKVWZjnI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/eeh59ryksfldjfbjrwwh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--FKVWZjnI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/eeh59ryksfldjfbjrwwh.png" alt="Perlin noise, rescaled and added to itself" width="300" height="300"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Cellular automata consist of discrete objects whose state evolves over time, usually following rules based on the state of surrounding objects. An early example of this on a computer is found in Conway’s Game of Life. Cellular automata are useful for terrain generation, real geologic processes can be simulated to create realistic landscapes. They can be used to simulate anything that changes over time and can produce unexpectedly complex results. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--yt4HYoxX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7cfm68tzn0ue3zxe4o0c.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--yt4HYoxX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7cfm68tzn0ue3zxe4o0c.gif" alt="Conway's Game of Life" width="360" height="240"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h6&gt;
  
  
  Image source: &lt;a href="https://www.jakubkonka.com/2015/03/15/game-of-life.html"&gt;https://www.jakubkonka.com/2015/03/15/game-of-life.html&lt;/a&gt;
&lt;/h6&gt;

&lt;p&gt;Deep neural networks are increasingly used in procedural generation. They can create more complex results and enhance the quality of procedurally generated content. Convolutional neural networks are a class of deep neural networks trained on images that are particularly suited to image generation. They can be trained on large datasets like real-world terrain to generate more realistic terrain. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--cE3zs0QP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4diym9f3m60qlgtg4ytg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--cE3zs0QP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4diym9f3m60qlgtg4ytg.png" alt="" width="800" height="649"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Procedural generation is an incredibly powerful tool for content creation. Manual creation is time-intensive and necessarily limited by memory or labor constraints. Procedural generation allows creators to specify a set of rules by which something will be created and then create near-infinite variations. Deep neural networks have enhanced procedural generation and with increasing processing power and more complex systems, procedural generation will only improve. &lt;/p&gt;

&lt;h6&gt;
  
  
  Lim, F., Tan, Y. and Bhojan, A. (2022) ‘Visually improved erosion algorithm for the procedural generation of tile-based terrain’, Proceedings of the 17th International Joint Conference on Computer Vision, Imaging and Computer Graphics Theory and Applications [Preprint]. doi:10.5220/0010799700003124.
&lt;/h6&gt;

&lt;h6&gt;
  
  
  Fischer, R. et al. (2020) ‘Autobiomes: Procedural Generation of multi-biome landscapes’, The Visual Computer, 36(10–12), pp. 2263–2272. doi:10.1007/s00371-020-01920-7.
&lt;/h6&gt;

&lt;h6&gt;
  
  
  Zhang, J. et al. (2019) ‘Example-based rapid generation of vegetation on terrain via CNN-based distribution learning’, The Visual Computer, 35(6–8), pp. 1181–1191. doi:10.1007/s00371-019-01667-w.
&lt;/h6&gt;

</description>
    </item>
    <item>
      <title>Introduction to TypeScript for JavaScript Users</title>
      <dc:creator>Alec V</dc:creator>
      <pubDate>Mon, 09 Oct 2023 10:44:20 +0000</pubDate>
      <link>https://dev.to/alecv/introduction-to-typescript-for-javascript-users-43bl</link>
      <guid>https://dev.to/alecv/introduction-to-typescript-for-javascript-users-43bl</guid>
      <description>&lt;p&gt;TypeScript is a free and open source language released in 2012 by Microsoft. It was created by Anders Hejlsberg, who developed Turbo Pascal, Delphi, C#, and the Microsoft .NET Framework. Development began in 2010, it was released to the public in 2012, and the first full version 1.0 was released in 2014. As of March 2023, Typescript is on version 5.0. Typescript is a superset of JavaScript, all valid JavaScript code is valid TypeScript, but can fail type-check during transpiling. &lt;/p&gt;

&lt;p&gt;Typescript transpiles to JavaScript, but the process is often described as compiling. The transpiler is called the TypeScript Compiler. TypeScript was created to make JavaScript more suited to developing large applications. Typescript uses gradual typing, which means that variables can optionally be statically typed. Statically typed variables will be type-checked code is compiled or transpiled. TypeScript will transpile with errors, but it will tell you about the errors.  In gradual typing, type errors in non-statically typed variables will throw errors at runtime. Static typing makes code more robust and reliable. Because TypeScript is a gradually typed superset of JavaScript, developers can gradually add static types or other TypeScript features to existing JavaScript code. Datatypes are assigned to variables like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;message&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Hello, world!&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In addition to the standard JavaScript datatypes, TypeScript includes four more: any, which can be any datatype, like a JavaScript variable; unknown, the datatype must be specified before it is used; never, the values stored in never cannot occur; and void, returns undefined, null, or nothing. &lt;/p&gt;

&lt;p&gt;Any is useful if you want something to behave like it does in JavaScript. It can be useful when you are transitioning between JavaScript and TypeScript or when you are uncertain what datatype something will be, but it removes the static type check. Unknown will preserve the static type check on data whose datatype you are unsure of by requiring a type for the data before it is used. Never can be used to prevent conditions that should not be possible. Void can be used to ensure or indicate that nothing should be returned by something. &lt;/p&gt;

&lt;p&gt;TypeScript also has interfaces, which define a structure and syntax for something. When the code is transpiled, the interface is type-checked against the things it defines. Interfaces describe the intended shape of data. &lt;/p&gt;

&lt;p&gt;In addition to interfaces, TypeScript also supports developer composed types. These types can be composed by unions, declaring the possible types for data; generics, which assign a datatype to a variable; and structural or duck typing, which considers two objects that share the same structure to be of the same type. &lt;/p&gt;

&lt;p&gt;A union:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="nx"&gt;door&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;open&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;closed&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;ajar&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Above is a union in which the door type can either be open, closed, or ajar.&lt;/p&gt;

&lt;p&gt;Generics:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="nx"&gt;NumArray&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;Array&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kr"&gt;number&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="nx"&gt;StringArray&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;Array&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="nx"&gt;BoolObj&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="na"&gt;key&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nl"&gt;value&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;boolean&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Above is an array whose values must be numbers, an array whose values must be strings, and an object whose key must be a string and whose value must be a boolean. &lt;/p&gt;

&lt;p&gt;TypeScript can make JavaScript code more robust and reliable, especially for larger scale projects. While writing code in TypeScript can require more lines of code and add complexity, TypeScript adds functionality to JavaScript and makes it easier to catch bugs early. TypeScript makes code easier to maintain and in the long run will decrease development time on large projects. &lt;/p&gt;

&lt;h5&gt;
  
  
  Documentation - typescript for JavaScript programmers. TypeScript. (n.d.). &lt;a href="https://www.typescriptlang.org/docs/handbook/typescript-in-5-minutes.html"&gt;https://www.typescriptlang.org/docs/handbook/typescript-in-5-minutes.html&lt;/a&gt;
&lt;/h5&gt;

&lt;h5&gt;
  
  
  The starting point for learning typescript. TypeScript. (n.d.-b). &lt;a href="https://www.typescriptlang.org/docs/handbook"&gt;https://www.typescriptlang.org/docs/handbook&lt;/a&gt;
&lt;/h5&gt;

</description>
      <category>blog</category>
    </item>
    <item>
      <title>Go Language Basics</title>
      <dc:creator>Alec V</dc:creator>
      <pubDate>Mon, 02 Oct 2023 11:03:03 +0000</pubDate>
      <link>https://dev.to/alecv/go-language-basics-47kc</link>
      <guid>https://dev.to/alecv/go-language-basics-47kc</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--qByMKIbH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ojfi129pyzp9tyvbh26y.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--qByMKIbH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ojfi129pyzp9tyvbh26y.png" alt="Go Gopher" width="500" height="500"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Go is an open source programming language developed by software engineers at Google. It is also known as Golang because of its first web address, but its official name is Go. Go was designed by Ken Thompson, one of the creators of the C programming language and Unix, Rob Pike, one of the creators of UTF-8 and unix, and Robert Greismer. Their goal was to create a language that had a runtime efficiency similar to C, but was as readable as Javascript and Python. &lt;/p&gt;

&lt;p&gt;Go is a fast growing language. It was created in 2007, released as an open-source project in 2009, and the first version was released in 2012. Githut 2.0 ranked it as third most popular language on Github by pull request for the first and second quarter of 2023, behind Python and Java. Go was recognized by TIOBE as language of the year in 2009 and 2016 and as of September of 2023, it ranked 12th on the TIOBE index. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--FirlLUSN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/o3vhvrcwyc8ag5acr5wj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--FirlLUSN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/o3vhvrcwyc8ag5acr5wj.png" alt="Githut Popularity" width="800" height="295"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h6&gt;
  
  
  &lt;em&gt;Source: Githut 2.0&lt;/em&gt;
&lt;/h6&gt;

&lt;p&gt;How does it compare to other languages? Go uses static typing, which means that every variable’s data type must be assigned when the code is compiled. Static typing can make code more robust and reliable. Go is garbage collected, it automatically attempts to reclaim memory that is no longer in use by the program, like C# and Java, which also makes it more memory efficient and easier to use. Go is compiled directly to machine code, unlike other similar languages like Python and Java which are compiled to byte code and then run on a virtual machine. This makes Go more memory efficient than those languages. Go is a very minimalist language, it has only 25 keywords.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--siJKNhZv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/810kqugmxdsa9hk843nq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--siJKNhZv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/810kqugmxdsa9hk843nq.png" alt="Companies using Go" width="800" height="242"&gt;&lt;/a&gt;&lt;br&gt;
Companies using Go &lt;/p&gt;
&lt;h6&gt;
  
  
  &lt;em&gt;Source: go.dev&lt;/em&gt;
&lt;/h6&gt;

&lt;p&gt;Go is an object oriented language, but does not support class inheritance. Instead, Go uses interfaces and structs which are similar to classes. Go must be compiled to run, but it compiles much more quickly than other languages like C, C++, Java, and Rust. Andrew Gerrand said in an interview with Jeff Meyerson that "there's a joke that Go was conceived while waiting for a C++ program to compile, which is kind of half true" (Meyerson, 101).&lt;/p&gt;

&lt;p&gt;Where Go really excels is in its efficient model for running concurrent functions. Go does not use threads for concurrency, but its own model called goroutines. These goroutines have a flexible stack that grows as necessary and starts out using only 2KB of memory, which makes goroutines much more memory efficient than threads, so many more goroutines can be created than threads. Goroutines communicate with one another through bidirectional channels. &lt;/p&gt;

&lt;p&gt;Go’s syntax is similar to C and Java because it uses curly braces to enclose blocks of code. To print the traditional “Hello, world!” function to the console, you need to declare the package that the file belongs to, import a library that will allow you to print things to console, declare a function and finally put the Println command in the function. It looks like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;package&lt;/span&gt; &lt;span class="n"&gt;main&lt;/span&gt;

&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="s"&gt;"fmt"&lt;/span&gt;

&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="n"&gt;main&lt;/span&gt; &lt;span class="p"&gt;(){&lt;/span&gt;
    &lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Hello, world!"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Datatypes in go are divided into basic, aggregate, reference, and interface. Basic data includes strings, numbers, and Booleans. Aggregate data includes arrays and structs. Reference data includes pointers, slices, functions, and channels. Interfaces allow a developer to implement polymorphism and code flexibility without using inheritance. &lt;/p&gt;

&lt;p&gt;Variables can be declared in a variety of ways and their datatype can be specified explicitly or be inferred. For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;
&lt;span class="k"&gt;package&lt;/span&gt; &lt;span class="n"&gt;main&lt;/span&gt;

&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="s"&gt;"fmt"&lt;/span&gt;

&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="n"&gt;main&lt;/span&gt; &lt;span class="p"&gt;(){&lt;/span&gt;
    &lt;span class="k"&gt;var&lt;/span&gt; &lt;span class="n"&gt;num0&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt;
    &lt;span class="k"&gt;var&lt;/span&gt; &lt;span class="n"&gt;num1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;
    &lt;span class="n"&gt;num2&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="m"&gt;2&lt;/span&gt;
    &lt;span class="k"&gt;var&lt;/span&gt; &lt;span class="n"&gt;num3&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="m"&gt;3&lt;/span&gt;
    &lt;span class="n"&gt;num4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;num5&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="m"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;5&lt;/span&gt;
    &lt;span class="n"&gt;arr&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;num0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;num1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;num2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;num3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;num4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;num5&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;var&lt;/span&gt; &lt;span class="n"&gt;sum&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;

    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;num&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="k"&gt;range&lt;/span&gt; &lt;span class="n"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;sum&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="n"&gt;num&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Printf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"%d&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;sum&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Above I first declare a num0 variable without a value using the var keyword and int to specify the datatype. If a value is not specified for an integer, it will be initialized to 0. Next I declare num1 without specifying the datatype, but because its value is 1, it is inferred to be an integer. The := allows variable declaration and assignment without a keyword. Multiple variables can be declared at the same time, as with num4 and num5. Below I declare an array containing the above variables and a sum variable and then I use a for loop to iterate over the array and add up the values. Finally, I print the value.&lt;/p&gt;

&lt;p&gt;Go is a young and fast-growing language that is in use at many large and successful businesses. It pairs speed and efficiency with readability and minimalist language design. This makes Go an easy language to learn and use that is very powerful, particularly in concurrent operations. Go has a large and growing library and is changing and growing rapidly. While it may require more lines of code to complete a project than some of its competitors, its power, clarity and ease of use suggests it will only grow in popularity. &lt;/p&gt;

&lt;h6&gt;
  
  
  &lt;em&gt;Meyerson, J. (2014). The go programming language. IEEE Software, 31(5), 104–104. &lt;a href="https://doi.org/10.1109/ms.2014.127"&gt;https://doi.org/10.1109/ms.2014.127&lt;/a&gt;&lt;/em&gt;
&lt;/h6&gt;

&lt;h6&gt;
  
  
  &lt;em&gt;Lee, W.-M. (2021). Go programming language for dummies. John Wiley &amp;amp; Sons Inc.&lt;/em&gt;
&lt;/h6&gt;

</description>
    </item>
    <item>
      <title>Introduction to Reduce</title>
      <dc:creator>Alec V</dc:creator>
      <pubDate>Sat, 19 Aug 2023 03:44:17 +0000</pubDate>
      <link>https://dev.to/alecv/introduction-to-reduce-246o</link>
      <guid>https://dev.to/alecv/introduction-to-reduce-246o</guid>
      <description>&lt;p&gt;Reduce is a native method in JavaScript that acts on arrays. It is a high-order function. Reduce takes two arguments, a callback function that is applied to each value in the array, and an optional initial value for the accumulator. The accumulator stores a value that is altered over the course of reduce’s execution. Reduce returns a single value. If no initial value is provided, the first element of the array becomes the initial value of the accumulator, unless the array reduce is called on is empty, in which case an error will be thrown.  &lt;/p&gt;

&lt;p&gt;To make this a bit clearer here is a simple example, using reduce to add all of the numbers in an array:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;nums&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;

&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;sum&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;reduce&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;accumulator&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;currentValue&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;accumulator&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;currentValue&lt;/span&gt;
&lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;sum&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="mi"&gt;6&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this classic example, I have provided an initial value of 0 as the second argument in reduce(). The function iterates through the array, adding each value in the array to the accumulator and returns 6. &lt;/p&gt;

&lt;p&gt;In this case, if I hadn't provided an initial value this example would still work because setting the initial value of the accumulator to the first item in the array would not affect the addition performed by reduce.&lt;/p&gt;

&lt;p&gt;Another example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;bools&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;

&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;truths&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;bools&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;reduce&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;accumulator&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;currentValue&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;currentValue&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
&lt;span class="nx"&gt;accumulator&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;accumulator&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;truths&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="mi"&gt;3&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, reduce iterates through the array bools and when the values in the array evaluate to true, it adds one to the accumulator. Because there are three values that are true in the array, this console logging truths will return to 3. &lt;/p&gt;

&lt;p&gt;Reduce can return more than just a number though. For instance, it can return an array. Here is an example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;nestedArray&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;7&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;9&lt;/span&gt;&lt;span class="p"&gt;]]&lt;/span&gt;

&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;flatArray&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;nestedArray&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;reduce&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;accumulator&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;currentValue&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
 &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;accumulator&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;concat&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;currentValue&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]);&lt;/span&gt;

&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;flatArray&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;7&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;9&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here, reduceiterates through the nested array and concatenates the accumulator with the current value in the array. Because I started with an initial value of [0], that is the value of the accumulator when it is concatenated with the first array in the nested array.&lt;/p&gt;

&lt;p&gt;Reduce is a very powerful method that has many uses. It can tackle a wide range of iterative operations performing aggregation, manipulating data, and transforming. Learning to use reduce effectively will allow you to write cleaner and more succinct code. &lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
