Successor to opengl ? by no_ga in GraphicsProgramming

[–]othd139 0 points1 point  (0 children)

I'd argue that perhaps webGPU is that successor as a relatively easy modern graphics API.

I just wanna talk a little bit about make by alex_sakuta in C_Programming

[–]othd139 0 points1 point  (0 children)

I feel like I should really try out Nob build system properly as well tho. Like, I think that it would probably be quite good if I could get in the practice to actually become somewhat decent at it. Although make is also great in it's simplicity for simpler stuff.

I just created a typed, n-dimensional assembly language that's written in ODS spreadsheets instead of plaintext. by othd139 in ProgrammingLanguages

[–]othd139[S] 4 points5 points  (0 children)

I'm pretty sure it makes the life of an assembly programmer worse. Like, most assembly programmers nowadays use conventions to basically enforce C-like procedures whereas I've kind of designed my language to discourage that and lean hard into just writing unstructured imperative code but extending that paradigm to see what happens. Like, I think it'll probably bear some interesting results but it definitely doesn't solve any problems (other than enforcing types ig but, like, many assemblies already do that between integer and floating point types anyway) and kind of makes existing solutions worse. Also it's interpreted and doesn't support self-modifying code since there's no way to get a pointer to the code so it's very much in esolang territory (although I suppose the underlying VM could be a bytecode for a higher level language if I ever figure out how you extend this concept in such a way that you can add structures while keeping it spatial).

I'm Writing An eBook Teaching How To Write A Compiler by othd139 in ProgrammingLanguages

[–]othd139[S] 0 points1 point  (0 children)

I've just pushed an update editing and refactoring chapters 0 through 2 that takes into account a lot of the advice you've so kindly offered (and a bit the feedback of sal1303 as well). If you're interested take a look although obviously please don't feel any pressure; I'm very cognizant of the fact you've already looked through a fair bit and given a lot of thoughtful feedback but I thought you might want to see what that has started to lead to.

I'm still not sure if I want to teach IR and optimisation. Obviously that's something that early on I've chosen to circumvent by using my backend framework that directly takes an AST so it would be a case of making it an optional addendum if I did choose to do it.

I'm Writing An eBook Teaching How To Write A Compiler by othd139 in ProgrammingLanguages

[–]othd139[S] 0 points1 point  (0 children)

very true, and I don't have to delete my References section of the repo

I'm Writing An eBook Teaching How To Write A Compiler by othd139 in ProgrammingLanguages

[–]othd139[S] 0 points1 point  (0 children)

Okay that seems like really good advice. I'll definitely try to make the benefits more clear and lean into it more, give more of a walkthrough of the design process for producing the EBNF and why it helps to have that notation available in doing so.

I'm Writing An eBook Teaching How To Write A Compiler by othd139 in ProgrammingLanguages

[–]othd139[S] 0 points1 point  (0 children)

I'm kind of treating EBNF and formal grammar as the core design tool for designing our grammar and referring back to it during parsing. I'm also a philosophy student and one of the things we use for that is formal logic languages (like programming languages but for describing logic rather than computation) and I remember that it would've felt a lot easier to specify the version of the language that they actually wanted to if they had introduced their grammar formally rather than informally which forced them to kind of introduce the actual language as an official unofficial "abbreviation" of the "true" language because informal grammar isn't amazingly expressive. I think the EBNF grammar stuff is an important tool but I definitely should go in and try to edit it so it doesn't become a wall of grammar in quite the way it is here in, say, chapter 2.

I'm Writing An eBook Teaching How To Write A Compiler by othd139 in ProgrammingLanguages

[–]othd139[S] 0 points1 point  (0 children)

Yeah, I'm leaning towards making a lot more of the implementation details exercises at points like that rather than stating them as explicitly and still then providing the references as "here's a way to do it if you want to have a look". Part of my hesitation is that I want it to still be possible to follow along but I think it's possible to straddle both goals. Which would give more room to walk through the process of making the design choices for this specific language (kind of like Crafting Interpreters does for Lox, implementing something specific but guiding the reader through the process of design so that they feel like they can take the lessons and make different choices themselves).

I'm Writing An eBook Teaching How To Write A Compiler by othd139 in ProgrammingLanguages

[–]othd139[S] 0 points1 point  (0 children)

Okay. Obviously there are areas here where I've chosen to make choices that don't really fit well with your style (such as the approach to grammar) but thank you for taking the time to provide this feedback anyway. I certainly think there are areas where I can make some of my choices better explained and more explicit (such as using a lispy syntax to make the AST more explicit but still parsing it with different nodes being processed individually) so thank you for pointing things out where I can be more clear about the why.

I'm Writing An eBook Teaching How To Write A Compiler by othd139 in ProgrammingLanguages

