> Another common criticism of Lua is that it lacks arity checks; that is, if you call a function without enough arguments, it will simply proceed instead of indicating an error. Fennel allows you to write functions that work this way (fn) when it's needed for speed, but it also lets you write functions which check for the arguments they expect using lambda. I don't understand this; why is this a speed consideration?
This is mostly based on my experience in the past with Lua circa 2015 when I developed a GUI using Crank Storyboard Engine and needed to write some stuff in C because the Lua equivalent code was too CPU-intensive. If I remember correctly, Lua is a stack-based VM. What this means is that every piece of data has a corresponding location on a stack data structure in-memory. Function arguments are pushed into the stack a…
Why Fennel?
61–70 of 106 posts
Re: Why Fennel?
#62Now I like lua and think single pass is the way to go for interpreted, since you don't have the disadvantage of a slow compile time no matter how big your codebase gets, BUT its not great to write in. some things are (apparently) not possible, which means the only solution is to transpile into it, which has led to some good languages like moonscript[0], and the dynamic nature is a boon as your codebase grows, which h…
> is a boon A boon is a good thing. I think you meant a problem?
Re: Why Fennel?
#63That seems strange to me. A range is a range so why have different ways to iterate over ranges based on what type of range it is?
Re: Why Fennel?
#64In there it says Lua uses 'for' for looping over integer ranges and object ranges. They didn't like that so they broke it up so that for is for integer ranges and each is for object ranges. That seems strange to me. A range is a range so why have different ways to iterate over ranges based on what type of range it is?
Re: Why Fennel?
#65> Another common criticism of Lua is that it lacks arity checks; that is, if you call a function without enough arguments, it will simply proceed instead of indicating an error. Fennel allows you to write functions that work this way (fn) when it's needed for speed, but it also lets you write functions which check for the arguments they expect using lambda. I don't understand this; why is this a speed consideration?
(fn add-1 [x] (+ x 1))
(lambda add-2 [x] (+ x 2))
transpiles to the following lua: local function add_1(x)
return (x + 1)
end
local function add_2(x)
_G.assert((nil ~= x), "Missing argument x on /home/sullyj3/tmp/fn-vs-lambda/fnl/x.fnl:3")
return (x + 2)
end
return add_2Re: Why Fennel?
#66Earlier quoted context omitted.
This is mostly based on my experience in the past with Lua circa 2015 when I developed a GUI using Crank Storyboard Engine and needed to write some stuff in C because the Lua equivalent code was too CPU-intensive. If I remember correctly, Lua is a stack-based VM. What this means is that every piece of data has a corresponding location on a stack data structure in-memory. Function arguments are pushed into the stack a…
Lua is a register based VM.
Re: Why Fennel?
#67Earlier quoted context omitted.
Emacs is a whoooooole lot more than an editor and Lispy config language.
What else is there apart from an editor and a lispy config language? I always thought of emacs as that, i.e. an editor that is extensible and dev friendly (in contrast to vimscript). I don’t know much about emacs though, so this got me curious.
From the GNU Emacs homepage:
At its core is an interpreter for Emacs Lisp, a dialect of the Lisp programming language with extensions to support text editing.
It's not an editor with a lispy config language, it's a Lispy interpreter that comes with an editor that can configure it via said Lisp.
It's kinda like one of those Smalltalk VMs where the line is blurred between the code you're writing and the environment that it runs in.
Re: Why Fennel?
#68Earlier quoted context omitted.
Emacs is a whoooooole lot more than an editor and Lispy config language.
What else is there apart from an editor and a lispy config language? I always thought of emacs as that, i.e. an editor that is extensible and dev friendly (in contrast to vimscript). I don’t know much about emacs though, so this got me curious.
Re: Why Fennel?
#69I've been wanting to give Fennel a try, currently I use Moonscript for my Lua transpilation ( https://moonscript.org/ ), but it has some criticisms and it can be a bit confusing sometimes.