r/ProgrammingLanguages • • 2d ago

EasyC, C made easy

[deleted] — view deleted post

0 Upvotes

13 comments sorted by

50

u/Spyromaniac666 2d ago

No manual memory management and no pointer arithmetic? How is that retaining the things people like about C?

16

u/trollol1365 2d ago

Sorry what do you think people like about C that you are preserving here that other languages dont already offer? Such as Rust/C++ or even languages like Java that have C-style syntax?

10

u/funbike 2d ago edited 2d ago

Sounds like Go, but 20x slower.

This is a great hobby project, but don't expect people to use it. How is your language better than Go?

I think you might have gotten upvotes if you had said this was a personal project to learn about compilers. But you framed it as something you want people to use. That won't happen with the current direction that's similar to 100+ other similar projects. Yours has nothing new.

5

u/Key_Detail15 2d ago

with familiar C-style syntax.

Half of all languages have C-style brace syntax!

Your language is not C, the syntax is incompatible, and major C features are missing. The problem is calling it 'EasyC': people not going to learn C via your language. The name is a distraction and is misleading.

BTW here is your example in actual C:

typedef struct {
    float x;
    float y;
} Point; 

float Point_length(Point self) {
    return sqrt(self.x * self.x + self.y * self.y);
}

int main() {
    Point p = { .x = 3.0, .y = 4.0 };
    printf("%f", Point_length(p));
}

This has a character count of 230; yours is 265. By this measure, C is simpler!

0

u/ntrel2 1d ago

Your code is not equivalent. self is not const, but also the original presumably allocates a string using the convert AST macro, and prints that string. printf is very unsafe and doesn't allocate. Idiomatic C is very inefficient with zero terminated strings.

1

u/Key_Detail15 1d ago

Your code is not equivalent.

Why, does it do something different?

self is not const,

That doesn't matter: 'self' is passed by value, so modifying it in the callee doesn't affect the caller's version. But I didn't know what semantics are used by EasyC.

the original presumably allocates a string using the convert AST macro, and prints that string.

And? Presumably the aim is to print a length, and that float->string conversion is done by 'printf'. In EasyC is it looks a lot harder!

printf is very unsafe and doesn't allocate

It's not unsafe as used here. I don't know what you mean by not allocating; why is that a problem?

Idiomatic C is very inefficient with zero terminated strings.

Inefficient in which ways, memory usage or processing?

(Most strings in programs tend to be very short. With longer ones, applications can keep track of their lengths. This is routine for anyone coding at this level.)

However, my point is really that EasyC is not C. If you need to code at the level of C for precise control, then using a higher level language will not help just because it has 'C' in its name.

7

u/TheChief275 2d ago

This screams like an AI slop post; (1) your title is clickbaiting it to be like C but the language already looks more syntactically quirky than it for little reason, (2) if you say "static typing by default" is what your language provides over C, than that is stupid because C is already a statically typed language. Do you even know C?

4

u/nacnud_uk 2d ago

If you can do anything, avoid all of the mistakes that C++ made with objects. That should start with ::...is it an object, a namespace? And don't use & in a billion different ways. Just use keywords or something like that.

And with your example, it's really hard to tell, with no syntax highlighting, that the function is part of the Point.

I don't get languages that like to make me type the same shit, over and over again.

Pint::function1
Pint::function2
Pint::function3

Notice the crap that I have to type, again and again and again, and again. You get my point.

And why "fn"? So your language makes my typing even more redundant?

fn Pint::function1
fn Pint::function2
fn Pint::function3

I think I'd get bored too easily. EasyC, but for whom? Maybe AI till love burning these tokens. You working for Anthropic?

2

u/tigrankh08 2d ago

This looks very Rust-inspired while also not being all the way there (e.g. types being on the left). While I'm against crystallized and rigid ways of thinking, I think lots of people would agree with me.

2

u/tigrankh08 2d ago

And P.S. I think people shouldn't design general-purpose programming languages around certain implementation ideas (like assuming being interpreted) but that's none of my business if you decide to look at it that way. I just advise against it

2

u/GunpowderGuy 2d ago

what would be the point of using this language ?

1

u/kwan_e tonal-lang 1d ago

I'm currently interested in getting feedback on the language syntax.

Syntax is the least interesting problem. Syntaxes are like arseholes, because they're opinions, and everyone has one.

You should look at all the syntactical elements of your language and ask "okay, but why this way?" It currently reads like a hodge-podge of language syntaxes that you like, which is fine. But people will have their own likes and dislikes, and so their opinion on it is worthless.

The only "real" syntax issues that are somewhat objectively interesting is parse-performance, for stuff like IDE integration; and forwards and backwards compatibility as it evolves. But they're all "solved" problems, one way or the other, and language design experts are too busy bikeshedding on their syntax pet-peeves, rather than the boring software-build-engineering side of things.

interpreted programming language with familiar C-style syntax.

C can be compiled to WASM. Or any bytecode that runs on a VM runtime, even JVMs. All its safety issues basically "go away" under that environment because the VM itself can implement GC and bounds checks under the hood.

It will be as safe as any other language running on those VMs. The remaining safety issues affect all languages on that VM, and not just the C that was compiled for it.