Live data from Hacker News

Why Fennel?

fennel-lang.org

61–70 of 106 posts

Re: Why Fennel?

#61

> 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…

Lua is a register based VM.

Re: Why Fennel?

#62
post #25

Now 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?

Perhaps they had in mind "bane".

Re: Why Fennel?

#63
In 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?

#64

In 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?

I mean it is lua that has two different ways to loop, with different syntax and semantics, but calls them both "for." "Numeric for" and "generic for" are the official names, with separate pages in the docs. Having different names for them seems like a reasonable and not that surprising choice.

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?

It's a runtime check. The following fennel:

    (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_2

Re: Why Fennel?

#66
post #61

Earlier 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.

I think he means that the C API is stack based?

Re: Why Fennel?

#67
post #55

Earlier 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.

Though it looks and acts like that, and can be used in such a way with no problem, in a sense, you've got it inside out.

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?

#68
post #55

Earlier 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.

The interactivity is one. It's easy to evaluate expressions from within the editor. I am not sure you can programmatically change aspects of nvim on the fly, and even if so, probably not a central component of nvim experience. M-x in Emacs is much more powerful than : in (n)vim.

Re: Why Fennel?

#69

I'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.

Are you using Moonscript for nvim config or something else?

Re: Why Fennel?

#70

Earlier quoted context omitted.

I use a plugin called Aniseed which loads first and does the transpiling on the fly for me.

I linked to aniseed originally, but nfnl is what Olical is pointing people toward now?

Yep, but I haven't made the leap yet.
Post reply on HN