In Lobster you must initialize a variable declaration. Now you can produce your bad case with `var x = nil`, but that is undesirable because nil types must be explicitly checked at compile time, so typically you want to use as few nils as possible. More likely thus is `var x = ""` if you must initialize later.
I had misunderstood a comment elsewhere and had claimed that you were the author of Quake (which I now know was developed by a team). My link above acknowledges that you are the author of some Quake maps (among many other things).
Yes, its somewhat similar, monomorphic specialization.
I am sure it has some limitations, but it is pretty powerful, it can even do things C++ can't, like have a type error in a branch that in the current specialization is never executed doesn't count as a type error :)
There's no FPL style pattern matching. It can do a switch case on types (the various subclasses of a base class) but only 1 level, i.e. can't match against type of members. That could still be added, just personally rarely have use for it.
> like have a type error in a branch that in the current specialization is never executed doesn't count as a type error
I’ve struggled with my feelings on this even to the extent that C++ allows it, because while it is flexible, it can also hide errors in libraries that will only blow up when used in very specific ways.
Yes, that is a downside, but when you write very generic code being limited in what code you can write because it has to typecheck even for types that it doesn't apply to is one of the more frustrating things of doing this in C++ and other languages.
It comes with a tiny minecraft clone in < 100 lines of Lobster.
Agreed it could use more actual game examples. I've written a ton of game prototypes in it, and some could do with open sourcing, just haven't gotten around to it.
I noticed that Lobster, like many other languages, does not use the C style for-loop syntax, `for (int i = 0; i < m; i++): print(i);`. Could you say why that is? I have been writing Python for many years but still miss that C syntax. Initiating `i` right before every loop feels clunky to me.
In Lobster, this is `for(m) i: print(i)`
Or simply `for(m): print(_)`
The syntax comes from the observation that even in C-like languages, 99% of the time I want to iterate over the range (0..m-1), so that's what it is optimized for.
I don't enjoy writing the same boilerplate over and over. Moreover, because it is so verbose, it is hard to spot `for (int i = 0; i <= m; i++): print(i);` being a special kind of loop since it looks so similar to the common `<` case. I'd rather that looks entirely different to alert me we're also iterating over the bound.
I am not sure what you mean by "Initiating `i` right before every loop"
the "gl" namespace is really a bit of misnomer since it is much higher level API than OpenGL, and does not really depend on OpenGL. It could pretty easily run on another API underneath.
The repo comes with a LOT of graphical samples (in the "samples" dir).
The lights are more of standard way of passing them to the shader (see the phong shader implementation).
Matrices are a bit of a weak spot since its all implicit (which is convenient, but not powerful). There are also classes for direct use of matrices though.
Cool. Thanks for the reply and clarification. Although the clarification is admittedly confusing when it's called the "gl" namespace.
Not seeing a phong example in the samples dir. "pendulum.lobster", "physics_boxes.lobster" Only reference to "phong" brought back in a search was milen-prg's comment on Aug 7, 2023 about using the phong shader in the "cgtest.lobster" example.
All the VM runtime functions are written in C++, as are all of the built-in functionality and the engine it uses. To use C, either all of that needs to be rewritten in C, or there needs to be a clear layer between the two, but the API surface is fairly big.
It actually uses C for the JIT (libtcc), but the fact it has to go thru a layer is a source of slowness and complication.
The actual game itself, yes. Based on this open source project though which provides the language its written in and core engine tech: https://github.com/aardappel/lobster