Ctypes.sh – A foreign function interface for bash
11–20 of 39 posts
Re: Ctypes.sh – A foreign function interface for bash
#12The problem with this project is that somebody might use it. I argue that if you need to do something in bash that involves more than a sequence of commands, including a simple if statement, then you should switch from bash to a proper scripting language (python, perl, ruby, nodejs, take your pick.)
A scripting language like those you mentioned is great for if you need to run your script on systems you don't control, or you need it to be cross platform, or you'd describe what you're doing as creating software rather than automating tasks.
No scripting language can ever integrate with the host system quite as well as shell scripts can. Sure, shell scripts make it easy to shoot yourself in the foot, but then can't you say the same of at least perl and ruby?
I don't really see many good use cases for this library though. By the time you'd use it you should probably move on to something else.
Re: Ctypes.sh – A foreign function interface for bash
#13The problem with this project is that somebody might use it. I argue that if you need to do something in bash that involves more than a sequence of commands, including a simple if statement, then you should switch from bash to a proper scripting language (python, perl, ruby, nodejs, take your pick.)
I disagree. Shell scripts are great for automating system tasks — for sysadminy type stuff, including tasks with high complexity with nested loops and conditionals. A scripting language like those you mentioned is great for if you need to run your script on systems you don't control, or you need it to be cross platform, or you'd describe what you're doing as creating software rather than automating tasks. No scriptin…
What is the basis for this? Shell script is a scripting language (more precisely, a set of scripting languages with similar features.) The difference between shell scripting languages and other scripting languages is that the former are optimized around the need to scale down to a convenient line-by-line way to work with the system in a REPL; while the others may support work in a REPL it is not what they are optimized for.
There's no real reason why other scripting languages can't integrate with the system as well as shell languages.
Re: Ctypes.sh – A foreign function interface for bash
#14Earlier quoted context omitted.
You can use gdb as an REPL for C.
This blew my mind the first time some one showed me, and is one of the reasons I currently prefer C to other mainstream compiled languages. Edit: I suppose it is possible to get some version of a repl with C++ (Cling?), Java (Beanshell, Java 9?), C# (Mono, but not currently .Net?). But each of those seems generally a bit harder to get access to than simply calling gdb on a binary with debugging symbols enabled.
Re: Ctypes.sh – A foreign function interface for bash
#15Earlier quoted context omitted.
I disagree. Shell scripts are great for automating system tasks — for sysadminy type stuff, including tasks with high complexity with nested loops and conditionals. A scripting language like those you mentioned is great for if you need to run your script on systems you don't control, or you need it to be cross platform, or you'd describe what you're doing as creating software rather than automating tasks. No scriptin…
> No scripting language can ever integrate with the host system quite as well as shell scripts can. What is the basis for this? Shell script is a scripting language (more precisely, a set of scripting languages with similar features.) The difference between shell scripting languages and other scripting languages is that the former are optimized around the need to scale down to a convenient line-by-line way to work wi…
> What is the basis for this? Shell script is a scripting language (more precisely, a set of scripting languages with similar features.) The difference between shell scripting languages and other scripting languages is that the former are optimized around the need to scale down to a convenient line-by-line way to work with the system in a REPL; while the others may support work in a REPL it is not what they are optimized for.
Disagree. The defining characteristic of shell scripting languages is that they are a shell that can be scripted. What's a shell? It's a program designed to be a layer around the OS, exposing all of the capabilities of the OS to the user in a convenient form.
So the only way a non-shell scripting language can become that powerful is to become a shell scripting language.
Re: Ctypes.sh – A foreign function interface for bash
#16Earlier quoted context omitted.
This blew my mind the first time some one showed me, and is one of the reasons I currently prefer C to other mainstream compiled languages. Edit: I suppose it is possible to get some version of a repl with C++ (Cling?), Java (Beanshell, Java 9?), C# (Mono, but not currently .Net?). But each of those seems generally a bit harder to get access to than simply calling gdb on a binary with debugging symbols enabled.
C# has REPL in the immediate window when the debugger is running; so it's kind of like using GDB as a REPL for C. Although it is somewhat limited in what you can do.
Visual Studio's a little bit heavyweight, but if you're programming C#, there's a good chance that's what you're using anyway.
Re: Ctypes.sh – A foreign function interface for bash
#17Earlier quoted context omitted.
> No scripting language can ever integrate with the host system quite as well as shell scripts can. What is the basis for this? Shell script is a scripting language (more precisely, a set of scripting languages with similar features.) The difference between shell scripting languages and other scripting languages is that the former are optimized around the need to scale down to a convenient line-by-line way to work wi…
>> No scripting language can ever integrate with the host system quite as well as shell scripts can. > What is the basis for this? Shell script is a scripting language (more precisely, a set of scripting languages with similar features.) The difference between shell scripting languages and other scripting languages is that the former are optimized around the need to scale down to a convenient line-by-line way to work…
I think that's what they were getting at when they said:
>optimized around the need to scale down to a convenient line-by-line way to work with the system in a REPL
The only real difference is optimization for the REPL. Many of the things you might consider part of the experience aren't even shell built-ins, they're utilities maintained separately from your shell. Powershell is a good example of a shell scripting language that has a lot more going on than your traditional shell. Native object pipelines, .net libraries, etc. but the most important thing about it is that it's optimized for the REPL.
Re: Ctypes.sh – A foreign function interface for bash
#18What could go wrong? /s All sarcasm aside, a very interesting idea. I'm not sure what the proper use case is, but I'm sure someone will love this.
The best use-case I can think of is using bash as a REPL for C libraries. Many times in the past, I've made library calls that either misinterpreted the parameters or the result value. I would have loved the ability to prototype those calls in bash until I understood them enough to call them properly.
Re: Ctypes.sh – A foreign function interface for bash
#19Earlier quoted context omitted.
You can use gdb as an REPL for C.
This blew my mind the first time some one showed me, and is one of the reasons I currently prefer C to other mainstream compiled languages. Edit: I suppose it is possible to get some version of a repl with C++ (Cling?), Java (Beanshell, Java 9?), C# (Mono, but not currently .Net?). But each of those seems generally a bit harder to get access to than simply calling gdb on a binary with debugging symbols enabled.
Re: Ctypes.sh – A foreign function interface for bash
#20Earlier quoted context omitted.
I disagree. Shell scripts are great for automating system tasks — for sysadminy type stuff, including tasks with high complexity with nested loops and conditionals. A scripting language like those you mentioned is great for if you need to run your script on systems you don't control, or you need it to be cross platform, or you'd describe what you're doing as creating software rather than automating tasks. No scriptin…
> No scripting language can ever integrate with the host system quite as well as shell scripts can. What is the basis for this? Shell script is a scripting language (more precisely, a set of scripting languages with similar features.) The difference between shell scripting languages and other scripting languages is that the former are optimized around the need to scale down to a convenient line-by-line way to work wi…
The primitives in shell scripts are the primitives of the operating system. The fundamental building blocks of your language are strings and files and processes, which makes it really convenient to work with strings and files and processes, AKA the operating system.