Live data from Hacker News

Borgo is a statically typed language that compiles to Go

github.com

121–130 of 559 posts

Re: Borgo is a statically typed language that compiles to Go

#121

Earlier quoted context omitted.

> In fact, Go doesn’t make you deal with your errors Your right, it does not. I will _ =: an error in a throw away script all the time. I see that in a code review, in production code... Big red flag. This is a departure from an exception, that might be thrown in one place and handled far far away from the code you're looking at.

I'm not an expert in Go, and my experience is somewhat limited, however, a few years back I fixed a really subtle bug in a project that was related to the fact that errors _weren't_ being handled correctly. As a relative newbie to Go, the code in the diff[0] didn't appear to be doing anything wrong, until I added some print statements and realized that the numbers were not adding up correctly. IMO, if the returned va…

> The fact that this was a bug at all makes me fear for the rest of the code base.

The fact that the commit was accepted into a release without any changes to accompanying tests is what is most concerning. You should be afraid.

Re: Borgo is a statically typed language that compiles to Go

#122
post #17

Earlier quoted context omitted.

The word "transpiler" propagates the misunderstanding that there is something special about a compiler that emits machine code, that requires some special "compiler" techniques for special "compiler" purposes that are not necessary for "transpiler" purposes because "transpiling" requires a completely different set of techniques. There aren't any such techniques. If one were to create an academic discipline to study "…

