<?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: Lance Bachmeier</title>
    <description>The latest articles on DEV Community by Lance Bachmeier (@bachmeil).</description>
    <link>https://dev.to/bachmeil</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%2F195985%2F23e49efc-3cc1-464c-a01a-5ee848308a2f.png</url>
      <title>DEV Community: Lance Bachmeier</title>
      <link>https://dev.to/bachmeil</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/bachmeil"/>
    <language>en</language>
    <item>
      <title>Learning JavaScript II </title>
      <dc:creator>Lance Bachmeier</dc:creator>
      <pubDate>Fri, 23 Oct 2020 14:53:14 +0000</pubDate>
      <link>https://dev.to/bachmeil/learning-javascript-ii-2m9c</link>
      <guid>https://dev.to/bachmeil/learning-javascript-ii-2m9c</guid>
      <description>&lt;p&gt;I'm learning JavaScript 30 minutes at a time...&lt;/p&gt;

&lt;p&gt;I posted my program from last night on Gitlab &lt;a href="https://gitlab.com/bachmeil/learning-javascript"&gt;in this new repo&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;My program doesn't do much, and it's obviously not useful to anyone else. It shows you what I learned in the bit of time I put into it last night.&lt;/p&gt;

&lt;p&gt;It (sort of) lets you move between two divs, with a box around the active div, using the up and down arrows. You can indent the active div (when it works) with the right arrow. That's it. As I said, it's definitely not anything useful at this point.&lt;/p&gt;

&lt;p&gt;It's interesting to me the way you can manipulate the dom. My end goal is going to be an outliner type of notes app with these features:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Do quick outlining.&lt;/li&gt;
&lt;li&gt;Add and edit text entries.&lt;/li&gt;
&lt;li&gt;Indent/outdent text trees (a text entry box and all of its children) using the keyboard.&lt;/li&gt;
&lt;li&gt;Rearrange text trees using the keyboard.&lt;/li&gt;
&lt;li&gt;Markdown support for text entries, including math.&lt;/li&gt;
&lt;li&gt;Save the current state to a file manually as a new html file.&lt;/li&gt;
&lt;li&gt;Optionally, run a local web server, which would make the saving and loading more convenient.&lt;/li&gt;
&lt;li&gt;Use a version system to determine if the current version in localStorage is newer than the version I'm loading from file. I think timestamps will work for this.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I want to be able to add a quick outline to a repo without a lot of ceremony. With everything in one html file, all I'll have to do is load that file into the browser and start typing. As I said earlier, I probably won't actually use this for anything, but I will learn a lot by implementing these features.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Learning Javascript</title>
      <dc:creator>Lance Bachmeier</dc:creator>
      <pubDate>Mon, 19 Oct 2020 14:23:20 +0000</pubDate>
      <link>https://dev.to/bachmeil/learning-javascript-4o1a</link>
      <guid>https://dev.to/bachmeil/learning-javascript-4o1a</guid>
      <description>&lt;p&gt;I haven't posted anything on here in a long time. It should come as no surprise that the pandemic has eaten up a big chunk of my schedule. I was overbooked prior to the pandemic. The need to move two classes to a new format, and learn and incorporate into my teaching new forms of technology, has been challenging.&lt;/p&gt;

&lt;h2&gt;
  
  
  Act I
&lt;/h2&gt;

&lt;p&gt;Last week I dug up an old script (from 2018?) I had written while deepening my Javascript beyond the occasional copying of a few lines of codes off the internet. It was a static page generator contained entirely in one html file, requiring no server, no command line interaction, nothing but the single html file. You enter text into a box on the screen in markdown format (complete with equation support). There's a live preview below the text entry box. When you're done, you click the button and download it to your computer. I'm pretty sure the goal was to have something that could be directly uploaded to a Github repo for display on a Github Pages site.&lt;/p&gt;

&lt;p&gt;I'll post a link when I make the html file publicly available. It still needs a little cleaning up, including the removal of personal information, before I can share it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Act II
&lt;/h2&gt;

&lt;p&gt;Over the weekend I decided to get a better understanding of modern web development by figuring out how to write a single-page web app. I was largely familiar with old school CGI apps. They're dead simple. You can learn all the "server" parts in 20 minutes. You then return text output based on the URL. CGI programming is just regular programming with external data.&lt;/p&gt;

&lt;p&gt;Considering that I'm not a web developer, that's more than I need to know. My curiosity tends to get the best of me, however, and I had no choice but to figure out how to write a web app that communicates with a server but never reloads the page. So I set out to write one of the single page apps that can be used to manage a directory of markdown files and a few other things inside a repository (Git, Fossil, or otherwise).  &lt;/p&gt;

