Live data from Hacker News

The Titania Programming Language

github.com

61–68 of 68 posts

Re: The Titania Programming Language

#61
post #57

Earlier quoted context omitted.

Please note the project isn't even 24 hours old yet. But I am using Oberon-07 as base, and I might deviate from it quite soon too. But I won't be going in the direction of things like Oberon+ (which adds generic and OOP programming) or Micron which adds the entire type system necessary to interact with foreign code. I just wanted something to explain to people how to do tokenizing, parsing, semantic checking (not jus…

> But I am using Oberon-07 as base, and I might deviate from it quite soon too. I am curious about your thoughts on var parameters (i.e. mutable references), as in: proc increment(var x: int) begin x := x + 1 end var i: int begin i := 10 increment(i) // i is now 11 end

i also wonder about this concept; is there a programming language that has this behavior?

Re: The Titania Programming Language

#62
post #28

Earlier quoted context omitted.

Wirth was obsessed with the idea of creating the absolutely minimal useful language, and many of his languages' warts come from that. Variables are at the top because: - you immediately see them (so, perhaps, easier to reason about a function? I dunno) - the compiler is significantly simplified (all of Wirths' languages compile superfast and, if I'm not mistaken, all are single-pass compilers) However, I feel that Wi…

Lua is single pass too and doesn’t have the same restrictions.

Wirth is also from a time when resources were incredibly constrained. So it was a combination of his ideas for what a PL should be: easy to understand, easy to learn, powerful enough to do everything he needed. And the compiler for the language also needed to be the same.

Unfortunately he got kinda stuck in that, and you can see it in all the Oberon flavors: he was clearly fighting against the limitations he imposed, but couldn't break out if them.

Re: The Titania Programming Language

#63
post #57

Earlier quoted context omitted.

> But I am using Oberon-07 as base, and I might deviate from it quite soon too. I am curious about your thoughts on var parameters (i.e. mutable references), as in: proc increment(var x: int) begin x := x + 1 end var i: int begin i := 10 increment(i) // i is now 11 end

i also wonder about this concept; is there a programming language that has this behavior?

Ada, Nim, Pascal. I think C++ also offers it with a specific syntax.

Rust also offers it, but you need to specify it on the call side as well.

Re: The Titania Programming Language

#64
post #10

Having done a fair degree of programming in Wirthwhile languages, I think the only main design decision that I think was a mistake was the variables at the top. I'm not sure of the value of seeing all of the variables used listed in one place, it has certainly led to me encountering a identifier scrolling up to determine the type then scrolling back down. When the variable is only used on a few consecutive lines it's…

> I'm not sure of the value of seeing all of the variables used listed in one place It means the compiler knows how much memory the function's activation frame will take and the offset into that for every variable before it encounters any code in the function. Basically, it makes it easier to write a single-pass compiler. That was important in the 70s but is less important these days.

A lot of people in this subthread are echoing this, but it's at most maybe very slightly easier. For example, TinyCC is a one-pass C compiler and yet C has sub-scopes int foo() { /.../ { int x; /.../ } }. The same could be said of Ken Thompson's C compiler which I believe was also one-pass.

Does Titania not have/intend to have lexically local subscopes? That would seem very un-Wirthian to me.

Re: The Titania Programming Language

#65
post #64

Earlier quoted context omitted.

> I'm not sure of the value of seeing all of the variables used listed in one place It means the compiler knows how much memory the function's activation frame will take and the offset into that for every variable before it encounters any code in the function. Basically, it makes it easier to write a single-pass compiler. That was important in the 70s but is less important these days.

A lot of people in this subthread are echoing this, but it's at most maybe very slightly easier. For example, TinyCC is a one-pass C compiler and yet C has sub-scopes int foo() { / ... / { int x; / ... / } }. The same could be said of Ken Thompson's C compiler which I believe was also one-pass. Does Titania not have/intend to have lexically local subscopes? That would seem very un-Wirthian to me.

One difference here might be that most Pascals support local functions and C does not.

Re: The Titania Programming Language

#66
post #50

Earlier quoted context omitted.

Please note the project isn't even 24 hours old yet. But I am using Oberon-07 as base, and I might deviate from it quite soon too. But I won't be going in the direction of things like Oberon+ (which adds generic and OOP programming) or Micron which adds the entire type system necessary to interact with foreign code. I just wanted something to explain to people how to do tokenizing, parsing, semantic checking (not jus…

Really nice project, well done. I would say it's probably not necessary to explain what the connection between Titania and Oberon is in the README. It's probably evident to most people?

Alas, most people have memorized at most seven Shakespearean sonnets.

Re: The Titania Programming Language

#67
post #10

Having done a fair degree of programming in Wirthwhile languages, I think the only main design decision that I think was a mistake was the variables at the top. I'm not sure of the value of seeing all of the variables used listed in one place, it has certainly led to me encountering a identifier scrolling up to determine the type then scrolling back down. When the variable is only used on a few consecutive lines it's…

A nice side-effect of "variables at the top": you keep your functions short.

One would assume that, but in practice, the predominant style is not one of many short procedures. Instead it feels that there's a preference to just inline the code unless the resulting procedure will have more than one caller.

For example, search for "PROCEDURE Scan" here: https://people.inf.ethz.ch/wirth/ProjectOberon/Sources/Texts...

Control structures are deeply nested and this goes on for 64 (very dense) lines. The low line count but is an artifact of how Oberon is conventionally formatted. When reformatted to mimic the conventions of languages like C, Java or Python it works out to more than 120 lines.

When I program in Oberon (recreationally) I tend to follow this style even though I would extract the same code into a separate method were I writing in Java.

Re: The Titania Programming Language

#68
post #63

Earlier quoted context omitted.

i also wonder about this concept; is there a programming language that has this behavior?

Ada, Nim, Pascal. I think C++ also offers it with a specific syntax. Rust also offers it, but you need to specify it on the call side as well.

Fortran can do "in out" arguments to subroutines also.
Post reply on HN