DEV Community

Cover image for To Code and Beyond: A Neverland Adventure in Bash, Lua, Python, and Rust

To Code and Beyond: A Neverland Adventure in Bash, Lua, Python, and Rust

Prayson Wilfred Daniel on December 23, 2023

Prologue: Departure to Neverland Once upon a time, in the mystical world of terminals, we find ourselves tagging along on a Peter Pan-...
Collapse
 
voyeg3r profile image
Sérgio Araújo

For me what makes the shell something unique are pipes:

seq -s+ 1 2 5 | bc
Enter fullscreen mode Exit fullscreen mode

A killer one-linner proves that

Collapse
 
proteusiq profile image
Prayson Wilfred Daniel

🤯Nice. Is there similar that takes a sequence of even and odd numbers and only sum odds?

Collapse
 
voyeg3r profile image
Sérgio Araújo

yes:

seq 9 | awk '{($1 % 2 ? sum+=$1 : 0)} END { print sum}'

Thread Thread
 
proteusiq profile image
Prayson Wilfred Daniel • Edited

Now that blows my mind 🤯. 😍🎊 Is awk not programming language by itself?

Collapse
 
antonov_mike profile image
Antonov Mike

Sir, your writing style is brilliant

Collapse
 
proteusiq profile image
Prayson Wilfred Daniel

Thank you, Antonov. I am attempting a story like telling of concepts 🫢 I love telling stories.

 
proteusiq profile image
Prayson Wilfred Daniel
Collapse
 
proteusiq profile image
Prayson Wilfred Daniel • Edited

WoW! That is awesome. Perhaps another article. I primary use Python 🐍 and Rust 🦀, Bash and Lua 🌘 are secondary.

My main goal was not to show the power or effectiveness or to compare the languages. My aim is to show that even though we can write some of code very similar, some languages have their syntactic sugar 🤗.

With the goal of filtering numbers and adding, is it possible to use Bash modern way of “hiding" loops? Did I miss Bash syntactic sugar?

Collapse
 
tharakamts profile image
Tharaka Sandaruwan

Great Story, Like it 🔥

Collapse
 
proteusiq profile image
Prayson Wilfred Daniel

I am glad you did 🪝🙏🏿

Collapse
 
proteusiq profile image
Prayson Wilfred Daniel • Edited

Nice catch! 👌🏾 The function already echo instead of return 🫣. And were we to return then we are limited to 0-255 😔

Thank you 🙏🏾 for reading and catching my blunder 🤭

 
proteusiq profile image
Prayson Wilfred Daniel

I am cheering 📣 for your success. You are awesome 🙌🏿

 
proteusiq profile image
Prayson Wilfred Daniel • Edited

That is another level 🙌🏿🥳 and pure genius.

 
proteusiq profile image
Prayson Wilfred Daniel • Edited

Nice! Are you using LLMs under the hood?

 
proteusiq profile image
Prayson Wilfred Daniel

Oh no! I am not suggesting for better-ness. I just thought I missed something in Bash 😊

Collapse
 
proteusiq profile image
Prayson Wilfred Daniel • Edited

Nice 👌🏾. I worked with Lua 🌘 primary with my kids as they are Roblox lovers. I have not yet dive into its power than simple scripts.