10,000 Matching Annotations
- Feb 2021
-
www.schneems.com www.schneems.com
-
As we know, naming is hard.
-
Another thing I don’t like is the name of the config file manifest.js. Internally Sprockets has the concept of a manifest already Sprockets::Manifest, but the two aren’t directly coupled. We also already have a “manifest” JSON file that gets generated in public/assets/ and has manifest in the name .Sprockets-manifest-140998229eec5a9a5802b31d0ef6ed25.json. I know one is a JS file and one is a JSON file, but it’s a bit confusing to talk about.
When I first heard of app/assets/config/manifest.js, I was a bit confused too, and assumed/wondered if it was related to the manifest it generates under
public
. -
The name makes me think of “The Legend of Zelda”. I imagine the original Sprockets author saying “It’s dangerous to go alone” and then handing me a javascript file.
-
The link name is not very helpful, it doesn’t explain what it does very well.
-
Instead of having this confusing maze of lambdas, regexes, and strings, we could, in theory, introduce a single entry point of configuration for Sprockets to use, and in that file declare all assets we wanted to compile. Well, that’s exactly what the manifest.js file is.
-
I guess in short you could say that I don’t like this interface very much.
-
Another big issue is that the config wasn’t really expressive enough. From the beginning Rails needed a way to say “only compile application.css and application.js, but compile ALL images” by default. With our previous interface, we’re limited to only strings.
-
That’s pretty gnarly. While the name of the constant LOOSE_APP_ASSETS gives me some idea of what it does, it still takes a second to wrap your mind around. If you were trying to figure out what assets are being precompiled and you did a puts config.assets.precompile that lambda object would be utterly baffling.
-
Another thing I don’t like: our asset behavior is decoupled from the assets. If you’re mucking around in your app/assets folder, then you have to first know that such a config exists, and then hunt it down in a totally different config folder. It would be nice if, while we’re working in asset land, we didn’t have to mentally jump around.
-
For example, what if your site has a customer interface and an “admin” interface? If the two have totally different designs and features, then it might be considerable overhead to ship the entirety of the admin interface to every customer on the regular site.
-
Before we get into what the manifest.js does, let’s look at what it is replacing.
-
When Sprockets was introduced, one of the opinions that it held strongly, is that assets such as CSS and JS should be bundled together and served in one file.
-
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.
-
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.
-
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.
-
When I hit ETOOMUCHFRUSTRATION, then I’m definitely fighting the framework.
Tags
- consistent
- not expressive enough
- library/framework getting in the way more than helping you
- TCP
- poor interface
- network performance
- overhead
- co-location: not co-located
- naming things is hard
- naming
- what is the alternative?
- I agree
- intention-revealing
- self-documenting
- bad combination/mixture/hybrid/frankenstein
- self-explanatory
- fast startup times
- inconsistent
- hard to understand
- hard to follow/read/understand
- illustrating problem before showing solution
- use meaningful names (programming)
- newer/better ways of doing things
- confusing
- the specific context is important
- composability
- programmer humor
- wasteful/inefficient use of resources
- code organization: co-location
- general solution
- fast load times (web pages)
- external assets: one larger file vs. multiple smaller files (HTTP requests)
- design goals
- configuration
- sprockets
- not:
- discoverability: not easily discoverable
- gamer humor
- messy
- what a mess
- strong opinions
Annotators
URL
-
-
stackoverflow.com stackoverflow.com
-
trailblazer.to trailblazer.to
-
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.
-
The entire framework is based on small, clean Ruby structures that can be executed programmatically.
-
-
trailblazer.to trailblazer.toTrailblazer14
-
Yes, we could and should use Reform or Dry-validation here.
-
a task in an activity can be any callable Ruby object
-
-
Each step receives the return value of its predecessor. The return value decides about what next step is called.
-
In order to invoke, or run
-
the ability to “error out” when something goes wrong
-
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.
-
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.
-
keeps a semantic
-
A task is often called step.
-
Your actual logic happens in tasks, the labeled boxes. A task may be any callable Ruby object, an instance method or even another activity.
-
Every path or flow stops in a terminus event. Those are the filled circles. Often, we call them end event, too!
-
The “error path” or “failure track” is the lower path going the the failure terminus.
-
The “happy path” or “success track” is the straight path from start to the terminus named success.
Tags
- good abstraction
- terminology
- good tutorial
- example: in order to keep example concise/focused, may not implement all best practices (illustrates one thing only)
- tutorial
- terminus/termini
- interchangeable
- programming: invoke/run/call
- abstractions
- reduce/minimize/simplify/remove control flow code
- example
- good explanation
- error path / failure track
- typo
- too many ifs: bad
- happy path / success track
- different names for the same/identical thing (synonyms)
- Trailblazer
- powerful
- ruby: callable object
- polymorphism
- control flow
- happy path
- error/exception handling
- what does this actually mean?
- railway-oriented programming
Annotators
URL
-
-
trailblazer.to trailblazer.toTrailblazer10
-
-
allowing you to limit what invoked tasks or nested activies “see” and what they propagate to the caller context.
-
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.
-
You may use keyword arguments in your filters for type safety and better readable code.
-
In both filters, you’re able to rename and coerce variables. This gives you a bit more control than the simpler DSL.
-
Trailblazer will automatically create a new Context object around your custom input hash. You can write to that without interferring with the original context.
-
a method that doesn’t have access to variables outside its scope
-
As usual, you may provide your own code for dynamic filtering or renaming.
-
Please note that I/O works for both “simple” tasks as well as nested activities.
-
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.
Tags
- flexibility
- annotation meta: may need new tag
- immutable data
- trailblazer-activity
- having enough control over something
- ruby: callable object
- polymorphism
- ruby: keyword arguments
- information hiding
- type safety
- applies/works in all cases/subcases (polymorphism) (no arbitrary limitation)
- DSL
- interchangeable
- allowlist
- scope (programming)
- readability
Annotators
URL
-
-
www.theregister.com www.theregister.com
-
-
Redmond suggests nuking 'profanity, geopolitical, diversity' terms from browser source
-
Allowlist, not whitelist. Blocklist, not blacklist. Goodbye, wtf. Microsoft scans Chromium code, lops off offensive words
-
a proposal to cleanse the open-source code of "potentially offensive terms."
-
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.
-
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.’"
-
-
github.com github.com
-
-
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".
-
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.
-
Frankly, a good number find it patronising to make this kind of change.
-
-
en.wikipedia.org en.wikipedia.org
-
in functional programming, the terms "conditional expression" or "conditional construct" are preferred, because these terms all have distinct meanings
-
-
-
en.wikipedia.org en.wikipedia.org
-
The forms of the final keyword vary:
-
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.
-
What Böhm and Jacopini's article showed was that all programs could be goto-free.
-
That such minimalism is possible does not mean that it is necessarily desirable
-
computers theoretically need only one machine instruction (subtract one number from another and branch if the result is negative)
-
-
sobolevn.me sobolevn.me
-
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.
-
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.
-
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?
-
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].
-
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.
-
we also wrap them in Failure to solve the second problem: spotting potential exceptions is hard
-
exceptions are not exceptional, they represent expectable problems
-
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.
-
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.
-
Exceptions are not exceptional
-
Exceptions are just like notorious goto statements that torn the fabric of our programs.
-
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.
-
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.
-
And checked exceptions won’t be supported in the nearest future.
-
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.
-
You still need to have a solid experience to spot these potential problems in a perfectly readable and typed code.
-
So, despite your code is type safe it is not safe to be used.
-
print will never be actually executed. Because 1 / 0 is an impossible operation and ZeroDivisionError will be raised.
-
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.
Tags
- programming: goto
- need to solve specific case/problems individually (there is no general solution)
- can't think of everything
- type annotations
- rule of thumb
- type safety
- difficult/hard problem
- depends on use case / application
- checked exceptions
- sad/unfortunate conclusion
- Python
- key point
- can't support everything / all cases
- traditional exception handling (try/catch; begin/rescue)
- too many ifs: bad
- the benefit of experience
- easy to see/notice
- error/exception handling: spotting potential exceptions is hard
- special cases
- safety (programming)
- easy to miss / not notice (attention)
- exceptions that are not exceptional
- anticipating what could go wrong / error/exception cases
- good example
- type checking: type annotations (unchecked; in comments)
- the specific context is important
- seemingly contradictory
- actually consider / think about how it _should_ (ideally) be
- why?
- monad: monadic value (wrapping a value within the monad)
- exceptions are expectable, not exceptional
- monad: Either
- type checking
- not:
- surprising
- analogy
- accidentally works
- error/exception handling
- railway-oriented programming
Annotators
URL
-
-
fsharpforfunandprofit.com fsharpforfunandprofit.com
-
(when used thoughtlessly)
-
-
-
github.com github.com
-
Or you can use Maybe container! It consists of Some and Nothing types, representing existing state and empty (instead of None) state respectively.
-
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.
-
But now, you can do the same thing in functional style!
-
Brings functional programming to Python land
-
Provides a bunch of primitives to write declarative business logic
-
Enforces better architecture
-
Make your functions return something meaningful, typed, and safe!
Tags
- too many ifs: bad
- monad: Maybe
- see content below
- functional programming
- programming: return values / result objects that communicate a more precise/complete representation of the outcome
- declarative
- unreadable
- primitives
- monad/container value/type
- software architecture
- make it hard to get wrong/incorrect
- type safety
- functional programming: in non-functional languages
- example
- business logic
Annotators
URL
-
-
drylabs.io drylabs.io
-
Our mission is to allow people to make money via educational efforts and to dedicate the rest of their time to creating great open source products.
What does this mean exactly? "Our mission is to allow people to make money via educational efforts"
-
-
-
en.wikipedia.org en.wikipedia.org
-
Examples
-
despite initially appearing to be an appropriate and effective response to a problem, has more bad consequences than good ones
-
there are two key elements to an anti-pattern that distinguish it from a bad habit, bad practice, or bad idea
-
-
-
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.
-
I'm not a fan of listing exceptions functions can throw, especially here in Python, where it's easier to ask forgiveness than permission.
-
certainly I wouldn't want it to start telling me that I'm not catching these!
-
I'm not a fan of checking exceptions either
-
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"?
Tags
- making decisive/definite/bold decisions
- don't constantly revisit a decision
- design decision
- Python: the Python way
- errors/warnings that may not apply to your case and be noisy/annoying to be warned about
- programming languages: requires verbosity / extra paperwork to explicitly list types/exceptions/...
- intentional/well-considered decisions
- checked exceptions
- easier to ask forgiveness than permission
- make bold decisions
- error/exception handling
Annotators
URL
-
-
www.python.org www.python.org
-
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.
Tags
Annotators
URL
-
-
www.morozov.is www.morozov.is
-
include Dry::Monads::Do.for(:call)
-
Railway Oriented Programming is a way to gracefully handle errors in your application
-
This is how the same example would look like using raw monads:
-
Do notation provides an alternative to bind, which also flattens the code.
-
Better control over flow of our application: more ways to add branching
-
bind applies unwrapped Success value to the block, which should return a Result object. No-op on Failure
-
It allows us to reuse steps
-
The Result object that we pass around keeps accumulating data and becomes enormous, so we have to use **rest in our function signatures
-
The DSL has a weaker control over the program’s flow — we can’t have conditions unless we add a special step
-
-
However, you don’t need to have an extensive knowledge of monads to use ROP in your code.
-
Railway Oriented Programming comes from functional programming, so it is tightly related to the usual FP concepts like monads, composition, and many others.
-
I want to emphasize that Result is just an alternative name for the Either monad.
Tags
- monad
- strong (extreme/great/high/intense degree/level/concentration/amount/quality of)
- functional programming
- it's just _
- Ruby
- disadvantages/drawbacks/cons
- advantages/merits/pros
- monad: unwrapping
- dry-monads (Ruby)
- ruby
- example
- monad: unwrapping: bind
- use case
- almost/nearly the same/identical / very similar / not very different
- different names for the same/identical thing (synonyms)
- conditional code
- origin story
- monad: Either
- control flow
- not:
- DSL
- don't need to fully understand in order to use
- alternative to:
- error/exception handling
- railway-oriented programming
- do notation
Annotators
URL
-
-
tineye.com tineye.com
-
-
boardgamegeek.com boardgamegeek.com
-
www.kickstarter.com www.kickstarter.com
-
let's be honest, print-and-play is A LOT of work (printing, cutting, laminating, sleeving, etc) and it is not everyone's cup of tea.
-
-
boardgamegeek.com boardgamegeek.comMaquis1
-
boardgamegeek.com boardgamegeek.comDEFCON 12
-
-
The game seems perfectly balanced, what is so rare for an assymétric game
-
-
www.kickstarter.com www.kickstarter.comDEFCON 12
-
The author will offer presentation/game sessions on Tabletopia, in French and English. In addition, the game will be freely available for players on Tabletopia as soon as the written rules are available.
-
-
-
www.metacritic.com www.metacritic.com
-
This is the perfect game when you are not wanting something with stakes or stress.
Tags
Annotators
URL
-
-
www.metacritic.com www.metacritic.comWarsaw1
-
Difficult enough to prove a worthy challenge, with an over-complexity that might have benefitted from a little self-restraint.
overly complex = unnecessarily complicated
-
-
www.metacritic.com www.metacritic.com
-
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.
-
-
www.metacritic.com www.metacritic.com#DRIVE1
-
The cars handling can be best explained as "its like steering a drunk sailor on a boat."
Tags
Annotators
URL
-
-
www.metacritic.com www.metacritic.com
-
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.
-
-
dry-rb.org dry-rb.org
-
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.
-
this implies direct work with nil-able values which may end up with errors.
-
To get the final value you can use value_or which is a safe way to unwrap a nil-able value.
-
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".
-
Writing code in this style is tedious and error-prone.
-
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
-
However, some people think these solutions are hacks and the problem reveals a missing abstraction.
-
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.
-
-
The gem was inspired by the Kleisli gem.
-
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.
Tags
- tell, don't ask
- monad: Maybe
- monad
- optional chaining/safe navigation operator
- monad: unwrapping
- nullable type/value
- type safety
- functions
- understandable
- dry-monads (Ruby)
- good point
- elegant solution
- good explanation
- opinionated
- make it impossible to get wrong/incorrect
- too many ifs: bad
- error-prone
- inspired by
- problems reveal a missing abstraction
- tedious
- reuse existing language constructs
- ruby library
- polluting the global scope/environment
- opaque
- remarkable
- don't modify objects you don’t own (monkey patching)
- don't need to fully understand in order to use
- chaining
- error/exception handling
- programming languages: features
- category theory
Annotators
URL
-
-
en.wikipedia.org en.wikipedia.org
-
built using nullary type constructors
first sighting nullary 
-
-
en.wikipedia.org en.wikipedia.org
-
-
Also, in non-functional programming, a function without arguments can be meaningful and not necessarily constant (due to side effects).
-
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?
-
Often, such functions have in fact some hidden input which might be global variables, including the whole state of the system (time, free memory, …).
-
-
en.wikipedia.org en.wikipedia.org
-
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?
-
For historical reasons, this map is instead called fmap in Haskell.
-
can transform monadic values m a applying f to the unwrapped value a
-
In fact, the Product comonad is just the dual of the Writer monad and effectively the same as the Reader monad (both discussed below)
-
procedure to wrap values of any basic type within the monad (yielding a monadic value)
-
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
-
A type constructor M that builds up a monadic type M T
-
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
-
allows monads to simplify a wide range of problems
-
another to compose functions that output monadic values (called monadic functions)
-
Monads achieve this by providing their own data type (a particular type for each type of monad), which represents a specific form of computation
-
In functional programming, a monad is an abstraction that allows structuring programs generically
-
Supporting languages may use monads to abstract away boilerplate code needed by the program logic.
-
Whatever language or default programming paradigm a developer uses, following the monad pattern brings many of the benefits of purely functional programming.
-
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.
-
category of functors (from values to computations)
-
To emphasize how Just acts on the underlying value by wrapping it, it can be redefined as a function too, called eta for now
-
With >>= available, add can now be redefined as something much more compact:
-
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
-
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.
-
Maybe T can be understood as a "wrapping" type, wrapping the type T into a new type with built-in exception handling
-
This is done to avoid confusion by differentiating between cases where a variable carries a defined value and those where it does not.
-
Undefined values or operations are one particular problem that robust software should prepare for and handle gracefully.
Tags
- _any_
- advantages/merits/pros
- monad: wrapping value (nomadic value)
- monad: unwrapping
- monad: data type
- generic programming
- functor
- use case
- annotation meta: may need new tag
- wrapping type
- declarative
- robust
- generalization
- reduce the amount of boilerplate/duplication
- representing a kind of computation (monad)
- reifying
- decoupled
- monad
- defining in terms of _
- dual (math)
- code/program structure
- functional programming
- encapsulation
- monad: Maybe
- monad: monadic functions (composition)
- clarity
- concise
- programming paradigm
- values (programming)
- abstractions
- simplify
- due to historical reasons
- differentiating
- monad: monadic value (wrapping a value within the monad)
- distinction
- higher-order function
- error/exception handling
- category theory
Annotators
URL
-
-
en.wikipedia.org en.wikipedia.org
-
The exception can be avoided by using ? operator on the nullable value instead:
-
The @ ? annotation can be used to denote a nullable value.
-
-
-
en.wikipedia.org en.wikipedia.org
Tags
Annotators
URL
-
-
www.martinfowler.com www.martinfowler.com
-
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.
-
-
jrsinclair.com jrsinclair.com
-
-
It’s definitely better than littering our code with endless if-statements.
-
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.
-
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.
-
And they are not the only way to handle errors.
-
In this article, we’ll take a look at using the ‘Either monad’ as an alternative to try...catch.
-
The .chain() method allows us to switch over to the left track if an error occurs. Note that the switches only go one way.
-
This stuff is intoxicating once you get into it.
-
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.
-
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.
Tags
- hard to follow/read/understand
- monad
- fun
- functional programming
- excellent technical writing
- replacement for:
- verbose / noisy / too much boilerplate
- JavaScript
- elegant solution
- different way of thinking about something
- sad path
- traditional exception handling (try/catch; begin/rescue)
- too many ifs: bad
- good illustration (visual)
- different way of solving/implementing something
- annotation meta: may need new tag
- encouragement
- you're not alone / it happens to/is like that for everyone
- monad: Either
- happy path
- error/exception handling
- railway-oriented programming
Annotators
URL
-
-
functionalprogramming.medium.com functionalprogramming.medium.com
-
polymorphic method inside shape class, its possible to discriminate them. without if’s.
-
-
-
en.wikipedia.org en.wikipedia.org
-
Since an inverse is the contrapositive of the converse, inverse and converse are logically equivalent to each other.
-
-
en.wikipedia.org en.wikipedia.org
-
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.
-
-
mmhaskell.com mmhaskell.com
-
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.
-
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.
-
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.
-
So if you don't yet understand functors or applicative functors, check out part 1 and part 2 of this series!
-
-
-
en.wikipedia.org en.wikipedia.org
-
Each of the programming language generations aims to provide a higher level of abstraction of the internal computer hardware details, making the language more programmer-friendly, powerful, and versatile.
-
-
en.wikipedia.org en.wikipedia.org
-
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.
-
-
en.wikipedia.org en.wikipedia.org
-
Purely functional programming may also be defined by forbidding state changes and mutable data.
-
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.
-
Purely functional data structures are persistent. Persistency is required for functional programming; without it, the same computation could return different results.
-
-
en.wikipedia.org en.wikipedia.org
-
Most C++ template idioms will carry over to D without alteration, but D adds some additional functionality
-
it is inconvenient to write specific implementations for each datatype contained, especially if the code for each datatype is virtually identical. For example, in C++, this duplication of code can be circumvented by defining a class template
-
-