4 ms·
Can anyone suggest a good embedded language with static or at least optional typing ? I feel this is a gap in the market for embedded languages.
by vitriol83 8y ago
Can anyone suggest a good embedded language with static or at least optional typing ? I feel this is a gap in the market for embedded languages.
- ainar-g 8y agoI wonder if the lack of strongly statically typed embeddable languages is due to an accident or a fundamental limitation of implementations of such languages. Is the type checker code too big? Is it too complex?
- vitriol83 8y agoWriting a type checker is conceptually much more specialised than just a scripting language. Certainly I have no idea how to write one!
- adwn 8y agoMoreover, designing the actual type system is at least as hard as implementing the type checker. Coming up with a static type system that is flexible/ergonomic, expressive/powerful, sound, easy to use, and also a good match for mutable state and imperative code is really, really difficult, as demonstrated by C, C++, and Java. A flexible/ergonomic dynamic type system is trivial in comparison. Soundness is handled at runtime when the exact value of each expression is known, and ease of use is almost a given.
- rurban 8y agoNot really. You just need to walk up both types until you find a match. It's similar to a simple eval matcher, which is about 10 lines in lisp. https://github.com/perl11/Bla https://github.com/perl11/Bla has typically the smallest and easiest to understand type inferencer and checker.
- PeCaN 8y agoIt's actually extremely easy, particularly if you're familiar with Prolog (the core algorithm is a couple lines in Prolog, so knowing how that works is useful for implementing it in other languages). I suspect the lack of statically typed scripting languages is more of a historical accident than anything.
- Lapz 8y agoGluon -http://marwes.github.io/2018/06/19/gluon-0.8.html http://marwes.github.io/2018/06/19/gluon-0.8.html
- mastax 8y agoDyon https://github.com/PistonDevelopers/dyon https://github.com/PistonDevelopers/dyon (Interesting and very easy to modify, maybe not "production ready")
- tomp 8y agoThanks for this! This is by far the most what the fuck language that I've seen in a long while. It displays an astonishing amount of creativity and novel (at least to me) ideas, most of which are probably bad and won't survive for long, but some of them are really cool! Things like "packed loops" for i, j { println(list[i][j]) } or using `return` as a variable without exiting return = 8 Really cool!
- Narishma 8y agoI seem to recall something similar in an old language (maybe Pascal?) where the way to return something was to assign it to the name of the function.
- semi-extrinsic 8y agoFortran does this (still does in F2008). But usually I end up using subroutines instead, since I want the code in question to modify more than one object. Functions can only return one object, and the overhead of packing/unpacking to a struct is annoying. What Fortran really needs to get is first-class string handling and saner IO. Apart from that being a pain, modern Fortran is a nice language to use.
- boznz 8y agoPascal you can set and return the "result" variable in a function without declaring it. You can also use the functions name to do the same
- tekacs 8y ago> or using `return` as a variable without exiting Also found in the Nim language (no affiliation/loyalty, just in case anyone is curious to see an existing use of this) https://nim-lang.org/0.18.0/tut1.html#procedures-result-variable https://nim-lang.org/0.18.0/tut1.html#procedures-result-vari...
- mlinksva 8y agoLily looked pretty interesting, discussed here a couple years ago https://github.com/FascinatedBox/lily https://github.com/FascinatedBox/lily https://news.ycombinator.com/item?id=12015158 https://news.ycombinator.com/item?id=12015158