Comments (2)
Finally writing up a response to this...I think Basil's approach is fundamentally different to that which can be achieved in a super-low-level language like a Forth, but should ideally achieve the same ends. The main thing is that while small Forth-like languages can get away with sort of reductive semantics (a global unscoped dictionary for definitions is graceful but also doesn't scale great...), Basil is more targeted at users of existing languages and aims for high performance - this means, among other things, clear lexical scope and static type checking.
The solution Basil adopts to the above problems, of course, is simply to permit a highly dynamic "meta-language" confined to compile-time evaluation - we can do crazy things (albeit not really any more crazy than the average Lisp dialect...) and as long as we resolve them all in advance we shouldn't incur a runtime cost. As you mentioned, Basil already achieves point 1. (much more so in recent iterations than before, IMO) pretty decently, but by ensuring that no metaprogramming or dynamic code reaches the actual binary, performance should remain quite competitive - achieving point 2 (there's really no reason, besides compiler backend quality, why Basil couldn't compete with OCaml or even C++ in terms of generated code performance).
Point 3 is a little less explored in the current Basil iteration. In theory, the compile-time environment is turing-complete and quite powerful - it's essentially a Lisp interpreter, and with some caveats it supports a superset of Basil's runtime functionality. The issue with this is that Basil's current compile-time evaluation is quite slow, so to avoid overdoing compile-time evaluation we automatically lower any code that crosses a fairly small operation-count threshold. This is good for making sure we still compile expensive benchmarks, even if they aren't effectful, but it's kind of bad for sophisticated compile-time analyses and assertions. I think a good solution would simply be to allow "explicit comptime" blocks - this would be a built-in function that would evaluate its arguments without any compile-time profiling and auto-lowering. We could permit certain stateful and effectful functions, such as mutation and IO, at compile-time within such a block. With that, the user essentially has the full extent of the language's semantics available to express whatever ahead-of-time constraints or transformations they want. :)
Closing this since it doesn't really pertain to a particular feature. But we'll probably be exploring explicit compile-time blocks in the near future.
from basil.
But we'll probably be exploring explicit compile-time blocks in the near future.
That makes sense. But from my experience only if the blocks can apply to as small parts as one lexeme/token (any token at any place!). I.e. I tend to imagine the "block" as something enclosed in [
]
(as in Tcl, Til, etc.) or as just some prefix for an arbitrary lexeme/token. IDK.
from basil.
Related Issues (20)
- Attributes/annotations HOT 1
- Escaped double quote lexes twice when next to start/end of string HOT 1
- Unable to lex escaped backslash in string literal HOT 1
- String formatting HOT 1
- Better pretty printing
- Continuation Passing Style (CPS) and compile-time evaluation (and parallelism/concurrency) HOT 4
- Control flow abstraction to avoid built-in exceptions, defer, multi-return, error handling, nil, etc. HOT 3
- Syntax sugar and other tricks for inspiration HOT 2
- XL lang with some similarities to Basil HOT 1
- Vaporization instead of reference counting to jump to the close-to-metal language battleground HOT 3
- Interpreted concatenative language ;) HOT 1
- Dreaming about end-user/programmer use-cases HOT 2
- Add floating-point primitives. HOT 4
- Add sub-64-bit integer types as primitives. HOT 1
- Add raw pointers and pointer types. HOT 3
- Tracing garbage collection. HOT 6
- Add garbage-collected references and reference types. HOT 7
- Forms versus macros HOT 1
- Killer app/lib/built-in-feature to make Basil stand out
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 basil.