<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>raku &amp;mdash; Swagg::Blogg</title>
    <link>https://blog.swagg.net/tag:raku</link>
    <description>or: How I Learned to Stop Worrying and Love the WWW&lt;br&gt;&lt;a href=&#34;https://www.swagg.net&#34;&gt;Home&lt;/a&gt;&amp;nbsp;&lt;a href=&#34;https://blog.swagg.net/feed/&#34;&gt;RSS&lt;/a&gt;</description>
    <pubDate>Fri, 17 Apr 2026 02:52:31 +0000</pubDate>
    <image>
      <url>https://i.snap.as/gopN8vBC.png</url>
      <title>raku &amp;mdash; Swagg::Blogg</title>
      <link>https://blog.swagg.net/tag:raku</link>
    </image>
    <item>
      <title>Variables: Declared? Defined? Both??</title>
      <link>https://blog.swagg.net/variables-declared?pk_campaign=rss-feed</link>
      <description>&lt;![CDATA[I&#39;ve put forth some effort recently towards exploring some other Perl-ish but not-Perl scripting languages to (I hope) reinforce my resume. I love Perl but if I hope to become a real professional with my programming then I think it behooves me to branch out a bit. I haven&#39;t strayed far from Perl however as the languages that have intrigued me the most so far have been Raku and Javascript.&#xA;&#xA;What is or isn&#39;t &#34;Perl-ish&#34; I suppose is subjective but I think these two have a syntax I can find some familiarity with. I still haven&#39;t felt empowered enough yet to really want to use either of these for actual $workStuff yet. Oddly enough I&#39;ve reached for another Perl-ish language for this that I initially only cared about for its killer app.&#xA;&#xA;If there&#39;s one thing that kinda struck me as odd about Ruby it&#39;s how variables are &#34;defined.&#34; Honestly I have a tendancy to spend hours of trial an error when learning new things to spare me the ten minutes it takes to just read the documentation but I got to thinking about it and realized I had a knowledge gap in what makes a variable &#34;defined&#34;? If I declare a variable like so:&#xA;&#xA;$ re.pl&#xA;$ my $string = &#39;ayy... lmao&#39;;&#xA;&#xA;I&#39;ve declared and defined the variable. But there&#39;s this other thing I&#39;ve been doing without ever giving it much thought:&#xA;&#xA;$ my ($string, %hash, @list);&#xA;&#xA;So I just defined 3 different variables at once right? Turns out that is not the case as I learned in, of all things, a JS tutorial. I&#39;ve declared these three variables but they are infact, undefined:&#xA;&#xA;$ node&#xA;Welcome to Node.js v14.17.0.&#xA;Type &#34;.help&#34; for more information.&#xA;  let string, hash, list;&#xA;undefined&#xA;  string&#xA;undefined&#xA;  undeclaredVar&#xA;Uncaught ReferenceError: undeclaredVar is not defined&#xA;&#xA;I recognized this as undef in Perl:&#xA;&#xA;$ re.pl&#xA;$ my ($string, %hash, @list);&#xA;$ use Data::Dumper;&#xA;$ Dumper($string);&#xA;$VAR1 = undef;&#xA;&#xA;Cool. So there&#39;s declared variables and then there&#39;s defined variables. But the thing about Ruby is there&#39;s no let or my keywords. The way you define a variable in Ruby reminds me more of bash:&#xA;&#xA;$ irb&#xA;irb(main):001:0  string = &#39;ayy... lmao&#39;&#xA;=  &#34;ayy... lmao&#34;&#xA;&#xA;But what if I just want to &#34;declare&#34; a variable but not &#34;define&#34; it? The best solution I&#39;ve found so far goes like this:&#xA;&#xA;irb(main):001:0  string = nil&#xA;=  nil&#xA;&#xA;This is actually different than:&#xA;&#xA;irb(main):001:0  string = &#39;&#39;&#xA;=  &#34;&#34;&#xA;&#xA;Coincidentally (or perhaps not, I&#39;m using a filler word) only false and nil will evaluate as false in Ruby:&#xA;&#xA;irb(main):001:0  string = &#39;&#39;&#xA;=  &#34;&#34;&#xA;irb(main):002:0  puts &#34;ayy... lmao&#34; if string&#xA;ayy... lmao&#xA;=  nil&#xA;&#xA;That means this madness is real:&#xA;&#xA;irb(main):003:0  puts &#34;ayy... lmao&#34; if 0&#xA;ayy... lmao&#xA;=  nil&#xA;&#xA;If only Ruby had let or my so I could declare but not define variables... Wait. What if I did something like... ?:&#xA;&#xA;irb(main):001:0  string, hash, list = nil&#xA;=  nil&#xA;irb(main):002:0  puts &#34;ayy... lmao&#34; if list&#xA;=  nil&#xA;irb(main):003:0  puts &#34;ayy... lmao&#34; if undeclaredVar&#xA;(irb):3:in main&#39;: undefined local variable or method undeclaredVar&#39; for main:Object (NameError)&#xA;&#x9;from /usr/share/gems/gems/irb-1.3.5/exe/irb:11:in `top (required)&#39;&#xA;&#x9;from /usr/bin/irb:23:in `load&#39;&#xA;&#x9;from /usr/bin/irb:23:in `main&#39;&#xA;&#xA;Ultimately it seems Ruby gives me all the roap I need to hang myself. It just doesn&#39;t look right to me because I&#39;ve grown fond of let and/or my. One could write their entire web backend and frontend both in JS but I&#39;d rather use Ruby on Rails in my backend. Or in theory at least. I learned Ruby to learn Rails but I can&#39;t yet write anything useful with Rails. But with plain Ruby I can do some neat system-side stuff as I would with Perl. My homepage uses Perl on the backend because I already knew how to do it with Perl. And my frontend is more JS than CSS because I actually like JS the more I learn about it.&#xA;&#xA;But I really need to stop dicking around and learn Rails already. I wrote a blog post for the first time in months to put off reading another chapter of my Rails book. On the brightside I won&#39;t have to learn SQL if I can master ActiveRecord. How nice would it be to just do everything in one language? SQL (pronounced like sequel) must be a conspiracy to sell more CS degrees. Or Oracle licenses.&#xA;&#xA;I should probably just learn SQL so I can finally learn Rails.&#xA;&#xA;Dan B&#xA;&#xA;perl&#xA;raku&#xA;javascript&#xA;ruby&#xA;&#xA;Homepage&#xD;&#xA;Code&#xD;&#xA;Mail&#xD;&#xA;Social&#xD;&#xA;Chat&#xD;&#xA;]]&gt;</description>
      <content:encoded><![CDATA[<p>I&#39;ve put forth some effort recently towards exploring some other Perl-ish but not-Perl scripting languages to (I hope) reinforce my resume. I love Perl but if I hope to become a real professional with my programming then I think it behooves me to branch out a bit. I haven&#39;t strayed far from Perl however as the languages that have intrigued me the most so far have been <a href="https://raku.org/">Raku</a> and <a href="https://nodejs.org/en/">Javascript</a>.</p>

<p>What is or isn&#39;t “Perl-ish” I suppose is subjective but I think these two have a syntax I can find some familiarity with. I still haven&#39;t felt empowered enough yet to really want to use either of these for actual <code>$workStuff</code> yet. Oddly enough I&#39;ve reached for another Perl-ish language for this that I initially only cared about for its <a href="https://rubyonrails.org/">killer app</a>.</p>

<p>If there&#39;s one thing that kinda struck me as odd about <a href="https://www.ruby-lang.org/en/">Ruby</a> it&#39;s how variables are “defined.” Honestly I have a tendancy to spend hours of trial an error when learning new things to spare me the ten minutes it takes to <a href="https://en.wikipedia.org/wiki/RTFM">just read the documentation</a> but I got to thinking about it and realized I had a knowledge gap in what makes a variable “defined”? If I declare a variable like so:</p>

<pre><code>$ re.pl
$ my $string = &#39;ayy... lmao&#39;;
</code></pre>

<p>I&#39;ve declared and defined the variable. But there&#39;s this other thing I&#39;ve been doing without ever giving it much thought:</p>

<pre><code>$ my ($string, %hash, @list);
</code></pre>

<p>So I just defined 3 different variables at once right? Turns out that is not the case as I learned in, of all things, a <a href="https://www.javascripttutorial.net/javascript-variables/">JS tutorial</a>. I&#39;ve <em>declared</em> these three variables but they are infact, <em>undefined</em>:</p>

<pre><code>$ node
Welcome to Node.js v14.17.0.
Type &#34;.help&#34; for more information.
&gt; let string, hash, list;
undefined
&gt; string
undefined
&gt; undeclaredVar
Uncaught ReferenceError: undeclaredVar is not defined
</code></pre>

<p>I recognized this as <code>undef</code> in Perl:</p>

<pre><code>$ re.pl
$ my ($string, %hash, @list);
$ use Data::Dumper;
$ Dumper($string);
$VAR1 = undef;
</code></pre>

<p>Cool. So there&#39;s <em>declared</em> variables and then there&#39;s <em>defined</em> variables. But the thing about Ruby is there&#39;s no <code>let</code> or <code>my</code> keywords. The way you define a variable in Ruby reminds me more of <code>bash</code>:</p>

<pre><code>$ irb
irb(main):001:0&gt; string = &#39;ayy... lmao&#39;
=&gt; &#34;ayy... lmao&#34;
</code></pre>

<p>But what if I just want to “declare” a variable but not “define” it? The best solution I&#39;ve found so far goes like this:</p>

<pre><code>irb(main):001:0&gt; string = nil
=&gt; nil
</code></pre>

<p>This is actually different than:</p>

<pre><code>irb(main):001:0&gt; string = &#39;&#39;
=&gt; &#34;&#34;
</code></pre>

<p>Coincidentally (or perhaps not, I&#39;m using a filler word) only <code>false</code> and <code>nil</code> will evaluate as false in Ruby:</p>

<pre><code>irb(main):001:0&gt; string = &#39;&#39;
=&gt; &#34;&#34;
irb(main):002:0&gt; puts &#34;ayy... lmao&#34; if string
ayy... lmao
=&gt; nil
</code></pre>

<p>That means this madness is real:</p>

<pre><code>irb(main):003:0&gt; puts &#34;ayy... lmao&#34; if 0
ayy... lmao
=&gt; nil
</code></pre>

<p>If only Ruby had <code>let</code> or <code>my</code> so I could declare but not define variables... Wait. What if I did something like... ?:</p>

<pre><code>irb(main):001:0&gt; string, hash, list = nil
=&gt; nil
irb(main):002:0&gt; puts &#34;ayy... lmao&#34; if list
=&gt; nil
irb(main):003:0&gt; puts &#34;ayy... lmao&#34; if undeclaredVar
(irb):3:in `&lt;main&gt;&#39;: undefined local variable or method `undeclaredVar&#39; for main:Object (NameError)
	from /usr/share/gems/gems/irb-1.3.5/exe/irb:11:in `&lt;top (required)&gt;&#39;
	from /usr/bin/irb:23:in `load&#39;
	from /usr/bin/irb:23:in `&lt;main&gt;&#39;
</code></pre>

<p>Ultimately it seems Ruby gives me all the roap I need to hang myself. It just doesn&#39;t look right to me because I&#39;ve grown fond of <code>let</code> and/or <code>my</code>. One could write their entire web backend and frontend both in JS but I&#39;d rather use Ruby on Rails in my backend. Or in theory at least. I learned Ruby to learn Rails but I can&#39;t yet write anything useful with Rails. But with plain Ruby I can do some neat <a href="https://codeberg.org/swaggboi/ocsp_verify">system-side stuff</a> as I would with Perl. My homepage uses Perl on the backend because I already <a href="https://mojolicious.org/">knew how to do it</a> with Perl. And my frontend is more JS than CSS because I actually like JS the more I learn about it.</p>

<p>But I really need to stop dicking around and learn Rails already. I wrote a blog post for the first time in months to put off reading another chapter of my Rails book. On the brightside I won&#39;t have to learn SQL if I can master <a href="https://guides.rubyonrails.org/active_record_basics.html">ActiveRecord</a>. How nice would it be to just do everything in one language? SQL (pronounced like <a href="https://en.wikipedia.org/wiki/SQL#Standardization_history">sequel</a>) must be a conspiracy to sell more CS degrees. Or Oracle licenses.</p>

<p>I should probably just learn SQL so I can finally learn Rails.</p>

<p>Dan B</p>

<p><a href="https://blog.swagg.net/tag:perl" class="hashtag"><span>#</span><span class="p-category">perl</span></a>
<a href="https://blog.swagg.net/tag:raku" class="hashtag"><span>#</span><span class="p-category">raku</span></a>
<a href="https://blog.swagg.net/tag:javascript" class="hashtag"><span>#</span><span class="p-category">javascript</span></a>
<a href="https://blog.swagg.net/tag:ruby" class="hashtag"><span>#</span><span class="p-category">ruby</span></a></p>
<ul><li><a href="https://www.swagg.net">Homepage</a></li>
<li><a href="https://codeberg.org/swaggboi">Code</a></li>
<li><a href="mailto:swaggboi@slackware.uk">Mail</a></li>
<li><a href="https://eattherich.club/@swaggboi">Social</a></li>
<li><a href="https://discord.gg/6MXVZKU">Chat</a></li></ul>
]]></content:encoded>
      <guid>https://blog.swagg.net/variables-declared</guid>
      <pubDate>Fri, 17 Sep 2021 09:21:27 +0000</pubDate>
    </item>
  </channel>
</rss>