3
davide
3y

My currently project. A migration of a project written 5 years ago in Java and PHP, to bash. I want to learn more about this language, the various peculiarities and also take the opportunity for refinements. I'm crazy I know, but what is life without a little bit of madness?

Comments
  • 1
    A cli based app?
  • 1
    @imaji Exactly. I found the previous version too heavy for its use. It's an application that always runs in the background and can also be queried via command line
  • 1
    Why bash? O.o
  • 2
    @iiii You mean why bash and not python, perl or similar? As I wrote in the post; it's an opportunity to learn better this language, bring improvements and finally have a philosophy of performance, which I wouldn't have in high-level languages
  • 0
    @davide yes. Bash would be a very limiting choice, I think. it's not really that performant (depends on use case)
  • 3
    My boy here woke up and chose pain
  • 1
    @iiii neither are Perl, Python, or PHP...
  • 2
    I love working in Bash, it's always so satisfying to get really basic things working because of Bash's terrible syntax.

    One recommendation is turn on as many warnings and errors as you can
  • 0
    @YADU You got the point. I already enabled ShellCheck from koalaman https://github.com/koalaman/.... Can you recommend anything more?
  • 0
    You are going FROM a PHP/Java implementation TO bash?

    Are the buttons on your keyboard possibly Benjamin buttons?
  • 1
    @DirtEffect Correct! I'm migrating a Java & Php Application into a bash one
  • 1
    @davide ShellCheck is pretty good.

    Beyond that, I'd say just following some basic "best practices" for bash.

    Stuff like "use local variables when possible" and "always quote variables". (ShellCheck helps with this stuff.)

    Also depending on what version of Bash you're in, you probably have Arrays and Hashtables built-in
  • 0
    @dUcKtYpEd disgusting, a CLI made with node.

    I really hate when I find the thing I need and it is made in node, I don't have nide installed and I won't install it.
  • 0
    @dUcKtYpEd that is the funny thing, it isn't.
    Node has a very specific use case, small backends so the front end guys can programm them with the language they know.

    And it sucks so much at it that now we have deno too.

    If you want a backend language to do more things and easy to code in, you go to python or ruby, if you need it to also be fast you go the go way.

    If you want ti maje a cli, the best bet is python. Why? Because it is already installed in your distro, if you want jt for windows, you can package it so it requieres no installs.

    But to be fair, I have done sone clis in ruby, which goes against my own rationale here.

    Bottom line, do not make me install node.
  • 0
    @YADU not as bad as bash)
  • 0
    @iiii what's not?
  • 0
    @YADU Perl, Python and PHP are not slower than bash
  • 0
    @iiii ah, right.

    I'd say if you're bothering to use any of these languages for anything you dont even need to bother thinking of speed though (for most use cases).
  • 2
    While Bash has it's uses...

    It is limited as anything beyond it's capabilities has to be relayed and processes to another command.

    You can do it... But it's complicated. :) And painful. And don't get me started on how completely fucked up some commands exit codes are (eg. docker).

    If you want anything reliable - especially cross platform - stay away from Bash.

    Otherwise, feel free to learn.

    Cross platform is hard to master - as you will need at least one dependency like coreutils to get stuff done.

    Awk / Grep / Sed can have different implementations, eg mawk vs gnu awk.

    As soon as you start going down the rabbit hole of "which package might be hidden behind the binary I found in PATH" it gets very funky.

    XD
  • 0
    @dUcKtYpEd well, I thought that is what you read for, learn things you don't use. The more I read, the less I need node.

    I did stretch it there, with the front en guys, but that is what it is used for nowdays, to make fullstack people.

    The gener idea I propose is something I read node's creator said.
    In short, he said "I fucked up, use go instead"

    And that is for its main thing, web shit.
    For CLIs and scripting there is phrase that applies "Jus because you can, doesn't mena you should".

    Anyway, I am just bashing it because I don't like it and I don't want to install it, I have used it a bit but I avoid it like the plague.
  • 0
    @dUcKtYpEd I was looking for this article https://edneypitta.com/on-node-go-c...

    This is before Ryan started working on Deno.
  • 0
    @dUcKtYpEd i agreed with everything except 2 things: Java being slow, a properly built JVM implementation is fast, reliable and extensible by means of (in Java's case) not being able to derive from an OOP paradigm thus having to properly modularize the application, if a dev does not do it.....well that is a different case. And Rails not being opinionated, if it is known for something it is it being opinionated, and I do love it for that btw.
  • 1
    @mundo03 you can actually get quite far with just Node as a runtime and not using any other libraries and using your own. My biggest pet peeve with node is how node_modules works, but this is not a wrong idea, your project lives inside of its directory rather than on the entire system. I see no fault with that, what I do see is in the event of needing one dependency that carries 50 other dependencies then you are getting the entire thing, I know that this is mostly a "during development" phase, but still, it is far too much, not different from how it might work on a virtualenv python environment, but definitely less expensive in system resources.
  • 1
    To OP, why not give it a try with Go? I have found it amazing for CLI applications and use some at work, if you feel more daring into something that you might not be completely familiar with, there is also Clojure.

    I have cli applications at work running through both of them. I like them both, but now a days prefer Go rather than the mental gymnastics I pull with Clojure.
  • 1
    @AleCx04 I believeethat is what deno is trying to fix, one of the things at least.
  • 1
    @mundo03 even for right now with node. I mean the runtime is there. I have built semi large cli apps with no external dependencies using just the node runtime. The idea was fine what the community did with the implementation....well
  • 0
    @AleCx04 yeah, I tried at some point to learn node, I went to a couple of workshops, took courses online, built a few simple things

    But I was already spoiled by ruby, why suffer with JS and node when you have ruby?
Add Comment