Why I have no favorite programming language
ilya-sher.org
ilya-sher.org
I wish the author good luck with his NGS, but I don't think it's possible to make something as direct as Bash that has all the other features the author wants. But more power to him for trying.
Although, looking at the Github page, I get the impression the author is writing software to automate AWS deployments after getting fed up with Terraform and CM tools, rather than a Better Shell Language. Maybe it's both, but the 100% AWS example code does not remotely appeal to this AWS sysadmin.
But I also think they should move away from plain text for everything as well. Almost everything in a unix system could be better served with some kind of standard system of typing. Config files, program inputs (give universal tab completion) ... etc.
So I tried powershell and found it to be terrible. It seems like the implementation is killing the idea, stack traces all over the place - rather than helpful errors - and different types for file system objects (I cannot quite remember exactly what) making it hard to combine operations.
There is something about using capital letters for commands that really bothers me. It may be an OCD thing, bc I use lower-case snake_case for all variable/class names in Lisp, C, C++, and Python.
I don't usually do any work on Windows, but when something came up where some scripting had to be done, I just installed the Cygwin and was done with it.
Lightly typed data (like strings you must parse) is more future proof at the expense of leaving more potential for bugs (escaping whitespace).
Strongly typing requires the shell designers to provide more opinions. More opinions provide more opportunities to be wrong about what needs we will have in the future decades.
https://docs.python.org/3.6/using/cmdline.html#envvar-PYTHON...
Some tasks were harder, some easier, but it was all quite entertaining to see.
To be fair, this is use case for shared libraries. I've not dabbled much in Ruby or Go, but in Python there are terrific libraries for handling filesystems, sockets, HTTP request, etc. Most of them (e.g. Requests) have terrific 'Pythonic' interfaces, one doesn't even feel that he's left Python for some decades-old legacy interface.
While generally a horrible idea, I can start a simple http server with a simple one-line command from the terminal. Yeah, it's probably not smart - but I find myself using simple things like that more and more often - and I'm just a retiree with a small home network.
If anything draws me back into programming, it's going to be Python or Java.
It has same terse syntax as bash but much more structured (and easy to add more) because language is powerful. The downside is its slow, but that might have changed already with Scala Native.
The key is it is full scala with some extra niceties that do the stuff bash does. So you get full power of a programming language, extended down to do stuff bash does. Better approach IMO than extending a shell "up" to more and more expressive power towards a quirky programming language.
https://github.com/ilyash/ngs#have-you-heard-of-project-x-ho...
I really am hoping that Lisp and specifically Racket can become the tool for the DSL since that is what they do really well.
Personally, I start with bash for very trivial tasks. As soon as there is data to manipulate, I switch to perl. If program gets bigger and needs to be split into modules or classes, I switch to python (I am less fluent in ruby and go). Sometimes I switch to python earlier because of some libraries. If the program gets more bigger, needs to be maintained or suffers from slowness, I switch to java. My favorite language is perl, but I use the one that fits best.
For more info, see http://rperl.org/performance_benchmarks_nbody.html
Why would a language concern itself with files and processes? This is precisely why libraries are for. And with languages like Ruby, you can pretty much make the syntax.
> I would like to fill the gap
Every time we decide the solution to a problem is a new language, we end up with two problems. There are valid reasons to invent new languages, but such a narrow domain-specific problem is not one of them.
To be honest, python is just the greatest thing ever. It's not penetrating well because there is no money behind it like java or go. Like I said, if there was as much money spent on python that there is on js, it would be just great.
Creating a good enough programming language is very hard because it requires experience in engineering and all the compromises it entails, and it also requires not trivial compsci skills. Creating a maintaining a language is hard.
Help me fix this line: https://github.com/kurocha/tagged-format/blob/283d9bb1c91768...
In Ruby it would be
output.puts "\t\t#{vertex.join(' ')}"You could use f-strings (introduced in Python 3.6) to get rid of the `.format(`. https://www.python.org/dev/peps/pep-0498/
The `[str(value) for value in flatten(vertex)]` part is missing in your Ruby. I assume that happens in some method of the vertex? You could make your vertex iterable as well.
Python philosophy prevents you from getting rid of the `str(x) for x in v` because "explicit is better than implicit", so join will not auto-convert stuff into strings.
map(str, flatten(vertex))
instead of the list comprehension. output.write("\t\t{0}\n".format(
" ".join(str(x) for x in flatten(vertex))))
But it looks like your core problem is that try you force another language's idioms onto python.Your flatten function could be a lot simpler (and without quadratic runtime):
import itertools
def flat(l):
return itertools.chain.from_iterable(
flat(e) if isinstance(e, (list, tuple)) else [e]
for e in l
)
But that is still not what you actually want – you only wrote this function because you have it in ruby. What you actually want is: def format_vertex(lst):
return " ".join(
format_vertex(e) if isinstance(e, (list, tuple)) else str(e)
for e in lst
)
output.write("\t\t{}\n".format(format_vertex(vertex))Maybe some day PyPy will be it.
It has a lot of the missing features that bash is missing according to the author and is a very underrated scripting language.
It has support for linux and you may write Cmdlets in Python or other languages for that matter.
F# makes me learn to be a better programmer and it's fun, so there's that. Coding using the Unix Philosophy gives me all the goodness that the author seems to want, all without having to install yet another shell. The only pieces of the bash shell I'm developing are the pieces that help solve the problem in front of me. Everything else is stuff that the next guy can't pick up off the web.
I don't like being a fanboy. Maybe next year I'll start playing around with Haskell. But rewriting/replacing the shell? E-gads. You'd have to make a tremendously better case than this author does. (Insert long discussion here about tools, frameworks, and bad coding discipline)
I'm a Perl fan and I have to say that sigils should go. Or at least become optional.
Most of the times it's just one character too many.
Say you want to write an anonymous function with three arguments like f(a,b,c) = a+b c
In Perl (either 5 or 6), you could for instance write :
sub ($a, $b, $c) { $a+$b*$c }
It's not that long, but each "$" is kind of a visual stain that beclouds the variable name.To me, it would make sense for instance that read-only variables would have no sigil. It's already the case in Perl 6 for constant, since you can write :
constant pi = 355/113;
but if you want sigilless parameter names, you have to use a backslash : sub (\a, \b, \c) { a+b*c }
which is quite ugly.Just make the sigils optional already.
Relevant project: https://github.com/ryanpcmcquen/config-o-matic
Unix has a long tradition of neat little languages that make system programming easier... but none of them is all that good.
I planned to make a language like this myself, and still do, in the back of my mind. Ever since running into Nix and NixOS, I've felt that I have to integrate that worldview into the hypothetical language/shell design. Not sure how.
Even if just to learn from them what they did wrong.
There is, https://github.com/ilyash/ngs#have-you-heard-of-project-x-ho...
> what they did wrong.
Syntax and overall feeling when using the language among other things.
> async/await
Callbacks, promises and async do not resonate with me at all. I find them inconvenient.
In addition, my recent trauma is changing functions from sync to async (promises) in Node.js. We had to do it because the functionality of these functions changed. You have to change all the callers ... and their callers and so forth.
I really prefer top-to-bottom execution.
> Mostly due to the great ecosystem.
You mean available npm packages?
> ES is certainly not made for sysadmin tasks
Yep, that's why it was not mentioned in the post.
Haskell melts my brain. Maybe it's getting better later, I tried about 3 days.
perl6 - sigils are still there (even more of them) and overall feeling is not that different from perl5 despite such great improvements as named function parameters :)
I tried asking #haskell on freenode about "using ghci as a shell" and everybody thought it was a horrible idea. Oh well :(
(There are people who've done work in this direction, but none of them haven't broken out to any significant amount of followers.)
* shelly [1],
* turtle [2], and
* hell [3].
I currently don't have much Haskell experience, but I do keep a ghci session open, hoping that the frustrations of using it as a shell push me to both learn and create.[1] https://hackage.haskell.org/package/shelly
Over my career as a developer I've learned to just embrace whatever I'm working on. Soon enough I learn the peculiarities of the language and framework, and I'm productive. Most of the time the productivity gain from the perfect language and/or framework is minor, compared to the time I spend thinking about a solution.
Personally I'd just select a reasonably available tech, say F#, and use that if I want to write my scripts in a functional way. Over time you make your own library of useful functionality, and you don't have to fight your way around the language because you get to know it well.
This is exactly why Powershell was invented - a desire to Replace the Shell with something Object-Oriented. Powershell passes .NET objects from function to function through the pipeline, instead of passing simply strings. (Sometimes the objects are strings, but not always).
Basically, he didn't do due diligence in PL. ;)
Edit: Guido wanted to do away with all of map, filter, reduce and lambda in Python 3 [0]
[0]: http://www.artima.com/weblogs/viewpost.jsp?thread=98196
That sounds really really weird. The worst I've seen is maybe a factor of 3-4 in some corner cases, largely related to how python does lambdas.
Yeah, isn't that the problem that Lisp macros have been the solution to for decades now?