<?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: Ilya Sher</title>
    <description>The latest articles on DEV Community by Ilya Sher (@ilya_sher_prog).</description>
    <link>https://dev.to/ilya_sher_prog</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%2F344035%2F66e33b8f-4e0f-401d-a9f9-ead7f1e4d1e9.jpg</url>
      <title>DEV Community: Ilya Sher</title>
      <link>https://dev.to/ilya_sher_prog</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ilya_sher_prog"/>
    <language>en</language>
    <item>
      <title>“Use Dumb Shell, don’t Reinvent the Wheel”</title>
      <dc:creator>Ilya Sher</dc:creator>
      <pubDate>Sat, 04 Jan 2020 15:05:40 +0000</pubDate>
      <link>https://dev.to/ilya_sher_prog/use-dumb-shell-don-t-reinvent-the-wheel-4b5j</link>
      <guid>https://dev.to/ilya_sher_prog/use-dumb-shell-don-t-reinvent-the-wheel-4b5j</guid>
      <description>&lt;h2&gt;
  
  
  Opening Rant
&lt;/h2&gt;

&lt;p&gt;You don’t hear one developer saying “Just use Notepad” to a colleague with argumentation that goes roughly like this:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Why are you using this horrible &lt;a href="https://code.visualstudio.com"&gt;Visual Studio Code&lt;/a&gt;? It has built-in debugger! No!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.jetbrains.com"&gt;JetBrains&lt;/a&gt; IDEs? No! They do too much! They are so into the code!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.vim.org"&gt;Vim&lt;/a&gt;? &lt;a href="https://www.gnu.org/software/emacs/"&gt;Emacs&lt;/a&gt;? Not pure enough! Who needs that stupid syntax highlighting?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Keep text editing pure! Any semantic understanding by the text editor is undesirable, other programs should handle that. You don’t want to complicate the text editor.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Developers are not saying that because &lt;strong&gt;user experience and productivity matter&lt;/strong&gt;. Yet, “Use Dumb Shell” is considered to be an acceptable opinion. Is that so common that people fall on their heads so hard (alternatively, did not give it any thought)? WTF?&lt;/p&gt;

&lt;p&gt;The solution (shell) should be as simple as possible but not simpler than possible. &lt;strong&gt;Current shells are simpler than required by good user experience. Wrong trade-off.&lt;/strong&gt; Keeping something simple is important but not more important than the outcomes.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://www.workcompass.com/"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--psxeYhqs--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://ilyasherdotorg.files.wordpress.com/2020/01/too_busy_to_improve_-_performance_management_-_square_wheels-1.png%3Fw%3D1024" alt=""&gt;&lt;/a&gt;&lt;em&gt;Source: &lt;a href="https://www.flickr.com/photos/toddle_email_newsletters/15413603567/" rel="nofollow"&gt;&lt;/a&gt;&lt;a href="https://www.flickr.com/photos/toddle_email_newsletters/15413603567/"&gt;https://www.flickr.com/photos/toddle_email_newsletters/15413603567/&lt;/a&gt;&lt;br&gt;Image is a link to &lt;a href="http://www.workcompass.com/" rel="nofollow"&gt;&lt;/a&gt;&lt;a href="http://www.workcompass.com/"&gt;http://www.workcompass.com/&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Additional food for thought:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Why use a car when bicycle is so much simpler?&lt;/li&gt;
&lt;li&gt;Why use electricity when fire is so much simpler?&lt;/li&gt;
&lt;li&gt;Why have water in your house when a wells are so much simpler?&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Background
&lt;/h2&gt;

&lt;p&gt;I was doing consulting. The usual suspects: AWS, bash, Python, &lt;a href="https://ilya-sher.org/2017/06/09/please-dont-use-puppet/"&gt;Puppet&lt;/a&gt;, Chef. Got to Terraform later. I had and I am still having subpar experiences with these tools. Anything I wanted to do, was overly burdensome, complicated and full of &lt;a href="https://github.com/terraform-providers/terraform-provider-aws/issues/3209"&gt;pitfalls&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Since I can’t attempt to fix everything, I picked the worst offender and started working on the alternative programming language and shell combo. The motivating opinion is that &lt;strong&gt;Ops have no good programming language nor adequate shell.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The &lt;a href="https://ilya-sher.org/2017/10/10/why-i-have-no-favorite-programming-language/"&gt;absence of good programming language for ops was covered in another post&lt;/a&gt;. In this post I will cover some of the things that are wrong with the interactive shell.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Shell
&lt;/h2&gt;

&lt;p&gt;The dominant player is &lt;code&gt;bash&lt;/code&gt;. It didn’t change much for decades: you type commands and get a dump of text on your screen. Most of the alternatives are essentially the same in this regard, for decades.&lt;/p&gt;

&lt;p&gt;Is this because of the brilliant design? I would ask: which design? &lt;a href="https://stackoverflow.com/questions/78497/design-patterns-or-best-practices-for-shell-scripts"&gt;This&lt;/a&gt;? Quoting:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;I wrote quite complex shell scripts and my first suggestion is “don’t”. The reason is that is fairly easy to make a small mistake that hinders your script, or even make it dangerous.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  The “Dumb Shell” Approach
&lt;/h2&gt;

&lt;p&gt;In this post I would like to address common thought that I hear from people regarding &lt;a href="https://ngs-lang.org/"&gt;Next Generation Shell&lt;/a&gt;, a new programming language and a shell that I’m working on. Note that other shells which are more advanced than POSIX shells also get this. &lt;a href="https://lobste.rs/s/gert97/section_syntax_next_generation_shell#c_q6ky8i"&gt;Quoting @cup from lobste.rs&lt;/a&gt;:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Wouldnt it be better to just have a dumb shell, that can call programs to do heavy lifting (read: programming languages). This way you have a “division of labor”. Shell works best for launching executables, and programming languages work best for handling data structures and algorithms.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;No, it would not. I refuse to accept under-powered tools.&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Dumbness is Fundamental Flaw
&lt;/h2&gt;

&lt;p&gt;The “dumb shell” has no semantic understanding and doesn’t care about programs’ inputs nor outputs. Let’s see how it plays out.&lt;/p&gt;

