12 ms·
Nelua Programming Language
- cies 5y agoIt advertises as "Lua flavour". I found Lua a rather quirky language, bit like JS or PHP. Non of these have to my taste (since we're talking about flavour) a very nice syntax, nor do they to me demonstrate clear vision in their design. To me Lua flavour tastes like shit.
- diego_moita 5y agoTo each it's own. E.g: I felt the same "taste" about your comment. It doesn't add anything objective to the discussion. And it sounds a lot like what my 4 year old son says about brussel sprouts.
- pull_my_finger 5y agoLua certainly has quirks (as all languages do), but I've not heard people complaining about it lacking vision or consistency. In fact, you'll hear a lot of people mention Lua's very _deliberate_ design choices. Changes happen slowly, and it's not afraid to break backwards compatibility for the betterment of the language. That's in stark contrast to JS and PHP which add whatever feature is popular at the time and can't purge or change APIs for fear of "break the web".
- forgotpwd16 5y agoSeems to have some overlap (natively compiled Lua with optional manual memory management) with Terra (https://terralang.org/ https://terralang.org/).
- junon 5y agoI'm technically a maintainer of Terra, and yes there's some overlap but still very different approaches. Nelua looks really really cool. I'm going to have to give it a try tomorrow.
- edubart 5y agoTerra was an inspiration to create Nelua in its metaprogramming aspects. Terra's famous Brainfuck example (on the front page of Terra) is available in Nelua's examples folder for comparison of meta programming.
- pie_flavor 5y agoMajor negatives: - Destructors are avoided for reasons, but then a full GC is wedged in. Unless you enable a particular flag, then you have to do all memory management manually, making code non-portable. Why on earth wouldn't you just use reference counting with destructors? Unless I'm missing something, that's better in every case. - Avoids LLVM because 'C code works everywhere', then doesn't support MSVC. - 1-indexed in libraries copied from Lua, 0-indexed elsewhere. That's just about the only worse thing you could do than 1-indexing everywhere. - Preprocessor model instead of the features being a more integrated component of the language. Zig has proved a function-based approach can work well and C's legacy has proved that preprocessors absolutely blow. - Aforementioned preprocessor directives get seriously wedged. You need them for polymorphism, varargs, etc. - No closures. This one seems the most baffling to me because Lua has the __call metamethod, which is exactly what you'd use for that, and they're 99% of the point of anonymous or inner functions.
- edubart 5y ago> Destructors are avoided RAII in general is avoided, because supporting it gives many unwanted consequences, increasing the language complexity and simplicity going against the goals. > Unless you enable a particular flag, then you have to do all memory management manually, making code non-portable. You can make portable code to work with or without the GC, the standard libraries do this. Of course you have more work to support both, but you usually don't need to, choose your memory model depending on your problem requirements (realtime, efficiency, etc) and stick with one. > Why on earth wouldn't you just use reference counting with destructors? Reference counting is not always ideal because it has its overhead, and the language is not to be slower than C, relying on referencing counting would impact a lot. The user can still do manual reference counting if he needs to, like some do in C. Also referencing counting requires some form of RAII which is out of the goals as already explained. > Avoids LLVM because 'C code works everywhere', then doesn't support MSVC. MSVC-Clang can be used, naive MSVC is just not really supported running directly from the Nelua compiler, but the user can grab the C file and compile himself in MSVC. Better support is not provided for MSVC just because of lack of time and interest. But Nelua supports many C compilers like GCC, TCC, Clang. Supporting more backends than just LLVM is still better than not officially supporting MSVC. > 1-indexed in libraries copied from Lua, 0-indexed elsewhere. 1-indexing is used in just a few standard library functions for compatibility with Lua style APIs. On daily use this usually matters little, also you can either make your code 1-indexed in Lua style, or 0-indexed in systems programming style, it's up to your choice. The language is agnostic to 1/0-indexing, just some libraries providing Lua style APIs use it, you could completely ignore and not use them, you can not even use the standard libraries or bring your own (like in C). > Preprocessor model instead of the features being a more integrated component of the language. Aforementioned preprocessor directives get seriously wedged. You need them for polymorphism, varargs, etc. The language specification and grammar can remain more minimal, by having a capable preprocessor, instead of having many syntax, semantics and rules. Also Nelua preprocessor is not really just a preprocessor, as it provides the context of the compiler itself while compiling, this gives the language some powerful capabilities that only meta-programming the language to understand better. Calling a preprocessor does not do it justice, but the name is used due the lack of a better name. > No closures. This one seems the most baffling to me because Lua has the __call metamethod, which is exactly what you'd use for that, and they're 99% of the point of anonymous or inner functions. The language is under development, not officially released yet, and this feature is not available yet but on the roadmap. Nevertheless people can code fine without closures, many code in C without closures for example.
- xedrac 5y agoWhile I don't begrudge anyone from creating a new language, I'm trying to figure out what this brings to the table that languages like Nim, Zig, Ecl, Crystal, V, Forth, Gambit, etc... lack. The only thing I can really find is "syntax". Lua isn't really my cup of tea, but to each their own. Regardless, looks like a fun project.
- corysama 5y ago"Telling a programmer there's already a library to do X is like telling a songwriter there's already a song about love." - Pete Cordell
- dbtc 5y agoAh yes, the principle of DRYO Definitely Rewrite Your Own. And some quote from Feynman about not understanding until you do it yourself.
- andrewmcwatters 5y agoIt’s funny you mention this because none of those languages appeal to me. This one only sort of begins to catch my attention.
- md224 5y agoThe "Concept" idea is very cool... seems like it would make it really easy to construct refinement types and build validation into the type system.
- no_time 5y ago>Although copying Lua syntax and semantics with minor changes is a goal of Nelua, not all Lua features are implemented yet. Most of the dynamic parts, such as tables (...) Ah I guessed so. The concept of lua tables probably doesn't map to efficient machine code. Real shame because that's what I consider the "killing feature" of Lua as a language.
- pull_my_finger 5y agoNelua will definitely have tables. They're just not implemented _yet_
- slackstation 5y agoIt's the Ruby/Lua 'end' that kills me. Why type a word when a character will do. Yes, my IDE can do it but, it's clunky. Reminds me of when I first started out and would put a comment on every closing bracket of the context of what started that bracket.
- cardanome 5y agoIt is a matter of taste. You can get used to it. Both Lua and Ruby are optimized for aesthetically pleasing syntax that is easy to parse for humans, even for people new to programming. I think "end" works better for that goal than curly braces which most people don't even know how to type and that are rarely used in English outside programming. Personally I vastly prefer keywords to special characters. My brain has more trouble parsing symbols than words. I have real trouble reading mathematical notation but if I see an algorithm written out with words I am able to grok it quite easily. I think lot's of people are the other way round, not sure . Might be because I was a heavy reader in my youth. That said I switch between C-like and Lua/Ruby style syntaxes back and forth all the time and it is really not an issue.
- deleted 5y ago[deleted]
- fithisux 5y agoHow does it compare to a. Ravi https://github.com/dibyendumajumdar/ravi https://github.com/dibyendumajumdar/ravi b. Moonscript https://moonscript.org/ https://moonscript.org/ c. Luajit https://luajit.org/ https://luajit.org/ d. Moonjit https://github.com/moonjit/moonjit https://github.com/moonjit/moonjit e. Terra https://terralang.org/ https://terralang.org/ What is the advantage? Can I use lua code verbatim?
- pull_my_finger 5y agoHere's the author's thoughts on Nelua vs Terra[1]. [1]: https://github.com/edubart/nelua-lang/discussions/51 https://github.com/edubart/nelua-lang/discussions/51
- fithisux 5y agoThank you very much.
- RattleyCooper 5y agoHaving to use an "end" keyword is enough to make me not want to use the language.
- andrewmcwatters 5y agoThis limits your discipline so much. Do you not use Shell because ifs close with fi? Do you not use HTML because declarations end with the same identifier? Would you not bother trying Python because it handles whitespace differently than most other programming languages?
- bsaul 5y agoIs there a way when using those kinds of new languages in a given platform (let's say iOS) to use a modern set of libraries to perform common tasks ( such as http networking, json parsing, websockets, basic multimedia features, etc) ? Or would i be doomed to rebuild it myself from scraps and random C libs i'd have to gather myself ?
- stephen82 5y agoWell, Eduardo has also created this https://github.com/edubart/nelua-decl https://github.com/edubart/nelua-decl Plus, whatever C library you may have used thus far, you can use it with Nelua as well without a fuss [1]. https://nelua.io/overview/#c-interoperability https://nelua.io/overview/#c-interoperability
- soapdog 5y agoLooks really cool. I wonder how it compares to teal
- edubart 5y agoTeal add type annotations and type checking to Lua, and transpiles to Lua, while Nelua is a new systems programming language with optional type annotations and compiles to C. @ubertaco also made a good comparison in his comment with Teal.
- Zababa 5y agoThe website to present it is beautiful and has all the necessary info, it's great. I also really like the name and logo.
- strappedup 5y agoIt looks like every other Bootstrap site
- nixpulvis 5y agoDocumentation needs a better way to navigate by module and ident.
- Svoka 5y agoInteresting. If you want to write whole application in Lua-like language, this looks very nice. However one would need some framework to work with it to make, say a simple game. nice if you are brave enough to use language which wasn't released yet and installs from `master`.
- andrewmcwatters 5y agoGod, does no one have respect for things in development anymore? This place shits on anything that doesn’t have documentation and an ecosystem with the equivalent of 10 years of free labor out of the gate and it pisses me off. It’s a total turn off to share something with a development community made up of mostly people who don’t actually make things themselves or people who think they know better than people with actual experience in a given discipline. It’s comments like this and the one below calling languages shit that makes this site a shithole to read sometimes.
- ysleepy 5y agoUses 0-based indexing, if you were wondering like me.
- 7thaccount 5y agoI'll never understand why this is such a big item of importance for developers :). Both 0 & 1 are pretty natural in my eyes.
- moomin 5y agoLet's see if Dijkstra can explain it. :p https://www.cs.utexas.edu/users/EWD/transcriptions/EWD08xx/EWD831.html https://www.cs.utexas.edu/users/EWD/transcriptions/EWD08xx/E...
- pull_my_finger 5y agoThis seems to get posted a lot in 0 vs 1 threads as a way to end the conversation in appeal to authority, but for arguments sake, Roberto Ierusalimschy (of Lua) has explained his design choice: > When we started Lua, the world was different, not everything was C-like. Java and JavaScript did not exist, Python was in an infancy and had a lower than 1.0 version. So there was not this thing when all the languages are supposed to be C-like. C was just one of many syntaxes around. > And the arrays were exactly the same. It’s very funny that most people don’t realize that. There are good things about zero-based arrays as well as one-based arrays. > The fact is that most popular languages today are zero-based because of C. They were kind of inspired by C. And the funny thing is that C doesn’t have indexing. So you can’t say that C indexes arrays from zero, because there is no indexing operation. C has pointer arithmetic, so zero in C is not an index, it’s an offset. And as an offset, it must be a zero — not because it has better mathematical properties or because it’s more natural, whatever. > And all those languages that copied C, they do have indexes and don’t have pointer arithmetic. Java, JavaScript, etc., etc. — none of them have pointer arithmetic. So they just copied the zero, but it’s a completely different operation. They put zero for no reason at all — it’s like a cargo cult. https://habr.com/en/company/mailru/blog/459466/ https://habr.com/en/company/mailru/blog/459466/
- duped 5y agoSomething I'd like to see more of are GC and memory allocation guarantees, not just an option to disable it. Most of the time GC is fine as long as it's low enough latency. Where it matters you don't really want any memory management - which isn't useful, since the memory needs to me managed somewhere in the code. For that reason the pattern isn't to switch to a non-GC'd language because it doesn't have GC but because you can guarantee all the memory is allocated up front and that no freeing or allocation happens in the tight loops. That's not actually sufficient though. Even in production code bases accidental allocation can slip through. What you'd really like to see is a `no-alloc:` block which forbids operations that may allocate or free memory - GC'd or otherwise - and force the programmer to allocate before entering the block and free outside it.
- mrec 5y agoIt's not production-ready and isn't a GC'd language, but Zig's approach might be to your taste: > Zig programmers must manage their own memory, and must handle memory allocation failure. > This is true of the Zig Standard Library as well. Any functions that need to allocate memory accept an allocator parameter. As a result, the Zig Standard Library can be used even for the freestanding target. https://ziglang.org/learn/overview/#manual-memory-management https://ziglang.org/learn/overview/#manual-memory-management
- elcritch 5y agoNim's new garbage collector was designed with embedded systems in mind [1]. It uses non-atomic/non-locking reference counting combined with C++11 move semantics. The usage of move semantics enables both performance increases and a method to ensure memory is only "owned" by one thread (which enables non-atomic reference counting). Theres optional cycle collection support but I prefer to keep embedded code acyclical. On your second point you can use Nim's effect system to ensure no allocations occur in a given function or its callees. Currently no one has done this, and might be tricky with the reference counting, but not too difficult either. I used Nim with ARC for a latency sensitive embedded project. To avoid allocation on the tight reading loop I pre-allocated the values needed, or made them global variables. A few extra integer ops didn't matter, but allocation is sloooow. However, I'd eventually like to add allocation tracking to the effect system. Rather, make the existing effects more granular for this purpose. 1: https://nim-lang.org/blog/2020/10/15/introduction-to-arc-orc-in-nim.html https://nim-lang.org/blog/2020/10/15/introduction-to-arc-orc...
- pshirshov 5y agoCool. I didn't find in the docs how do I make higher-kinded types and typeclasses there?.. Could you give me a hint?
- edubart 5y ago> how do I make higher-kinded types In Nelua you can create new specialized types using compile time parameters, they are called "generics", you can use this for example to create a specialized vector type. > and typeclasses there? Yes, but with some metaprogramming. In Nelua you can create a "concept", that is just a compile time function called to check whether a type matches the concept.
- pshirshov 5y agoIs there a monoid example implemented in Nelua?
- nixpulvis 5y agoThis language has what looks like a potentially interesting macro system.
- pshirshov 5y agoGood macro system is a must, indeed, that's very nice. Though just macro system is not enough. In order to be useful a language should support a combo of HKTs, typeclasses (better implemented with implicits) _and_ macros with implicit materialization. Scala has that (and I'm using Scala) but it has some quirks and problems and I would be really happy to see something with these features but with fast compiler and separated from JVM.
- jhhh 5y agoYou want this new language to implement a particular set of features in a similar way to a specific, named feature from Scala which they themselves are moving away from in 3.0?
- 6d65 5y agoI will definitely give it a try. Even after many years of not using terralang I still cannot forget what a good of an idea it is. Nelua seems like a more pragmatic implementation of similar ideas, but generates C code instead of embedding the llvm. And doesn't generate code at runtime. But still, things like ecotypes should be possible. It will be interesting to play with the compile time lua scripting. Also, as mentioned in the other comments not sure about the GC. But there seems to be a manual memory management option. But still, looks great, kudos to the author, keep up the great work. PS: If I would implemented it, I would deviate a bit from Lua and replace local with let. It's highly subjective but I think it would make code "prettier"(whatever that means)
- scythe 5y agoAs long as we're bikeshedding, I've often thought that Lua should warm up to using `my` as a keyword in place of `local`. `let` doesn't convey that it's a scope keyword (LISP heritage notwithstanding), while `local` is long and `loc` is an eyesore.
- 6d65 5y agoEyesore is a precise word for the local keyword, from what I see the variable names in scripts are usually short, and the local keyword seems to draw more attention than the variable names themselves. Of course this can be alleviated with syntax highlighting that would slightly mute the local keyword. And, people using Lua they day probably learn to ignore the keyword automatically.
- 6d65 5y agoBy ecotypes i meant exotypes(see https://cs.stanford.edu/~zdevito/pldi083-devito.pdf https://cs.stanford.edu/~zdevito/pldi083-devito.pdf)
- stephen82 5y ago> PS: If I would implemented it, I would deviate a bit from Lua and replace local with let. It's highly subjective but I think it would make code "prettier"(whatever that means) The idea behind it is to have the lowest syntax barrier possible for Lua developers so they can migrate from Lua to Nelua without a sweat.
- gautamcgoel 5y agoThis looks really fucking cool. I've long said that Lua is a neat language, but hobbled by a few warts/footguns. I think this project corrects many of those issues. Does this project provide a package manager with automated dependency resolution? That was an issue in Lua, IIRC.
- stephen82 5y agoAbout package manager, I don't think it has one yet (at least officially that I know of), but feel free to join discord [1] and ask the core developers about it. [1] https://discord.gg/7aaGeG7 https://discord.gg/7aaGeG7
- ubertaco 5y ago> There is no interpreter or VM, all of the code is converted directly into native machine code. This means you can expect better efficiency than Lua. However, this also means that Nelua cannot load code generated at runtime. The user is encouraged to generate code at compile-time using the preprocessor. Sounds like this is less like Typescript (take the "base" language, add typechecking, and then "transpile" back into the base language) and more like Crystal (take the "base" language, and create a separate language that's similar to it but with static types and AOT compilation) If you're looking for something more in the Typescript "transpiler" vein, there's Teal (https://github.com/teal-language/tl https://github.com/teal-language/tl), written by the guy who created LuaRocks (and htop, interestingly). It still seems a little "early" in its life; it supports most everything you'd need, including some support for Typescript-style "type declaration files" for third-party libs, but it lacks the nice distribution mechanism Typescript grew over time for shipping/installing those declaration files (right now just have to "vendor" them yourself).
- armchairhacker 5y agoThere’s also https://typescripttolua.github.io https://typescripttolua.github.io where you literally write TypeScript and it transpiles to Lua
- abraxas 5y agoThis would be an amazing language to use with one of those SBC boards like Arduino or STM32.
- edubart 5y agoActually Nelua have been tested to work with Arduino, AVR, RISC-V and some other embedded devices. You can make some free standing code with the language if you follow some rules (avoid APIs that uses lib C and use a custom allocator).
- andrewmcwatters 5y agoSeems nice. I don't agree with all of it's deviations from Lua, which unfortunately breaks portability, but I get it. I wish C was scriptable, versus Lua being compliable, but this is really cool.
- edubart 5y ago> I wish C was scriptable C kinda can be used as scripting language with MIR project https://github.com/vnmakarov/mir https://github.com/vnmakarov/mir It released version 0.1 just a few days ago, and I've successfully used it as an alternative and fast C compiler with Nelua.
- stefanos82 5y agoWell, you can still use Lua 5.4 from inside Nelua since it's integrated as part of the backend mechanism for the metaprogramming and not only, therefore I don't think it breaks portability...unless I did not fully understand you correctly. Can you please clarify a bit more your concern about it?
- andrewmcwatters 5y agoIt seems like global is a requirement for newindexing on _G (or if _G is even a thing in Nelua) from the documentation unless I'm reading it incorrectly.
- edubart 5y agoYou are correct, but this is an enhancement to have better compile time type checking and runtime efficiency. In the future _G table with similar Lua semantics is considered to be implemented to have better compatibility with Lua code. But using the "global" keyword will always be recommended, this way the compiler can do better type checking and generate more efficient code.
- andrewmcwatters 5y agoYep. Totally get that.
- haolez 5y agoLooks similar to Terra: https://terralang.org/ https://terralang.org/