Remix.run Logo
▲ pull_my_finger a day ago

I need to put a disclaimer to say that I hate when people hijack a post about foo to talk about bar, but:

> The language is not object oriented but it provides some features to facilitate object oriented designs.

It has classes and implicit `self`. Not nothing, but I don't think it's incorrect to say has any more OOP than general purpose languages like Lua or JavaScript in that sense.

Something like Pony[1] is a more mature and feature rich entry and has a much better OOP story.

All that said: a) I'm sorry for doing the thing I hate when other people do

b) Creating a language is a big undertaking, and it's super cool that they did it

c) I see it seems to already be written in Copper too, which is also very neat!

[1]: https://www.ponylang.io/

▲stevefolta a day ago | parent | next [-]

Re "c)": No, self-hosting is the biggest temptation, and the worst mistake, for any programming language. It's death to bootstrapping. However, if you do succumb to the temptation to self-host, having a C backend, as Copper does, is probably the best way to handle it.

▲p1necone a day ago | parent | next [-]

I've never really understood the opposition to self-hosting.

As long as:

* Your language is the kind of language that suits compiler development.

and

* You support compiling to C or something so that bootstrapping doesn't involve an opaque binary or compiling 30 different git commits in a row.

What are the downsides exactly?

▲simonask a day ago | parent | next [-]

The usual argument is that it is a distraction when you’re designing a language, and it leads to programming languages that are all excellent for writing compilers and parsers, but not particularly good for other things.

Since the majority of programs are not compilers, it might make more sense to focus on interesting things that aren’t relevant to compilers.

Some ideas from the top of my head: async I/O, a great SIMD story, effect systems, robustness systems for long-running processes (I’m only aware of Erlang/Elixir), and many others.

Compilers do exercise some things, like error handling and memory management, but they’re not particularly difficult or interesting in general.

▲12_throw_away 6 hours ago | parent | prev | next [-]

I had a little homebrew CI system, and decided its first use case would be building itself. Seems like an extremely obvious thing to do, right?

The problem happens when you have bugs and test failures. The hoster and hostee look the same, behave the same, and emit the same error messages. So I had unknowingly opted into spending a big chunk of my debugging time being confused and wrong about A) where errors were coming from and B) what they even signified.

