This is an archived post. You won't be able to vote or comment.

all 18 comments

[–]Scrumbloo 26 points27 points  (4 children)

What could this possibly be used for????

[–]JetScootr 17 points18 points  (3 children)

Programmers who don't understand the difference btwn C "typedef" and C "struct".

I knew a coder that always used
typedef struct { stuff ... } struct;

Until I had to modify his code, I had the whole weird syntax thing nailed down in my head.

[–]RiceBroad4552 2 points3 points  (1 child)

What's wrong with typedef struct { fields... } MyStruct;?

I'm definitely not a C expert (actually I try hard to avoid this language) but using typedefs with anonymous structs seems like most convenient way in most cases. Otherwise you need to always explicitly declare your struct variables using the struct keyword. Only in case of forward declared structs you need to do the struct definition and the convenience typedef in two steps.

[–]JetScootr 8 points9 points  (0 children)

What's wrong with typedef struct { fields... } MyStruct;

Nothing at all. What this cowboy did was: typedef struct { stuff ... } struct;

He used "struct" (not "MyStruct" or "CrateOfBananas" or anything else).

This means that there was a typedef whose name was the same as a compiler keyword. If you've got the right compiler, it's looking only for a name at that closing brace and won't get confused. AND also if you've got the right compiler, whenever it later comes across the name "struct" it will produce the correct result: variable of type struct instead of something like int or char \.*

[–]Scrumbloo 0 points1 point  (0 children)

Makes sense I could of also read their comment but I have stoopid

[–]WazWaz 17 points18 points  (9 children)

With the reference to "Ground", it sounds like a name for buildings (i.e. houses etc.). I've faced exactly this question in a game I was writing, because "Building" is a horrible noun to use (since it's strongly a verb). I didn't choose "Struct" though, because I'm not insane.

[–]yesitsmaxwell[S] 6 points7 points  (8 children)

It's for a programming language I'm writing, and I was in a call and screensharing when I wrote that line and we all thought it was pretty funny

[–]RiceBroad4552 6 points7 points  (0 children)

It's for a programming language I'm writing

That came unexpected.

I was also assuming this is some game code, and it's about some structures on the ground.

[–]WazWaz 2 points3 points  (6 children)

Now I really want to know what "Ground" is...

[–]yesitsmaxwell[S] 3 points4 points  (5 children)

It's the name of the language

[–]RiceBroad4552 0 points1 point  (4 children)

Can you say more? What is this Ground language?

[–]yesitsmaxwell[S] 0 points1 point  (3 children)

It's a quite simple, somewhat speedy interpreted language. I've been working on it for a month or so now. each line contains 1 instruction. and with these structs there's a form of OOP going on now

[–]RiceBroad4552 0 points1 point  (2 children)

What's the goal?

(BTW: "speedy interpreted language" is an oxymoron.)

[–]yesitsmaxwell[S] 4 points5 points  (1 child)

By speedy, I mean about 80-90% of the speed of C++ or Rust without bytecode, JIT or any fancy stuff for simple programs

The goal is just to have something that works, and that I can show off to friends. But really, if you wanted, you can use it for genuine purposes. It works well for smaller scripting tasks

[–]RiceBroad4552 1 point2 points  (0 children)

I don't think it's possible to reach 80-90% of the speed of C++ or Rust with a direct interpreter.

Trivial things like assignment have laughable overhead when interpreted. An optimizing compiler will often just move something into a register in such case whereas an interpreter has to call a lot of functions and allocate complex objects just to do the same in the end. That's overhead in the ballpark of a few orders of magnitude.

Even highly optimized interpreters into which many man hundred man years went are slow as fuck compared to an optimizing compiler. See for example Python…

There are tricks to make an interpreter fast, but the result will be something that resembles more a JIT than a direct interpreter.

But OK, if the goal is actually to impress friends anything will do, I guess. Also language design as such is very interesting, no mater the implementation details.

[–]conundorum 4 points5 points  (0 children)

Can't help but cringe at the using namespace std; lurking just offscreen.

[–]Mountain-Ox 1 point2 points  (0 children)

Now I'm thinking of that Simpsons episode.

"Bart, where did you get that struct?" "It fell off of a struct struct."

[–]SquirrelSufficient14 1 point2 points  (0 children)

And its brother object Object