Comments (5)
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.
Also really curious to hear if @TimDeve has thoughts on this
from carp.
Hey Scott,
I think these three improvement would be useful for sure.
- 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 ownCore.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. - 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.
- 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.
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.
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)
- Memory management in nested lambdas is not working properly HOT 1
- memory management crash
- performance: better default string functions
- Bug with REPL displaying result of calling function that returns Char HOT 1
- REPL prompt is not `鯉` on Linux HOT 2
- (()) seems to cause an infinite loop on the latest release
- Packaging issues. HOT 1
- `format` leaks memory HOT 1
- `--eval-preload` does not have access to Core anymore HOT 6
- [Bug] Not handling all cases during pattern-matching in lambdas HOT 8
- [Bug] Control.iterate-until double-uses a variable, and thus is broken HOT 3
- [Feat Request] Exhaustive pattern-matching for `defn` HOT 5
- [Bug] Issue pattern matching structs HOT 7
- Document println*
- Feature Request: Make running tests not dependent on stack?
- CarpHask fails to build with hashable >= 1.4 (GHC 9.2 / Stackage LTS-20) HOT 4
- Get Can't find symbol 'make-update-deriver' when trying to run example on Windows 11 HOT 7
- [bug] duplicate bindings in environment HOT 2
- Repl crashes on type of Map
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from carp.