&lt;p&gt;I wrote the backend in D using Adam Ruppe's cgi.d. In spite of the name, it has an embedded http server that can be run locally to respond to requests on the local filesystem.&lt;/p&gt;

&lt;p&gt;The frontend (I think that's what the kids call it these days) is in Javascript. I learned about &lt;code&gt;fetch&lt;/code&gt;, which is both simple to use and beautiful in the functionality it provides. I had heard of &lt;code&gt;fetch&lt;/code&gt; before but it was limited to copying a single line of code from a stackoverflow answer. I used &lt;code&gt;URLSearchParams&lt;/code&gt; to create a URL that can be used for a &lt;code&gt;GET&lt;/code&gt; request. I learned &lt;code&gt;async&lt;/code&gt; and &lt;code&gt;await&lt;/code&gt; to deal with promises. In the end, I had some functionality working. I had a sidebar with a listing of all files, could display and edit existing files, create new files, and preview files.&lt;/p&gt;

&lt;p&gt;While this is functional, it doesn't do anything more than I can do better with various other tools, including a basic text editor. As a learning exercise, it was successful. As a tool, it provides no value at all in its current state. I just want to be clear on that last point because tool creation was &lt;em&gt;not&lt;/em&gt; my goal over the weekend.&lt;/p&gt;

&lt;p&gt;The project will continue. Some of the things I will do include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Figuring out &lt;code&gt;XMLHttpRequest&lt;/code&gt;, which seems to be powerful but not as easy as &lt;code&gt;fetch&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Understanding promises.&lt;/li&gt;
&lt;li&gt;Adding tag support to allow easy querying of all files in the repo with that tag.&lt;/li&gt;
&lt;li&gt;Adding backlink support to query all files that refer to the current file. I'm not sure how useful that will be but it should be easy to implement and experiment with.&lt;/li&gt;
&lt;li&gt;Saving to &lt;code&gt;localStorage&lt;/code&gt; and allowing recovery if the browser gets closed.&lt;/li&gt;
&lt;li&gt;Add file metadata support so I can add a description of arbitrary length to be displayed with individual files.&lt;/li&gt;
&lt;li&gt;Add a "timeline" where I can quickly enter project updates. One problem I have with Git repos is that there's no standard way to post updates. When I return to them later, I can't easily figure out the state of the project.&lt;/li&gt;
&lt;li&gt;Add an "inbox" to note things that need to be done or issues. This would differ from the timeline in that these posts would need to be queried, grouped, and archived.&lt;/li&gt;
&lt;li&gt;Rewrite the Javascript parts in other languages that compile to Javascript. Strictly speaking, there's nothing wrong with JS as a language, but there's also not much that makes me enthusiastic. I'd describe it as a "vanilla" language that does the same things as other languages but not providing anything that reduces the pain of programming. In that sense, the "Java" part of "Javascript" fits even if they are unrelated.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Everything will be handled in text files - no database. Standard Unix tools such as awk, sed, and grep provide the database functionality I need. My repos are small (a few hundred files at most). The advantages of no dependencies and   having text files under version control with no overhead far outweigh any possible advantages of a database.&lt;/p&gt;

&lt;p&gt;This remains a learning adventure. If I end up with a tool customized for my workflow that I use in the future, that's a bonus. I probably won't use it when it's written. That's okay with me.&lt;/p&gt;

&lt;p&gt;Edit: It looks like I've played with ClojureScript in the past. &lt;a href="https://dev.to/bachmeil/messing-with-clojurescript-5cff"&gt;I posted about it here.&lt;/a&gt; I don't have any recollection of that, and rereading the post, it looks like I didn't spend much time with it.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>org-mode quick start</title>
      <dc:creator>Lance Bachmeier</dc:creator>
      <pubDate>Mon, 25 May 2020 15:19:28 +0000</pubDate>
      <link>https://dev.to/bachmeil/org-mode-quick-start-52ak</link>
      <guid>https://dev.to/bachmeil/org-mode-quick-start-52ak</guid>
      <description>&lt;p&gt;Someone on Hacker News &lt;a href="https://news.ycombinator.com/item?id=23301186"&gt;made this comment&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;A few simple observations:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;the venn diagram of people using emacs and using org-mode seems to largely overlap. That makes it impractical in non emacs heavy environments (aka. the wider industry).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;tooling outside of emacs is mostly not there.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;org mode is a basically similar to other wiki dialects with similar syntax, limitations, tooling, etc. Other than the (emacs) tooling, I don't see a strong reason for preferring it.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The above makes it a non-starter for me personally (not an emacs user) or for teams that have non emacs users (i.e. all teams I've been on, ever). That does not invalidate it as a personal note taking tool of course. But lets indeed not overstate its utility. Some people like post-its, scribbling in a notebook, simply remembering to do stuff, or their super duper emacs setups. Whatever works for you. &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I thought it would be worthwhile to elaborate on my reply here. I think it's a myth, promoted by Emacs users, that you have to engage in extensive customization and memorize many weird keyboard shortcuts, in order to use org-mode. That's very wrong. &lt;strong&gt;Anyone that uses a computer can use org-mode in Emacs.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;org-mode is available by default&lt;/em&gt;. That means you only need to open a .org file in Emacs and all of org-mode is waiting for you. It may not be well known, but Emacs has a menu bar. You can click to open a file as in any other GUI program.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Wiki-style hyperlinks without a browser and web server.&lt;/em&gt; Hit &lt;code&gt;C-c C-l&lt;/code&gt; and it will prompt for the link and description. If you want to link to another .org file, remember to add the path, as in &lt;code&gt;./anotherfile.org&lt;/code&gt;. To edit the link, use the same shortcut. To open anotherfile.org for editing, click the link. None of this is hard. Indeed, this is as easy as any self-hosted personal wiki solution I know of. It's unclear how it could be any easier in the absence of reading your mind.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;A full-blown outliner.&lt;/em&gt; If you want a top-level heading, start the line with &lt;code&gt;*&lt;/code&gt;. If you want a second-level heading, start the line with &lt;code&gt;**&lt;/code&gt;. And so on, as deep as you want to go. You can add notes to an item by typing below the heading. You can hide the notes by hitting Tab on the heading. What's really powerful is the ability to move subtrees around using Alt plus arrows. Left and right change the level of the heading. Up and down move the entire subtree up or down. If you want to get REALLY FANCY, you hit Shift along with the right and left arrows to cycle through marking items as TODO, DONE, and unmarked.&lt;/p&gt;

