1. 10

    vim is like a curse, in that after you get comfortable with it you won’t be able to use a normal text editor anymore, lest your buffers fill with jjjjjjkkk. Fortunately there’s vim plugins for most IDEs and text editors you’ll need to use, but they all have their quirks and bugs and unsupported features, so you’ll end up using only the subset of vim that is supported by all the IDEs you’re using at the moment.

    1. 3

      I think in cases where regular expressions get as big as this you’d be better served by using parser combinators instead, which are much more composable and can return structured data instead of just match groups.

      1. 5

        I find Ruby to be a really comfy language to use, both because it’s the first one I learned and so I already know where all the knobs are, and because it’s so malleable that you can easily do silly things like this, and as Gary Bernhardt said this is actually a result of how awesome Ruby is.

        1. 4

          I’m sorry…

          Original work, public domain, with some help from this:

          require 'cgi'
          require 'shellwords'
          
          module StackOverflow
            def self.method_missing method, ex
              method = method =~ /=$/ ? method.to_s[0..-2] : method.to_s
              search = "[#{method.gsub('_', '-')}] #{ex.class}: #{ex.message}"
              escaped = CGI.escape(search)
              open_browser "https://stackoverflow.com/search?q=#{escaped}"
            end
          
            private
          
            def self.open_browser url
              if RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/
                system ['start', url].shelljoin
              elsif RbConfig::CONFIG['host_os'] =~ /darwin/
                system ['open', url].shelljoin
              elsif RbConfig::CONFIG['host_os'] =~ /linux|bsd/
                system ['xdg-open', url].shelljoin
              end
            end
          end
          
          begin
            raise "lol"
          rescue => StackOverflow.ruby
          end
          
          1. 4

            Oh you can do so much worse.

            1. 1

              Oh, good, a way to search for errors when that gem inevitably throws!

          1. 3

            I understand name (particularly with the graphical logo japanese text) is a reference to this anime and the light novel it is based on.

            1. 4

              Actually that’s just a spinoff, the original is Toaru Majutsu no Index.

              1. 2

                I am aware, but keep in mind railgun is the popular on. Toaru os seems to be named after both. This is explicit in the Misaka git repository readme.

                Index isn’t anywhere as popular. The repo author seems to favor railgun too, thus Misaka.

              2. -1

                Eh no. Toaru is just a normal Japanese word for “some”, hence “some OS”. It does not necessarily refer to any particular light novel or anime work.

                1. 4

                  Eh no

                  Eh yes.

                  Toaru is just a normal Japanese word for “some”

                  I have never claimed it’s not. But the “just” part is not accurate this time, because…

                  It does not necessarily refer to any particular light novel or anime work.

                  It doesn’t, but this OS does.

                  Refer to this image from toaru OS site and this logo from index II (same “toaru” in the other toaru works in that series).

                  Not to mention the naming of misaka, which is one of the main characters.

                  From that repository, I quote:

                  Misaka is named after the main character of A Certain Scientific Railgun (とある科学の超電磁砲) in the same way that ToaruOS itself is named after the series and its predecessor, A Certain Magical Index (とある魔術の禁書目録).

                  1. 3

                    That’s definitive indeed. Thanks for finding the reference.

                    1. 2

                      You’re welcome. Ultimately, I’ve known of this OS for a few years now, and it used to be more upfront regarding its connection to the Light Novel; It took a little more effort than expected to find a reference now.

              1. 4

                I’m pretty sure Photoshop does this too.

                There’s also a similar hidden slider in Firefox’s (maybe even Chrome’s) inspector: if you click on a number you can scale it up and down with the arrow up/down keys and ctrl/shift, with just up/down scaling to the first integer digit of the number, shift scaling the second and ctrl scaling the first fractional digit. I’ve just discovered it works on hex colors too.

                1. 2

                  Trying to survive the summer heat and the rest of this sprint.

                  1. 5

                    Not that great lately. I’ve been working remotely for about a year and a half, but when the pandemic started my previous client ended the contract to cut costs, and the new project is just… boring, especially in comparison to the old one. I have much less responsibility; I went from being basically a fully fledged employee of a somewhat big company, leading a couple projects with my team and being responsible for pretty much every aspect of them, to getting a bunch of tasks on jira and some XD mockups every two weeks. The dullness is really getting to me, and working from home only makes it worse.

                    As for hobbies, I just kept my old ones. I started playing a lot of videogames again and knocked a lot of stuff off my backlog, I’m watching at least two new movies every week, and I started reading novels and manga again.

                    I’m trying to develop a few new habits. Since getting a VR headset I’ve been playing Beat Saber for about an hour every day (which is a pretty good workout), and now I’m trying to cut out another half an hour after work to grind some Project Euler problems; I don’t feel much like working on my side projects lately and I want to change jobs and maybe try my luck at $BigCorp later this year, so brushing up on that kinda stuff is probably good.

                    I read this post about developing habits so I’m taking it slow. Maybe in a month or so I’ll tackle writing blog posts more regularly.

                    1. 10

                      I think he makes an excellent argument for making Zig the introductory language, simple clear semantics and the notation is made to describe allocations / directly interacting with the memory. It doesn’t have a repl though :/

                      Then at some later point make them write a lisp and teach them Haskell then you’ve got a solid base for learning anything. Rust is dismissed by having unique semantics / control structures. JS/TS by too much noise. Maybe ReasonML? Cleaner syntax than OCaml and has mutability…

                      Overall I think his point about academia ‘guiding’ industry by choice of language to teach outweighs everything else. For this reason alone I would pick either a C replacement (Zig) or a Java replacement (which to be fair Scala is, but that is also a leaky abstraction, I would go with Haskell personally).

                      1. 3

                        OCaml has relatively ‘easy’ mutability too: https://dev.realworldocaml.org/imperative-programming.html

                        1. 2

                          Zig or Nim would be great introductory languages. Nim in particular lets you start higher level (whereas afaik Zig makes you worry about more low-level details up front like allocators), but runs the full gamut of what a systems language can do, supporting pointers, manual memory allocation, and so on.

                          1. 8

                            Overall I think starting higher level to learn is better if you want a broad overview.

                            1. 4

                              Overall I think starting lower level to learn is better if you want a solid foundation.

                              1. 2

                                I do think it’s important to understand the concepts which underpin the abstractions. However, most programming is done in relatively high-level languages. In this situation, I believe it is much more important to write what you mean, rather than trying to express how you think the underlying hardware works.

                                If you teach someone the higher-level way to do something, then later show them how it might itself be implemented, they’ll probably keep using the high-level way, but will know how to drop down a level on the rare occasion that it becomes necessary. However, if you teach them the low level implementation first, that becomes “normal” for them, and they will keep reimplementing the wheel all over the place. When you show them the higher-level construct later, it could be viewed as an unnecessary curiosity, because the user has become set in their ways.

                                1. 1

                                  You’ve convinced me that every JavaScript class should start with a few weeks of APL

                                  1. 1

                                    It depends on how long you stay at each layer.

                              2. 1

                                Why not start with simplified machine code, then move to assembly, then C, etc.? That’s what my undergrad EE curriculum did in 2005-2009.

                                Given, I had already had 2 years of Java in highschool CS. But I didn’t learn much of value from that, except for how to do numeral base conversions.

                                1. 4

                                  I don’t think that assembler is required or helpful when teaching fundamental algorithms and data structures, and at worst it just makes it harder for less experienced students. Ideally, whatever language is used, the student should never have to think “I know how to do it, but I don’t know how to implement it” – not “implement it well”, but just have a working algorithm.

                                  1. 0

                                    If the student doesn’t know assembler, it will be hard to understand the C ABI which is so commonly used in FFI’s to make languages interoperable. So I think you’re contradicting yourself. If you don’t know assembler, you don’t know how to implement everything. And what about boot loaders that the student will be using every day?

                                    Also, history is important. If you know the story of how people used to work before “high-level” C programming became popular, it gives you perspective which is applicable when deciding whether an abstraction is a productivity boost or not. Tony Hoare gave an interesting talk with all sorts of explanations of why null-pointers became popular. You can only understand the world if you understand the history.

                                    1. 4

                                      I’m not saying they should never learn it – just not in introductory CS. I’ve thought people in such courses, and there are far too many who haven’t ever programmed at all or not enough to understand basic concepts such as recursion. Overwhelming them with FFI’s and ABI’s before they can even implement binary search on an array won’t be manageable, either for the students or the coordinators.

                                      1. 1

                                        I really think you should teach things from the fundamentals and move up.

                                        1. 1

                                          I agree, just my fundamentals are computational thinking familiarity with how computers “think”.

                                      2. 1

                                        If the student doesn’t know assembler, it will be hard to understand the C ABI which is so commonly used in FFI’s to make languages interoperable.

                                        In most languages, you can use the FFI, call C functions from another language and even call the other language’s functions from C, without encountering even a whiff of assembly.

                                        And what about boot loaders that the student will be using every day

                                        Unless they are studying some sort of embedded programming, why would they have anything to do with bootloaders? The subject of the original article is an introductory CS course that would be taken by a broad range of students. Writing your own bootloader probably belongs in a less general course, along with assembly.

                                  2. 1

                                    I always wonder when people say ReasonML has a “cleaner” syntax, what do they mean precisely?

                                    1. 1

                                      It means they like the syntax because it is more familiar, that’s it. For example, it means they prefer f(x, y) to f x y. This kind of superficial differences shouldn’t matter, but in practice, it matters A LOT, in fact having the familiar syntax may be one of the most important thing language needs to have to be popular.

                                      1. 2

                                        Well, that’s what I also think, but I’m curious to hear from people who say that. I haven’t seen Elm fans say “I love that language, if only it had f(x, y), not f x y for example.

                                      2. 0

                                        I guess ‘clean’ == no semicolons xD

                                        Thanks for calling it out.

                                        1. 1

                                          …but ReasonML has way more semicolons than OCaml?

                                          1. 1

                                            I guess I’m full of it, I haven’t programmed in either just read some code and been influenced by facebook marketing, retracted.

                                    1. 2

                                      I can see why just “upgrade your ruby version” would be considered rude, as others pointed out, because it’s just a command, and it would be better to frame it as a suggestion (“You should upgrade…”), but personally I find adding what the author calls small acknowledgment of their emotions (“Oh no! 😕”) a bit offensive. It sounds really fake and infantilising, if not condescending, and if I’m feeling frustrated because I’ve been banging my head against this problem for a while it would probably just make me more angry.

                                      Edit: this turned out to be more negative than I meant to. We should definitely be more kind when talking to each other online and I agree with the other suggestions in the post, I just take issue with that part.

                                      1. 1

                                        Are there significant differences between transducers and e.g. F#‘s sequences? I’ve seen people talk about how great these things are, but from what I can tell their selling point is that they’re more composable than some other implementations like Java’s streams and that they’re used pervasively in the language’s ecosystem, because unlike Java’s streams or F#’s sequences they were there from the start.

                                        1. 2

                                          I really want to like OCaml, but it has what I see as a fundamental misfeature, and I can’t tell whether I’m holding it wrong or whether there’s a good reason for it that I haven’t found yet. Specifically, partial application monomorphizes the result type.

                                          For example:

                                          # let id1 = fun a b -> b;;
                                          val id1 : 'a -> 'b -> 'b = <fun>
                                          # let id : 'a -> 'a = id1 "foo";;
                                          val id : '_a -> '_a = <fun>
                                          # id;;
                                          - : '_a -> '_a = <fun>
                                          # id 1;;
                                          - : int = 1
                                          # id;;
                                          - : int -> int = <fun>
                                          

                                          In my opinion, the type of id shouldn’t be monomorphized just because I happened to use it with a specific type. The fact that it does make it feel really awkward to define functions in a point-free style.

                                          What am I missing?

                                          1. 7

                                            Specifically, partial application monomorphizes the result type.

                                            Partial application only sometimes monomorphizes the result type. This ‘misfeature’ is caused by the relaxed value restriction, which is required to make the type system sound in the presence of mutation. You can read more about the value restriction in the OCaml manual.

                                            The fact that it does make it feel really awkward to define functions in a point-free style.

                                            In my experience, the value restriction is seldom an obstacle to most OCaml code. It’s not particularly common to mix point-free style pure code with code that uses side-effects and mutations—and when it happens, it’s probably a bad idea anyway, in terms of making it difficult to reason about the evaluation order. Plus, OCaml programmers don’t have as much of a desire to make their code point-free as, say, some Haskell folks seem to want to do.

                                            1. 4

                                              It’s not generally considered good practice to define functions in point-free style in OCaml, so there you have it.

                                              Whether this is due to the value restriction you mention or to the language’s general “aesthetics” is up for debate; personally I’ve never found the value restriction to be anything more than a mild annoyance.

                                            1. 1

                                              Boring stuff at work, hopefully next week I’ll start working on the Next.js part. I’m not very familiar with Next but I like what I’ve seen so far.

                                              Outside work: I got myself an Index VR Kit so (outside of a quick joke library I spent minutes 30 minutes on) I’ve spent the weekend playing HL Alyx and Beat Saber. Arms are quite sore from swinging the sabers around. I also bought Elite Dangerous (which can be played in VR) so I don’t think I’ll be doing much else in the evenings this week.

                                              1. 9

                                                Racket’s racket/gui is good, I’ve never used it for anything particularly big though and the controls it offers out of the box are kinda limiting. You’re gonna have to do a lot of stuff yourself. Still, the fact that you don’t have to do any complicated build processes to work with it and release your program, because it’s built into the standard library that you get when you download DrRacket, is reason enough to put me off using anything more powerful, like Qt.

                                                1. 4

                                                  Yeah, Racket is leaps and bounds more pleasant to use than any of the cross-platform alternatives I’m aware of. The simplicity of the build really spoils you; raco distribute and you’re done. Even works in wine.

                                                1. 3

                                                  Continuing to work on a UI for the Synapse torrent client. I’ve watched a talk about design systems and I really liked the layout components it showed, so I reimplemented some of them for building the UI.

                                                  1. 5

                                                    This looks like it’s trying to be a “complete” solution over TypeScript’s 80% solution. I like the better type inference and especially the typed errors, but the focus on correctness will probably impair its chances at being successful.

                                                    1. 2

                                                      Just finished with a contract at a client’s and I have to wait until the 20th for the next one to start, so I guess I’ll be sleeping a lot and finally living the quarantine life to the fullest for a week.

                                                      1. 1

                                                        I’m making a discord bot with a friend for a server we’re in, we syncplay movies together every week so this would help coordinate the times (timezones are hard!) and manage backlog and voting.

                                                        I’ve been trying to package it for Nix so I can run it on my rpi. It’s an uphill battle because the bot is in F# and the existing package for the dotnet SDK doesn’t currently support arm64, and I also had very little idea about how packaging works in Nix. I might write a blog post on this later.

                                                        1. 7

                                                          I think there’s two sides to vim: there’s vim itself, which has the virtue of being available on most platforms but is in many ways inferior to a modern IDE (even with loads of plugins), and then there’s the vim model of editing, which has been ported to many other editors and IDEs with plugins (though of course they’re emulation layers, and might not always work the way vim does). You don’t really need to use vim itself to get most of its benefits.

                                                          1. 4

                                                            One interesting difference between SML and OCaml is how functors handle abstract types.

                                                            Actually OCaml has generative functors too since 4.02.