
Lemon – An embeddable, lightweight programming language in ANSI C - zhicheng
https://github.com/lemon-lang/lemon
======
wbhart
The documentation [1] appears to come from a very ordered mind. There's
something very appealing about simplicity.

I see more similarity with Python than either Java or C, except for the braces
and semicolons.

The description says that everything is an object, even types, though there's
no way to specify types in the function prototypes so far, it seems. (Whilst
that is what you would expect from a dynamically typed language, it can still
be useful for optional type checking, or for later optimisation (AOT or Jit),
or to make it easier to efficiently add methods for existing "types".)

Actually, what I can't quite see from the documentation is how one calls
methods, whether it is necessary to put methods inside the classes, whether
they dispatch only on the first argument or an implicit "this", and how
inheritance is handled.

So I guess this is all at a very early stage of development.

[1] [http://www.lemon-lang.org/documentation](http://www.lemon-
lang.org/documentation)

~~~
kobeya
> So I guess this is all at a very early stage of development.

That should be the top link

~~~
Semiapies
Submitters here have developed a truly odd habit of posting a github link when
a project has a site with actual documentation. And then, we get random, angry
posters (visible elsewhere on this page) who don't notice the link to the
actual site at the top of the github page.

~~~
exikyut
Or who think "if the github is in this state, the site's probably terrible!"

------
robotresearcher
How about this link instead, since the GitHub page has no info about the
language?