1. Transpilers output to another programming language that is typically written by hand by others (so not assembly). 2. Transpilers don’t typically optimize code, leaving those transformations to the compiler of the target language. 3. Compilers will typically have an internal representation (SSA) which they operate on to optimize. Transpilers typically operate on the AST (because they don’t need to do any but the mo…

These differences aren't inherent to transpilers vs compilers, they're mostly the result of the fact that the vast majority of transpilers are less mature than the battle-tested compilers that you're thinking of.

The average hobby compiler—regardless of target—doesn't optimize code and works directly on the AST because that's simple to get started with. Most hobby compilers also target some other language rather than LLVM or machine code because that's simple to get started with, so the result is that most transpilers are hobby projects that don't optimize. But there's no reason why a transpiler shouldn't include optimization steps that adapt the output to use code paths that are known to be fast, and a production-grade transpiler typically will include these steps.

Re: Borgo is a statically typed language that compiles to Go

#123
post #15

Earlier quoted context omitted.

Thanks, I'd always thought targeted transformations -> transpiler, but it makes sense it's really a subset of general compiler functionality, sans binary output.

> but it makes sense it's really a subset of general compiler functionality, sans binary output. Tell us more about this compiler subset that does not produce binary output. What do they produce? Ternary? Qubits? Nothing?

They produce text, such as Golang source code.

Re: Borgo is a statically typed language that compiles to Go

#124
post #17

Earlier quoted context omitted.

The word "transpiler" propagates the misunderstanding that there is something special about a compiler that emits machine code, that requires some special "compiler" techniques for special "compiler" purposes that are not necessary for "transpiler" purposes because "transpiling" requires a completely different set of techniques. There aren't any such techniques. If one were to create an academic discipline to study "…

I'm fairly certain that source-to-source transpilers rarely use anything like BURS or any other sufficiently smart "instruction selection" (or insturction scheduling, for that matter) algorithms because why would they, the compilers for the targeted language already incorporate such algorithms, maybe even of the higher quality than the transpiler's author are capable to write themselves.

All compilers end up with local considerations. Instruction selection or register allocation is not a consideration special to compilers that "transpilers" do not need to have, they are specific considerations for that particular compiler target. A compiler to Go must consider Go's identifier rules, which does not apply to compilers targeting a CPU. A compiler to SQL must consider valid SQL syntax and have their own optimization concerns that don't apply to Go. And so on.

The middles all look very similar, though, which is where the heart of "compiler" comes from; that process of some sort of parsing and then transforming down to some other representation. This has a distinguishing set of characteristics and problems despite what frontends and backends get slapped on them.

Re: Borgo is a statically typed language that compiles to Go

#125

The only language I can think of that has pulled off “compiles to another totaling language” and gained mainstream adoption is typescript, and I’m sure it wouldn’t have done so if it were possible to run in the browser otherwise. Can anyone think of another example?

There’s web2c which transpiles Pascal-Web to C code. And in the 90s, Eberhard Mattes, to enable his port of TeX and friends to OS/2 and DOS wrote a Pascal to C compiler (I remember when it was first released, there was speculation that it might have been a pirated commercial implementation because how could one guy manage this, but that was short-lived as people realized it was faster than any of the commercial versions.)

Re: Borgo is a statically typed language that compiles to Go

#126
post #63

Earlier quoted context omitted.

It doesn't matter but I fully disagree with this. A transpiler emits code the user is supposed to understand, a compiler does not. At least that's the general way I've seen the term used, and it seems quite consistent.

There is a phenomenon I have observed many times where you can get a bunch of people in a room and make some statement, in this case, "Compilers are different than transpilers", and everyone around the table will nod sagely. Yup. We all agree with this statement. But if you dig in, it will turn out that every single one of them has a different interpretation, quite often fatally so to whatever the task at hand is. I…

2 hours later, I think it's safe to say there are multiple definitions in play that are, if not outright contradictory, certainly not identical.

It seems the term is not terribly useful even on its own terms... it is not as well defined as everyone thinks.

Ultimately, "compiler" isn't a bright shining line either... I can take anything and shade it down to the point where you might not be sure ("is that a 'compiler' or an 'interpreter'?"), but the "transpiler" term is trying to draw a line where there isn't even a seam in the landscape.

Re: Borgo is a statically typed language that compiles to Go

#127
post #2

Is it correct to say Borgo "compiles to Go", or should it say "transpiles to Go" It appears to be a transpiler (consumes a Borgo and does the work to convert and emit a Go program as text): https://github.com/borgo-lang/borgo/blob/main/compiler/src/c...

Readme says transpile: "Borgo is a new language that transpiles to Go." And it's written in rust. Kinda unholy.

Nothing unholy there. It's easier to transpile to a less constrained language. Transpiling to Rust would require using one of the GC crates or refcount everything. Then you'd have to also satisfy the mutability and send/sync constraints. Go needs none of these things, so all the transpiler needs to care about is it's own added constraints.

Re: Borgo is a statically typed language that compiles to Go

#128

Earlier quoted context omitted.

> but it makes sense it's really a subset of general compiler functionality, sans binary output. Tell us more about this compiler subset that does not produce binary output. What do they produce? Ternary? Qubits? Nothing?

They produce text, such as Golang source code.

Thanks for your response, but the Go spec asserts that Go source is represented as UTF-8. UTF-8 is a binary encoding.

We're talking about compilers that produce something other than binary output.

Re: Borgo is a statically typed language that compiles to Go

#129

Earlier quoted context omitted.

> In fact, Go doesn’t make you deal with your errors Your right, it does not. I will _ =: an error in a throw away script all the time. I see that in a code review, in production code... Big red flag. This is a departure from an exception, that might be thrown in one place and handled far far away from the code you're looking at.

I'm not an expert in Go, and my experience is somewhat limited, however, a few years back I fixed a really subtle bug in a project that was related to the fact that errors _weren't_ being handled correctly. As a relative newbie to Go, the code in the diff[0] didn't appear to be doing anything wrong, until I added some print statements and realized that the numbers were not adding up correctly. IMO, if the returned va…

Is the wrong code in the new part of the diff or in the old one?

Generally getting zero value from a map is a feature, but the code that the diff replaces did look overly complex and fragile to me already tbh

Re: Borgo is a statically typed language that compiles to Go

#130

Many people on HN “Rust syntax is so ugly” rustaceans “I love the Rust syntax so much I want it in Go too”

The author notes[0] that it keeps the Rust syntax to avoid having to write a parser. I have no issue with the syntax but I think the chance of uptake would be considerably improved if the syntax were as close to Go's as reasonably possible. That's because I estimate Go programmers to be a better target for this than Rust programmers, but maybe I'm wrong. [0] https://news.ycombinator.com/item?id=36847594

Having a soft-Rust alternative is a recurring topic in the Rust community and is acknowledged as being of interest by core members:

https://www.reddit.com/r/rust/comments/j2l9v9/revisiting_a_s...

Post reply on HN