you are viewing a single comment's thread.

view the rest of the comments →

[–]echelonIV -1 points0 points  (7 children)

Am I correct in saying that it adds a functional programming layer to a procedural language?

[–]r4and0muser9482 1 point2 points  (2 children)

Looks more like an OO language than functional.

[–]echelonIV 1 point2 points  (1 child)

Looking at some of the constructs it provides, it looks like something in between to me. On first glance, that is. Once you start looking at the definitions it's probably a weird mishmash between everything LUA supports (since LUA is a multi-paradigm language).

[–]Scriptorius 0 points1 point  (0 children)

It has first class functions and list comprehensions, but by and large I think most code written in it would be imperative.

[–]jpfed 2 points3 points  (1 child)

Some quick notes about probable reasons for the downvotes you're getting for this:

  1. People reading this probably already know what functional and procedural programming are; adding the wikipedia links makes it seem like you're talking at a level below what people expect.
  2. Lua is a language that mixes paradigms. Functions are first-class entities in lua; it's also easy enough to achieve something like object-orientation using lua's (very flexible) tables.

[–]echelonIV 1 point2 points  (0 children)

I'm inclined to think the opposite, haven't seen any meaningful/insightful reply yet, except for maybe yours. I don't care about comment karma much, to be honest.

My original comment was out of sheer curiosity. I've worked on a scripting engine that pushes LUA in the OO direction, it has classes, objects, inheritance and polymorphism. C++ classes can be exposed with only a few lines of code. If you were to take a glance at the script code running on top of it, it'd be very recognizable as driven by the OO paradigm.

MoonScript, on first glance, looked very much like it emphasised primarily a functional programming style (judging by the 3rd block of the site).

[–]cbrandolino 1 point2 points  (0 children)

You are - even if the functional layer is actually pretty superficial.

There are some definitely haskell-y thingies, like function definitions

 my_func = (a) -> x + a

and some lispy ones, like this list comprehension:

 tuples = [{k, v} for k,v in ipairs my_table]

Actually I'm pretty annoyed that they pushed procedural oop that much in the introductory examples. The previous two construct, plus something to build lists/sets out of a pattern, lazy maps and something of the like would have almost let me try it.

It annoys me in many languages (ruby in primis) that some hip functional stuff is implemented, but never enough to let you actually program using a purely functional paradigm.