[http://www.lemon-lang.org](http://www.lemon-lang.org)

~~~
ateesdalejr
I agree. Maybe [http://www.lemon-lang.org/documentation](http://www.lemon-
lang.org/documentation) ?

------
geraldcombs
Not to be confused with SQLite's Lemon parser generator:

[https://www.sqlite.org/src/doc/trunk/doc/lemon.html](https://www.sqlite.org/src/doc/trunk/doc/lemon.html)

------
bpicolo
Why is the `var` keyword required in function arguments if it's dynamically
typed and there's no other possible option?

~~~
fasquoika
This is a complete guess, but maybe so they can treat it the same way as
normal variable declarations

~~~
ateesdalejr
Might be. Probably reusing the same pattern matching code in function
definitions.

------
ateesdalejr
Nice seed for random number generation used here: [https://github.com/lemon-
lang/lemon/blob/9a0b3dbc854532b31f7...](https://github.com/lemon-
lang/lemon/blob/9a0b3dbc854532b31f731a15f57365972d0cac73/src/lemon.c#L274) I'm
not sure because I haven't read very far yet but I wonder if the lemon
standard lib allows lemon code to change the seed?

------
jonathanstrange
Went to the doc directory and got this:

 _TODO: Add Doc_

Could developers please stop doing that? These 'agile development' and
'release early and often' mantras have really gone overboard.

Why would anybody use a programming language with zero documentation for
anything? Are we supposed to guess the language and its features from a single
five-line hello world program?

~~~
exDM69
> Why would anybody use a programming language with zero documentation for
> anything? Are we supposed to guess the language and its features from a
> single five-line hello world program?

As someone who has done a handful of compiler/interpreter projects: I don't
think that they expect anyone at this point to be using that language. They're
targetting it at language geeks like myself (who go and dig around the source,
which I just did). Maybe in some years' time this project will reach a stage
where end user docs matter.

A little more verbose readme would have been nice, though. Things that I did
not find out by looking at the examples/docs, but I care about:

    
    
      * what paradigm? imperative, functional, etc?
      * interpreted or compiled language?
      * what's the target? interpreter, a bytecode VM, LLVM, compile-to-C, native codegen?
      * static/dynamic typing? type inference?
    

By looking around the code, I _think_ that this is an interpreted language
with dynamic typing that's implemented with a stack-based bytecode virtual
machine. Not unlike Lua, Python or Ruby, that is.

~~~
le-mark
It is dynamic, curly braced, garbage collected, coroutines. Some really
squeaky clean C code too. One can immediately tell this is a great code base
to read and learn from, at the very least.

~~~
augustk
What's so squeaky clean about hiding a goto inside a macro?

~~~
le-mark
I guess you're referring to this[1]. I'd actually call that usage svelte. The
macro is undefined not far after it's use in the file, and makes the section
it's in far more readable.

[1] [https://github.com/lemon-
lang/lemon/blob/9a0b3dbc854532b31f7...](https://github.com/lemon-
lang/lemon/blob/9a0b3dbc854532b31f731a15f57365972d0cac73/src/lemon.c#L257)

~~~
billytetrud
Why does it have the do-while(0)?

~~~
le-mark
It's a safeguard because {} statement blocks are optional [1].

[1]
[https://stackoverflow.com/a/923833/2561675](https://stackoverflow.com/a/923833/2561675)

------
keithnz
seems a bit similar to lua? So little information it's hard to know what
interesting things the language provides

------
4lch3m1st
Not too much documentation nor examples there, right? However, the two test
files and the documentation website immediately made me think about Python and
Nim at the first glance. I might give it a try as an embeddable language, it
looks promising.

------
nurettin
Interesting optimizations:

[https://github.com/lemon-
lang/lemon/blob/master/src/peephole...](https://github.com/lemon-
lang/lemon/blob/master/src/peephole.c)

------
cestith
> TODO: Add Doc

It's not a programming language if there's no documentation. It's just a
compiler implementation for a dialect of something amorphous and ethereal.

That said, I kind of like the examples on [http://www.lemon-
lang.org/documentation](http://www.lemon-lang.org/documentation) and I wish
the author(s) well in fleshing this out.

------
nodefourtytwo
What problem does it solve?

~~~
baybal2
Looks like an attempt of a JS programmer to reinvent a lighter weight JS with
aim at system programming.

If it is yet again tied to a complex, feature rich VM (a stack based one),
then he went the wrong way in achieving his goal. Direct interpretation
should've been the way forward for such task.

~~~
andrewchambers
A stack based VM or direct interpretation have no real difference with regard
to what you mention. Please elaborate further.

------
billytetrud
What's the motivation for this language? It seems like Javascript with
destructuring assignment, named function parameters, and a few miner quirks
(like sentinal)

~~~
khedoros1
It seems like it's meant to be easy to embed in another language's code. Like
embedding LUA into a C game engine to provide a convenient way to build
higher-level game logic on top of the engine.

------
maxpert
Interesting mixture of C/C++, Python (__init__) and Javaish. Has no package
manager (atleast I can’t see one).

Would like to see how it compares against Lua in performance.

------
sesteel
Looks like Python with curly braces. I assume the developer is also a python
dev based on the comments in his code.

~~~
klibertp
No way. No Python dev would ever use both tabs and spaces...

------
shortstuffsushi
I'm seeing in the source that the author prefers

type

methodName(args...)

Is this a common C-ism? I'm not familiar with this code style.

~~~
mratzloff
GNU style.

[https://en.m.wikipedia.org/wiki/GNU_coding_standards](https://en.m.wikipedia.org/wiki/GNU_coding_standards)

~~~
dfox
GNU style is mostly about the funny and ugly indentation of braces.

Return type on separate line is shared by many other coding styles.

~~~
mratzloff
Sure. It’s an illustrative example that it’s a common C style.

------
krylon
The source code is very pleasant to read - both in terms of layout and
variable names.

------
ateesdalejr
Looks like the documentation website is down right now.

------
jlebrech
i'd like to see an embedded language designed to not have OO, and for the host
system/language to handle the objects. I guess Lua 5.2 kinda fulfills that.

~~~
pavlov
JavaScript? The original use case was exactly that.

~~~
jlebrech
it's too open to abuse and shoehorning of libraries etc. also you cannot embed
javascript into something built in javascript it's eval.

------
singularity2001
What a lemon

------
rubyfan
Looks like a mashup of Ruby, JavaScript and tiny bit of Python.

~~~
Hemospectrum
I’m mostly seeing a lot of Python. The examples show that multiple assignment
unpacks collections, functions can be called with argument name assignment,
and collections can be unpacked into named arguments, as opposed to using
collections to replace named arguments.

~~~
vidarh
Ruby supports that too. Here's a snippet that shows named arguments, and
unpacking a Hash into named arguments.

It can do multiple assignment and unpacking collections into them too, though
unlike with named arguments, that will treat the collection as an Array:

    
    
        def foo bar:, baz:
            p [bar, baz]
        end
        
        h = {bar: 1, baz: 2}
        
        foo(h)

------
otabdeveloper1
"Lemon – An embeddable, lightweight programming language in ANSI C that lacks
documentation."

Uh, thanks for posting this strange link, I guess.