&lt;p&gt;I've just outlined a tremendously powerful knowledge management system. I provided &lt;em&gt;one shortcut&lt;/em&gt; for hyperlinking. I talked about the Alt-arrow combinations for outlining. I talked about Shift-arrow combinations for TODO functionality. I challenge anyone that reads this to leave a comment demonstrating another system that does all that but with a significant reduction in complexity. No such system exists, because it's close to the lower bound on complexity.&lt;/p&gt;

</description>
      <category>emacs</category>
      <category>orgmode</category>
    </item>
    <item>
      <title>FOSS and Entitlement</title>
      <dc:creator>Lance Bachmeier</dc:creator>
      <pubDate>Mon, 20 Jan 2020 15:58:28 +0000</pubDate>
      <link>https://dev.to/bachmeil/foss-and-entitlement-2h64</link>
      <guid>https://dev.to/bachmeil/foss-and-entitlement-2h64</guid>
      <description>&lt;p&gt;Another day, another discussion of entitlement on Hacker News. This time the post that drove the discussion is &lt;a href="https://blog.burntsushi.net/foss/"&gt;My FOSS Story&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Let me say that I know nothing about the author or any of the background behind the post. My comments are general in nature. The biggest problem is inappropriate expectations of open source project maintainers.&lt;/p&gt;

&lt;p&gt;The author of the post writes:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;I've seen or experienced this in FOSS in a number of different ways:&lt;/p&gt;

&lt;p&gt;You should put out a new release.&lt;br&gt;
   You should rewrite this in [insert programming language here].&lt;br&gt;
   You should rename your project.&lt;br&gt;
   You should [insert major architectural change here].&lt;br&gt;
   You should change the license of your project.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That apparently bothers the author. I don't understand why it matters. &lt;em&gt;Of course&lt;/em&gt; people are going to request/suggest things. If you don't like what they're asking you to do, just ignore it, or even better, answer that you've open sourced your project so that you can incorporate pull requests.&lt;/p&gt;

&lt;p&gt;Anyway, I don't really understand what this has to do with "entitlement". If you put your project out there for the world to see, you're &lt;em&gt;inviting&lt;/em&gt; comments, feedback, and shoulds. If you don't like it, don't share your work.&lt;/p&gt;

&lt;p&gt;Later on, he writes "At some level, even the act of opening a bug is a form of entitlement". &lt;em&gt;Of course it is. That's why the dang bug tracker exists.&lt;/em&gt; The author even says that in the very next sentence. Evidently the complaint has nothing to do with entitlement.&lt;/p&gt;

&lt;p&gt;My suggestion (or "should" if you want to use that term) is to be very clear on the project site what limitations there are. If you don't want feedback, state that clearly. If you don't want bug reports, state &lt;em&gt;that&lt;/em&gt; clearly. Even better, make a release and tell the world "this is complete, take it as it is, I have no plans to make changes to this project". It's my opinion that you should normally release open source code without any promise to evolve the project or to do any more than basic maintenance. The real problem in that post is that the author is experiencing burnout. He's spending a lot of time on things he doesn't want to do because he doesn't see them as valuable. He should step away, or at least be clear as to the things he's going to work on, and let the community take care of the rest.&lt;/p&gt;

