1. 5

    panic() is the equivalent of the exception mechanism many languages use to great effect. Idiomatically it’s a last resort, but it’s a superior mechanism in many ways (e.g. tracebacks for debugging, instead of Go’s idiomatic ‘here’s an error message, good luck finding where it came from’ default.)

    1. 5

      Go’s idiomatic ‘here’s an error message, good luck finding where it came from’

      I think the biggest problem here is that too often if err != nil { return err } is used mindlessly. You then run in to things like open foo: no such file or directory, which is indeed pretty worthless. Even just return fmt.Errorf("pkg.funcName: %s", err) is a vast improvement (although there are better ways, such as github.com/pkg/errors or the new Go 1.13 error system).

      I actually included return err in a draft of this article, but decided to remove it as it’s not really a “feature” and how to effectively deal with errors in Go is probably worth an article on its own (if one doesn’t exist yet).

      1. 6

        it’s pretty straightforward to decorate an error to know where it’s coming from. The most idiomatic way to pass on an error with go code is to decorate it, not pass it unmodified. You are supposed to handle errors you receive after all.

        if err != nil {
            return fmt.Errof("%s: when doing whatever", err)
        }
        

        not the common misassumption

        if err != nil {
            return err
        }
        

        in fact, the 1.13 release of go formally adds error chains using a new Errorf directive %w that formalises wrapping error values in a manner similar to a few previous library approaches, so you can interrogate the chain if you want to use it in logic (rather than string matching) .

        1. 5

          It’s unfortunate IMO that interrogating errors using logic in Go amounts to performing a type assertion, which, while idiomatic and cheap, is something I think a lot of programmers coming from other languages will have to overcome their discomfort with. Errors as values is a great idea, but I personally find it to be a frustratingly incomplete mechanism without sum types and pattern matching, the absence of which I think is partly to blame for careless anti-patterns like return err.

          1. 3

            You can now use errors.Is to test the error type and they added error wrapping to fmt.Errorf. Same mechanics underneath but easier to use. (you could just do a switch with a default case)

          2. 4

            I guess you mean

            if err != nil {
                return fmt.Errorf("error doing whatever: %w", err)
            }
            

            but yes point taken :)

            1. 3

              Sure, but in other languages you don’t have to do all this extra work, you just get good tracebacks for free.

              1. 1

                I greatly prefer the pithy, domain-oriented error decoration that you get with this scheme to the verbose, obtuse set of files and line numbers that you get with stack traces.

            2. 1

              I built a basic Common-Lisp-style condition system atop Go’s panic/defer/recover. It is simple and lacking a lot of the syntactic advantages of Los, and it is definitely not ready for prime time, at all, but I think maybe there’s a useful core in there.

              But seriously, it’s a hack.

            1. 3

              This article is getting a few things about git wrong. They claim git only supports ‘One check-out per repository’. Heard of git worktree?

              They also claim git is only portable to POSIX, yet it runs fine on Windows with full line-ending support. (They achieve this by including the tools like ls, ssh and cat, thereby not requiring the host OS to be posix)

              They claim Sqlite is a superior storage method, yet it is widely known for getting corrupted (probably the reason they run integrity checks all the time), lacks the ability of multiple entities accessing it at the same time, and almost all its column types are silently converted to strings columns with no type checks.

              1. 5

                I don’t think they got this one wrong:

                They also claim git is only portable to POSIX, yet it runs fine on Windows with full line-ending support. (They achieve this by including the tools like ls, ssh and cat, thereby not requiring the host OS to be posix)

                From the article:

                This is largely why the so-called “Git for Windows” distributions (both first-party and third-party) are actually an MSYS POSIX portability environment bundled with all of the Git stuff, because it would be too painful to port Git natively to Windows. Git is a foreign citizen on Windows, speaking to it only through a translator.

                1. 1

                  this was also somewhat true of mac os, if you were working with it’s traditional approach to case insensitivity. As the article notes, this is almost by design. Git was built to facilitate linux development, and it’s not surprising that linux hosting is a prerequisite for that.

              1. 3

                What’s so special about platform.sh that it charges 50$ for a tiny server. ?

                1. 5

                  Well, based on the domain name, I assume it’s written entirely in Bash, so that probably takes some extra cycles.

                  1. 2

                    It’s not 50 USD for a server, but for a project. So if you had two “projects” (I’m guessing web sites/apps) it’d be 100 USD instead. I imagine the overhead is for if you don’t want to deal with AWS/Google yourself.

                    Their pricing model reminds me of Webflow.

                    1. 1

                      It’s not exactly like that. There’s a little more provided to ‘project’ than just ‘a server’. The project model gets you an app (I think just one on the standard plan, but it can be more) connected to provisioned services (databases, search index, queues, whatever) and a git server and some storage. Within your project plan you get a certain number of environments, which are branches. (e.g. staging, feature branch etc.) When you branch you can clone the whole setup, services, data, etc. and everything can be driven via git So there is additional value and a different workflow compared to just provisioning some cloud servers.

                      1. 2

                        I think we are both saying the same thing :-)

                        Their site isn’t very clear (your description confirms things that I’ve guessed at from their site) but it sounds like you get a lot for your 50 USD. They’re taking care of CloudFront, ELB/ALB, CodeCommit/CodePipeline, DynamoDB/RDS, ElasticSearch, SQS etc. for you. If you set it all up yourself you’d undoubtedly pay less to AWS per month, but then you’d have to operate it all yourself.

                        For devs it sounds great if you don’t want to manage all that yourself (or don’t have a team that does it for you at work). It really does remind me of Webflow, which does a similar thing for content sites (i.e. they do everything for you including visual design tool, CMS, form creation & submission handling etc.).

                  1. 7

                    That depends a lot on what you want to use it for and what your personal tastes are like. As people have said in other threads, CL is kitchen sink, and standardised a long time ago which means it is very stable: code written decades ago is going to work unmodified in CL today. There are several high-quality implementations around. On the flip side, it has many warts.

                    Racket is a single implementation-defined language. On the other hand, if you learn Scheme, most of it just carries over into Racket, and you can also choose from a bevy of implementations depending on your requirements. It’s a clean and elegant language, but that also means many things are missing. For those, you’ll have to rely on SRFIs, portable libraries or implementation-specific extensions.

                    1. 3

                      while the stability argument is probably true from a high level perspective, I’ve run into a few problems with libraries that don’t want to build on older CL installations, e.g. if using the old sbcl that comes with debian, quicklisp systems don’t always build. So in practice, you still have to migrate things forward.

                      1. 1

                        while the stability argument is probably true from a high level perspective, I’ve run into a few problems with libraries that don’t want to build on older CL installations

                        It’s possible to write unportable, nonstandard Common Lisp, but relatively little care is required to write it properly.

                        if using the old sbcl that comes with debian, quicklisp systems don’t always build.

                        That’s entirely because Quicklisp isn’t written properly. If you ever take a look at the code, you’ll notice it’s leagues more complicated than it has any need to be, as merely one issue with it. Of course, Quicklisp hosting doesn’t even bother testing with anything that isn’t SBCL as of the last time I checked.

                        So in practice, you still have to migrate things forward.

                        This is wrong. All of my libraries work properly and will continue to work properly. Don’t believe that merely because some libraries aren’t written well, that none or a significant amount of them are. I’m inclined to believe most of the libraries are written by competent programmers and according to the standard.

                        1. 1

                          This is wrong. All of my libraries work properly and will continue to work properly. Don’t believe that merely because some libraries aren’t written well, that none or a significant amount of them are. I’m inclined to believe most of the libraries are written by competent programmers and according to the standard.

                          The last library you shared (the alternative to uiop:quit) is most definitely not written in portable Common Lisp so as the /u/cms points out the implementations may change their may change their APIs and the code would need to be updated.

                          1. 1

                            Firstly, it should be understood that a library with the sole purpose of working over differences of implementations in this manner is different from my other libraries, which don’t. Secondly, if you look at the documentation, I note that the library will merely LOAD properly, but may not actually exit the implementation, which is something one may want to test against, as it’s a feature caveat. Thirdly, if any implementation thinks about changing the underlying function, such as SBCL has already done once, I’d rather complain about the stupid decision than change my program.

                            In any case, sure I could’ve explicitly mentioned that one library, but it disturbed the flow of the sentence and I figured these points were obvious enough, but I suppose not so.

                          2. 1

                            That’s entirely because Quicklisp isn’t written properly

                            It’s completely fair to say that things that do not build portably could be better written to do so. I would like to add that it is not quicklisp per se that I had seen problems, rather building systems within it. Off the top of my head, ironclad and perhaps cffi both exhibited problems on older sbcl. I haven’t checked, but I think that this would be the case if they were just build with asdf, so I do not wish to imply quicklisp introduced these problems. I think both of these libs are very tightly coupled to the host system libraries, and could be considered atypically lisp in that sense.

                            probably I should have better said in practice you may have to migrate things forwards

                          3. 1

                            if using the old sbcl that comes with debian

                            The problem is more likely due to the fact that you are using the version packaged by Debian instead of your SBCL being old. You should avoid all lisp software packaged by Linux distributions, they tend to give you nothing but trouble.

                            However it is true that not all Lisp code is portable, especially with the implementation-compatibility shims that are becoming more common. And while one is likely to encounter code that uses implementation specific extensions there tends to be a fallback for when the feature is not available. As a data point I’ve loaded software from before ASDF (that used MK:DEFSYSTEM) with little modifications.

                            1. 1

                              Yes, that could well be so. It doesn’t really change the point that it’s not as straightforward as just assuming you have a working lisp, everything you need will just be stable. I think we’re in agreement there. Also, I’m building standalone executables for 32 bit ARM, I’m not super-surprised that there’s system-specific bugs in things like math / crypto primitives. FWIW I would favour CL for building anything myself, but not because I think stable dependencies are just a moot point.

                              (I did actually manage to work quite fine on debian’s ancient sbcl for quite a while so it’s not useless)

                        1. 3

                          I think some of it is becaue image-based development does not have good collaborative tools

                          1. 5

                            That’s always been a bit dubious (Smalltak has had changesets since at least the late 80s), but it’s been truly false for a long time. Squeak had Monticello, VisualWorks had ENVY and StORE, and Pharo just uses Git straight-up these days. I’m not arguing images don’t have other issues with them, but collaboration isn’t one of them.

                            1. 2

                              completely fair point. I didn’t only mean source code control, I’m also thinking that the developer process, incrementally manipulating a running image isn’t very easily mapped onto distributed working, maybe never was?

                              e.g. are there workflows/tools where multiple developers push changes to a central image ? Because that’s kind of the mapping there - if I’m writing C, I am diffing text files, and compiling the changed ones into new objects, linking everything, running tests - this extends quite naturally to continous integration, and automation for collaborators.

                              When I’m working on an image style system, I’m updating a running thing typically, usually interactively testing as I go. Ideall collaboration flow for this kind of thing would be to pull small upstream changes directly into my image, switch branches without resetting the world, this kind of thing.

                              I don’t know very much about the detail of your counter-examples, but I did not mean to suggest it was impossible, so much as ungainly, which was my understanding.

                              1. 3

                                Sorry for responding so late; I know others won’t see this, but thought you deserved a response.

                                I’m also thinking that the developer process, incrementally manipulating a running image isn’t very easily mapped onto distributed working, maybe never was?

                                You do kind of have to decide if you’re gonna work in the classic Smalltalk mold, or if you’re going to work in a modern mold; that’s fair. It’s just that the modern mold is really common, to the point that relatively few people sculpt an app out of a Smalltalk image (which is closer to the original intent) than write Smalltalk code that really is the program.

                                are there workflows/tools where multiple developers push changes to a central image ?

                                This is in fact exactly how at least GNU Smalltalk and Pharo (which is to Smalltalk what Racket is to Scheme) do. E.g., this is Pharo’s Jenkins server, which works by just building off master constantly, just as any other project would do. The only difference is that, rather than diffing or thinking in terms of files, you think in terms of changes to classes and methods. Behind the scenes, this is converted into files using a tool called Iceberg.

                                The only place this system calls down is if you’re building constants directly in the image, rather than in code. E.g., if I were truly building a Smalltalk program in a traditional Smalltalk way, I might just read an image into a variable and then keep the variable around. That’s obviously not going to have a meaningful source representation; there might be a class variable called SendImage, but the contents it happens to have in my image won’t be serialized out. Instead, I’d have to have the discipline to store the source image alongside the code in the repository, and then have a class method called something like initializeImages that set SendImage to the contents of that image file. In practice, this isn’t that difficult to do, and tools like CI can easily catch when you mess up.

                                Whether this is working against or with the image system is debatable. I’ve used several image systems (Common Lisp and Factor being two big ones) that don’t suffer “the image problem”, but tools in the ilk of Smalltalk or Self are obviously different beasts.

                                1. 1

                                  Thanks for the reply! I wish I had more smalltalk experience. Maybe some day.

                            2. 2

                              Smalltalk does have Monticello and Metacello. I’ve heard good things about them.

                            1. 6

                              I own a number of thinkpads, also have a bench power supply than can source 5a @ 20v, so I can do some analysis next week by removing the battery and looking at the current consumption under various configurations and workloads.

                              The power management system on modern laptops should be able track power usage with a fairly fine granularity.

                              1. 3

                                yes, actual measurement would be much more helpful than my anecdata. Although, even if I’ve just enabled more accurate estimate reporting, I’ll take it.

                                1. 2

                                  I don’t have a thinkpad any more, but won’t most modern laptops’ battery management system give you a measurement of battery current draw when they’re disconnected from a charger? On my current Dell it’s at /sys/class/power_supply/BAT0/current_now. PowerTop shows this metric as well, I think.

                                  I would expect this could be as accurate as measuring the average draw with a bench supply, if not more accurate (the BMS needs a reasonably accurate measurement of battery discharge current for “gas gauge” state of charge estimation.)

                                  1. 2

                                    I’ll take a look the next time I boot up my x220, I had planned on removing the battery and only operate it off the bench supply so load wouldn’t be conflated with any power going directly to charging.

                                    1. 2

                                      Yeah, I got that - it’s a good idea, I just thought this option might also be useful to know about (has the similar-but-opposite problem that the battery’s internal current meter is not useful if external power is connected to the battery).

                                1. 3

                                  My newer linux systems use ip and ifconfig docker0 down doesn’t change anything. What’s the equivalent command with ip ?

                                  1. 2

                                    ip link set down docker0 i think

                                  1. 5

                                    I think there’s something else going on.

                                    I’ve had this same problem, used the same solution, and several extra watts moved to some other device or task. After doing this repeatedly, I’ve seen the screen or sometimes the Ethernet claim to use four watts. The power usage is still there, but moves.

                                    I’ve seen this on four Thinkpad models I own. Either powertop is confused or something is masquerading as another device or process.

                                    Maybe the Intel management engine is mining Bitcoin?

                                    1. 3

                                      heh. The accounting is definitely obscure, but the reported drain drop for me is consistent. Early days though.

                                    1. 2

                                      i don’t feel I have any understanding about setv variable scoping

                                      Although the author doesn’t say so explicitly, from an outsiders perspective, this seems to be hylangs biggest negative, it doesnt support let. It was removed from the language after several attempts to implement it correctly.

                                      1. 1

                                        Yes, that’s a succinct way of putting it. Indeed, when I am using a lisp, I usually am aware of dynamic / lexical scope to some degree, but like I say I am not really sure where hy is putting them. I’m sure it’s all documented and demonstrable of course.

                                      1. 6

                                        I decided to spend a year away from Twitter. I hope this will nudge me into more side projects and experiments with solo web publishing

                                        1. 4

                                          I found quitting twitter was pretty easy once I uninstalled the app from my phone. Desktop wise I still click on the occasional link but I no longer consume timelines, and haven’t posted in over a year.

                                          Good luck!

                                        1. 2

                                          This is perfect timing. I was just wondering about how to add webmention to my mostly static site.

                                          1. 2

                                            Glad to be of service <3

                                          1. 20

                                            The strangest thing about this whole story is finding an Emacs user who hasn’t rebound caps lock to ctrl.

                                            1. 7

                                              (author of the post here) I have tried caps as a ctrl, but I don’t like it, I think it’s almost as much of an emacs pinky trigger as ctrl on the outside! with my scheme I have a ctrl either side of the space bar, where I can key them easily with alternating thumbs, which works well for me.

                                              On this particular laptop, I think I am going to end up making caps lock another modifier (probably hyper) to use as a prefix command key. I usually have that as Ins, but that’s another key that’s disappeared on this generation.

                                              1. 2

                                                Well to be fair I have ctrl on the thumbs too on my primary keyboard, (https://atreus.technomancy.us/i/layout.svg) but I could never make it stick on hilariously-oversized-spacebar keyboards.

                                                1. 3

                                                  Your keyboard is awesome, and makes more ergonomic and practical sense, but my thing is all about working on a laptop, portably. I don’t like to use external peripherals, so I try and find the best compromise with whatever is built in. Pretty ridiculous, I know, but I kind of enjoy the constraints.

                                                  1. 1

                                                    Thanks! I typically use it with my laptop (sitting on top of the laptop with the internal keyboard disabled) but it’s definitely not for everyone.

                                              2. 1

                                                Caps Lock can be used for other things like switching between keyboard maps, for example: Romaji and Hiragana, QWERTY and DVORAK, etc.

                                                1. 1

                                                  Not really. I tried it for a while, but never found the convenience worth the hassle of setting it up.

                                                  And then it’s just one more thing making it look like I can’t type when I use a new computer.