&lt;p&gt;Today, &lt;strong&gt;“Understanding” of programs’ inputs&lt;/strong&gt; is covered by &lt;a href="https://www.gnu.org/software/bash/manual/html_node/Programmable-Completion.html"&gt;completion&lt;/a&gt;. Completion was added because “dumb shell” had horrible user experience. It’s slightly better now when the shell “understands” programs’ input to some degree. To some people completion is a scope creep. I think of it as better user experience and productivity gain.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;“Understanding” of programs’ outputs?&lt;/strong&gt; We are not there yet. It also seems that interacting with objects on the screen is too novel of an idea for the shell. Considering how much time this idea is out there: WTF?&lt;/p&gt;

&lt;p&gt;Let’s see how this “dumbness” manifests as bad user experience even at the very basic, “intended” functionality:&lt;/p&gt;

&lt;h2&gt;
  
  
  Programs’ Output – Size
&lt;/h2&gt;

&lt;p&gt;Do you know of any real world scenario when a human supposed to go over 10K lines on the screen? I mean just sit there and read it. Let me know. I’ve never seen such use case.&lt;/p&gt;

&lt;p&gt;The shell is dumb, the shell “does not intervene” in programs’ outputs. Sounds good until you get unlimited number of lines dumped on your screen.&lt;/p&gt;

&lt;p&gt;“Should have used &lt;code&gt;less&lt;/code&gt;” you think later. Right. What if you forgot? The buffer is now filled with useless output and you can’t see outputs of previous programs. Are you being punished? No, just nobody cared about the UX. Alternatively, “it would be to complicated to implement”.&lt;/p&gt;

&lt;h2&gt;
  
  
  Programs’ Output – All Mixed
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Want to know what’s on your screen is stdout and what is stderr? Well… you can’t. Your shell is dumb, it doesn’t deal with things like that.&lt;/li&gt;
&lt;li&gt;Want to know from which program the output came from? Nope. Some programs cope with that to some degree by prepending their name to error messages: &lt;code&gt;ls xxx&lt;/code&gt; gives you &lt;code&gt;ls: xxx: No such file or directory&lt;/code&gt;. What a wonderful strategy! Keep the shell dumb and &lt;strong&gt;push the burden to all the programs&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;You can’t type because some background job is continuing to dump text on the screen where you are trying to work? Too bad, should have used redirection because guess what … you shell doesn’t handle that either… and you can’t add redirection after the program is running; again not shell’s business.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Programs’ Output – Semantic Understanding
&lt;/h2&gt;

&lt;p&gt;You just typed &lt;code&gt;aws ec2 describe instances --filters ...&lt;/code&gt; and now you have some output.&lt;/p&gt;

&lt;p&gt;You now see on your screen instance you would like to stop. The ID of the instance is right in front of your face. Now you type &lt;code&gt;aws ec2 stop-instances --instance-ids&lt;/code&gt;. You would like to append the instance ID that you see on the screen. Nope. Your shell doesn’t do that. Too dumb. Select with the mouse and paste, because f*ck you!&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Side note: amazing AWS engineers &lt;a href="https://ilya-sher.org/2016/05/06/aws-cli-inhuman-output-and-what-i-suggest/"&gt;did not include any human readable output format&lt;/a&gt; so you get JSON dumped on your screen (or any other format which is still non-human-compatible).&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Let’s imagine for a moment that the command output had some semantic meaning to the shell.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The shell would display the output as a table.&lt;/li&gt;
&lt;li&gt;The table would be interactive (interactive output, what a heresy!) and one could navigate with arrow keys and have a shortcut for copy/paste the current cell value to the command line (for completion).&lt;/li&gt;
&lt;li&gt;You could interact with the objects in the table with the mouse (very new concept, another heresy for the shell).&lt;/li&gt;
&lt;li&gt;How about instead of typing &lt;code&gt;aws ec2 stop-instances --instance-ids&lt;/code&gt; you navigate to the correct line, press enter, choose “stop” from the menu and the command is constructed for you? &lt;code&gt;aws ec2 stop-instances --instance-ids i-123...&lt;/code&gt; amazing, ha? Well, your shell can’t do that.&lt;/li&gt;
&lt;li&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;blockquote&gt;
&lt;p&gt;Meaning, do you speak it mo***er?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;How about after performing operations using the UI you would get as per your choice one of the below snippets which would re-create the operation:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;CLI commands&lt;/li&gt;
&lt;li&gt;CloudFormation tempalte&lt;/li&gt;
&lt;li&gt;Terraform “code”&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Solution: UI for the Shell
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;Suppose I agree for a second, what do you suggest?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://github.com/ngs-lang/ngs/wiki/UI-Design"&gt;https://github.com/ngs-lang/ngs/wiki/UI-Design&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I personally don’t see how the described features could be implemented as external programs, keeping the shell “dumb”.&lt;/p&gt;

&lt;h2&gt;
  
  
  We Can Do Better Today
&lt;/h2&gt;

&lt;p&gt;The reality has changed. What was once amazing is subpar by today’s standards. The world outside of the shell moved forward while the shell stayed almost the same. Brilliant design? Brilliant what?&lt;/p&gt;

&lt;p&gt;Let’s move this industry together from the stone age of bash shell to the bronze age of something a bit less subpar – &lt;a href="https://ngs-lang.org"&gt;Next Generation Shell&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Closing Rant
&lt;/h2&gt;

&lt;p&gt;Imaginary UNIX people:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;We wanted to separate things because they are semantically different so we split the things into stdout and stderr. Well… stderr was is actually for everything that is not stdout.&lt;/p&gt;

&lt;p&gt;One bit of metadata (stdout vs stderr) for semantic meaning of the output should be enough for everyone forever. Well… at least it’s simple for us to implement.&lt;/p&gt;

&lt;p&gt;One of the greatest misnomers: stderr. Should be stddmp – dumpster for everything that is not stdout: logs, warnings, errors, …&lt;a href="https://twitter.com/hashtag/unix?src=hash&amp;amp;ref_src=twsrc%5Etfw"&gt;#unix&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;— Ilya Sher (&lt;a class="comment-mentioned-user" href="https://dev.to/ilya_sher_prog"&gt;@ilya_sher_prog&lt;/a&gt;
) &lt;a href="https://twitter.com/ilya_sher_prog/status/1191392071036395520?ref_src=twsrc%5Etfw"&gt;November 4, 2019&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;