</description>
      <category>opensource</category>
    </item>
    <item>
      <title>Does It Make Sense To Prefer A Text Editor?</title>
      <dc:creator>Lance Bachmeier</dc:creator>
      <pubDate>Fri, 11 Oct 2019 13:21:09 +0000</pubDate>
      <link>https://dev.to/bachmeil/does-it-make-sense-to-prefer-a-text-editor-5amj</link>
      <guid>https://dev.to/bachmeil/does-it-make-sense-to-prefer-a-text-editor-5amj</guid>
      <description>&lt;p&gt;I've always had a preference for using a text editor like Emacs or Vim rather than a program like MS Word or Evernote. I'm not the only one; millions of others use text editors by choice and complain when it's not an option.&lt;/p&gt;

&lt;p&gt;This confuses a lot of people. They just cannot wrap their minds around the idea that someone would prefer a primitive text editor over a fully evolved GUI program like MS Word. Someone even asked me once, with a disgusted/shocked look on his face, "Why would anyone use that?"&lt;/p&gt;

&lt;p&gt;I have an answer to that question &lt;a href="https://lancebachmeier.com/tools/text-editors-why.html"&gt;on my website&lt;/a&gt;:&lt;/p&gt;

&lt;p&gt;The vast majority of people do not use text editors like Emacs. They'll use MS Word, Google Docs, and the like. In contrast, I try to avoid those apps as much as possible. I'd much rather use Emacs in the terminal. This is not because, as many people might assume, I'm old and don't understand how to use technology. Over time my workflow has evolved in the direction that provides the greatest productivity, and for me that has been away from Google Docs and toward text editors. There are two reasons a text editor in a terminal makes me more productive. (I make no claim that this applies to others; you should use what works for you. This works for me.)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Text editors are designed to support a full workflow without a mouse.&lt;/strong&gt; This is one that I never understood until I was trying to understand why I was so much more productive when I avoided using the mouse. Text editors allow you to do everything with the keyboard. A mouse distracts you every time you use it. No matter what you do, the mouse will be in a different position the next time you use it, the cursor will be in a different position on the screen, and you will be doing different things. You can never automate the use of a mouse no matter how many times you use it. You have to think about it every single time, every time you save the document, select text, or scroll to the start of the document. The keyboard never changes. You quickly adjust to the keyboard shortcuts associated with a task, and you can do it without thinking about it. I'm able to think much more clearly when I'm typing in a non-GUI text editor because I'm not subject to the constant distraction I'd have if using a mouse. Many writers have moved to markdown, and I think that's because you don't have to leave the keyboard to write a fully-formatted document.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Text editors make it easier to focus.&lt;/strong&gt; A text editor is a minimalist app. You don't worry about formatting. You just write. There's no way to procrastinate when you're looking at a terminal with no formatting options other than what you put into the text. &lt;em&gt;The content is all you have.&lt;/em&gt; You get it right if you can't make up for weak content by making your document look nice.&lt;/p&gt;

&lt;p&gt;This doesn't say anything about the ability to customize the heck out of your text editor to do everything you want it to do. I haven't mentioned that because text editors vary in their support for customization.&lt;/p&gt;

</description>
      <category>emacs</category>
      <category>vim</category>
      <category>texteditor</category>
    </item>
    <item>
      <title>Customizing Emacs for Editing org Files</title>
      <dc:creator>Lance Bachmeier</dc:creator>
      <pubDate>Tue, 08 Oct 2019 02:50:45 +0000</pubDate>
      <link>https://dev.to/bachmeil/customizing-emacs-for-editing-org-files-59bn</link>
      <guid>https://dev.to/bachmeil/customizing-emacs-for-editing-org-files-59bn</guid>
      <description>&lt;p&gt;My preferred way to use Emacs is to open it to edit a particular filetype with a custom init file. Most commonly, this is a .org file that I'm opening with a script. The primary advantage of using a custom init file is that you can optimize Emacs for one type of file without causing conflicts for other modes. Emacs is almost unusable in its raw form. &lt;a href="https://stackoverflow.com/a/88737/2225804"&gt;Duplicating a line&lt;/a&gt; requires this mess: &lt;code&gt;C-a C-SPACE C-n M-w C-y&lt;/code&gt;. Obviously, nobody wants to deal with that. It's easier to select, copy, and paste the line than to type that - assuming you can even remember it.&lt;/p&gt;

