Hacker News new | past | comments | ask | show | jobs | submit login
A port of the GTK+3 Hello World to Bash (github.com/taviso)
109 points by regitwo on March 9, 2016 | hide | past | favorite | 25 comments



This seems to basically showcase the ctypes.sh Bash plug-in, which is what is doing the magic calling into a native library. See https://github.com/taviso/ctypes.sh/wiki, that was very interesting.


Previous discussion on ctypes.sh: https://news.ycombinator.com/item?id=10184940


As someone who has written quite large projects in both C and Bash, I find it amusing that it's now even easier to use two of our biggest footguns together. Still, I can see this being very useful for writing test scripts for libraries.


I don't know if this is awesome or just sick.


Here are the reactions from the parent project's readme: https://github.com/taviso/ctypes.sh#here-is-what-people-have...


From a previous HN story, the comment was made "The problem with this project is that somebody might use it."


You can play with dynamic libraries without a compiler.


I don't know whether to be delighted or appalled, and I love the brain-twist.


I've never heard of ctypes.sh, but it sounds pretty interesting: https://github.com/taviso/ctypes.sh/wiki


Whilst it's a fun proof of concept, the real solution would be zenity: https://help.gnome.org/users/zenity/stable/info.html.en


I have long been annoyed that this wasn't possible. Seems like you could use this as a kind of "C REPL".


Why not use Tk/wish? Result is basically the same but means are much, much more conventional.


tightly packed portable version of this code

--------------------------------------------------------

#!/usr/bin/env bash

cat <<EOF | /usr/local/bin/wish

package require Tk

pack [button .b -text {Push Me} -command {

    tk_messageBox -message {hello, world}
}]

EOF

--------------------------------------------------------

Of course doing it directly in Tk Tcl would be even more portable, readable, simple and smarter and easier to deploy/maintain.

And at the opposite of gtk team tk team does not breaks API for the pleasure of being more right than the users.

So it would be a win-win-win situation to use Tk/Tcl instead of gtk3.


You can simplify it by starting your program like this:

  #!/bin/sh
  # \
  exec wish "$0" ${1+"$@"}
( You wouldn't need the cat pipe. )


I hate that something like this is possible.

This gives people who know only bash the ability to create a mess rather than learn a real scripting language like Python.


Python elitism cannot challenge the glory of the Hack. :)


I've tried writing a GTK 3 app in python, it was pretty horrible. The GTK XML format is very annoying to work with, and writing interfaces programmatically requires using an automatically generated C->python API, which has essentially no documentation.


I didn't find GTK2 with Glade all that difficult.

But eventually I dropped GTK and switched to Qt. I thought they worked through all the common issues with better solutions.


Are there any GTK bindings that feel "native"? These automatically generated bindings are almost as “ugly” and uncomfortable as using GObjects in C.


They could accomplish this and worse in Pyhon.


All the languages provide the tools to create a mess, the only external dependency is the user. This can be abused quite destructively, but with good intentions it can be used for testing purposes or making a tiny interface to a library. Why throw the baby with the bathwater?


I'm trying to understand your position.

Would you rather that something like this not be possible or that people would not create things like this?


You should be able to do something like this in PowerShell on Windows already; .NET types are easy to use in it.

Since I haven't heard any screams of anguish coming from Windows people, I wouldn't worry about it.


I think the same thing was said about Javascript when node.js was created.


And rightly so. It would be much better to be running Python in the browser than to be running Javascript on the server.




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: