4 ms·
Hope it's not seen as criticism... but I could love more elaborate examples... Checking the examples, my friction here is... why should I introduce a new langu
by txutxu 3y ago
Hope it's not seen as criticism... but I could love more elaborate examples...
Checking the examples, my friction here is... why should I introduce a new language for those things?
First example program equivalence:
tr -s ' ' '\n' < file.txt
Second program equivalence:
awk 'NR <= 10 {print} {total += $1} END {print "total:", total}' monies.txt
It takes to me more time, to understand what is doing D, even if theres is a previous explanation, that write down the equivalence with known tools.
The last example needs to download/install dependencies, from the outside of the upstream software origins of my servers (that's a no-no in many places). apt-cache search vibe is no good for me.
If I could have need a program like that simple web example, nowadays I could go with golang, compile and deploy.
But the first two other solutions that come to my mind...
perl -Mojo -E 'a("/")->to_text(sub {
"Hello World " . shift->req->url->path
})->start' -l http://localhost:8080
Or something like...
from flask import Flask, request
app = Flask(__name__)
@app.route('/')
def hello_world():
path = request.path
return f'Hello World {path}'
if __name__ == '__main__':
app.run(host='localhost', port=8080)
I know that apt-get install libmojolicious-perl or install python3-flask is not an issue in many internal audits we did pass. Perl an Python are already present in the servers... or if puppet is in use, maybe ruby?
ruby -rwebrick -e"WEBrick::HTTPServer.new(Port: 8000){ |req, res| res.content_type = 'text/plain'; res.body = 'Hello World ' + req.path; }.start"
But I know many places were adding new languages, using external package repositories for scripting languages, etc, is a problem...
So, if it's for that article, I'm not 100% convinced to switch to D or invest my time in it... maybe I'm not the target audience.
I've nothing against D itself, but I need better marketing to be attracted.
- destructionator 3y agoWhat I like about D is if you already know it, it can adapt to just about anything you want, from these kind of shorter "scripts" to experimenting on bare metal to regular applications. But yeah, if you already know ruby and python and perl and awk and the unix shell, there's not much to be gained in these examples. Just if you don't know those things and know a little D, it can meet you where you are and take you where you're going.
- garrisonhh 3y agoYou can say that about most general purpose compiled languages. I guess I don't see why I would use D for any particular compiled use case over something like zig or rust? and if I just want to script system tasks I'm going to use popular languages with popular libraries and full batteries like python
- nmz 3y agoawk 'NR<=10 {print; total+=$1} END {print "total:", total}' monies.txt