20,173 Matching Annotations
  1. Feb 2021
    1. The alternative was to have multiple scripts or stylesheet links on one page, which would trigger multiple HTTP requests. Multiple requests mean multiple connection handshakes for each link “hey, I want some data”, “okay, I have the data”, “alright I heard that you have the data, give it to me” (SYN, ACK, SYNACK). Even once the connection is created there is a feature of TCP called TCP slow start that will throttle the speed of the data being sent at the beginning of a request to a slower speed than the end of the request. All of this means transferring one large request is faster than transferring the same data split up into several smaller requests.
    2. One way to alleviate this configuration fatigue is by making configuration consistent and composable. That’s what Sprocket’s new “manifest.js” seeks to do.
    3. Have you ever felt like a framework was getting in the way instead of helping you go faster? Maybe you’re stuck on some simple task that would be easy to do manually, but your framework is making you jump through configuration hoops. I end up getting lost in a sea of documentation (or no documentation), and the search for that one magical config key takes just a tad bit too long. It’s a productivity sink, and worse than the time delay it adds to my frustration throughout the day.
    4. When I hit ETOOMUCHFRUSTRATION, then I’m definitely fighting the framework.
    1. So, whenever you hear the medieval argument “Trailblazer is just a nasty DSL!”, forgive your opponent, you now know better. The entire framework is based on small, clean Ruby structures that can be executed programmatically.
    2. The entire framework is based on small, clean Ruby structures that can be executed programmatically.
    1. Yes, we could and should use Reform or Dry-validation here.
    2. a task in an activity can be any callable Ruby object
    3. Each step receives the return value of its predecessor. The return value decides about what next step is called.
    4. In order to invoke, or run
    5. the ability to “error out” when something goes wrong
    6. Six lines of code create an executable object that, when invoked, will run your code in the order as visible in our diagram, plus the ability to “error out” when something goes wrong.
    7. While you could program this little piece of logic and flow yourself using a bunch of Ruby methods along with a considerable amount of ifs and elses, and maybe elsif, if you’re feeling fancy, a Trailblazer activity provides you a simple API for creating such flow without having to write and maintain any control code. It is an abstraction.
    8. keeps a semantic
    9. A task is often called step.
    10. Your actual logic happens in tasks, the labeled boxes. A task may be any callable Ruby object, an instance method or even another activity.
    11. Every path or flow stops in a terminus event. Those are the filled circles. Often, we call them end event, too!
    12. The “error path” or “failure track” is the lower path going the the failure terminus.
    13. The “happy path” or “success track” is the straight path from start to the terminus named success.
    14. Modelling the flow of a program where chunks of code are executed in a certain order, with a successful “happy path” and an “error-out” path is called a Railway. It popped up in functional languages

      first sighting: railway-oriented programming

    1. allowing you to limit what invoked tasks or nested activies “see” and what they propagate to the caller context.
    2. Please note that the actual task doesn’t have to be a proc! Use a class, constant, object, as long as it exposes a #call method it will flow.
    3. You may use keyword arguments in your filters for type safety and better readable code.
    4. In both filters, you’re able to rename and coerce variables. This gives you a bit more control than the simpler DSL.
    5. Trailblazer will automatically create a new Context object around your custom input hash. You can write to that without interferring with the original context.
    6. a method that doesn’t have access to variables outside its scope
    7. As usual, you may provide your own code for dynamic filtering or renaming.
    8. Please note that I/O works for both “simple” tasks as well as nested activities.
    9. An array value such as [:params] passed to :input will result in the configured task only “seeing” the provided list of variables. All other values are not available, mimicking a whitelist.
    1. Redmond suggests nuking 'profanity, geopolitical, diversity' terms from browser source
    2. Allowlist, not whitelist. Blocklist, not blacklist. Goodbye, wtf. Microsoft scans Chromium code, lops off offensive words
    3. a proposal to cleanse the open-source code of "potentially offensive terms."
    4. a suggestion by Microsoft to “cleanup of potentially offensive terms in codebase” aims to rid the software blueprints of language such as whitelist (change to allowlist), blacklist (change to blocklist), “offensive terms using ‘wtf’ as protocol messages,” and other infelicities.
    5. In May, Microsoft announced AI features in Word that, among other features, will emit “advice on more concise and inclusive language such as ‘police officer’ instead of ‘policeman.’"
    1. Good intentions, but I doubt there's any relation of the origin of the terms blacklist/whitelist to race. There are many idioms and phrases in the English language that make use of colours without any racial backstories. I haven't met any black person (myself included) who was ever offended by the use of "blacklist".
    2. Regardless of origin, allow/deny are simply clearer terms that does not require tracing the history of black/white as representations of that meaning. We can simply use the meaning directly.
    3. Frankly, a good number find it patronising to make this kind of change.
    1. The forms of the final keyword vary:
    2. found that using only the Pascal-provided control structures, the correct solution was given by only 20% of the subjects, while no subject wrote incorrect code for this problem if allowed to write a return from the middle of a loop.
    3. What Böhm and Jacopini's article showed was that all programs could be goto-free.
    4. That such minimalism is possible does not mean that it is necessarily desirable
    5. computers theoretically need only one machine instruction (subtract one number from another and branch if the result is negative)
    1. Literally, everything in this example can go wrong. Here’s an incomplete list of all possible errors that might occur: Your network might be down, so request won’t happen at all The server might be down The server might be too busy and you will face a timeout The server might require an authentication API endpoint might not exist The user might not exist You might not have enough permissions to view it The server might fail with an internal error while processing your request The server might return an invalid or corrupted response The server might return invalid json, so the parsing will fail And the list goes on and on! There are so maybe potential problems with these three lines of code, that it is easier to say that it only accidentally works. And normally it fails with the exception.
    2. Return None. That’s evil too! You either will end up with if something is not None: on almost every line and global pollution of your logic by type-checking conditionals, or will suffer from TypeError every day. Not a pleasant choice.
    3. Let’s start with the same number dividing example, which returns 0 when the error happens. Maybe instead we can indicate that the result was not successful without any explicit numerical value?
    4. And we can specify types of wrapped values in a function return annotation, for example Result[float, ZeroDivisionError] returns either Success[float] or Failure[ZeroDivisionError].
    5. Now you can easily spot them! The rule is: if you see a Result it means that this function can throw an exception. And you even know its type in advance.
    6. we also wrap them in Failure to solve the second problem: spotting potential exceptions is hard
    7. exceptions are not exceptional, they represent expectable problems
    8. You can use container values, that wraps actual success or error value into a thin wrapper with utility methods to work with this value. That’s exactly why we have created @dry-python/returns project. So you can make your functions return something meaningful, typed, and safe.
    9. Write special-case classes. For example, you will have User base class with multiple error-subclasses like UserNotFound(User) and MissingUser(User). It might be used for some specific situations, like AnonymousUser in django, but it is not possible to wrap all your possible errors in special-case classes. It will require too much work from a developer. And over-complicate your domain model.
    10. Exceptions are not exceptional
    11. Exceptions are just like notorious goto statements that torn the fabric of our programs.
    12. Not all cases can be covered and easily restored. And sometimes when we will reuse this function for different use-cases we will find out that it requires different restore logic.
    13. But why do we return 0? Why not 1? Why not None? And while None in most cases is as bad (or even worse) than the exceptions, turns out we should heavily rely on business logic and use-cases of this function.
    14. And checked exceptions won’t be supported in the nearest future.
    15. Almost everything in python can fail with different types of exceptions: division, function calls, int, str, generators, iterables in for loops, attribute access, key access, even raise something() itself may fail. I am not even covering IO operations here. And checked exceptions won’t be supported in the nearest future.
    16. You still need to have a solid experience to spot these potential problems in a perfectly readable and typed code.
    17. So, despite your code is type safe it is not safe to be used.
    18. print will never be actually executed. Because 1 / 0 is an impossible operation and ZeroDivisionError will be raised.
    19. So, the sad conclusion is: all problems must be resolved individually depending on a specific usage context. There’s no silver bullet to resolve all ZeroDivisionErrors once and for all. And again, I am not even covering complex IO flows with retry policies and expotential timeouts.
    1. Or you can use Maybe container! It consists of Some and Nothing types, representing existing state and empty (instead of None) state respectively.
    2. So, what can we do to check for None in our programs? You can use builtin Optional type and write a lot of if some is not None: conditions. But, having null checks here and there makes your code unreadable.
    3. But now, you can do the same thing in functional style!
    4. Brings functional programming to Python land
    5. Provides a bunch of primitives to write declarative business logic
    6. Enforces better architecture
    7. Make your functions return something meaningful, typed, and safe!
    1. But so far everything brought up has just been about the relative advantages of checked exceptions, and that issue is closed. We won't do it.
    2. I'm not a fan of listing exceptions functions can throw, especially here in Python, where it's easier to ask forgiveness than permission.
    3. certainly I wouldn't want it to start telling me that I'm not catching these!
    4. I'm not a fan of checking exceptions either
    5. In my past life with Java, I've had mixed feelings about exception checking. It's saved me from some mistakes more than it's been annoying. Maybe the checking of exceptions could be controlled by some notion of "unchecked exceptions"?
    1. This PEP provides a standardized means to leverage existing tooling to package and distribute type information with minimal work and an ordering for type checkers to resolve modules and collect this information for type checking.
    1. include Dry::Monads::Do.for(:call)
    2. Railway Oriented Programming is a way to gracefully handle errors in your application
    3. This is how the same example would look like using raw monads:
    4. Do notation provides an alternative to bind, which also flattens the code.
    5. Better control over flow of our application: more ways to add branching
    6. bind applies unwrapped Success value to the block, which should return a Result object. No-op on Failure
    7. It allows us to reuse steps
    8. The Result object that we pass around keeps accumulating data and becomes enormous, so we have to use **rest in our function signatures
    9. The DSL has a weaker control over the program’s flow — we can’t have conditions unless we add a special step
    10. However, you don’t need to have an extensive knowledge of monads to use ROP in your code.
    11. Railway Oriented Programming comes from functional programming, so it is tightly related to the usual FP concepts like monads, composition, and many others.
    12. I want to emphasize that Result is just an alternative name for the Either monad.
    1. This is the perfect game when you are not wanting something with stakes or stress.
  2. www.metacritic.com www.metacritic.com
    1. Difficult enough to prove a worthy challenge, with an over-complexity that might have benefitted from a little self-restraint.

      overly complex = unnecessarily complicated

    1. It seems like such a beautiful little visual novel and while I wasn’t expecting a masterpiece of localisation based on its low price, I was expecting to be able to read it. But that just cannot be done. Developers from Japan, China, Taiwan, Indonesia, and every other emerging game development centre through Asia-Pacific, listen to me carefully: You can have the most beautiful aesthetics and a heartwarming concept for your game. If the localisation isn’t going to be good, though, do not bother with an English release, because it is going to get reviews like this one. Make “invest in proper translation” your big resolution for 2021. I do not want to play any other games like Lily in the Hollow - Resurrection ever again.
  3. www.metacritic.com www.metacritic.com
    1. The cars handling can be best explained as "its like steering a drunk sailor on a boat."
    1. This tedium would be unacceptable in an action game, but Windbound is a survival game. In survival games, death is supposed to mean something. Loss of progress represents the stakes; repetition is the barrier of entry.
    1. One can say this code is opaque compared to the previous example but keep in mind that in real code it often happens to call methods returning Maybe values.
    2. this implies direct work with nil-able values which may end up with errors.
    3. To get the final value you can use value_or which is a safe way to unwrap a nil-able value.
    4. In other words, once you've used Maybe you cannot hit nil with a missing method. This is remarkable because even &. doesn't save you from omitting || "No state" at the end of the computation. Basically, that's what they call "Type Safety".
    5. Writing code in this style is tedious and error-prone.
    6. Another solution is using the Safe Navigation Operator &. introduced in Ruby 2.3 which is a bit better because this is a language feature rather than an opinionated runtime environment pollution
    7. However, some people think these solutions are hacks and the problem reveals a missing abstraction.
    8. It's hard to say why people think so because you certainly don't need to know category theory for using them, just like you don't need it for, say, using functions.
    9. The gem was inspired by the Kleisli gem.
    10. Monads provide an elegant way of handling errors, exceptions and chaining functions so that the code is much more understandable and has all the error handling, without all the ifs and elses.
    1. Also, in non-functional programming, a function without arguments can be meaningful and not necessarily constant (due to side effects).
    2. The latter are important examples which usually also exist in "purely" functional programming languages.

      How can they exist and it still be considered pure??

      I guess that's not quite the same / as bad as saying something had side effects in a purely functional programming context, right?

    3. Often, such functions have in fact some hidden input which might be global variables, including the whole state of the system (time, free memory, …).
    1. Though rarer in computer science, one can use category theory directly, which defines a monad as a functor with two additional natural transformations. So to begin, a structure requires a higher-order function (or "functional") named map to qualify as a functor:

      rare in computer science using category theory directly in computer science What other areas of math can be used / are rare to use directly in computer science?

    2. For historical reasons, this map is instead called fmap in Haskell.
    3. can transform monadic values m a applying f to the unwrapped value a
    4. In fact, the Product comonad is just the dual of the Writer monad and effectively the same as the Reader monad (both discussed below)
    5. procedure to wrap values of any basic type within the monad (yielding a monadic value)
    6. A combinator, typically called bind (as in binding a variable) and represented with an infix operator >>=, that unwraps a monadic variable, then inserts it into a monadic function/expression, resulting in a new monadic value:(mx >>= f) : (M T, T → M U) → M U
    7. A type constructor M that builds up a monadic type M T
    8. A type converter, often called unit or return, that embeds an object x in the monad:.mw-parser-output .block-indent{padding-left:3em;padding-right:0;overflow:hidden}unit(x) : T → M T
    9. allows monads to simplify a wide range of problems
    10. another to compose functions that output monadic values (called monadic functions)
    11. Monads achieve this by providing their own data type (a particular type for each type of monad), which represents a specific form of computation
    12. In functional programming, a monad is an abstraction that allows structuring programs generically
    13. Supporting languages may use monads to abstract away boilerplate code needed by the program logic.
    14. Whatever language or default programming paradigm a developer uses, following the monad pattern brings many of the benefits of purely functional programming.
    15. By reifying a specific kind of computation, a monad not only encapsulates the tedious details of that computational pattern, but it does so in a declarative way, improving the code's clarity.
    16. category of functors (from values to computations)
    17. To emphasize how Just acts on the underlying value by wrapping it, it can be redefined as a function too, called eta for now
    18. With >>= available, add can now be redefined as something much more compact:
    19. these two functions >>= and eta were designed to simplify add, but they clearly do not depend on the specifics of add in any way, just the Maybe type
    20. While other monads will embody different logical processes, and some may have extra properties, all of them will have three similar components (directly or indirectly) that follow the basic outline of this example.
    21. Maybe T can be understood as a "wrapping" type, wrapping the type T into a new type with built-in exception handling
    22. This is done to avoid confusion by differentiating between cases where a variable carries a defined value and those where it does not.
    23. Undefined values or operations are one particular problem that robust software should prepare for and handle gracefully.
    24. Since monads make semantics explicit for a kind of computation, they can also be used to implement convenient language features.
    25. Research beginning in the late 1980s and early 1990s established that monads could bring seemingly disparate computer-science problems under a unified, functional model.
    26. handling potential undefined values (with the Maybe monad)
    1. It reminds us that rather than asking an object for data and acting on that data, we should instead tell an object what to do.
    1. It’s definitely better than littering our code with endless if-statements.
    2. As you can see, we end up with a lot of boilerplate if-statements. The code is more verbose. And it’s difficult to follow the main logic.
    3. In JavaScript, we have a built-in language feature for dealing with exceptions. We wrap problematic code in a try…catch statement. This lets us write the ‘happy path’ in the try section, and then deal with any exceptions in the catch section. And this is not a bad thing. It allows us to focus on the task at hand, without having to think about every possible error that might occur.
    4. And they are not the only way to handle errors.
    5. In this article, we’ll take a look at using the ‘Either monad’ as an alternative to try...catch.
    6. The .chain() method allows us to switch over to the left track if an error occurs. Note that the switches only go one way.
    7. This stuff is intoxicating once you get into it.
    8. Don’t worry if you get confused at first. Everyone does. I’ve listed some other references at the end that may help. But don’t give up.
    9. And a word of warning. If you haven’t come across things like monads before, they might seem really… different. Working with tools like these takes a mind shift. And that can be hard work to start with.
    1. Since an inverse is the contrapositive of the converse, inverse and converse are logically equivalent to each other.
    1. In logic and mathematics, statements p {\displaystyle p} and q {\displaystyle q} are said to be logically equivalent if they are provable from each other under a set of axioms,[1] or have the same truth value in every model.
    1. So every program starts in the IO monad. From here you can get any input you need, call into relatively "pure" code with the inputs, and then output the result in some way. The reverse does not work. You cannot call into IO code from pure code like you can call into a Maybe function from pure code.
    2. The IO monad wraps computations in the following context: "This computation can read information from or write information to the terminal, file system, operating system, and/or network". If you want to get user input, print a message to the user, read information from a file, or make a network call, you'll need to do so within the IO Monad. These are "side effects". We cannot perform them from "pure" Haskell code.
    3. A Monad wraps a value or a computation with a particular context. A monad must define both a means of wrapping normal values in the context, and a way of combining computations within the context.
    4. So if you don't yet understand functors or applicative functors, check out part 1 and part 2 of this series!
    1. It turns out that, given a set of constraints defining a particular problem, deriving an efficient algorithm to solve it is a very difficult problem in itself. This crucial step cannot yet be automated and still requires the insight of a human programmer.
    1. Purely functional programming may also be defined by forbidding state changes and mutable data.
    2. purely functional programming usually designates a programming paradigm—a style of building the structure and elements of computer programs—that treats all computation as the evaluation of mathematical functions.
    3. Purely functional data structures are persistent. Persistency is required for functional programming; without it, the same computation could return different results.
    1. In mathematics, a structure is a set endowed with some additional features on the set (e.g. an operation, relation, metric, or topology)
    1. This is a useful approach to error handling, but please don’t take it to extremes! See my post on “Against Railway-Oriented Programming”.