1. 5

    I found this part pretty interesting:

    In fact, exception handling in Lobster is not a language feature, it is simply some utility functions (try/catch/…) implemented on top of return/from (implemented in exception.lobster).

    It’s very concise!

    def try(body, catch):
    def exception_handler(body):
        return body() from try
    def throw(v):
        return v from exception_handler 

    I was surprised that unlike let/ec or setjmp, you only need the function’s name to return from it: there’s no jump buffer / continuation you have to communicate from try to throw.

    1. 2

      That’s because Lobster’s return already takes care of that: it can unwind multiple stackframes until it encounters one with the correct function id. Turns out, that is the minimum building block you need to implement exception handling.

    1. 2

      I like it! It seems to be a “what if Rust, but without any type annotations”. It has memory management similar to Swift’s ARC, but an ambition to optimize it to more Rust-like single ownership.

      Lifetime analysis is done based on AST. That will probably end up being limiting/complex. Rust has moved from AST-based lifetime analysis to CFG-based (known as Non-Lexical-Lifetimes).

      1. 1

        True, it is rather complex.. though Lobster does take quite a bit of control flow effects into account with its “flow-based” type checking (and thus lifetime analysis, they are intertwined). It can probably be done better, and I am sure someone will. Baby steps.

      1. 1

        Too many MCs not enough mics.

        The programming language market exploded like the electronic music market in the ’00s, or the typography / fonts market last decade.

        Every week a new language pops up. Soon every respectable shop / individual will have its own programming language.

        And that’s good. Taylor made programming languages for every problem, every taste.

        The question is, with this inflation, will programming become an irrelevant market activity? Because DJ-ing, MC-ing did. Around 1% of musicians make their living from music. The rest are hobbyist, even if exploring unimaginable niches in highly professional ways.

        1. 2

          Your point is valid, but Lobster isn’t brand new. I don’t know its exact age, but it was first noted here seven years ago (see “Stories with similar links” at the bottom of this page.)

          The question is, with this inflation, will programming become an irrelevant market activity?

          I think it makes more sense here to say “language design”, not “programming”, since we’re talking about production, not consumption, of languages.

          Has language design/implementation ever been a relevant market activity? The only language I can think of that became a big business to its creators is Java. (Companies like Microsoft and Borland did make businesses out of BASIC and Pascal, but didn’t invent them.) Languages have usually been labors of love, or infrastructure for a platform.

          1. 3

            Yup its from 2010.. though you wouldn’t recognize the Lobster from back then as being the same one as today :) Some history here (scroll to the end): http://aardappel.github.io/lobster/philosophy.html

            And yes, language design & implementation today is going to make you even less rich and famous than it used to.. but that doesn’t stop me :P

            1. 1

              From the examples, Lobster reminds me a lot of Dylan, but with a Pythonesque syntax.

        1. 12

          There’s a real interesting historical connection here. The author of this, Wouter van Oortmerssen, also created FALSE in 1993. Not only was FALSE one of the first “true” esolangs, it inspired Chris Penner’s Befunge and Urban Müller’s… brainfuck! I don’t think esolangs would be nearly as vibrant today without Wouter’s work.

          1. 3

            Wouter was huge in the Amiga scene. He created the E programming language, which was definitely my favorite language to use on the Amiga.

            EasyGUI (also written by Wouter, I believe), was the sweet spot for GUI development on the Amiga. It got you 80% of the way to MUI without needing MUI (and trust me, GUI development on the Amiga without something BOOPSI-based like MUI was terrible.)

            Wouter then went on to develop Flat Buffers at Google. He’s had an amazing career.

            1. 5

              He also did TreeSheets!

              1. 4

                which is written in Lobster, incidentally!

                1. 8

                  That’s what I would do if I’d write it today, but it is actually in C++ (using wxWidgets), though nowadays has a way to script it in Lobster. TreeSheets actually predates Lobster by a few years (2008 vs 2010 or so).

              2. 1

                He created the E programming language

                I’m assuming this is a different E than the one of capabilities fame created by Mark Miller ?

                EDIT: nm, the wikipedia page links to AmigaE, which is the one you were referring to.

                1. 1

                  Yeah, sorry. This one: https://en.wikipedia.org/wiki/Amiga_E

              3. 2

                Can you enlighten me on what an esolang is?

                1. 3
                  1. 1

                    Hey it’s not a “previously on” because I never submitted that one to lobsters :P

                    (The lecture is definitely going up, if it doesn’t kill me first. One more week to go…)

                    1. 2

                      Wouter’s homepage is worth a browse.

                    2. 1

                      inspired Chris Penner’s Befunge

                      just to clarify (incase anyone else was confused like me), it’s Chris Pressey that invented Befunge; Chris Penner is someone else; at least I think so :)

                      1. 1

                        Mea culpa! No idea why I wrote “Penner”

                      2. 1

                        The visual programming language he did for his PhD thesis (late ’90s) is interesting as well: http://strlen.com/aardappel-language/

                      1. 21

                        If I’d write an article called “Protobuffers Are Wrong” its content would mostly be mutually exclusive to this article. Because the #1 problem with Protobuf is performance: it has the need to do a ton of dynamic allocations baked into its API. That’s why I designed FlatBuffers to fix that. Most of the rest of Protobuf is actually rather nice, so I retained most of it, though made some improvements along the way, like better unions (which the article actually mentions).

                        1. 5

                          Your comment and also some remarks in the article suggests to me that Protobuf was designed for Java and never lost that bias.

                          1. 6

                            At the time Protobuf was designed, Google was mostly C++. It is not that unnatural to arrive at a design like Protobuf: 1) Start with the assumption that reading serialized data must involve an unpacking step into a secondary representation. 2) Make your serialized data tree-shaped in the general case, 3) allow arbitrary mutation in any order of the representation. From these 3 it follows that you get, even in C++: 4) the in-memory representation must be a dynamically allocated tree of objects. FlatBuffers questions 1) and 3) :)

                          2. 1

                            To me it sounds like your issue is with whichever protobuf implementation you were playing with when you checked it out.

                            There are protobuf libs that will do the job fine without all the allocations. Are you aware there are other implementations, and that protobuf is by now a bit of a protocol in and of itself… ?

                            1. 1

                              Link to these magical allocation-less Protobuf implementations?

                              At least internally to Google, Protobuf allocs are a huge cost, which they’ve so far been unable to eliminate. The best they can do is arenas. If it was easy to fix, they would have done it by now.

                              I can imagine ways in which you could read a Protobuf without allocations, but it be a) completely incompatible to the current API, b) not have O(1) or random access to data (unlike FlatBuffers) and c) not allow mutation. That would thus be entirely useless to most users of Protobuf.

                                1. 1

                                  I’m aware of nanopb.. using that without malloc is only possible in very limited situations, where you might as well have used an even simpler serialization method. It has some serious limitations and is.. slow. Compare that with FlatBuffers, which can be used with even less memory, is very fast, and can also be used with more complex datasets.

                                  1. 1

                                    I use nanopb quite effectively, so none of your issues bother me in the slightest. Nevertheless it demonstrates that its quite possible to use Protobufs without any of the original issues you claim make it unsuitable.

                          1. 2

                            Most of the “reasonable” ones in this list (the ones not using a large language runtimes) will have their memory usage dominated by graphical assets (fonts, and maybe textures/buffers derived from them, etc). The actual efficiency of the widget data structures is going to matter little in comparison.

                            I worked on an immediate mode gui a while ago (https://github.com/google/flatui) and was proud of the fact that most memory use was transient, i.e. it could layout and render hundreds of widgets while using only a few hundred bytes of memory! (code: https://github.com/google/flatui/blob/master/include/flatui/internal/flatui_layout.h). That is, until you actually try to render something, and fonts/textures dwarf memory usage of the core of the system. Oh, and having to link in lots of i18n libs etc that dwarf the code size of the core gui system.

                            So a truely efficient library would need to render all fonts with vectors, on the fly. I presume some of the lower memory use ones may use system font rendering, so it doesn’t count towards their own memory usage, like all the GL based ones.

                            Surprised by dear IMGUI, which should be much lower since a) immediate mode can easily be more efficient memory wise than retained mode, and b) it uses a tiny built-in font.

                            1. 2

                              The numbers next to Dear ImGui are mostly flat cost of SDL + OpenGL/Vulkan setup which need to create multiple framebuffers. Measure of that cost is likely to grow with resolution.

                              There’s a line saying: “SDL (14.0 mb)” above it which gives an indication of that fixed cost. Whereas e.g. “Nuklear (rawfb)” is poking into a framebuffer it doesn’t own, and curiously there’s no equivalent “Nuklear (SDL+GL)” for comparaison of those fixed costs. Rawfb is also probably a bad idea for perf reason (we could also render Dear ImGui with software rendering but in most situations it is silly), and users of accelerated graphics API in their app are already paying the flat framebuffer costs. Which is to say that even though that page is correct, caring about those numbers means ignoring the big picture and can be largely misleading. If there was a measurement to do outside of productivity and flexibility, it would be more interesting to measure prolonged cost of equally elaborate apps - but that’s impossible to achieve because no one is going to write equally elaborate apps for all those toolkits.

                              1. 1

                                Yup makes sense. Would be great if these tests can be run somehow not counting framebuffer costs. Or maybe they can be run forcing each window to be some very small size.

                            1. 5

                              See, everyone has a different thing they find important about Rust. He suggest abandoning zero cost abstractions (letting stack/inline allocation be decided by the compiler instead) which I think would remove most of the power of the language. Default thread safe primitives sounds really wasteful too.

                              I think languages similar to Rust but with less complexity will be a very cool space to watch going forward. All sorts of interesting language designs possible.

                              I’m working on a language that does “Rust-like” things, but unlike the article, what I am going for is the efficient memory management, in this case the inline structs (zero cost abstraction) and compile time memory management (automatic lifetime analysis). The biggest difference with Rust is that it is fully automatic: when ownership can’t be determined at compile time, by defaults it falls back to a reference count increase at runtime (in Rust this would just be an error). The advantage is zero annotations, and a language that can be used mostly by people that don’t even understand ownership. There may be ways to explicitly (optionally) enforce ownership in the future, for those who want more control.

                              Language: http://strlen.com/lobster/ Details on memory management: http://aardappel.github.io/lobster/memory_management.html

                              1. 5

                                I honestly tried several times to get into it but I don’t know, it just didn’t click yet.

                                I find golang much nicer to work with if I need to do what rust promises to be best at.

                                I won’t give up on it yet but that’s just my feeling today.

                                1. 12

                                  I’ll likely take some heat for this but my mental model has been:

                                  • Go is the Python of 2019
                                  • Rust is the C++ of 2019

                                  Go has found its niche in small-to-medium web services and CLI tools where “server-side scripting languages” were the previous favorite. Rust has found its niche in large (or performance-sensitive) interactive applications where using GC is untenable. These aren’t strict boundaries, of course, but that’s my impression of where things have ended up.

                                  1. 9

                                    I agree with the mental model, although I usually think of Go as the Java for (current year).

                                    1. 5

                                      The tooling is light years behind though

                                      1. 3

                                        “go fmt” offers a standard way to format code, which removes noise from diffs and makes code other people have written more readable.

                                        “go build” compiles code faster than javac.

                                        The editor support is excellent.

                                        In which way is the Java tooling better than Go, especially for development or deployment?

                                        1. 8

                                          How is the debugger these days?

                                          When I was doing go a few years ago, the answer was “it doesn’t work”, whereas java had time-travel debugging.

                                          1. 1

                                            Delve is a pretty great debugger. VSCode, Atom etc all have good debugging support for Go, through the use of Delve. Delve does not have time-travel, but it works.

                                            Packaging Java applications for Arch Linux is often a nightmare (with ant downloading dependencies in the build process), while with Go, packaging does not feel like an afterthought (but it does require setting the right environment variables, especially when using the module system that was introduced in Go 1.11).

                                            Go has some flaws, for example it’s a horrible language to write something like the equivalent of a 3D Vector class in Java or C++, due to the lack of operator overloading and multiple dispatch.

                                            If there are two things I would point out as one of the big advantages of Go, compared to other languages, it’s the tooling (go fmt, godoc, go vet, go build -race (built-in race detector), go test etc.) and the fast compilation times.

                                            In my opinion, the tooling of Go is not “light years behind” Java, but ahead (with the exception of time-travel when debugging).

                                          2. 2

                                            My three favourite features when developing Java:

                                            • The refactoring support and IDE experience for plain Java is outstanding. Method extraction (with duplicate detection), code inlining, and rearranging classes (extract classes, move methods, extract/collapse hierarchies) makes it very easy to re-structure code.
                                            • Java Flight Recorder is an outstandingly good tool for insight into performance and behaviour, at virtually no overhead.
                                            • Being able to change code live, drop frames, and restart the system in the debugger is a life-saver when debugging hard-to-reach issues. that the process being debugged can be essentially anywhere is a wonderful bonus.

                                            Sure, it would be nice if there was a single Java style, but pick one and use that, and IDE’s generally reformat well. Also, the compile times can be somewhat long, but for plain Java thay are usually ok.

                                            Note that I have never had to work in a Spring/Hibernate/… project with lots of XML-configurations, dependency injections, and annotation processing. The experience then might be very different.

                                            1. 1

                                              Just the other day I connected the debugger in my IDE to a process running in a datacenter across the ocean and I could step through everything, interactively explore variables etc. etc. There is nothing like it for golang.

                                        2. 5

                                          “I’ll likely take some heat for this but my mental model has been:”

                                          All kinds of people say that. Especially on HN. So, not likely. :)

                                          “These aren’t strict boundaries, of course, but that’s my impression of where things have ended up.”

                                          Yup. I would like to see more exploration of the middle in Rust. As in, the people who couldn’t get past the borrow checker just try to use reference counting or something. They get other benefits of Rust with performance characteristics of a low-latency GC. They still borrow-checker benefits in other people’s code which borrow checks. They can even study it to learn how it’s organized. Things click gradually over time while they still reap some benefits of the language.

                                          This might not only be for new folks. Others know know Rust might occasionally do this for non-performance-sensitive code that’s not borrow-checking for some reason. They just skip it because the performance-critical part is an imported library that does borrow-check. They decide to fight with the borrow-checker later if it’s not worth their time within their constraints. Most people say they get used to avoiding problems, though, so I don’t know if this scenario can play out in regular use of the language.

                                          1. 6

                                            I agree, for 99% of people, the level of strictness in Rust is the wrong default. We need an ownership system where you can get by with a lot less errors for non-performance sensitive code.

                                            The approach I am pursuing in my current language is to essentially default to “compile time reference counting”, i.e. it does implement a borrow checker, but where Rust would error out, it inserts a refcount increase. This is able to check pretty much all code which previously used runtime reference counting (but with 10x or so less runtime overhead), so it doesn’t need any lifetime annotations to work.

                                            Then, you can optionally annotate types or variables as “unique”, which will then selectively get you something more like Rust, with errors you have to work around. Doing this ensures that a) you don’t need space for a refcount in those objects, and b) you will not get unwanted refcount increase ops in your hot loop.

                                            1. 2

                                              Ha ha, just by reading this comment I was thinking ‘this guy sounds a bit like Wouter van Oortmerssen’, funny that it turns out to be true :-) Welcome to lobste.rs!

                                              Interesting comment, I assume you are exploring this idea in the Lobster programming language? I would love to hear more about it.

                                              1. 2

                                                Wow, I’m that predictable eh? :P

                                                Yup this is in Lobster (how appropriate on this site :)

                                                I am actually implementing this as we speak. Finished the analysis phase, now working on the runtime part. The core algorithm is pretty simple, the hard part is getting all the details right (each language feature, and each builtin function, has to correctly declare to its children and its parent wether it is borrowing or owning the values involved, and then keep those promises at runtime). But I’m getting there, should have something to show for in not too long. I should definite do a write-up on the algorithm when I finish.

                                                If it all works, the value should be that you can get most of the benefit of Rust while programmers mostly don’t need to understand the details.

                                                Meanwhile, happy to answer any more specific questions :)

                                          2. 4

                                            I don’t understand, and have never understood, the comparisons between Go and Python. Ditto for former Pythonistas who are now Gophers. There is no equivalent of itertools in Go, and there can’t be due to the lack of generics. Are all these ex-Python programmers writing for loops for everything? If so, why???

                                            1. 1

                                              Not Go but Julia is more likely the Python of 2019.

                                          1. 3

                                            Rather than the “rule of 2” (classic DRY) and the “rule of 3” (what this guy is proposing), have “the rule of N”, where N depends on ratio between the size of the duplicated code and the cognitive complexity of the abstraction.