from Hacker News

The Lobster Programming Language

by openbasic on 4/3/19, 8:49 PM with 164 comments

  • by Aardappel on 4/3/19, 10:06 PM

    Hi, author of the language here.

    Not a great time for HN exposure, as I just added a lot of new functionality, but none of that is documented yet :) But hey, all publicity is good publicity?

    For those interested, some recent things that have been happening:

    - Compile time reference counting. This does an analysis similar to the Rust borrow checker to infer lifetimes, but unlike Rust doesn't make the programmer jump through hoops.

    - "Inline" structs: structs are allocated in their parent, and come at zero overhead compared to individual variables, which is particularly useful for Lobster's heavy use of 2d & 3d vector types.

    - Multi-threading that uses separate memory spaces, meaning individual threads can run at max speed with no GIL overhead etc.

    - A WebAssembly backend is being worked on.

    - A lot of optimization work to make the language run faster.

    For reference, it has been on HN before, as early as 2013 (https://news.ycombinator.com/item?id=5904430), but it has changed a TON since then (e.g. it was a dynamically typed language, now it is statically typed, with flow sensitive type inference).

  • by dfox on 4/3/19, 11:35 PM

    Major reason why many game engines used to have native core and then some kind of "scripting" language for game logic (think Unreal Engine before 3, but many engines are similar) is that then you can trivially serialize the simulation state (ie. save game) and even run the whole thing as either lock-step, forward predicted or fully distributed network game without much effort on the part of whoever is writing the "scripting language" part of the game code.
  • by baldfat on 4/3/19, 10:01 PM

    I use Haxe which is a

    Haxe is an open source toolkit based on a modern, high level, strictly typed programming language, a cross-compiler, a complete cross-platform standard library and ways to access each platform's native capabilities.

    what would be the benefit for using Lobster since I can work directly with each OS with a great scripting language built in?

    https://haxe.org

  • by aitchnyu on 4/4/19, 6:37 AM

    Did you create a VM that is several times faster than Python's, for a static typed language thats as productive as a dynamic language, with true multithreading? How did you outdo entire language communities?
  • by c3534l on 4/3/19, 9:42 PM

    I don't really see the point in using Python syntax and then throwing in a handful of random differences that don't have anything to do with the domain you're working in. Syntax level support for vector operations or for shader interopability I would get. Making for loops follow some randomly different syntax, I don't see the point of that.
  • by throwaway190102 on 4/3/19, 9:43 PM

    This reminds me of processing. https://processing.org/
  • by jkcxn on 4/4/19, 11:33 AM

    This looks really fun: https://github.com/aardappel/lobster/blob/master/lobster/sam...

    Are the generators implemented entirely in user space using continuation passing style? And the coroutine function turns it into something pausable?

    Edit: I can't wrap my head around how return returns out of all the generators

  • by eggy on 4/5/19, 7:50 PM

    I am an old Amiga user Vic-20, A1000, A500, etc., so I am a fan of the author.

    I tried running the sierpinski example with a pre-compiled Windows .exe that I placed in the lobster root directory, and it gives me this error: "can't open file: stdtype.lobster".

    I placed lobster and lobster/modules in my path, and it still throws the same error. I am assuming I need to build the .exe myself due to some incompatibility with the master branch and this older .exe?

    I like a self-contained game PL. I use Raylib for that type of experience right now, but I like the concepts here. Thanks!

    EDIT: copied modules to root of lobster, and now I get:

    "stdtype.lobster(8): error: end of file expected, found: <"

    I tried an included test file and a copy/paste of the sierpinski example, and both throw this error.

  • by hyperpallium on 4/4/19, 2:55 AM

    Is the first example's last line:

      var i = find [ 1, 2, 3 ]: _ > r
    
    the same as?:

      var i = find ([ 1, 2, 3 ]) a: a > r
    
    i.e. argument parantheses are optional for one argument; and _ is an implicit argument for a block.

    Would multiple functions arguments be done just with parentheses, like this?:

      var i = find [ 1, 2, 3 ] (: _ > r), (: _ < r)
    
    Seems like the syntactic generality of lisp or haskell, with the predictability of performance of C. EDIT I see it's as fast as non-JIT Lua... are there any features that prevent it from theoretically approaching the speed of C?

    PS: small detail, but that's got to be the best for-loop I've ever seen.

  • by Gravityloss on 4/3/19, 10:33 PM

    Very personal opinion and matter of taste: Many lambda syntaxes are a bit weird.

        map(my_array)element:element*2 //lobster
        my_array.map{|element|element*2} //ruby
        Arrays.stream(my_array).map(element -> element*2).collect(something list something)  //java?
    
    Lobster feels a bit unbalanced. Ruby has "pipes" which are a bit confusing substitute parentheses. Java has the cool arrow syntax but otherwise it feels very glued on. (edited and fixed, thanks for the comment)
  • by estomagordo on 4/4/19, 7:24 AM

    Really stupid question here, but how do I start compiling Lobster programs on my machine (Windows or Linux)?
  • by sansnomme on 4/4/19, 12:32 AM

    This reminds me of the language used in Godot Engine, maybe talk to them and use this in the engine?
  • by z3phyr on 4/4/19, 9:58 AM

    I enjoyed playing Cube based games, editing maps live and whatnot. Will check this out too!
  • by tjpnz on 4/4/19, 7:22 AM

    I really like the inclusion of basic graphics routines. Not a lot of languages include these out of the box and it's something I've really missed since I first started toying with programming in QBasic.
  • by qarw on 4/4/19, 3:27 PM

    000000128039 000000128034 000000128039 000000128034 000000128034 000000128034 000000128039 000000128008 000000128039 000000128008 000000128013 000000128039 000000128013 000000128034 000000128039 000000128034
  • by jbb67 on 4/4/19, 7:43 AM

    Oh this looks rather nice. I'll have to take a look at this.
  • by sscarduzio on 4/3/19, 10:15 PM

    Why choosing 'value' as a keyword for types? Super odd
  • by mshockwave on 4/4/19, 6:06 AM

    > Discuss things in the google+ community

    google+?

  • by stesch on 4/4/19, 8:16 AM

    Yeah, cool Google+ community.
  • by Eire_Banshee on 4/3/19, 9:40 PM

    Portable python for games...? Does it compile and run natively?