News for hackers. Stuff that matters.
Re:Lemon – An embeddable, lightweight programming language i... by wbhart on Wednesday October 25, 2017 @09:21AM (#15549834)
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

Re:Lemon – An embeddable, lightweight programming language i... by kobeya on Wednesday October 25, 2017 @11:36AM (#15550977)
> So I guess this is all at a very early stage of development.

That should be the top link

Re:Lemon – An embeddable, lightweight programming language i... by Semiapies on Wednesday October 25, 2017 @01:41PM (#15552213)
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.
Re:Lemon – An embeddable, lightweight programming language i... by exikyut on Friday October 27, 2017 @05:58AM (#15566999)
Or who think "if the github is in this state, the site's probably terrible!"
Re:Lemon – An embeddable, lightweight programming language i... by robotresearcher on Wednesday October 25, 2017 @12:24PM (#15551498)
How about this link instead, since the GitHub page has no info about the language?

http://www.lemon-lang.org

Re:Lemon – An embeddable, lightweight programming language i... by ateesdalejr on Wednesday October 25, 2017 @12:57PM (#15551791)
Re:Lemon – An embeddable, lightweight programming language i... by geraldcombs on Wednesday October 25, 2017 @01:06PM (#15551867)
Not to be confused with SQLite's Lemon parser generator:

https://www.sqlite.org/src/doc/trunk/doc/lemon.html

Re:Lemon – An embeddable, lightweight programming language i... by bpicolo on Wednesday October 25, 2017 @09:13AM (#15549773)
Why is the `var` keyword required in function arguments if it's dynamically typed and there's no other possible option?
Re:Lemon – An embeddable, lightweight programming language i... by billytetrud on Wednesday October 25, 2017 @03:06PM (#15553136)
So you don't create variables when you typo a variable name. Declarations are an error catching mechanism
Re:Lemon – An embeddable, lightweight programming language i... by fasquoika on Wednesday October 25, 2017 @11:09AM (#15550738)
This is a complete guess, but maybe so they can treat it the same way as normal variable declarations
Re:Lemon – An embeddable, lightweight programming language i... by ateesdalejr on Wednesday October 25, 2017 @01:26PM (#15552079)
Might be. Probably reusing the same pattern matching code in function definitions.
Re:Lemon – An embeddable, lightweight programming language i... by ateesdalejr on Wednesday October 25, 2017 @01:06PM (#15551879)
Nice seed for random number generation used here: https://github.com/lemon-lang/lemon/blob/9a0b3dbc854532b31f7... 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?
Re:Lemon – An embeddable, lightweight programming language i... by jonathanstrange on Wednesday October 25, 2017 @06:57AM (#15549022)
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?

Re:Lemon – An embeddable, lightweight programming language i... by exDM69 on Wednesday October 25, 2017 @07:09AM (#15549086)
> 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.
Re:Lemon – An embeddable, lightweight programming language i... by le-mark on Wednesday October 25, 2017 @08:47AM (#15549564)
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.
Re:Lemon – An embeddable, lightweight programming language i... by augustk on Wednesday October 25, 2017 @10:03AM (#15550190)
What's so squeaky clean about hiding a goto inside a macro?
Re:Lemon – An embeddable, lightweight programming language i... by le-mark on Wednesday October 25, 2017 @11:57AM (#15551196)
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...

Re:Lemon – An embeddable, lightweight programming language i... by billytetrud on Wednesday October 25, 2017 @03:08PM (#15553148)
Why does it have the do-while(0)?
Re:Lemon – An embeddable, lightweight programming language i... by le-mark on Wednesday October 25, 2017 @04:54PM (#15554171)
It's a safeguard because {} statement blocks are optional [1].

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

Re:Lemon – An embeddable, lightweight programming language i... by sparkie on Wednesday October 25, 2017 @07:15AM (#15549118)
I'm a language geek and none of the above is what I want to see when I read about a new language. What I want to know is, what does this language offer that no other language does? What platform it runs on or whatnot is trivial boring detail that I might want to know afterwards if the language offers something interesting to try out.
Re:Lemon – An embeddable, lightweight programming language i... by Danihan on Wednesday October 25, 2017 @12:09PM (#15551340)
>What platform it runs on or whatnot is trivial boring detail

Not caring about actual usage mechanics / acting like they are trivial details makes me question a lot about your perspective.

Re:Lemon – An embeddable, lightweight programming language i... by sparkie on Thursday October 26, 2017 @03:57PM (#15562444)
Language X runs on platform A, it offers little innovative but merely re-expresses what you're already used to doing on platform A in another language.

Language Y has some really innovative features that no other languages are currently doing. There is currently no reference implementation.

Which of these is the more interesting one to a language geek? The former might be more interesting to a "platform A" geek. Or someone who uses platform A in production.

The perspective is being interested in language design rather than "the next big thing". A language that doesn't change the way you think about programming is not worth learning, because you're only re-learning what you already know. In fact, learning such language is trivial and all you really need is a grammar reference from which you can deduce the rest. If it runs on platform A which you're familiar with, you can take advantage of platform A's libraries and become productive in X in no time.

Re:Lemon – An embeddable, lightweight programming language i... by baybal2 on Wednesday October 25, 2017 @07:50AM (#15549265)
Lua.org's Lua is a VM, but a register based one. Perl 6 is another odd case of register based VM
Re:Lemon – An embeddable, lightweight programming language i... by _ph_ on Wednesday October 25, 2017 @07:04AM (#15549062)
In all fairness: there seems to be a little bit more of documentation on http://www.lemon-lang.org So, whoever posted this to hacker news should have used that link rather than the GitHub link and of course, it seems to be way to early in development to post it at all. I have some quite unfinished projects of mine on GitHub, but I would never post a link to them until they are in a state where they would be relevant to a larger community.
Re:Lemon – An embeddable, lightweight programming language i... by skrebbel on Wednesday October 25, 2017 @12:08PM (#15551324)
Wow you're entitled. The author owes you nothing!

It's not like they submitted this to HN themselves.

Re:Lemon – An embeddable, lightweight programming language i... by naasking on Wednesday October 25, 2017 @08:22AM (#15549425)
> Why would anybody use a programming language with zero documentation for anything?

Why would you write documentation if your language implementation is still rapidly evolving?

Re:Lemon – An embeddable, lightweight programming language i... by 4lch3m1st on Wednesday October 25, 2017 @09:20AM (#15549822)
Regardless, shouldn't you at least write documentation to isolate and identify confusing points of your rapidly evolving language? It's almost a matter of good practices; explaining something is usually the best way to learn it.
Re:Lemon – An embeddable, lightweight programming language i... by naasking on Wednesday October 25, 2017 @02:04PM (#15552474)
It depends. The language's author probably didn't post this, so who knows what stage of development his project is at.
Re:Lemon – An embeddable, lightweight programming language i... by billytetrud on Wednesday October 25, 2017 @03:10PM (#15553161)
You should write the documentation first. Otherwise what are you writing?
Re:Lemon – An embeddable, lightweight programming language i... by naasking on Thursday October 26, 2017 @12:42AM (#15556400)
You're writing code for a purpose, obviously. Sometimes that purpose isn't clear from the outset, hence exploratory programming. So what would you be documenting at this point exactly?
Re:Lemon – An embeddable, lightweight programming language i... by chaoticmass on Wednesday October 25, 2017 @10:47AM (#15550558)
Developer: Read the source code!

I've seriously seen this kind of response from developers while looking for help using melt (Media Lovin' Toolkit). You typically see this kind of response for better documentation: "melt is for developers. Use one of the GUI front ends to generate a script for you or read the source code."

Re:Lemon – An embeddable, lightweight programming language i... by Kuraj on Wednesday October 25, 2017 @12:37PM (#15551621)
> Why would anybody use a programming language with zero documentation for anything?

What alternative do you suggest? Not putting it out there until it's production ready?

Re:Lemon – An embeddable, lightweight programming language i... by keithnz on Wednesday October 25, 2017 @07:09AM (#15549089)
seems a bit similar to lua? So little information it's hard to know what interesting things the language provides
Re:Lemon – An embeddable, lightweight programming language i... by 4lch3m1st on Wednesday October 25, 2017 @08:04AM (#15549342)
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.
Re:Lemon – An embeddable, lightweight programming language i... by nurettin on Wednesday October 25, 2017 @10:24AM (#15550338)
Re:Lemon – An embeddable, lightweight programming language i... by cestith on Wednesday October 25, 2017 @01:02PM (#15551846)
> 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 and I wish the author(s) well in fleshing this out.

Re:Lemon – An embeddable, lightweight programming language i... by nodefourtytwo on Wednesday October 25, 2017 @07:21AM (#15549140)
What problem does it solve?
Re:Lemon – An embeddable, lightweight programming language i... by gvb on Wednesday October 25, 2017 @08:24AM (#15549438)
My guess is a lighter weight (than Lua, Python, JS) embed-able language. A quick build creates a .so that is bigger than lua as reported below, but that is a naive and probably invalid comparison metric.

    make DEBUG=0 STATIC=0 USE_MALLOC=0 MODULE_OS=1 MODULE_SOCKET=1

    ls -lh liblemon.so
    -rwxrwxr-x 1 guest guest 271K Oct 25 08:21 liblemon.so

"Lua - Smaller footprint than Python. e.g. Look at the size of python22.dll, 824kb. A basic Lua engine, including parser/compiler/interpreter, but excluding standard libraries, weighs in at under 100kb."

Ref: http://lua-users.org/wiki/LuaVersusPython

Re:Lemon – An embeddable, lightweight programming language i... by wahern on Wednesday October 25, 2017 @10:15PM (#15555857)
Except liblemon is larger than liblua.

  $ ls -lh /usr/lib/x86_64-linux-gnu/liblua5.3.so.0.0.0
  -rw-r--r-- 1 root root 219K Apr 13  2016 /usr/lib/x86_64-linux-gnu/liblua5.3.so.0.0.0
And that's with Lua having many more bindings--basically, all of ANSI C, including math and stdio interfaces. Lemon only seems to bind a dozen or so POSIX routines--see os.c and socket.c.

There are other things that make it less suited for embedding than Lua. For example, Lua very carefully avoids touching any global process state. But one the very first things lemon_create() does it call srandom().

Those particular things, at least, could be easily remedied. Another reason why Lua is great for embedding is because of it's very carefully designed C API. With just a cursory look I can't tell how well Lemon compares on that score.

Re:Lemon – An embeddable, lightweight programming language i... by stephen82 on Wednesday October 25, 2017 @02:04PM (#15552485)

   2, What problems are you trying to solve?
   A: 1, easily integrate with C. 2, stable and modern syntax. that's all I wanted.
I have asked a few more questions about the language:

https://github.com/lemon-lang/lemon/issues/6

Re:Lemon – An embeddable, lightweight programming language i... by baybal2 on Wednesday October 25, 2017 @07:30AM (#15549188)
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.

Re:Lemon – An embeddable, lightweight programming language i... by andrewchambers on Wednesday October 25, 2017 @08:30AM (#15549471)
A stack based VM or direct interpretation have no real difference with regard to what you mention. Please elaborate further.
Re:Lemon – An embeddable, lightweight programming language i... by cond289123 on Wednesday October 25, 2017 @08:52AM (#15549604)
You are making very unnecessary comments..
Re:Lemon – An embeddable, lightweight programming language i... by billytetrud on Wednesday October 25, 2017 @03:04PM (#15553127)
What's the motivation for this language? It seems like Javascript with destructuring assignment, named function parameters, and a few miner quirks (like sentinal)
Re:Lemon – An embeddable, lightweight programming language i... by khedoros1 on Wednesday October 25, 2017 @04:14PM (#15553737)
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.
Re:Lemon – An embeddable, lightweight programming language i... by sli on Wednesday October 25, 2017 @04:33PM (#15553948)
JS has destructuring assignment and named function parameters can be emulated, sorta, with parameter destructuring.
Re:Lemon – An embeddable, lightweight programming language i... by maxpert on Wednesday October 25, 2017 @09:19AM (#15549811)
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.

Re:Lemon – An embeddable, lightweight programming language i... by sesteel on Wednesday October 25, 2017 @11:02AM (#15550685)
Looks like Python with curly braces. I assume the developer is also a python dev based on the comments in his code.
Re:Lemon – An embeddable, lightweight programming language i... by klibertp on Wednesday October 25, 2017 @12:26PM (#15551521)
No way. No Python dev would ever use both tabs and spaces...
Re:Lemon – An embeddable, lightweight programming language i... by pletnes on Wednesday October 25, 2017 @12:17PM (#15551431)
A python dev that uses braces?
Re:Lemon – An embeddable, lightweight programming language i... by shortstuffsushi on Wednesday October 25, 2017 @10:02AM (#15550177)
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.

Re:Lemon – An embeddable, lightweight programming language i... by mratzloff on Wednesday October 25, 2017 @10:10AM (#15550236)
Re:Lemon – An embeddable, lightweight programming language i... by dfox on Wednesday October 25, 2017 @11:28AM (#15550909)
GNU style is mostly about the funny and ugly indentation of braces.

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

Re:Lemon – An embeddable, lightweight programming language i... by mratzloff on Wednesday October 25, 2017 @04:40PM (#15554050)
Sure. It’s an illustrative example that it’s a common C style.
Re:Lemon – An embeddable, lightweight programming language i... by nachexnachex on Wednesday October 25, 2017 @10:13AM (#15550263)
It is. It allows to search for function declarations with the regex '^[^( ]+[(]' (or similar) -- while more common in the past, many have adopted it and keep using it.

Personally I've come to find it nice to read, particularly when you're returning complex, long types.

Re:Lemon – An embeddable, lightweight programming language i... by krylon on Wednesday October 25, 2017 @12:53PM (#15551754)
The source code is very pleasant to read - both in terms of layout and variable names.
Re:Lemon – An embeddable, lightweight programming language i... by ateesdalejr on Thursday October 26, 2017 @12:08PM (#15560168)
Looks like the documentation website is down right now.
Re:Lemon – An embeddable, lightweight programming language i... by jlebrech on Wednesday October 25, 2017 @08:55AM (#15549624)
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.
Re:Lemon – An embeddable, lightweight programming language i... by pavlov on Wednesday October 25, 2017 @09:04AM (#15549717)
JavaScript? The original use case was exactly that.
Re:Lemon – An embeddable, lightweight programming language i... by jlebrech on Wednesday October 25, 2017 @09:08AM (#15549744)
it's too open to abuse and shoehorning of libraries etc. also you cannot embed javascript into something built in javascript it's eval.
Re:Lemon – An embeddable, lightweight programming language i... by singularity2001 on Wednesday October 25, 2017 @08:06AM (#15549348)
What a lemon
Re:Lemon – An embeddable, lightweight programming language i... by rubyfan on Wednesday October 25, 2017 @06:43AM (#15548969)
Looks like a mashup of Ruby, JavaScript and tiny bit of Python.
Re:Lemon – An embeddable, lightweight programming language i... by Hemospectrum on Wednesday October 25, 2017 @06:58AM (#15549029)
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.
Re:Lemon – An embeddable, lightweight programming language i... by vidarh on Wednesday October 25, 2017 @09:48AM (#15550064)
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)
Re:Lemon – An embeddable, lightweight programming language i... by otabdeveloper1 on Wednesday October 25, 2017 @07:51AM (#15549270)
"Lemon – An embeddable, lightweight programming language in ANSI C that lacks documentation."

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