&lt;p&gt;I open .org files with a command like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;emacs -q -l custom.el foo.org
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;This opens file foo.org using custom.el as the init file. Inside custom.el are the lines:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;(setq inhibit-startup-screen t)
(global-set-key (kbd "C-c x") 'org-cut-special)
(global-set-key (kbd "C-c c") 'org-copy-special)
(global-set-key (kbd "C-c v") 'org-paste-special)
(cua-mode t)
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;The first line makes Emacs open without the annoying startup screen that for some reason opens by default no matter what. You'll go crazy if you have to deal with it every time you open a .org file, so get rid of it. Lines 2-4 make it possible to cut, copy, and paste items in your outline. This is really handy for moving content around. Line 5 is by no means necessary, but I always forget which of &lt;code&gt;C-w&lt;/code&gt; and &lt;code&gt;M-w&lt;/code&gt; is copy and which is paste. cua-mode gives copy, cut, and paste the normal shortcuts of &lt;code&gt;C-c&lt;/code&gt;, &lt;code&gt;C-x&lt;/code&gt;, and &lt;code&gt;C-v&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;This minimal configuration file is sufficient to make me extremely productive editing .org files that contain project information, checklists, and any other information I need to track.&lt;/p&gt;

</description>
      <category>emacs</category>
      <category>orgmode</category>
    </item>
    <item>
      <title>Pandoc TOC without standalone mode</title>
      <dc:creator>Lance Bachmeier</dc:creator>
      <pubDate>Fri, 13 Sep 2019 02:44:08 +0000</pubDate>
      <link>https://dev.to/bachmeil/pandoc-toc-without-standalone-mode-2ki9</link>
      <guid>https://dev.to/bachmeil/pandoc-toc-without-standalone-mode-2ki9</guid>
      <description>&lt;p&gt;This is a specialized post that very few people will find useful. But since it's not something you can easily find by searching, I'll make it available to anyone else in my position.&lt;/p&gt;

&lt;p&gt;I wanted to add a table of contents to a document in Pandoc, but without standalone mode - something that is not possible. However, you can just use a very minimalist template called something like blank.html:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$toc$
$body$
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;That's it. Then this&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pandoc -s file.md -o file.html --template=blank.html
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;is just as good as not using standalone mode.&lt;/p&gt;

</description>
      <category>pandoc</category>
      <category>markdown</category>
    </item>
    <item>
      <title>D Interop with C++</title>
      <dc:creator>Lance Bachmeier</dc:creator>
      <pubDate>Sat, 07 Sep 2019 01:34:10 +0000</pubDate>
      <link>https://dev.to/bachmeil/d-interop-with-c-4nbf</link>
      <guid>https://dev.to/bachmeil/d-interop-with-c-4nbf</guid>
      <description>&lt;p&gt;D continues to carry C++ interoperability &lt;a href="https://dlang.org/blog/2019/09/06/dmd-2-088-0-released/"&gt;forward more than any other language&lt;/a&gt;. I've not dug into it at all, but the latest additions allow you to work with C++'s std::vector and std::string in your D code. Various other libraries let you work with &lt;a href="https://dlang.org/phobos/core_stdcpp_allocator.html"&gt;std::allocator&lt;/a&gt; and &lt;a href="https://dlang.org/phobos/core_stdcpp_new_.html"&gt;the C++ new operator&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>d</category>
      <category>cpp</category>
      <category>interoperability</category>
    </item>
    <item>
      <title>Scripting with Textadept</title>
      <dc:creator>Lance Bachmeier</dc:creator>
      <pubDate>Fri, 30 Aug 2019 15:44:47 +0000</pubDate>
      <link>https://dev.to/bachmeil/scripting-with-textadept-1ikj</link>
      <guid>https://dev.to/bachmeil/scripting-with-textadept-1ikj</guid>
      <description>&lt;p&gt;Yesterday on Hacker News, someone &lt;a href="https://news.ycombinator.com/item?id=20829818"&gt;commented&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Other editor users simply have no concept of how easy it is to whip up some quick script to perform some task in emacs.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I think many Emacs users have this view, and as a long time Emacs user, I love the ability to write libraries of functions and interact with them from a text editor. Unfortunately, it's not an accurate statement. Other text editors do have that capability. Textadept - probably influenced by Emacs - is one that I've used extensively as a frontend for a programming language. &lt;a href="https://news.ycombinator.com/item?id=20830710"&gt;This&lt;/a&gt; was my response&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;I don't want to start a flamewar, but I moved most things I was doing in Emacs to Textadept a while back because I found Textadept more convenient. That's not to say TA does everything you can do in Emacs, but it replaced all of the scripting I was doing with Emacs.&lt;/p&gt;

&lt;p&gt;You have the full power of Lua inside TA. Emacs always has a lag when I start it up, whereas TA is instant. I slowly built up functionality inside TA to the point that I realized I could replace everything I was doing in Emacs.&lt;/p&gt;

&lt;p&gt;It's so small and lightweight that, just for fun, I wrote a "web browser" inside TA. It calls out to lynx and loads a readable text version of the page. I use a keyboard shortcut to open links. I have functions for searching the web, I can search YouTube and open the videos in VLC, and so on. This was a practical thing to do: I can use TA as a browser on really old laptops.&lt;/p&gt;

&lt;p&gt;It maybe isn't for everyone, but in Emacs when I was doing this[1] to duplicate a line:&lt;/p&gt;

&lt;p&gt;C-a C-SPACE C-n M-w C-y&lt;/p&gt;

&lt;p&gt;I asked why I wasn't using a better text editor. In TA, it's C-d. Just as Emacs is an interface for Emacs Lisp, TA is an interface for Lua, and with a lot less overhead.&lt;/p&gt;

&lt;p&gt;[1] &lt;a href="https://stackoverflow.com/questions/88399/how-do-i-duplicate"&gt;https://stackoverflow.com/questions/88399/how-do-i-duplicate&lt;/a&gt;... &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That last bit wasn't important from the perspective of scripting. (But it's correct - Emacs is not a lightweight text editor, and you can end up going down rabbit holes when you try to change a key binding, unless you're willing to accept verbosity. Textadept, by just being a text editor out of the box, doesn't have that problem.)&lt;/p&gt;

&lt;p&gt;I might post more on this topic in the future, but let me give you an example of one customization I've done with Textadept. First, some background on my workflow so you understand what I need to do. I have a lot of information flying at me during the day: a link I come across that is not of any particular use right now but that may be useful in the future, a few pieces of reference material someone sent me for a service project, a request for a meeting, an example that came to mind randomly that I want to incorporate into tomorrow's lecture, a minor comment from a coauthor about a problem with one of the figures in our paper, a clarification on a rule for the graduate program. It's an unending stream of a few big items and a lot of small items. &lt;/p&gt;

&lt;p&gt;There's simply no way I can properly organize the several dozen of these that come along each day while I'm working. After trying many different solutions, what I found works best is a file called capture.txt where I know everything will be safe until I have time to review each item, make a decision about what needs to be done, and take appropriate action. There's no time or mental energy available for an elaborate system while I'm working. I need to enter a few keystrokes and start typing.&lt;/p&gt;

&lt;p&gt;So, how did I implement this system in Textadept? The first thing I did was add a menu item for opening the capture file if it's not already open. (I prefer a menu item because I don't do this task often and the cognitive overhead of a menu item is lower than a keyboard shortcut or calling a function.) I added this in the &lt;code&gt;menu.lua&lt;/code&gt; file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{_L['Open Capture'], function() io.open_file(_HOME .. "/capture.txt") end},
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Upon restart, which is instantaneous, I had a menu item to open that file.&lt;/p&gt;

&lt;p&gt;Just having the file open isn't enough. I might be in the middle of the document when a new item comes in. I wrote a function that moves to the top of the document, adds two line feeds, and moves the cursor to the beginning:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function new_capture()
    buffer.insert_text(0, "\n\n")
    buffer.goto_pos(0)
end
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;0&lt;/code&gt; in the first line of the function body tells it to insert that text at the start of the document. The second line moves the cursor to the start of the document. I could have called that function by hitting Ctrl-e and typing&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;new_capture
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;That's inconvenient, so I bound that function to Alt-i (for insert). In my init.lua file, I added&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;keys.ai = new_capture
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Now all I have to do is hit Alt-i and start typing. &lt;/p&gt;

&lt;p&gt;I quickly discovered that isn't a complete solution. If I just type, I'll soon have a file that's a big wall of text, and it's not easy to work with something like that when I'm processing everything at the end of the day. That led me to resist the processing, and the system's a failure if I'm not doing the processing on a daily basis.&lt;/p&gt;

&lt;p&gt;The solution is to start each item with an identifier so I know what I'm dealing with. If it's a task I need to do, it starts with &lt;code&gt;%task&lt;/code&gt;. If it's a note, it stars with &lt;code&gt;%note&lt;/code&gt; followed by a timestamp, which I've learned is often useful information. I have several other identifiers that may change from time to time.&lt;/p&gt;

&lt;p&gt;For notes, I have the following in my init.lua file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;snippets['n'] = '%%note ' .. '%&amp;lt;os.date("%x at %X")&amp;gt; '
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;To enter a new note with a timestamp, the total work I do is:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Hit Alt-i to make space at the top of the file for the note.&lt;/li&gt;
&lt;li&gt;Hit n followed by tab to insert the snippet.&lt;/li&gt;
&lt;li&gt;Get all the information out of my head.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The snippet puts something like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;%note 08/30/2019 at 09:53:54 AM 
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Of course you can do any of this with Emacs. The point is that you can do it in Textadept just as well, or even easier, and you might prefer a lightweight, extremely performant editor. It's not the case that you &lt;em&gt;have&lt;/em&gt; to use Emacs to get this functionality. Anything you can do in Lua (which is a heck of a lot) or by calling out to a command line program (which might be written in Emacs Lisp) you can do in Textadept.&lt;/p&gt;

</description>
      <category>textadept</category>
      <category>texteditor</category>
      <category>emacs</category>
    </item>
    <item>
      <title>"Don't Rewrite Code" is bad advice</title>
      <dc:creator>Lance Bachmeier</dc:creator>
      <pubDate>Thu, 22 Aug 2019 19:32:10 +0000</pubDate>
      <link>https://dev.to/bachmeil/don-t-rewrite-code-is-bad-advice-14i7</link>
      <guid>https://dev.to/bachmeil/don-t-rewrite-code-is-bad-advice-14i7</guid>
      <description>&lt;p&gt;I have read many times the advice that you shouldn't do a rewrite of a working program. I think the idea was popularized many years ago in a blog post by Joel Spolsky. That's probably reasonable advice for a million-lines-of-code program you're using in production. It's bad advice when your programs is only a few thousand lines. Here are a couple of reasons rewriting code is a good thing.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Freedom to rewrite makes you more productive.&lt;/strong&gt; If you know in the back of your mind that you can do a rewrite if it doesn't work out, you won't try to engineer a perfect, general solution on the first go. The critical step is writing a working program, complete with tests, that does exactly what you need it to do. You want to silence the voice in the back of your head that keeps asking, "What if I decide to add X in the future?" Once you give in to that urge, you'll be going down rabbit holes and spending long hours engineering solutions for problems you don't have.&lt;/p&gt;

&lt;p&gt;Rewrites are cheap. Your time, on the other hand, is not - don't waste it writing programs that don't provide an immediate return.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;You can rewrite and test a lot of code quickly.&lt;/strong&gt; I can knock out a lot of (fully tested) code in a couple of hours if I'm doing a rewrite. I can reuse much of the earlier code, and once I understand the logic, I can do a much better job. And it can be hard to write good tests while you're trying to define the problem. When you start a rewrite, you know what you're trying to accomplish, and that makes it a lot less challenging (and faster!) to write good tests.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Messing with ClojureScript</title>
      <dc:creator>Lance Bachmeier</dc:creator>
      <pubDate>Thu, 15 Aug 2019 14:12:23 +0000</pubDate>
      <link>https://dev.to/bachmeil/messing-with-clojurescript-5cff</link>
      <guid>https://dev.to/bachmeil/messing-with-clojurescript-5cff</guid>
      <description>&lt;p&gt;My usage of Javascript has been limited to copying and pasting a few code snippets from the web. I don't do much web development, and when I do, I normally use CGI with D. JS does offer some big advantages, however, like not requiring a running web server.&lt;/p&gt;

&lt;p&gt;The main reason I haven't learned JS is that I don't like it. That's not due to flaws in the language - though like any language, those exist - it's purely a matter of preference.&lt;/p&gt;

&lt;p&gt;I worked with Clojure years ago, but didn't really have a good use for it, so I set it aside and never returned. ClojureScript has some appeal because it allows me to write Clojure rather than JS. So last night I checked it out.&lt;/p&gt;

&lt;p&gt;I went to the website and found a "Quick Start" page. The first thing I learned is that this isn't really true:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;If you are using macOS or Linux the only dependencies required for the main part of this tutorial are a web browser and an installation of Clojure.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;You actually need an installation of Clojure &lt;em&gt;as described at that link&lt;/em&gt;. It doesn't work if you install Clojure using your distribution's package manager.&lt;/p&gt;

&lt;p&gt;I then created several directories and the two files. I was left guessing which was the directory to do the compilation, so I tried the one with my source file (that seemed natural coming from the C world). Nope. I had to go to the top directory and do it from there.&lt;/p&gt;

&lt;p&gt;After a while, a browser tab opened and I waited for something to happen. Nothing happened. For some reason, an html file that does nothing gets opened. I returned to the terminal. I could type things in, but this was in no way different from just running a Clojure repl. At that point, I was done with my "quick start". I didn't feel I got started on much of anything, because I hadn't replaced JS with Clojure (the whole reason I tried ClojureScript). So I decided to look around for a guide that might show me what to do. There are a lot of links, but there was really nothing that helped.&lt;/p&gt;

&lt;p&gt;I searched for ways to call Clojure functions from JS, and it pointed me to &lt;a href="https://stackoverflow.com/questions/31641030/call-clojurescript-from-javascript"&gt;this answer on SO&lt;/a&gt;. From there, I went to &lt;a href="https://clojurescript.org/reference/advanced-compilation#access-from-javascript"&gt;this documentation page&lt;/a&gt;. I used that information to export my Clojure functions, compiled a Clojure library, and called those functions from html using something like&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;button onclick="console.log(hello_world.core.average(3.4,7.8))"&amp;gt;Click me&amp;lt;/button&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;I think part of the problem is that I don't know JS, so none of this was obvious to me, and evidently the standard use case for JS is something other than creating functions to be called from html when you're clicking buttons. It can be frustrating when you see others writing about how good ClojureScript is, but you can't even figure out how to do basic things.&lt;/p&gt;

</description>
      <category>clojurescript</category>
      <category>learning</category>
    </item>
    <item>
      <title>There are very few cases where the language choice actually matters?</title>
      <dc:creator>Lance Bachmeier</dc:creator>
      <pubDate>Mon, 12 Aug 2019 02:43:48 +0000</pubDate>
      <link>https://dev.to/bachmeil/there-are-very-few-cases-where-the-language-choice-actually-matters-64k</link>
      <guid>https://dev.to/bachmeil/there-are-very-few-cases-where-the-language-choice-actually-matters-64k</guid>
      <description>&lt;p&gt;The title is a reference to &lt;a href="https://stackoverflow.blog/2019/08/07/what-every-developer-should-learn-early-on/"&gt;this blog post&lt;/a&gt;. The author writes&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Before I talk about how I evaluate languages, I want to make something very clear. There are very few cases where the language choice actually matters. There are things you can obviously not do in some languages. If you write frontend code, you don’t get a language choice. There are also specific contexts where performance is important and X language just won’t do, those situations are quite rare. In general, language choice is usually one of the least important issues for a project.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I strongly disagree with this statement &lt;em&gt;in general&lt;/em&gt;. Of course there are many cases where it is true, but as a general statement that every developer should learn, I don't think it's anywhere close to correct.&lt;/p&gt;

&lt;p&gt;I would say that one of the most important things you can do is choose the correct language. Here are some things that you do need to take into account when you're working on a software project:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;What are the performance requirements? This is not limited to the small subset of programming problems, like high frequency trading, where you need to squeeze every ounce of performance from the processor. Is the interface responsive? Will the program scale? Can I write in an idiomatic style, or do I have to resort to things like vectorization, which destroys readability and is hard to do? Performance concerns are not as big as they used to be, but they are not rare. Jeff Atwood had &lt;a href="https://meta.discourse.org/t/the-state-of-javascript-on-android-in-2015-is-poor/33889"&gt;a few things to say about performance a while back&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;How am I going to model the problem? Sometimes a functional approach is best, sometimes an OOP approach is best, and sometimes you just want to write a quick script. Haskell's not the right choice for an OOP program. Java's not the right choice for a script. But it's more than that. We resist doing things that our language doesn't do well. We limit our projects to the things we can do easily in the language we've chosen to use.&lt;/li&gt;
&lt;li&gt;Which libraries do I need? Not all languages have equal access to libraries. Even if they exist, they might not be complete, they might not be supported, they might not be documented well, or they might be awkward to use. Poor/nonexistent library support can sink a problem or require a costly rewrite.&lt;/li&gt;
&lt;li&gt;What parts of the ecosystem have to be strong? If you prefer using an IDE, some languages are better choices than others. If you run into trouble, is there a community that can help you? Is there good documentation to guide you to do what you need to do?&lt;/li&gt;
&lt;li&gt;Which languages are fun to use? Nothing can kill your motivation like having to use a crappy language. If you dread the thought of open the project up because the language sucks, I can say with certainty that you will be less productive. If a language is fun, and you enjoy learning about it, you will leave for the office 30 minutes early and stay 30 minutes late at the end of the day.&lt;/li&gt;
&lt;li&gt;Which languages do you know well? Do you need to hire others to work on the project?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It's surprisingly common to see people say the choice of language is unimportant. I find that argument to be bizarre. You wouldn't expect a mechanic to say "The choice of tools is not important. If all you have is a hammer and a socket set, use that." If you ordered an Uber and the driver showed up in a Kenworth T800, it's not likely that you'd think "The choice of vehicle isn't important. All we need is a tool to take me from my house to the airport." Sure, you'd have plenty of space for luggage, but it would not seem to be an unimportant implementation detail. And you wouldn't say the choice of spouse is an unimportant detail so long as they are capable of carrying out the spousal duties.&lt;/p&gt;

&lt;p&gt;No, the choice of language matters, and it matters a lot. I won't speculate on why someone might claim otherwise. It is an observation that conflicts with my experience.&lt;/p&gt;

</description>
      <category>languagechoice</category>
    </item>
  </channel>
</rss>
