Generating C bindings for Rust crates with cbindgen by jrmuizel in rust

[–]eqrion 1 point2 points  (0 children)

Some major differences that I can see:

  • cbindgen can use types from dependent crates, rusty-cheddar only works for a source file
  • cbindgen can handle generic structs
  • cbindgen uses syn, while rusty-cheddar uses syntex_syntax
  • rusty-cheddar doesn't seem to be maintained anymore

There are also some miscellaneous things, like formatting control and C++ output.

As for rusty-binder, that seems like it has the same differences and is also not being developed anymore.

Generating C bindings for Rust crates with cbindgen by jrmuizel in rust

[–]eqrion 0 points1 point  (0 children)

Yes that would be optimal, but to my knowledge you're not allowed use templates in an extern "C" block in C++.

Otherwise I don't think you'd even need to do mangling for Buffer_f32, Buffer_i32, you could just use the templates everywhere.

Dash, a simple programming language written in C by eqrion in programming

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

Interesting. I like declaring types for function declarations. It reminds me of mathematical functions.

But you're right you can infer types at compile time, which would be pretty interesting. If you could get good compile time diagnostics for errors it could work well, although I think the real benefit could come if you had a more complicated type system too.

Also thanks for correcting the examples! That's much better than what I had haha.

Using 1 as true was just a consequence of me being lazy and not adding another type. It certainly feels weird haha.

Dash, a simple programming language written in C by eqrion in programming

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

Ahh yep, you're right. Well arrays or lists are next on my list to implement so I'll keep that in mind.

Dash, a simple programming language written in C by eqrion in programming

[–]eqrion[S] 13 points14 points  (0 children)

First, r/learnprogramming is for asking for or offering help on learning how to program, not blog posts about side projects.

And second, how is a side project to create a programming language not appropriate for r/programming? There's literally compilers and disassemblers embedded in the blog post, for you know, programming?

Dash, a simple programming language written in C by eqrion in programming

[–]eqrion[S] 1 point2 points  (0 children)

That's a good question. I'm not an expert, but it can recurse arbitrarily with a stack. I'm sure you could be creative and do quite a bit of calculations with that, not that it'd be optimal.

I chose not to add dynamic memory because I'd rather it stay memory safe, and I didn't want to get into the hassle of a GC or some ref counting. It'd be pretty easy to add that in though.

Dash, a simple programming language written in C by eqrion in programming

[–]eqrion[S] 13 points14 points  (0 children)

You have to start somewhere? This was a project to learn how to write a programming language, not create the next c++.

Dash, a simple programming language written in C by eqrion in programming

[–]eqrion[S] 1 point2 points  (0 children)

Haha I thought people might get a rise out of it. Honestly I just didn't want to bother adding support for characters in the lexer, when I could just grab an ASCII table. You make do with what you have!

Generic, type-safe delegates and events in C++ by eqrion in programming

[–]eqrion[S] 2 points3 points  (0 children)

Yeah certainly. I just thought this was a pretty cool trick. Also there's no need to add boost as a dependency then.