Basically, self-hosting too early, before the thing was stable and trustworthy, was a disaster. (It's obvious in retrospect, really, but was still pretty awful at the time.) I tried again later, after everything had stabilized and it was routinely building other projects routinely, and it was fine.

▲ModernMech 12 hours ago | parent | prev [-]

The main objection I used to have was there are infinite things to do when building a programming language, it's already enough to build 1 compiler, you probably shouldn't also build a second as your main stress test of the language.

That said if your languages is for building compilers you'd probably want to do it. Otherwise, basically no one writes compilers, and if they are they're writing them for their own languages in something much more mature than your nascent language. And if the ambient advice is to bootstrap asap, they'll only be using your language for a hot second anyway, so they're the worst users to cater towards.

These days I think all languages should try to do it with an LLM because, why not? That also means bootstrapping a compiler isn't exactly an impressive feat anymore, most new languages are doing it now.

▲Zak a day ago | parent | prev | next [-]

As long as one of the backends is something widely available, I don't see a problem. C is a decent option. LLVM IR is another.

▲ktimespi a day ago | parent | prev | next [-]

What's the problem with self-hosting? I do imagine it's easier to write a compiler in something like Haskell.

▲Conscat a day ago | parent [-]

The problems with bootstrapping a self hosted compiler are often greatly overstated.

▲ModernMech 12 hours ago | parent [-]

It's not a "problem", it's just the juice isn't worth the squeeze.

▲ivan_gammel a day ago | parent | prev | next [-]

Self-hosting is a trivial matter if you can roughly map a subset of features of an existing language to your language. Write bootstrap compiler in that language and translator in parallel (as long as you have good AST/LST), run conformance tests on both.

▲ModernMech 12 hours ago | parent [-]

These days with LLM bootstrapping the compiler is a lot like using YACC for the parser. You just point the LLM at your compiler spec, tell it "bootstrap this" and then it does.

▲ivan_gammel 11 hours ago | parent [-]

Sort of. Although the process may not look exactly like that unless you have a really good spec.

▲ModernMech 4 hours ago | parent [-]

True, I’m assuming you’ve already implemented one compiler. You point the ai to that and instruct the ai machine “bootstrap the language using this reference compiler”.

▲ivan_gammel 3 hours ago | parent [-]

Sort of. You do not have to implement full compiler before starting building the self-hosted one. With LLM it is possible now to write the spec, and at the same time build both reference compiler and translator, validating your design early. No big upfront effort.

▲jibalt a day ago | parent | prev | next [-]

This isn't at all true, as proven especially by Zig.

▲Conscat a day ago | parent [-]

I would go so far as to say Zig even tries too hard to solve it (although they reused existing technology they already wanted, so it was almost free). You can bootstrap a self-hosted compiler to new environments by porting the source, cross-compiling it, and scp'ing or otherwise downloading it over to the target. And that's if you don't want to just use QEMU to develop it. We already do this exact thing when developing for embedded devices or often any type of aarch64 programs.

▲dnautics a day ago | parent [-]

As someone who has monkeyed around with the zig compiler, having the bootstrap done made monkeying around way, way more straightforward than when it wasn't around. I will admit I don't know the details and it's possible the QOL improvements that affected me only depended on other things that got solved along the way. But I have been building the stage0 and stage1 compilers to get my first artifact when I bump to the latest.

▲throwaway894345 a day ago | parent | prev [-]

Why is it harder to bootstrap a self-hosted language than it is to bootstrap a language implemented in C, which itself must be bootstrapped?

Bootstrapping is a one-time cost, but implementing the toolchain in C is a cost everyone has to pay every single time they touch the toolchain source.

▲uecker 18 hours ago | parent [-]

What additional cost does it have to implement the toolchain in C? I would say there is some benefit in terms of implicit testing to have a compiler self-hosting. But having a toolchain in C also has real benefits.

▲throwaway894345 12 hours ago | parent [-]

C is a notoriously difficult language to work in. It has no build system, no module system, an anemic standard library with footguns like null terminated strings, loads of undefined behavior, etc. Moreover, and maybe most importantly, the people developing the language have less opportunity to dogfood it.

I’m sure there are benefits to a C toolchain, but the costs overwhelmingly favor self-hosting for many languages.

▲uecker 9 hours ago | parent [-]

We see so much languages being invented, and many of them do active anti-C marketing. But personally, I do not find it difficult to work in and also enjoy it much more than working in many other languages. There are, of course, build systems one can use, they are just not tied to the language - which build systems should not be. I also do not find most UB a problem in practice, many of them can be fixed simply by using the right compiler flags. Some are more difficult to fix, but think the problem is massively exaggerated. One can also use C with a garbage collector, as GCC does (technically it is now C++).

I agree about your dogfooding comment though.

▲throwaway894345 8 hours ago | parent [-]

I like working in C too, but if better C developers than me say they can’t use it safely then I’m not going to think that I somehow can.

And even though I like writing C, the build tooling and the lack of modules system and a bunch of other footguns remain. (And say what you will about language-specific build tools, but they work very well for 99% of cases, and the benefits of the entire ecosystem using the same tool are significant).

Moreover, I want contributors to my language, and the reality is that however much I like C, the intersection of people who want to work on my language and people who like writing C is going to be vanishingly small. If my language is C-like (e.g., Zig) then that intersection will likely be much bigger, but as the target language approaches C, the benefit of using C goes to 0.

▲uecker 8 hours ago | parent [-]

I think the argument that it is too difficult to write safe C misleading. While it is very difficult to write perfectly safe code in C, this seems to be used as explanation for the amount of CVEs we see. But when I look at the CVEs, the code is often terrible! I recently read a study where the authors observed that most of the projects did not compile without warnings when using GCC's analyzer. At the same time, the Rust rewrite of coreutils with more than 100 CVEs does not exactly convince me that the problem is mainly the choice of language.

I agree that there exist many good reasons to make a language self-hosting. Still, I think there also many obvious benefits from using C.

▲throwaway894345 a day ago | parent | prev | next [-]

OOP is one of the weirdest topics in computer science in that no one can agree on what it means. Even proponents of “OOP” have wildly different ideas about what it means. For some it’s “encapsulation”, for others it’s “inheritance”, for others it’s “message passing”. It seems the glue that binds OOP proponents together is little more than the sequence of letters: O-O-P.

▲pull_my_finger a day ago | parent [-]

I drank the Elegant Objects[1] koolaid, and recommend the two books (Elegant Objects vol 1 and 2) whole-heartedly to anyone interested in OOP. Pony lang lets you write 95% of the kind of OOP described in the books idiomatically, without any kind of crazy shenanigans.

I think most people today would say encapsulation and message passing are pretty core to the definition of OO and inheritance is largely seen as an anti-pattern.

One thing I really like about Elegant Objects is that it is very palatable to FP enjoyers. Objects must encapsulate state, but they must also be immutable. Good OOP is declarative like good FP. It looks a lot like lisp imo. You're encouraged to code against interfaces instead of using inheritance etc.

[1]: https://www.elegantobjects.org/

▲dumpsterdiver a day ago | parent | prev | next [-]

Since we’re nitpicking: you used a double negative, which is a confusing way of communicating an idea.

▲soperj a day ago | parent [-]

The bike shedders have entered the chat.

There's a difference between nitpicking the topic of the article and nitpicking someone's grammar.

▲dumpsterdiver a day ago | parent [-]

To be fair, it really is a confusing way of communicating, and it’s useful feedback when taken to heart.

▲Conscat a day ago | parent [-]

It's not confusing.

▲Someone a day ago | parent | next [-]

> Not nothing, but I don't think it's incorrect to say has any more OOP than general purpose languages like Lua or JavaScript in that sense.

IMO, that text is confusing.

“Not nothing” is saying it has some OO features.

“I don't think it's incorrect to say has any more OOP than general purpose languages like Lua or JavaScript in that sense” = I think this language has more OOP than languages like Lua or JavaScript”

So, that more or less says “A, but A”. If so, what’s the “but” about?

▲pull_my_finger a day ago | parent [-]

I think it needs more negatives. "I don't think it's incorrect to say [it does not have] any more OOP than general purpose languages like Lua or JavaScript in that sense".

I had retyped it a few times trying not to come off as overly negative or a jerk.

▲F3nd0 a day ago | parent | prev | next [-]

> Not nothing, but I don't think it's incorrect to say has any more OOP than general purpose languages like Lua or JavaScript in that sense.

The comment is saying that the language has more OOP than Lua or JavaScript, but it seems like it might have been meant to say the opposite. That, and it appears to be missing a subject (which I assume to be ‘it’ or ‘the language in question’, based on context). So personally I do find it somewhat confusing.

The problem is not the double negative itself, though; it’s more how it’s being used in context here.

▲lukan a day ago | parent | prev [-]

It was also to me. I also prefer simple clear language, so much for my feedback. Can we now move on?

▲anonymous908213 a day ago | parent | prev [-]

Lampshading that you're doing something wrong doesn't make doing the thing less wrong. Hijacking a language post, of all things, to tell people some other completely unrelated project is better is ridiculously uncouth.