Coder Social home page Coder Social logo

FR: Better Support for Embedded about carp HOT 5 OPEN

scolsen avatar scolsen commented on May 26, 2024 4
FR: Better Support for Embedded

from carp.

Comments (5)

scolsen avatar scolsen commented on May 26, 2024

re: (1.) the less we bundle with the compiler the easier it is to use it as a Carp in constrained environments. right now, we kind of force users to adopt our array and box types -- if we roll them entirely into the core lib instead, we'd be able to allow users to exclude them w/ no-core

re: (2.) code size matters in embedded. chances are C compilers would strip away unused C code anyway, we might as well help with that if we can by not generating unused C to begin with.

re: (3.) volatile and other qualifiers/attributes are important in embedded to ensure compilers don't e.g. eliminate unused bindings in register structs and such.

And another I thought of:

  • Make it possible to generate libraries in addition to binaries. This isn't really necessary for embedded, but it's a nice to have in order to better organize utilities and to provide bindings for C to libs written in carp. (2) would help support this since it'd move us toward generating C output that has a little bit better readability for users from C.

from carp.

scolsen avatar scolsen commented on May 26, 2024

Also really curious to hear if @TimDeve has thoughts on this

from carp.

TimDeve avatar TimDeve commented on May 26, 2024

Hey Scott,

I think these three improvement would be useful for sure.

  1. Being able to remove the part of carp that relies on allocation would be nice, on that point the proposal from @eriksvedang to make lambda stack allocated by default and make their heap allocation explicit via copy would also be quite useful. Another related thing is that managing core imports when using --no-core is quite painful, you have to maintain your own Core.carp and it breaks when the one in core gets updated. I was thinking a helper macro where you can pass the cores to omit might be nicer.
  2. In my experience gcc/clang are pretty good at discarding all the extra stuff we generate but for niche embedded use case you might not get one of the big compilers.
  3. You can certainly get around that with typedef at the moment but a cleaner way to annotate defs or let could be useful.

On the library point I think the current implicit thing with main is kinda confusing, and explicit flag could be better. I also don't even remember what we generate then? An object file or a dynlib?

from carp.

eriksvedang avatar eriksvedang commented on May 26, 2024

I also think all of these suggestions are great!

Perhaps the slightly extreme solution of not loading any core libraries by default could help? (I think Purescript does this..?) So it's all up to the user to decide what they bring in, except for stuff that is absolutely necessary for the compiler to start. One question then is what to do with the [ ] syntax for array, since that is surely the nicest syntax. In a way it would make more sense if the built in (static) array used that one, and dynamic arrays switched to $[] (or just a macro, like vec! in Rust). And yes, lambdas should definitely not have to allocate by default (I have been thinking about that recently, and I think the fix is even simpler than what I tried to do in the feature branch. But I can make a comment there instead...)

Regarding code generation (and executable/library generation) I think a neat UX could be to provide something like emit-exe / emit-library which would accept a module (or several) as an argument. In case of exe that module would have to have a main defined (or you'd pass the function that should act as main). Then the code generator would walk all the dependencies of that module (or function) and only emit those.

Regarding point 3 – we do support this for definitions, right? (using meta data) But I guess it has to go in more places to be truly useful? Perhaps a separate issue with more details could clarify this.

from carp.

scolsen avatar scolsen commented on May 26, 2024

Regarding point 3 – we do support this for definitions, right? (using meta data) But I guess it has to go in more places to be truly useful? Perhaps a separate issue with more details could clarify this.

Yes, we do! If I remember correctly though the UX around it wasn't perfect. I recall having to use const qualifiers for a lot of stuff when making bindings to some Apple core libs and it was a bit awkward and didn't always work quite right for pointers, I think.

from carp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.