Make a tool with Red-lang, it's fun!
This year I have released a simple tool coded by Red-lang. It saves ChatWork's messages and files to local. ChatWork is a chat service for business, very popular in Japan. Because my company stopped using ChatWork, I wanted to save my data in ChatWork. That was the motivation.
Repository
Here is my repository for the tool, ChatWorkKeeper. Sorry the description in the repo is in Japanese only, but most people who need this tool are Japanese. 😅
Why using Red?
This post mainly explains non-functional aspects. If you are interested in only codes, take a look at my next post!
Red is an alpha stage programming language, not so many production use cases yet(maybe). However it already has amazing capabilities and is comfortable to code. Following points are benefits with coding Red, I think.
- REPL included, official VS Code plugin is awesome
- Simple and immersive coding, not requiring powerful PC
- Typing comfortability - less times to press Shift key and symbol keys
- Compiled to single binary - easy to share and no worries about runtime installed
- Interacting with WEB API is very easy (written in next post)
1. REPL included, official VS Code plugin is awesome
Red has a REPL called GUI console. It is very comfortable especially to code a program interacting with WEB APIs of other companies. Since I am not sure how the API returns response, GUI console gives an efficient process to write a code, run it and see the results. Also Red has an official VS Code pulgin. It's very handy.
2. Simple and immersive coding, not requiring powerful PC
Red is a very simple language and does not force you to consider much other than coding. I have used C# in my business for 10 years. Though I like and thank C#, I need to consider many things before I start coding when use it. For example, what version of .NET I use (and is the version available for all of the users I expected?). Which types of project I use?(Console app or WPF app? The project files' structure decided by the type). In Red it is a really easy choice whether my app has GUI or not. All I need is to use view
function. It does not shake project level structure at all. With Red, I can write codes that directly match with what I am thinking, at any time. It helps me motivate myself a lot to keep coding at my leisure time. Also, Red and its editor do not require quite high resources, I can develop my app on my modest spec laptop.
3. Typing comfortability - less times to press Shift key and symbol keys
If you took a glance at my repo above, you might find there are fewer symbols in the source code. We are too used to seeing many symbols in traditional programming languages to have doubts about that. But is it really readable using ?
and ??
to conditional operators? Isn't it uncomfortable to type ()
every place method called? (it means, most lines of the codebase in practice!) After meeting Red, I have gotten too lazy to type ()
because it needs to press the Shift key (and (
is a little far from Shift!).
Let's look at an example, JavaScript's code below;
var result = 'Hello, 2020!'.replace('2020', '2021');
console.log(result);
// => Hello, 2021!
would be in Red,
result: replace "Hello, 2020!" "2020" "2021"
print result
; => Hello, 2021!
Red is much neater and more readable, isn't it?
Or if you want to write in one line,
console.log('Hello, 2020!'.replace('2020', '2021'));
would be
print replace "Hello, 2020!" "2020" "2021"
Probably, it seems possible even for a non-programmer person to read and guess what Red's code means. Great readability!
4. Compiled to single binary - easy to share and no worries about runtime installed
While I can use the GUI console when stacking codes, I can compile the Red code after coding done. It makes a single machine code binary file so really easy to share it. Because it's machine code binary, UPX can be used to compress the file. Final compressed size of my tool is only 369KB!
5. Calling WEB API and handling response are very easy
This post has been a little long, so I have written one more post about this topic. Let's focus on the actual code next!
Top comments (0)