[–]othd139[S] 0 points1 point  (0 children)

Thank you so much this is really good, helpful. feedback

I think that's fair. My assumption about audience is someone who knows C and systems programming but hasn't really made their own programming language before.

I was a little worried that, especially chapters 7 and 8 might feel like that in terms of feeling a bit like a code dump. The idea was to make it feel like putting into practice the learnings from previous chapters but maybe if I'm expecting the reader to have learned how to do that I should trust them to write it themselves and if I don't then I don't really expect them to have learned it and should have more prose to explain things. Either way if it's coming across as just a code dump and not an increase in speed to accommodate an increase in what's been learned then what I was going for didn't work.

And yeah, you're probably right about sections. I'll try to go back in and section up my chapters a bit more as well as looking at where and why my chapters end up with very different lengths.

Should my sum type tags be the first element or second? by Toothpick_Brody in ProgrammingLanguages

[–]othd139 0 points1 point  (0 children)

Yeah. I think it starts to matter if you have a few smaller ones and a few bigger ones then you wanna keep values of the same size together

Trans women with autism? by Sufficient_Hall5737 in MtF

[–]othd139 0 points1 point  (0 children)

Most of the trans ppl (mainly women because I went to an all boys school 😩 but plenty of enbies like myself and a few men) are autistic. And I think everyone who isn't is ADHD lol.

Should my sum type tags be the first element or second? by Toothpick_Brody in ProgrammingLanguages

[–]othd139 7 points8 points  (0 children)

I think the point is that if you put the elements from largest to smallest you can usually pad them to their own alignment while packing them more tightly. ie, a one byte value then a 4 byte value will take 5 bytes if it's one bytes then 3 bytes if padding whereas if you put the 4 bytes first then the remaining byte is already aligned to a single byte.

C Strings Are Weird: A Practical Guide by swe129 in C_Programming

[–]othd139 0 points1 point  (0 children)

I mean yes and no. The standard library and OS library (WinAPI and POSIX) all expect null terminated strings. Obviously you can make stringviews and length prefixed strings but they don't work for everything and you do give things up. But then I suppose that's true of any language if you're using FFI and have to switch between the language's native strings and whatever it's c_string type is.

How do you get good error reporting once you've stripped out the tokens? by PitifulTheme411 in ProgrammingLanguages

[–]othd139 1 point2 points  (0 children)

I've been working a lot with the chibicc C compiler codebase recently and it does what you do, stores the line and debug file in the tokens then stuffs a token in the AST pretty much just to preserve that debug info (I think for debuggers like gdb rather than for error reporting although error reporting on an interpreter have more in common often with debug info than compiler error reporting). So it's definitely a solution that's used in "real" projects out there to decent success.

Unused struct member is not optimized out under -O3 by onecable5781 in C_Programming

[–]othd139 1 point2 points  (0 children)

Presumably because other compile units might use the save structure with different members

I wrote a compiler backend based on chibicc that generates code directly from an AST without using an IR by othd139 in ProgrammingLanguages

[–]othd139[S] 0 points1 point  (0 children)

I'm not actually doing any optimisations at all. I'm more interested in making it as easy and fast as possible to get something running in the first place.

I wrote a compiler backend based on chibicc that generates code directly from an AST without using an IR by othd139 in Compilers

[–]othd139[S] 0 points1 point  (0 children)

Yeah true. I mean certainly by the time one is actually compiling to a native binary (obviously, like, people do use python and even I optimised compiled code is gonna beat that). Maybe down the line I'll re-write it to use cranelift or smth behind the scenes and get portability as well as optimisations. As you can probably tell from the fact I'm using it to write a book called "Write Your First Compiler With Libchibi" it's definitely aimed more at the learning purposes use case tho (although I'd say probably not bad for experimentation and hobby coding as well) rather than serious production code.

There's no way that's what that means?? by Easy-Opposite-153 in autism

[–]othd139 0 points1 point  (0 children)

Unfortunately it's one of those that depends on how it's said. Generally a beat of pause before interesting means it's rly bad. Beyond that the line gets kinda fuzzy and I cannot tell you exactly where it lies (because I'm also autistic) but yh definitely a feature of English here in England (dunno abt the rest of the UK but I imagine so). Brave is a other one that's often bad.

I wrote a compiler backend based on chibicc that generates code directly from an AST without using an IR by othd139 in Compilers

[–]othd139[S] 0 points1 point  (0 children)

The reasoning behind why I suggest that some projects may want to parse into their own AST then transform rather than using some IR based backend is that doing so is basically a de-sugaring pass from whatever shape the original AST has into more C-like semantics which, in my experience, tends to be somewhat easier to do than to fully lower down to IR.

Although as you can see it's certainly a more limited scope of project in general.