&lt;p&gt;Update: &lt;a href="https://lobste.rs/s/b8xanw/use_dumb_shell_don_t_reinvent_wheel"&gt;discussion on lobste.rs&lt;/a&gt;&lt;/p&gt;

</description>
      <category>bashingbash</category>
      <category>ngs</category>
      <category>rant</category>
      <category>systemadministratio</category>
    </item>
    <item>
      <title>Section Syntax – Next Generation Shell</title>
      <dc:creator>Ilya Sher</dc:creator>
      <pubDate>Mon, 21 Oct 2019 11:34:15 +0000</pubDate>
      <link>https://dev.to/ilya_sher_prog/section-syntax-next-generation-shell-emg</link>
      <guid>https://dev.to/ilya_sher_prog/section-syntax-next-generation-shell-emg</guid>
      <description>&lt;h2&gt;
  
  
  Problem
&lt;/h2&gt;

&lt;p&gt;Using comments to denote code sections feels like subpar solution.&lt;/p&gt;

&lt;p&gt;One starts with something like the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// workaround for API stupidity
if(result === null) {
  result = [];
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Then somebody adds another bit so it becomes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// workaround for API stupidity
if(result === null) {
  result = [];
}
if(result === [1]) {
  foo();
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Now you are not sure whether the second &lt;code&gt;if&lt;/code&gt; is still workaround. You don’t want that. What I usually do in this situation and recommend to others is clearly mark start and end:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// workaround for API stupidity - start
if(result === null) {
  result = [];
}
// workaround for API stupidity - end

if(result === [1]) {
  foo();
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Now you have duplicated text and subpar programming experience.&lt;/p&gt;

&lt;h2&gt;
  
  
  Solution
&lt;/h2&gt;

&lt;p&gt;Today (2019-10-21) I have added &lt;code&gt;section&lt;/code&gt; syntax (to &lt;code&gt;dev&lt;/code&gt; branch) to the language I am working on, &lt;a href="https://ngs-lang.org/"&gt;Next Generation Shell&lt;/a&gt;. I think it solves the problem in a clean way, consistent with syntax and semantics of the language:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;section "workaround for API stupidity" {
  if result is Null {
    result = []
  }
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



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

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;result = section "Use algorithm X to calculate blah" {
  a = 1
  b = 2
  a + b
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;In future, for programmer’s convenience backtraces could be augmented with sections’ names.&lt;/p&gt;

&lt;h2&gt;
  
  
  Update: discussion
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;a href="https://www.reddit.com/r/ProgrammingLanguages/comments/dkzcls/section_syntax_next_generation_shell/"&gt;https://www.reddit.com/r/ProgrammingLanguages/comments/dkzcls/section_syntax_next_generation_shell/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://lobste.rs/s/gert97/section_syntax_next_generation_shell"&gt;https://lobste.rs/s/gert97/section_syntax_next_generation_shell&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;




&lt;p&gt;Have a nice week!&lt;/p&gt;

</description>
      <category>ngs</category>
      <category>programming</category>
    </item>
    <item>
      <title>On Information Loss in Software</title>
      <dc:creator>Ilya Sher</dc:creator>
      <pubDate>Sat, 18 May 2019 17:35:18 +0000</pubDate>
      <link>https://dev.to/ilya_sher_prog/on-information-loss-in-software-ch6</link>
      <guid>https://dev.to/ilya_sher_prog/on-information-loss-in-software-ch6</guid>
      <description>&lt;p&gt;“Information Loss” is a way to look at the world. The topic is very broad. This blog post will focus on information loss during development and operation of computer software.&lt;/p&gt;

&lt;p&gt;This post discusses why Information Loss is bad and gives some examples.&lt;/p&gt;

&lt;p&gt;My hope is that after reading this post, you will be able to spot information loss more easily. This should help you avoiding information loss, eliminating the need for costly information recovery phase. Some examples include specific recommendations how to avoid that particular case of information loss.&lt;/p&gt;

&lt;h2&gt;
  
  
  Information Loss Definition
&lt;/h2&gt;

&lt;p&gt;Information Loss for the purposes of this blog is the situation where information &lt;code&gt;I&lt;/code&gt; is available and is easily accessible at point in time &lt;code&gt;t1&lt;/code&gt; but later, when it’s needed at point in time &lt;code&gt;t2&lt;/code&gt;, it is either not available or not easily accessible.&lt;/p&gt;

&lt;p&gt;The post will present various categories of information loss with examples. The list is not exhaustive; it’s not meant to be. The intention is to give some examples to help you get the feel and start looking at things from the information loss perspective.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Information Loss is Bad?
&lt;/h2&gt;

&lt;p&gt;In many cases of Information Loss, the missing information can be recovered but that requires resources to be thrown at the issue (time and/or money). That is the situation I would like to help you to avoid.&lt;/p&gt;

&lt;h2&gt;
  
  
  Between the Head and the Code
&lt;/h2&gt;

&lt;p&gt;When working on software, the first place the information loss occurs is when the programmer translates thoughts into code. Information loss at this stage will manifest itself as increased &lt;a href="https://www.osnews.com/story/19266/wtfsm/"&gt;WTF-per-minute&lt;/a&gt; during code review or just code reading. Each time the code is read, there will be additional cognitive load while the reader reconstructs the programmer’s idea behind the code.&lt;/p&gt;

&lt;p&gt;I have identified two main causes for information loss at the head-to-code stage:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Programmer’s fault&lt;/li&gt;
&lt;li&gt;Programming language imposed&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Information Loss due to Programmer’s Fault
&lt;/h3&gt;

&lt;p&gt;The more a programmer is experienced, the less likely is the occurrence of information loss at this stage.&lt;/p&gt;

&lt;h4&gt;
  
  
  Misnamed Variable
&lt;/h4&gt;

&lt;p&gt;In programmers head: &lt;code&gt;number of servers running the ETL task&lt;/code&gt;. Name of the variable in the code: &lt;code&gt;n&lt;/code&gt;. WTFs at code review – guaranteed.&lt;/p&gt;

&lt;h4&gt;
  
  
  Misnamed Function
&lt;/h4&gt;

&lt;p&gt;I’m pretty sure &lt;code&gt;getUser()&lt;/code&gt; should not update say last name of the user in database. Such naming is criminal but unfortunately I’ve seen code similar to that.&lt;/p&gt;

&lt;h4&gt;
  
  
  Use of Magic Numbers
&lt;/h4&gt;

&lt;p&gt;&lt;code&gt;if (result == 126) ...&lt;/code&gt;. The person who wrote &lt;code&gt;126&lt;/code&gt; knew what that number means. The person reading the code will need to spend time checking what that number means. One should use constants or enums instead: &lt;code&gt;if (result == NOT_EXECUTABLE) ...&lt;/code&gt;.&lt;/p&gt;

&lt;h4&gt;
  
  
  Missing Comments in Code
&lt;/h4&gt;

&lt;p&gt;Most important comments are about why something is being done as opposed to how. If ones code is in a high-level language and of a good quality, it’s a rare occasion one needs to comment about what or how something is being done. On the other hand comments like “Working around API bug: it returns false instead of empty array” are very valuable.&lt;/p&gt;

&lt;h4&gt;
  
  
  Incorrect Usage of Data Types
&lt;/h4&gt;

&lt;p&gt;A list of people, for example, is not just a list. It has semantic meaning. It’s much easier to understand a program when correct types are used for the data. Java has &lt;a href="https://docs.oracle.com/javase/tutorial/java/generics/index.html"&gt;generics&lt;/a&gt; to convey such information, for example &lt;code&gt;List&amp;lt;Person&amp;gt;&lt;/code&gt;. Some other languages have type systems that are powerful enough to convey such information too.&lt;/p&gt;

&lt;h3&gt;
  
  
  Programming Language Imposed Information Loss
&lt;/h3&gt;

&lt;p&gt;Limitations of programming languages lead to less expressive code because the idea in programmer’s head can not be expressed in a straightforward manner. The readers of the code will struggle more (read waste time) to understand the code.&lt;/p&gt;

&lt;h4&gt;
  
  
  Unnamed Function Parameters
&lt;/h4&gt;

&lt;p&gt;bash and perl5 (not sure about perl5 anymore, there was something experimental) do not have the syntax for specifying function parameter names. This makes the code less expressive. Sometimes programmers will do “the right thing”:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;myfunc() { local target\_file=$1 ...}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;… but when they don’t, you finish with unnamed parameter, wondering what it could mean:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;myfunc() { if [[-f $1]];then ... fi}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Is that a file to generate or a source file? You don’t know, you have to read on in &lt;code&gt;myfunc&lt;/code&gt; hoping for the answer.&lt;/p&gt;

&lt;p&gt;Recommendation: even if your language does not support named parameters, emulate them.&lt;/p&gt;

&lt;h4&gt;
  
  
  Expansion of Strings into Several Arguments (bash)
&lt;/h4&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;rm $x
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Does that remove one file or several? What the programmer meant? You simply don’t know. It depends on the &lt;em&gt;contents&lt;/em&gt; of &lt;code&gt;x&lt;/code&gt;, which is typically split into arguments by spaces. You are lucky if you can deduce from the variable name whether it’s one or several files.&lt;/p&gt;

&lt;p&gt;From today’s perspective this is just bad design. Back at the day I guess it was the most practical way to implement arrays.&lt;/p&gt;

&lt;p&gt;Recommendation: use one of the two alternatives blow and do not use &lt;code&gt;rm $x&lt;/code&gt; form.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Single file: &lt;code&gt;rm "$x"&lt;/code&gt; (proper quoting)&lt;/li&gt;
&lt;li&gt;Multiple files: &lt;code&gt;rm "${my_files[@]}"&lt;/code&gt; (&lt;a href="https://www.tldp.org/LDP/Bash-Beginners-Guide/html/sect_10_02.html"&gt;bash arrays&lt;/a&gt;)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Side note: this “feature” caused so much pain over the years when &lt;code&gt;x&lt;/code&gt; would contain a spaces by accident. Even when &lt;code&gt;x&lt;/code&gt; is meant to be used as an array, &lt;em&gt;elements&lt;/em&gt; of that array can also contain spaces by accident.&lt;/p&gt;

&lt;h4&gt;
  
  
  Error Handling
&lt;/h4&gt;

&lt;p&gt;In languages that do not support exceptions (bash, C, Go), the programmer is forced into one of two situations:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Write incorrect code that ignores the errors (on purpose or by mistake, go figure which one)&lt;/li&gt;
&lt;li&gt;Write verbose code that handles the errors. When the code handles every possible error, it becomes cluttered with error handling and it takes more time to understand the code. That’s the case where information loss occurs because the reader is overwhelmed by the code.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In &lt;a href="////ngs-lang.org/"&gt;NGS&lt;/a&gt;, since typical use case is scripting, I wanted to have the option for the code to be concise. That rules out returning status code along with the result because the caller is then forced to check it. It does make more sense for NGS to have exceptions and for scripts to decide whether to catch them or let the whole script terminate with error because of an uncaught exception.&lt;/p&gt;

&lt;h4&gt;
  
  
  Unordered Hash/Map/dict Data Structure
&lt;/h4&gt;

&lt;p&gt;Hash data structure is implemented in a non-order-preserving manner in some languages. That means that the programmer can not express the intention freely in situations where the order of key/value pairs is important. That pushes towards less readable code as the programmer fights the language by implementing his/her own ordered dictionary.&lt;/p&gt;

&lt;p&gt;Information loss in this case is again losing the sight of programmer’s intention.&lt;/p&gt;

&lt;p&gt;Fortunately many modern languages solved the issue by now:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Python solved this issue by adding &lt;a href="https://docs.python.org/2/library/collections.html#collections.OrderedDict"&gt;OrderedDict&lt;/a&gt; in Python 2.7.&lt;/li&gt;
&lt;li&gt;Ruby &lt;code&gt;Hash&lt;/code&gt; became &lt;a href="https://www.igvita.com/2009/02/04/ruby-19-internals-ordered-hash/"&gt;ordered since version 1.9&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;JavaScript has &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map"&gt;Map type&lt;/a&gt;. The older &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object"&gt;Object type&lt;/a&gt; documentation does not mention anything about the order so I assume it was not guaranteed.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Recommendation: check whether your language has the data structure you really want to use, either built-in or in a library.&lt;/p&gt;

&lt;h4&gt;
  
  
  Limited Data Structures (bash)
&lt;/h4&gt;

&lt;p&gt;Working with data structures in bash results more or less convoluted code, depending on the data structures one need to work with. This is direct consequence of bash supporting exactly three data structures:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Scalar (strings which can sometimes be treated as numbers or arrays)&lt;/li&gt;
&lt;li&gt;Array&lt;/li&gt;
&lt;li&gt;Associative array&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These data structures can &lt;em&gt;not&lt;/em&gt; be nested.&lt;/p&gt;

&lt;p&gt;The result is much less readable code where the original intent of the author is harder to recover as opposed to data manipulation in other popular languages (Python, Ruby, etc).&lt;/p&gt;

&lt;p&gt;Recommendation: consider using other languages besides bash for heavy data manipulation code.&lt;/p&gt;

&lt;h4&gt;
  
  
  Absence of non-nullable Types
&lt;/h4&gt;

&lt;p&gt;In some languages there is no straightforward way to specify non-nullable parameters. The programmers are then required to check whether each passed parameter is &lt;code&gt;null&lt;/code&gt;. That results more boilerplate code. Let’s look at the following bit of Java code from the popular Apache Flink project:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// flink/flink-java/src/main/java/org/apache/flink/api/java/DataSet.javaprotected DataSet(ExecutionEnvironment context, TypeInformation&amp;lt;T&amp;gt; typeInfo) { if (context == null) { throw new NullPointerException("context is null"); } if (typeInfo == null) { throw new NullPointerException("typeInfo is null"); } this.context = context; this.type = typeInfo;}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h4&gt;
  
  
  Asynchronous Computing Model (JavaScript)
&lt;/h4&gt;

&lt;p&gt;In JavaScript for example, progressively more readable code uses:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Glossary/Callback_function"&gt;Callbacks&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise"&gt;Promises&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function"&gt;async/await&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Again, information loss occurs when programmer’s intention is lost in the code because the code looks like a big struggle against asynchronicity and the language.&lt;/p&gt;

&lt;p&gt;Recommendation: prefer &lt;code&gt;async/await&lt;/code&gt; over Promises and prefer Promises over callbacks.&lt;/p&gt;

&lt;h4&gt;
  
  
  Loss of semantic information (JavaScript)
&lt;/h4&gt;

&lt;p&gt;&lt;code&gt;console.log()&lt;/code&gt; vs &lt;code&gt;debug('my-module')('my message')&lt;/code&gt; in JavaScript. When a programmer chooses to use &lt;code&gt;log()&lt;/code&gt; instead of &lt;code&gt;debug()&lt;/code&gt;, loss of semantic information occurs. In this case it means more effort in finding the needed information in the output as opposed to simpler turning on and off the relevant debug sections.&lt;/p&gt;

&lt;p&gt;Recommendation: use the &lt;a href="https://www.npmjs.com/package/debug"&gt;debug&lt;/a&gt; module.&lt;/p&gt;

&lt;h2&gt;
  
  
  Information Loss at Runtime
&lt;/h2&gt;

&lt;p&gt;Information loss at runtime will manifest as harder debugging.&lt;/p&gt;

&lt;h4&gt;
  
  
  Empty Catch Clause
&lt;/h4&gt;

&lt;p&gt;&lt;em&gt;This is borderline criminal&lt;/em&gt;. Except for very few cases when empty catch clause is really appropriate, by placing empty catch clause in the code, you are setting up a bomb for your colleagues. They will pay with their time, tears and mental health, not to mention they will be hating you. Where is the information loss? At the time the exception is generated, there is useful information about what happened. Empty catch clause loses that information. Result: hard to find exceptions and their causes.&lt;/p&gt;

&lt;p&gt;In &lt;a href="https://ngs-lang.org/"&gt;NGS&lt;/a&gt;, there are clear ways to express that you didn’t just forgot to handle the exception (&lt;code&gt;try ... catch(e) { }&lt;/code&gt;) but you actually don’t care (or know exactly) what happened:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;try EXPR&lt;/code&gt; without the &lt;code&gt;catch&lt;/code&gt; clause at all. If EXPR throws exception, &lt;code&gt;try EXPR&lt;/code&gt; evaluates to &lt;code&gt;null&lt;/code&gt;, otherwise evaluates to &lt;code&gt;EXPR&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;EXPR tor DFLT&lt;/code&gt; if EXPR throws an exception, evaluates to &lt;code&gt;DFLT&lt;/code&gt;, otherwise evaluates to &lt;code&gt;EXPR&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Writing to &lt;code&gt;stdout&lt;/code&gt; Instead of &lt;code&gt;stderr&lt;/code&gt;
&lt;/h4&gt;

&lt;p&gt;&lt;code&gt;stdout&lt;/code&gt; has semantic meaning (result of the computation) and &lt;code&gt;stderr&lt;/code&gt; also has semantic meaning (errors description). It will make harder for any wrapper script to deal with a program that outputs errors to &lt;code&gt;stdout&lt;/code&gt; or outputs the result to &lt;code&gt;stderr&lt;/code&gt;. The semantic information about the text is lost and then needs to be recovered by the caller if the two outputs are mixed.&lt;/p&gt;

&lt;h4&gt;
  
  
  Wrong exit codes reporting
&lt;/h4&gt;

&lt;p&gt;This one really hinders automation.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if ... then { ... error("error occurred") exit(0) # incorrect error code reported}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Since it’s easy to forget about exit code, and the common case is that &lt;code&gt;exit()&lt;/code&gt; means abnormal termination of the program, in NGS &lt;code&gt;exit()&lt;/code&gt; that does not provide an exit code defaults to exit code 1.&lt;/p&gt;

&lt;h4&gt;
  
  
  Wrong exit codes handling
&lt;/h4&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if [-e MY\_FILE] ...
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;This is all over bash scripts… and it’s wrong. Which exit codes &lt;code&gt;[&lt;/code&gt; program/built-in returns? Zero for “yes”, one for “no”, and two for “An error occurred”. Guess what. You can’t handle three distinct cases with two &lt;code&gt;if&lt;/code&gt; branches; “An error occurred” is causing the “false” branch of the &lt;code&gt;if&lt;/code&gt; to be taken. If you are lucky, you will spot error message on &lt;code&gt;stderr&lt;/code&gt;. If you are not lucky, your script will just work incorrectly in some circumstances.&lt;/p&gt;

&lt;p&gt;At this point the tradeoff in NGS was made in favor of correctness, not simplicity. &lt;code&gt;if $(test -e MY_FILE) ...&lt;/code&gt; in NGS can go three ways: “yes” branch, “no” branch and an exception. After any external process is finished, NGS checks the exit code. For unknown process, non-zero exit code cases an exception. For &lt;code&gt;test&lt;/code&gt; and a few others, zero and one are not causing an exception. The exit code checking facility is extensible and one can easily “teach” NGS about new programs.&lt;/p&gt;

&lt;h2&gt;
  
  
  Broaden your Horizon – Extras
&lt;/h2&gt;

&lt;p&gt;I’ll mention here non-strictly software development related information loss cases.&lt;/p&gt;

&lt;h3&gt;
  
  
  Untagged Cloud Resources (AWS)
&lt;/h3&gt;

&lt;p&gt;Have you just created an EC2 instance and named it &lt;code&gt;Server&lt;/code&gt; or maybe you haven’t tagged it at all? Congratulations, semantic information has just been lost. You colleagues will strugle to understand what is the role of instance.&lt;/p&gt;

&lt;p&gt;Recommendation: rigorously tag the resources, have alerts for untagged or improperly tagged resources. In AWS you can also know who created the resource by looking at &lt;a href="https://aws.amazon.com/cloudtrail/"&gt;CloudTrail&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Side note: In Azure, any resource must belong to a “Resource Group” which makes it much easier to track the resources.&lt;/p&gt;

&lt;h3&gt;
  
  
  GUI
&lt;/h3&gt;

&lt;p&gt;You just performed operation in GUI. The information of what happened was just lost the minute you performed the operation. Good luck reproducing or documenting it.&lt;/p&gt;

&lt;p&gt;The plan to combat this in NGS is to have textual representation for each operation that is performed via GUI.&lt;/p&gt;

&lt;h3&gt;
  
  
  String Concatenation
&lt;/h3&gt;

&lt;p&gt;Every time two strings are concatenated into one, there is some information loss.&lt;/p&gt;

&lt;p&gt;Recommendation: instead of parsing unstructured text (result of concatenation) later, consider using structured data format when producing the output. (Example: JSON).&lt;/p&gt;




&lt;p&gt;Hope that helps. Have fun!&lt;/p&gt;

</description>
      <category>code</category>
      <category>ngs</category>
      <category>philosophy</category>
      <category>programming</category>
    </item>
    <item>
      <title>AWS CloudFormation became a programming language (2018)</title>
      <dc:creator>Ilya Sher</dc:creator>
      <pubDate>Sat, 15 Sep 2018 05:07:46 +0000</pubDate>
      <link>https://dev.to/ilya_sher_prog/aws-cloudformation-became-a-programming-language-2018-2ehi</link>
      <guid>https://dev.to/ilya_sher_prog/aws-cloudformation-became-a-programming-language-2018-2ehi</guid>
      <description>&lt;p&gt;… kind of.&lt;/p&gt;

&lt;p&gt;Declarative has its advantages which are hyped all over the internet so I’ll skip that part. &lt;strong&gt;The painful downside of declarative approach is often the expressivity.&lt;/strong&gt; Sample proofs:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;People &lt;a href="https://pypi.org/project/cfn-pyplates/"&gt;generate CloudFormation files&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Size of the Puppet standard library, which I mentioned under “Limited DSL limitations” in my older post “&lt;a href="https://ilya-sher.org/2017/06/09/please-dont-use-puppet/"&gt;Please don’t use Puppet&lt;/a&gt;“.&lt;/li&gt;
&lt;li&gt;Terraform is enhancing the DSL (HCL)

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://www.hashicorp.com/blog/terraform-0-1-2-preview"&gt;HashiCorp Terraform 0.12 Preview&lt;/a&gt; (official blog post)&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://ilya-sher.org/2018/06/30/terraform-becomes-a-programming-language/"&gt;Terraform becomes a programming language&lt;/a&gt; (my post about this)&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now you can have &lt;a href="https://github.com/awslabs/aws-cloudformation-templates/tree/master/aws/services/CloudFormation/MacrosExamples/PyPlate"&gt;Python embedded in your CloudFormation file&lt;/a&gt;. That is part of the &lt;a href="https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/template-macros.html"&gt;CloudFormation Macros&lt;/a&gt; which were &lt;a href="https://aws.amazon.com/about-aws/whats-new/2018/09/introducing-aws-cloudformation-macros/"&gt;introduced on 2018-09-06&lt;/a&gt;.&lt;/p&gt;




&lt;p&gt;Happy coding, everyone!&lt;/p&gt;

</description>
      <category>systemadministratio</category>
    </item>
    <item>
      <title>What I did not steal from Perl 6</title>
      <dc:creator>Ilya Sher</dc:creator>
      <pubDate>Mon, 10 Sep 2018 06:50:53 +0000</pubDate>
      <link>https://dev.to/ilya_sher_prog/what-i-did-not-steal-from-perl-6-5b0g</link>
      <guid>https://dev.to/ilya_sher_prog/what-i-did-not-steal-from-perl-6-5b0g</guid>
      <description>&lt;p&gt;I’m curious about programming languages. Not because I’m creating one right now. I always was. This post is about ideas and features that I have seen in Perl 6 and found interesting. If you are curious about programming languages in general, you should take a look at these.&lt;/p&gt;

&lt;p&gt;There are various reasons for not stealing the interesting ideas from Perl 6:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;I’m trying to keep number of concepts in &lt;a href="https://ngs-lang.org/"&gt;NGS&lt;/a&gt; as small as possible. If I’m not seeing huge immediate value in a concept – I skip it.&lt;/li&gt;
&lt;li&gt;Not taking anything that I think can confuse me or other programmers. I’m not talking here because someone is a beginner. I’m talking about confusing concepts.&lt;/li&gt;
&lt;li&gt;Simply because I don’t have enough resources to implement it at the moment.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Here are the interesting Perl 6 features, in no particular order (except the first one). There are also my comments whether I would like the feature in NGS or why not.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;a href="https://docs.perl6.org/language/syntax"&gt;Syntax&lt;/a&gt;. Very expressive an terse. Perl6 has even more of it than Perl 5. Now that we got rid of the &lt;code&gt;$&lt;/code&gt; and friends in the room:&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://docs.perl6.org/language/grammars"&gt;Grammars&lt;/a&gt;. Would actually be nice to have something like that in NGS.&lt;/li&gt;
&lt;li&gt;Lots of &lt;a href="https://docs.perl6.org/language/operators"&gt;operators&lt;/a&gt;. The most interesting concept is &lt;a href="https://en.wikibooks.org/wiki/Perl_6_Programming/Meta_Operators"&gt;Metaoperators&lt;/a&gt;. I’m trying to keep the amount of syntax elements in NGS relatively low. There are already two syntaxes in NGS: commands and expressions. Not taking more syntax without serious need.&lt;/li&gt;
&lt;li&gt;How the &lt;a href="https://en.wikibooks.org/wiki/Perl_6_Programming/Blocks_and_Closures"&gt;“pointy block” syntax&lt;/a&gt; mixes with “for” syntax: &lt;code&gt;for @list -&amp;gt; @element&lt;/code&gt; . NGS already has several syntaxes for Lambdas.&lt;/li&gt;
&lt;li&gt;Flow control

&lt;ol&gt;
&lt;li&gt;“&lt;a href="https://docs.perl6.org/language/control#when"&gt;when&lt;/a&gt;” flow control. The closest NGS has is “cond” and friends, stolen from Lisp.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://docs.perl6.org/language/control#repeat/while,_repeat/until"&gt;repeat while / repeat until&lt;/a&gt; . It would be nice to have something like that in NGS.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://docs.perl6.org/language/control#once"&gt;once&lt;/a&gt; . Not sure about this one. The functionality might be needed.&lt;/li&gt;
&lt;/ol&gt;


&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://docs.perl6.org/language/list#Slips"&gt;Slips&lt;/a&gt;. The behaviour is frightening me: if it does expand, how do I pass a Slip if I just want to pass it, say as an item of an array? NGS uses syntax for slips: &lt;code&gt;[1, 2, *myitems, 3, 4]&lt;/code&gt; which I think is cleaner. You know you can’t pass it because it’s syntax.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://docs.perl6.org/language/objects#Type_objects"&gt;.WHAT&lt;/a&gt; method. I stole something similar from Ruby: the &lt;code&gt;inspect&lt;/code&gt; method.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;As a special note, I have seen a welcome change from &lt;code&gt;$arr[0]&lt;/code&gt; to &lt;code&gt;@arr[0]&lt;/code&gt; . I think it removes confusion. (That was Perl 5 vs Perl 6).&lt;/p&gt;

&lt;p&gt;Please don’t be offended if you are a Perl 6 hacker and you see that there is amazing feature that I have not mentioned. It could be that I’ve seen this in several other languages already or maybe I did not find it interesting or … maybe I just missed it. Don’t hesitate to leave a comment anyway.&lt;/p&gt;




&lt;p&gt;Happy coding, in whatever language rocks your boat! Except for bash. Coding in bash will never be happy.&lt;/p&gt;

</description>
      <category>ngs</category>
      <category>programming</category>
      <category>perl</category>
      <category>perl6</category>
    </item>
    <item>
      <title>JQ is a symptom</title>
      <dc:creator>Ilya Sher</dc:creator>
      <pubDate>Mon, 10 Sep 2018 05:48:49 +0000</pubDate>
      <link>https://dev.to/ilya_sher_prog/jq-is-a-symptom-2e92</link>
      <guid>https://dev.to/ilya_sher_prog/jq-is-a-symptom-2e92</guid>
      <description>&lt;p&gt;&lt;a href="https://stedolan.github.io/jq/"&gt;jq&lt;/a&gt; is a great tool. It does what bash can not – work with structured data. I use it. I would like &lt;em&gt;not&lt;/em&gt; to use it.&lt;/p&gt;

&lt;p&gt;In my opinion, working with structured data is such a basic thing that it makes much more sense to be handled by the language itself. I want my shell to be capable and &lt;strong&gt;I strongly disagree with the view that a shell “is not supposed to do that”. Shell is supposed to do whatever is needed to make my life easier&lt;/strong&gt;. Handling structured data is one of these things.&lt;/p&gt;

&lt;p&gt;If “shell is not supposed to do that”, by that logic, bash is not supposed to do anything except for running external commands and routing the data between them. Doesn’t it seem odd that bash &lt;em&gt;does&lt;/em&gt; have builtin string manipulation then? Maybe bash shouldn’t have added associative arrays in version 4? … or arrays in version 2? How about &lt;code&gt;if&lt;/code&gt; and &lt;code&gt;while&lt;/code&gt; ? Maybe bash shouldn’t have them either?&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--KGe76ZlZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://ilyasherdotorg.files.wordpress.com/2018/09/woman-698943_640.jpg%3Fw%3D201" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--KGe76ZlZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://ilyasherdotorg.files.wordpress.com/2018/09/woman-698943_640.jpg%3Fw%3D201" alt="woman-698943_640"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;jq is a symptom that bash can’t handle today’s reality: structured data.&lt;/strong&gt; The world is increasingly more about APIs. APIs consume and return structured data. I &lt;em&gt;do&lt;/em&gt; work with APIs from shell. Don’t you guys use AWS CLI or any other API that returns JSON?&lt;/p&gt;

&lt;p&gt;The reality has changed. bash hasn’t. I’m working on bash alternative. &lt;a href="https://github.com/ngs-lang/ngs"&gt;Please help me with it&lt;/a&gt;. Or at least spread the word.&lt;/p&gt;

&lt;p&gt;If you don’t like my project, join &lt;a href="https://github.com/elves/elvish"&gt;Elvish&lt;/a&gt; . Elvish is another shell that supports structured data.&lt;/p&gt;




&lt;p&gt;Happy coding! Hope it’s not in bash.&lt;/p&gt;

</description>
      <category>bashingbash</category>
      <category>ngs</category>
      <category>rant</category>
    </item>
    <item>
      <title>Terraform 0.12 language looks bad (2018)</title>
      <dc:creator>Ilya Sher</dc:creator>
      <pubDate>Fri, 13 Jul 2018 06:45:07 +0000</pubDate>
      <link>https://dev.to/ilya_sher_prog/terraform-0-12-language-looks-bad-2018-5bjo</link>
      <guid>https://dev.to/ilya_sher_prog/terraform-0-12-language-looks-bad-2018-5bjo</guid>
      <description>&lt;p&gt;I was &lt;a href="https://ilya-sher.org/2018/06/30/terraform-becomes-a-programming-language/"&gt;hoping&lt;/a&gt; that smart guys vs bad situation will have another outcome but &lt;a href="https://www.hashicorp.com/blog/hashicorp-terraform-0-12-preview-for-and-for-each"&gt;Terraform language for version 0.12&lt;/a&gt; looks bad… as languages of Puppet and Ansible.&lt;/p&gt;

&lt;p&gt;I’m not saying that people that made Puppet and Ansible are not smart. It’s that we could learn from the mistakes they made… unless we don’t consider those being mistakes.&lt;/p&gt;

&lt;p&gt;Puppet and Ansible went through very similar difficult situation. They have limited themselves to a declarative format and then they tried to accommodate the real life. Terraform has this situation right now.&lt;/p&gt;

&lt;p&gt;The situation is:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Declarative format being used&lt;/li&gt;
&lt;li&gt;People need something more powerful, like a programming language because … real life where conditionals, loops and data transformations make much more sense than working around declarative languages limitations.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Interestingly enough, they all did not switch to a proper programming language. Maybe because that would be at least partially admitting that &lt;strong&gt;the product should have been a library in the first place&lt;/strong&gt;?&lt;/p&gt;

&lt;p&gt;Terraform is actually in very crappy situation because even if they decide to expose everything as a library as the main interface, I don’t see people start using Go for “infrastructure as code”. Not as smooth as Ruby or Python anyway.&lt;/p&gt;

&lt;p&gt;Happy coding, everyone!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Update (2018-07-21):&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;On a bit more positive note, &lt;a href="https://www.hashicorp.com/blog/terraform-0-12-generalized-splat-operator"&gt;the new splat operator&lt;/a&gt; looks like an improvement.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Update (2018-07-27):&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Terraform looks even more like a “normal” language with &lt;a href="https://www.hashicorp.com/blog/terraform-0-12-conditional-operator-improvements"&gt;Conditional Operator Improvements&lt;/a&gt; and &lt;code&gt;null&lt;/code&gt; value. The conditional operator fixes previous oddities that it had.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Update (2018-08-02):&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Terraform got &lt;a href="https://www.hashicorp.com/blog/terraform-0-12-rich-value-types"&gt;type system&lt;/a&gt;. Looks powerful. Just need to see that Terraform does not evolve to Scala &lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--zCyXRrdx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://s0.wp.com/wp-content/mu-plugins/wpcom-smileys/twemoji/2/72x72/1f642.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--zCyXRrdx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://s0.wp.com/wp-content/mu-plugins/wpcom-smileys/twemoji/2/72x72/1f642.png" alt="🙂"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Update (2018-08-11):&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;New &lt;a href="https://www.hashicorp.com/blog/terraform-0-12-template-syntax"&gt;template syntax&lt;/a&gt; brings more raw power. Looks good.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Update (2018-08-26):&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;HCL to JSON &lt;a href="https://www.hashicorp.com/blog/terraform-0-12-reliable-json-syntax"&gt;one-to-one mapping&lt;/a&gt;. When I read “having a clean 1:1 mapping between HCL and JSON, and ensuring every feature of HCL is supported in JSON” I immediately thought that there must be converting tools then… and was not disappointed &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--zCyXRrdx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://s0.wp.com/wp-content/mu-plugins/wpcom-smileys/twemoji/2/72x72/1f642.png" alt="🙂"&gt; “In future versions of Terraform, we will also support native tooling to convert HCL to JSON and JSON to HCL cleanly (including comments)”&lt;/li&gt;
&lt;li&gt;“Comments in JSON” – nice!&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>rant</category>
      <category>systemadministratio</category>
      <category>ansible</category>
      <category>puppet</category>
    </item>
    <item>
      <title>Terraform becomes a programming language (2018)</title>
      <dc:creator>Ilya Sher</dc:creator>
      <pubDate>Sat, 30 Jun 2018 06:00:57 +0000</pubDate>
      <link>https://dev.to/ilya_sher_prog/terraform-becomes-a-programming-language-2018-5a8d</link>
      <guid>https://dev.to/ilya_sher_prog/terraform-becomes-a-programming-language-2018-5a8d</guid>
      <description>&lt;h1&gt;
  
  
  Declarative languages failure
&lt;/h1&gt;

&lt;p&gt;Approach that in my eyes failed, again and again, is to start with your own declarative language and then with time grow the language. (SQL being among notable exceptions)&lt;/p&gt;

&lt;p&gt;Puppet is the best example. &lt;a href="https://puppet.com/docs/puppet/4.10/function.html#map"&gt;map&lt;/a&gt; and &lt;a href="https://puppet.com/docs/puppet/4.10/function.html#each"&gt;each&lt;/a&gt;, added in Puppet 4.0.0 are, in my opinion, just two in a sea of evidence that the envisioned simple format has failed to handle the needs of the real world.&lt;/p&gt;

&lt;p&gt;Ansible’s &lt;a href="https://docs.ansible.com/ansible/latest/user_guide/playbooks_loops.html"&gt;loop&lt;/a&gt; looks bad as the whole idea of making top levels of programs in YAML based syntax (and the rest in Python).&lt;/p&gt;

&lt;p&gt;In my opinion, it makes more sense to create a language first and then libraries for it, not a library and then a language around it.&lt;/p&gt;

&lt;h1&gt;
  
  
  My hope for Terraform
&lt;/h1&gt;

&lt;p&gt;I think Terraform guys are smart. Among other things, it manifests in implementing &lt;a href="https://www.terraform.io/docs/configuration/data-sources.html"&gt;data sources&lt;/a&gt;. Data sources make Terraform much more flexible. I think it’s very clever.&lt;/p&gt;

&lt;p&gt;Terraform, which started declarative, are now &lt;a href="https://www.hashicorp.com/blog/terraform-0-1-2-preview"&gt;inventing their own programming language&lt;/a&gt;. They are going the way of Puppet and Ansible. &lt;strong&gt;I hope they can do better&lt;/strong&gt; , in this awkward situation: there are quite a lot of constraints on the programming language because of the existing syntax and semantics.&lt;/p&gt;

&lt;p&gt;Happy coding, everyone!&lt;/p&gt;

</description>
      <category>ngs</category>
      <category>rant</category>
      <category>systemadministratio</category>
    </item>
  </channel>
</rss>
