Programming thread

  • 🐕 I am attempting to get the site runnning as fast as possible. If you are experiencing slow page load times, please report it.
My number one want for a programming language would be groups, essentially enums that define pure bijections to other members. It's a math construct, but it's a surprisingly common pattern within enums, and I think formalizing it would make people better able to use group properties, and potentially allow for constexpr evaluation, or at least very fast code.
 
I just want something super simple like c but with better strings, arrays, std library, and generics. I also don't want it to take over a decade like Jai so it just spits out c code text. The parser took me three attempts to get right and the c code gen is rudimentary for now but it's getting there slowly
 
I just want something super simple like c but with better strings, arrays, std library, and generics. I also don't want it to take over a decade like Jai so it just spits out c code text. The parser took me three attempts to get right and the c code gen is rudimentary for now but it's getting there slowly
Are you using flex/yacc?
 
Are you using flex/yacc?
No I wrote it from scratch in c++ except vector/string/map/regex from std. I considered using a parser generator briefly but I wanted to do the fun parts myself to learn so I had to figure out the tree traversal and recursive descent parsing myself which I hadn't done before, hence the pain.
 
Is it AMD64/x86 or just C interpolation?
Just c interpolation for now and ever (probably), which itself isn't finished yet but it can generate function/struct definitions. If I ever want to go beyond that I might do an llvm backend first and see how that works as I've never written an optimizing compiler and have minimal assembly experience, but I want it to be tightly integrated with c so generating c code text and letting gcc/clang/whatever do the heavy lifting should be enough. It's all up in the air until I have a fully working prototype soon(tm)
 
I used a small bit of flex and bison/yacc (I forget which) in college. Found it ok, more recently though I used lalrpop which I much preferred.
 
  • Like
Reactions: y a t s
My number one want for a programming language would be groups, essentially enums that define pure bijections to other members. It's a math construct, but it's a surprisingly common pattern within enums, and I think formalizing it would make people better able to use group properties, and potentially allow for constexpr evaluation, or at least very fast code.
Like tagged unions?
 
  • Like
Reactions: y a t s
Okay, here’s an example:
Say you’re making a top down game like Zelda or whatever, and you decide to use only cardinal directions. The set of possible rotations forms a group
 
  • Like
Reactions: UERISIMILITUDO
Okay, here’s an example:
Say you’re making a top down game like Zelda or whatever, and you decide to use only cardinal directions. The set of possible rotations forms a group
What's the advantage over just making three functions for neutral element, composition, and inverse that satisfy certain relations?
 
What's the advantage over just making three functions for neutral element, composition, and inverse that satisfy certain relations?
So, by the nature of groups, these mappings are bijections and pure, which means that they lend themselves to some very clean optimizations. I also think formalizing the concept is useful. A lot of programmers use group theory mechanisms without realizing it, and I think making it more explicit could improve code design
 
  • Thunk-Provoking
Reactions: 306h4Ge5eJUJ
It sounds like you just want an enum of anonymous functions with the same input and output types.

Something like:
Code:
function go_left=(pos,amount) => {pos.x=- amount}
function go_up=(pos,amount) => {pos.y=+amount}
Type DirectionOp= (name,action,conditional)
enum movement<DirectionOp> = {(LEFT,go_left,left_button_down),(UP,go_up,up_button_down)}

for (temp in movement){
  if(temp.conditional){
      temp.action(pos,1)
}
}
Those are in nearly every language now. Java has them JavaScript has them.
 
Last edited:
  • Disagree
Reactions: 306h4Ge5eJUJ
So, by the nature of groups, these mappings are bijections and pure, which means that they lend themselves to some very clean optimizations. I also think formalizing the concept is useful. A lot of programmers use group theory mechanisms without realizing it, and I think making it more explicit could improve code design
So is the core idea having an explicit, immutable set of mappings between objects at compile/runtime? If so, you could probably pull that off with something like Go's interfaces.
 
  • Like
Reactions: Anti Snigger
Speaking of mathematics I've been having fun recently building a personal resume site in the inevitability possibility my current job gets made redundant. Rather than the usual boilerplate I've been making a fully interactive ray-traced scene which lets you bring up my resume, work experience, applicable hobbies, and other miscellaneous details while flexing somwhat in terms of math and graphics integration. Even if somewhat overkill it's been quite enjoyable re-learning technical knowledge I've lost since uni and re-discovering the programming spark daily work can quickly extinguish. Almost temps me to go into video game programming. Almost :lol:
 
So is the core idea having an explicit, immutable set of mappings between objects at compile/runtime? If so, you could probably pull that off with something like Go's interfaces.
Pretty much. Logically speaking, element.operation <=> resultElement
 
  • Like
Reactions: y a t s
Back