News for hackers. Stuff that matters.
Re:A statically typed scripting language that transpiles to ... by sdevonoes on Friday March 25, 2022 @11:21AM (#30803241)
What I miss in the README page is the output of the transpilation.
Re:A statically typed scripting language that transpiles to ... by maggs on Friday March 25, 2022 @03:46PM (#30806358)
I, too, missed that in the README. I was curious enough try it out in a vm. Here's the output for fib.li: https://termbin.com/pagk Or for something more complex, raytracing.sh: https://termbin.com/4rpd

I was mostly wondering how/if it does any type checks for function input; it does not. Also raytracing.sh unfortunately fails to run on my system as it is.

Re:A statically typed scripting language that transpiles to ... by JyB on Friday March 25, 2022 @11:39AM (#30803458)
I guess the output is not really meant to be readable in any way
Re:A statically typed scripting language that transpiles to ... by em-bee on Friday March 25, 2022 @11:45AM (#30803535)
if it transpiles to sh then the output should be an sh script. that should be at least somewhat readable.
Re:A statically typed scripting language that transpiles to ... by xyzzy123 on Friday March 25, 2022 @11:52AM (#30803651)
Yes although it might be readable in the same way that autotools configure scripts are readable -- technically you can, but you probably don't want to, and if you need to then something has gone badly wrong.
Re:A statically typed scripting language that transpiles to ... by xg15 on Friday March 25, 2022 @01:57PM (#30805269)
I mean yes. Things do go wrong, especially with bleeding-edge projects such as this.

You'll have to look at that output if you want to debug things, understand error messages.

As such, I'd absolutely see it as a quality measure for a transpiler how readable the code it produces is.

Re:A statically typed scripting language that transpiles to ... by em-bee on Friday March 25, 2022 @12:48PM (#30804410)
yeah, that's kind of what i meant. especially if the script has external commands you should be able to at least recognize something.
Re:A statically typed scripting language that transpiles to ... by ketralnis on Friday March 25, 2022 @12:31PM (#30804160)
That's not a given, think typescript compiling to minified javascript. Some compilers like coffeescript do put in some effort to have the output be readable but I wouldn't assert that it should be a goal for everyone
Re:A statically typed scripting language that transpiles to ... by eyelidlessness on Friday March 25, 2022 @01:05PM (#30804638)
> typescript compiling to minified javascript

This is an odd example. TypeScript compiles to readable JavaScript for nearly everything except the odd runtime behavior (eg enums) and “downleveling”, which is increasingly unnecessary. Minification is still a separate step AFAIK (if you’re using tsc; obviously ESBuild and SWC are another story, as will be Bun).

Re:A statically typed scripting language that transpiles to ... by ketralnis on Friday March 25, 2022 @06:46PM (#30807729)
You caught me, I've never written typescript. I don't think that changes my claim though
Re:A statically typed scripting language that transpiles to ... by eyelidlessness on Friday March 25, 2022 @08:47PM (#30808336)
I think I have varying and stronger feelings about it depending on context. Personally if I were to use this or any compile-to-shell thing, I’d probably prefer it produces unreadable output. I don’t want to ever read bash if I can help it. If I have to, it’s a good sign I’m already beyond my preferred scope for using bash in any way.

Whereas if I’m compiling TypeScript/CoffeeScript/anything to JS, it’s pretty likely I already have JS as a built in constraint and I probably want to be able to read the output so I can debug it.

Re:A statically typed scripting language that transpiles to ... by Brian_K_White on Friday March 25, 2022 @04:54PM (#30806950)
It's possible to express many common features and functions of other languages in sh fairly well, so it's probably possible for a tool like this to output something not too bad.

But even so, I would never expect any transpilation output to be more than technically readable.

The part with the high level meaning is the part the human wrote. That's the entire point of any language.

The output can not be considered source, regardless that it's possible to also write source in that same syntax.

The only reason to even bother with transpiling instead of just requiring the necessary interpreter, is to ship something that the target already supports. It's very very little different than shipping a binary.

The differences are just that a .sh is at least possible to read and hack vs not-possible. Not convenient or good, merely possible vs not-possible. And a .sh is more portable than a binary in that it doesn't care what the cpu or os is.

If you want anything more high level meaningful instead of some 90's web page generator html output, you have to write that yourself. An automated tool cannot reverse engineer some code into an elegant expression of the original intent of that code. In that way a compiler or transpiler is not much different from a decompiler.

Though, I admit there is room for levels. I don't know just how crude this tool's output is, but I know there is a range of what's possible, it does't have to be

Re:A statically typed scripting language that transpiles to ... by catlifeonmars on Saturday March 26, 2022 @01:46PM (#30813787)
Also, source maps a la JavaScript.
Re:A statically typed scripting language that transpiles to ... by hnlmorg on Friday March 25, 2022 @11:55AM (#30803690)
I think you can liken this to web assembly. The output might be text but it’s not intended to be human readable.