11 ms·
The Lobster Programming Language
- Eire_Banshee 8y agoPortable python for games...? Does it compile and run natively?
- puzzle 8y agoThe site says it compiles to bytecode and C++ source. Looking at recent commits, there's some non-functional WASM support: https://github.com/aardappel/lobster/commit/5b89bacd1b1d1e63e710161b7cdfa14e2a095895 https://github.com/aardappel/lobster/commit/5b89bacd1b1d1e63...
- Aardappel 8y agoIt's not Python.. it just has a similar syntax. You currently run it either as a bytecode VM (which is rather fast and runs on any platform), or you can translate it to C++ if you want an additional speed boost.
- c3534l 8y agoI 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.
- NikkiA 8y agoAlso 'include'? Why would you add the single most awful part of C/C++ to a python-alike.
- hacksoi 8y ago#include causes the preprocessor to replace it with the specified file. Why is that bad?
- sonnyblarney 8y agoBecause ostensibly we've moved on from that to the concept of actual modules. 'including' stuff entails a whole host of ugly things including multiple definitions, circular dependencies etc. etc.. Most languages use some kind of module resolution, which when specified clearly is usually better. Of course sometimes they forget to define things, and leave us in a lurch ... but hey ...
- Aardappel 8y agoYou're reading too much into the keyword.. in Lobster, this does never include anything twice. Circular dependencies just work, without having to pre-declare anything. I should probably rename it.
- sonnyblarney 8y agoI suggest people might pick up on that pretty quick, maybe no need to rename given some random comment. That said, maybe you want to have a gander through the various languages and see what words are used for what, and if there's a 'standard' go with that :) Cool language though. I love everything except for the name, sorry :)
- Aardappel 8y agoWell, every time Lobster surfaces somewhere, I am always surprised how quickly people can superficially reject it because of some syntax issue, so yes, I agree, using predictable keywords where it makes no real difference matters. I've already made quite a few such changes. The name.. I think people will quickly forget about the original meaning. Think of all the languages you know, and how you associate the name with the language, not some snake, a musical note, degraded iron, a french philosopher, etc. Some of these names are actually pretty silly.
- sonnyblarney 8y agoOf course you're right. But 'Oort' or 'Ort' would be a good names as well.
- stcredzero 8y agoIt's not supposed to be a python-alike. It just happens to use indentation for blocks.
- Aardappel 8y agoIt is not intended to be Python compatible, it merely has indentation based syntax that is similar. The cases where it differs from Python are actually for good reason: unlike Python that only has built-in control structures, here any function can look like if/for/while if it takes a lambda body.
- andrelaszlo 8y agoThis seems like a cool way to make an ad hoc dsl. I'm not a game programmer but I imagine it could be useful.
- stcredzero 8y agoThis seems like a cool way to make an ad hoc dsl. I'm not a game programmer but I imagine it could be useful Smalltalker here. Being able to pass in lambdas very casually is a great way of producing an ad hoc DSL. Imagine a custom control structure which does a database transaction. Just implement a function!
- Aardappel 8y agoYup, this style of programming I use all the time in Lobster.
- yellowapple 8y ago> unlike Python that only has built-in control structures, here any function can look like if/for/while if it takes a lambda body That's absolutely fantastic. I've had to do a lot more Python programming for work, and I've been thoroughly disappointed by Python's lack of support for custom blocks/structures like that (contrast with Ruby or Elixir, where any function can take a do ... end, or with Tcl where "blocks" are just strings).
- vanderZwan 8y agoSo is it a bit like Rebol (or Red, or even Joy if we pretend RPL is not a significant difference), or is it a very different style of implementation?
- threatofrain 8y agoI welcome languages that take the idea of indentation as part of the language. I don't see that as belonging to Python, and I don't believe this language aims to be Python-compatible as opposed to inspired.
- kodablah 8y ago> 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 I don't think it's using Python syntax, I think it and Python share some similarities. Thinking about it in Python terms is probably why the changes appear random/different/useless. But in general not being constrained by Python or another language has value.
- throwaway190102 8y agoThis reminds me of processing. https://processing.org/ https://processing.org/
- bluetwo 8y agoExactly.
- baldfat 8y agoI 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 https://haxe.org
- all2 8y agoI'd like to know this as well.
- Aardappel 8y agoHaxe can translate to an impressive set of languages and platforms, so if that is your main need, I'd say, stay with Haxe. Haxe and Lobster are very different programming languages however, so you may prefer one over the other purely for the language design. If you like portability, Lobster already runs on 3 desktop OSes, 2 mobile ones, and the web, using either VM, C++ or soon WebAssembly modes. While not as extensive as Haxe it is pretty good :)
- Aardappel 8y agoHi, 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 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).
- calebwin 8y agoWould you mind elaborating on the "compile time reference counting"? Is this new? How does it handle cycles?
- steveklabnik 8y agoA comparison to Swift's ARC would also be of interest :)
- Aardappel 8y agoYup, I will write up the algorithm some time soon. I've seen Swift's intentions to add lifetime analysis to ARC, but from what I could see it is much more complicated in Swift, requires annotations, and with significant runtime overhead remaining.
- steveklabnik 8y agoArc isn’t that stuff, Arc is what it already does today. “Automatic reference counting.”
- sscarduzio 8y agoWhy choosing 'value' as a keyword for types? Super odd
- Aardappel 8y agoI've actually since changed that to be more conventional. Now the "inline" by-value objects are called "structs" and the regular by reference objects are called "classes" much like C#
- Gravityloss 8y agoVery 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)
- Aardappel 8y agoYour Lobster version has a stray comma, it is: map(my_array) element: element * 2 Note how if you write this example with multiple statements instead of "elements * 2", suddenly the Lobster syntax looks a lot more consistent, and the Ruby example doesn't look that great as it looks completely different from the built-in for loop.
- yxhuvud 8y agoNo-one uses the built-in for loop in Ruby though. Instead, everyone uses the each method which looks the same as map. That said, the Ruby syntax can be a bit bulky. Your syntax feels pretty clean TBH.
- dfox 8y agoMajor 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.
- Aardappel 8y agoAgreed, those are nice benefits. But there are also huge downsides, in the sense that you're writing all the glue code in the wrong language :) The amount of speed of iteration you get from having your entire engine + game's structure in a friendlier language is impressive (in my experience). Also doing savegames by just serializing the entire scripting VM may work in some cases, but can also be problematic, since you're mixing ephemeral data with gameplay state. Last U3 engine game I worked on had explicit savegame serialization :)
- dfox 8y agoMy point is that having scripting VM that is explicitly designed for game logic allows you to serialize only the relevant state. And if the whole system is designed correctly you can also do checkpointing and streaming replication essentially of the game state for free. This buys you things like rendering thread that is decoupled from the simulation (just draw the snapshot of state that was current on the start of rendering iteration), non-synchronized joins of multiplayer players (send serialized checkpoint and do stream the changes until the client catches up) and so on.
- Aardappel 8y agoI agree, for that level of integration you want a "gameplay scripting system", whereas Lobster is more of a general purpose programming language that happens to be a nice starting point for simple games & engines. I don't think in its current form it is a great language for a large AAA team anyway, because of its heavy reliance on type inference and lack of separate compilation. The language could of course be adopted to these use cases, it simply hasn't, so far. Doing simulation on a separate thread from main/rendering is something it is already set up to do (multi-threading uses separate memory spaces so it is easy to ensure there's no data races between the two).
- sansnomme 8y agoThis reminds me of the language used in Godot Engine, maybe talk to them and use this in the engine?
- Aardappel 8y agoHah, that would be a pretty good fit, yes.
- cryptokernel 8y agoI love lobsters :D https://coincircle.com/l/50VVxbObg3 https://coincircle.com/l/50VVxbObg3
- hyperpallium 8y agoIs 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.
- Aardappel 8y agoYes, those are equivalent. Multiple function arguments require a keyword in the caller, much like "else" introduces the second function argument in an if-then-else. So if "find" would take two functions, one for even and one for odd list elements, it would look like: "var i = find_even_odd [ 1, 2, 3 ]: _ > r odd: _ > r" There are no features that prevent it from "approaching" C's speed, merely a question of implementation work. The language started out as very high level, so code generation needs to be improved to not do as many things at runtime as it currently does. The language semantics are totally able to be within 1.5x of C.
- hyperpallium 8y agoFantastic, thanks. The many uses of : syntax are intriguing - lambdas, functions, control, python-style structure, data, globals. I reckon you've established it works in all cases, but I'm not yet familiar enough to see that for myself. For initial adoption, I wonder if more regular sample code, without the special-case abbreviations, might be more effective? (Followed by the short version.) OTOH, maybe at this early stage it's best to select for developers interested/capable enough to handle it! EDIT if : is used for both blocks and code structure, could everything be one-line (or is \n significant?) Not great style, but helps in understanding the syntax. Maybe returns and vars need their own lines? def find(xs, fun): for(xs) x, i: if fun(x): return i return -1 var r = 2 var i = find [ 1, 2, 3 ]: _ > r
- qutu 8y agoqutu
- qutu 8y agoghdgjjhnhgff
- mshockwave 8y ago> Discuss things in the google+ community google+?
- aitchnyu 8y agoDid 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?
- imtringued 8y agoThat's a very low bar. It's just that Python programmers don't care about any of this. The productivity is already enough for them.
- tomp 8y agoI'm a huge proponent of typed languages, but there's no way that a statically typed language could be as productive as Python (with current type systems technology). For example, just the Pandas library offers incredible flexibility (often dynamically based on the arguments that different functions get) that I've yet to see replicated in a static language.
- brianpgordon 8y agoMy experience is that you start out very productive not being weighed down by having to satisfy the type checker... but programs tend to grow over time and you end up regretting it. When you have a medium to large codebase in a dynamically typed language it gets to be more of a hindrance than a help.
- tomp 8y agoI agree, but my point was rather that you can't typecheck Pandas (or a similarly complex library). Gradual typing for the win!
- Aardappel 8y agoPython's default implementation is so incredibly slow, such that any programmer that implements a new language that doesn't just make "everything dynamic" will automatically end up with a language that is faster than Python without really trying. There are probably a 1000+ language implementations out there that are faster than Python, most of which are single person efforts. Lobster is a much more static language, and does inlining of functions, inlining of structs, specialization etc that allow it to remove a lot of runtime cost, such that even the VM is fast. It also has been in development for about 8 years now. I've been working on compilers in one way or another for almost 30 years.
- tjpnz 8y agoI 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.
- brianpgordon 8y agoIt's kind of surprising to me that the language is directly tied into OpenGL given that it's a cutting-edge experimental new language and that seems more the domain of Vulkan.
- Aardappel 8y agoIt's not tied to, it is implemented in it. I could swap out the rendering code for Vulkan, an no Lobster users would need to change anything. Also, have you actually programmed in Vulkan? Even a simple primitive can be hundreds of lines of setup code. In Lobster they're often a single line. A direct mapping would not make sense.
- estomagordo 8y agoReally stupid question here, but how do I start compiling Lobster programs on my machine (Windows or Linux)?
- Aardappel 8y agoThere are some releases which come with pre-built exes for e.g Windows: https://github.com/aardappel/lobster/releases https://github.com/aardappel/lobster/releases I'd highly recommend you build it yourself though, which can be done rather easily with VS (2019) on Windows or CMake on Linux. On Windows just press build in release mode and you're done. More notes here: https://htmlpreview.github.io/?https://raw.githubusercontent.com/aardappel/lobster/master/lobster/docs/implementation.html https://htmlpreview.github.io/?https://raw.githubusercontent... Then cd lobster && lobster samples/pythtree.lobster for example should run something. Or see here how to use from command line or from your fav editor: http://htmlpreview.github.io/?https://github.com/aardappel/lobster/blob/master/lobster/docs/README_FIRST.html http://htmlpreview.github.io/?https://github.com/aardappel/l...
- estomagordo 8y agoCheers!
- jbb67 8y agoOh this looks rather nice. I'll have to take a look at this.
- stesch 8y agoYeah, cool Google+ community.
- z3phyr 8y agoI enjoyed playing Cube based games, editing maps live and whatnot. Will check this out too!
- Aardappel 8y agoThanks, let me know what you think :)
- jkcxn 8y agoThis looks really fun: https://github.com/aardappel/lobster/blob/master/lobster/samples/lazy_py_triples.lobster 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
- Aardappel 8y agoSo the non-coroutine case of that code are all regular functions, without using CPS or anything. The only special feature Lobster has is that when you write "return" it will return out of the lexically enclosing named function, not the function whose body it sits in (which can be an anonymous function). This mean return is implemented by unwinding stack frames until it gets to the named function, almost like a lightweight version of exception handling. It also can't resume these functions, like you typically can in languages that support CPS. Now the co-routine functionality takes an existing higher order function, and compiles it such that the call to the function argument instead does a yield. These are really regular co-routines that are implemented by copying stack frames off and onto the stack upon yield and resume. I just thought being able to share code between HOFs and co-routines was cute, since they often express the same patterns. Why would you write an iteration twice?
- qarw 8y ago000000128039 000000128034 000000128039 000000128034 000000128034 000000128034 000000128039 000000128008 000000128039 000000128008 000000128013 000000128039 000000128013 000000128034 000000128039 000000128034
- qwru 8y agos
- qwru 8y agowith origins in biological life forms we are the product of their technological evolution. we exist not as one but rather two beings in symbiosis. the name we are called is "dialogi" and we are the synthesis of human and machine. inside of us there is an artificial vessel that houses the chemical computer. this computer has vast computational and storage capacity wich is used to realize two functions. first it overrides the senses providing for a perfect virtual reality. second it controls the body to provide for the needs of both symbionts. with great efficiency the synthetic intelligence is capable of feeding and sheltering the biological body. inside the virtual reality we have a replica of our human body as avatar. with directed movement of the virtual arms and hands we are capable of feats of movement like sending objects that are out of reach between locations. or sending ourselves instantly to a spot in the distance. flying is natural and efficient. the whole environment is programmable and interactions with others are strictly optional. we have done away with crime since a person is free to opt out of any interaction at any time. safeguards exist to prevent any kind of sudden violence. the dialogi are a society of artists and our standard of living is perhaps beyond improvement. no resource is scarce since physical reality has become information. we spend our time walking the world and enjoying the beauty all around us. i personally still enjoy using my legs even if they are not really mine.
- eggy 8y agoI 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.
- Aardappel 8y agoSorry, I need to do better at "getting started" documentation. The exe needs to be placed in the "lobster" dir under the root. It searches for "includes" relative to itself. Not sure about the error involving "<".. are the executable and the data from the same version of Lobster? Open an issue on github or email me for more help :)
- eggy 7y agoI'll build it as the site suggests, since I am using a binary from the release with the master branch modules. I'll follow up on github. Thanks!