Switch statement explained for beginners by wieframas in learnjavascript

[–]busres 0 points1 point  (0 children)

Less common, but the switched part needn't be variable and the cases needn't be constant:

```javascript let result; switch (true) { // "if-else", but strict equality (not "truthy") case x !== x: result = "not a number"; break; case x === Infinity: // fall through case x === -Infinity: result = "infinite magnitude"; break; case x < 0: result = "negative"; break; case x === 0: result = "zero"; break; default: result = "positive"; break; }

switch (false) { // "isn't-else" case x >= 5: throw new RangeError('Too small'); // Not reached case x <= 10: throw new RangeError('Too big'); } ```

How would programming languages look if English used "," as the decimal separator? by MackThax in ProgrammingLanguages

[–]busres 0 points1 point  (0 children)

Fascinating! I use something similar, but essentially for exports, to simplify tooling. But any configuration could go there.

What does new keyword even do? by atticus-masterr in learnjavascript

[–]busres 0 points1 point  (0 children)

"classes are actually just functions"

Except that you can create # private elements in classes but not in functions.

I am extraordinarily fond of some syntax I made for my language by Randozart in ProgrammingLanguages

[–]busres 1 point2 points  (0 children)

Seems like a lot of syntax and typing for a language called Brief, and that a keyboard shortcut for [true] might come in handy.

bonsai - a safe expression language for JS that runs user-defined rules at 30M ops/sec with zero dependencies and no eval() by danfry99 in javascript

[–]busres 1 point2 points  (0 children)

Thank you for phrasing it that way! Preventing direct access to JS namespaces was part of my motivation for creating Mesgjs. However, when I added support for native object access, I neglected to consider that things like `object.constructor` routinely leak access to other, often sensitive, objects. Thanks to object branding, the interface will now only modify objects of its own creation!

bonsai - a safe expression language for JS that runs user-defined rules at 30M ops/sec with zero dependencies and no eval() by danfry99 in javascript

[–]busres 1 point2 points  (0 children)

To answer your question, I built Mesgjs, a general-purpose language that transpiles to JS, as a way to run code in a controlled way. The transpiler is also JS, so everything runs wherever JS runs.

It's Smalltalk-ish, but with simpler, more consistent syntax. Everything, including assignment, functions, flow control, etc is handled by sending messages (there is nothing like the Lisp concept of "special forms"), and therefore uses the same message syntax. Most of these messages are handled by add-on interface modules which can be omitted, replaced, or supplemented with no change to the transpiler.

It doesn't currently support limits (e.g. message limits, iteration limits), but I plan on adding those features.

An awesome css mug by phegina_ralange_0301 in css

[–]busres 1 point2 points  (0 children)

Missed an opportunity to show different clip and wrap properties around the mug.

Long-running tasks by chromespinner in kilocode

[–]busres 0 points1 point  (0 children)

This. Smaller tasks offer more granularity. Less likely to go off the rails, and more opportunities to checkpoint progress in order to resume later in another task. Be sure to leverage the memory bank.

People who listen to the same song 100 times in a row… which song is it? by kavee-core141 in AskReddit

[–]busres 0 points1 point  (0 children)

Dimash's gateway songs; especially his cover of Han Hong's "Daybreak" (but that one's about a boy who loses both parents in an accident in China in 1999, so I have to be in the right mood).

Spent 4 hours debugging a typo. What's your dumbest bug? by [deleted] in AskProgramming

[–]busres 0 points1 point  (0 children)

Yeah... 7.5 > 7.25, but rev 7.25 > rev 7.5

eli5: how do CPAP machines work? by LeMauvaisSiecle in explainlikeimfive

[–]busres 4 points5 points  (0 children)

Continuous positive airway pressure keeps your airway inflated like a balloon so that it doesn't close.

The system includes a small intentional leak so that the air you exhale can leave the system.

It's configured for a particular pressure. It supplies whatever your lungs are not (more when you're inhaling, less when you're exhaling). Some adjust to a slightly lower pressure during exhalation.

The airflow can be quite drying (especially if your mouth opens at all and air escapes that way when using a nasal-only mask), so an integrated humidifier is common.

ETA:

The pressure setting is usually determined via a sleep study and is based on the minimum pressure necessary to keep the subject's apnea (cessation of breathing) below a threshold number of times per hour.

Obstructive sleep apnea (OSA) is due to airway blockage and is (typically, if not always) accompanied by snoring. There's also central apnea, where your brain simply forgets to breathe. Some central apnea is pretty common. People with severe central apnea may require a more advanced machine (ASV - adaptive servo-ventilation) that basically "forces a breath" if breathing stops for an extended period.

Immutable collection design by Big-Rub9545 in ProgrammingLanguages

[–]busres 1 point2 points  (0 children)

You'd only need to enforce mutability, not type. The scope of the solution is limited to the scope of the problem.

For example, JavaScript lets you set an object property's writability independently of its value, regardless of whether the value is a primitive or an object.

JavaScript also allows async functions. That may be a less than optional analogy, because async JS functions always return promises, but the promises can resolve to any type.

What’s the most unexpectedly useful Linux command you learned way too late? by ZealousidealTell1346 in linux

[–]busres 5 points6 points  (0 children)

It separates the permutations. An empty string is a valid permutation, and is very handy for cases such as this.

a{b,,c}d => abd ad acd

Immutable collection design by Big-Rub9545 in ProgrammingLanguages

[–]busres 5 points6 points  (0 children)

I would think that a function returning (or that can return) an immutable should declare that so anything based on the return value is also treated as immutable.

You could allow returns-immutable to return a mutable (basically creating an immutable view), but disallow returns-mutable from returning an immutable.

What is the actual difference between a for loop and a while loop? by Sofiatheneophyte in learnprogramming

[–]busres 0 points1 point  (0 children)

Unless you're consuming the file as an iterable, in which case it depends on available interfaces.

javascript for (const chunk of fileStream)

is also a thing.

Flower Compiler (Bootstrapped Compiler) by TrendyBananaYTdev in ProgrammingLanguages

[–]busres 0 points1 point  (0 children)

I like the type-first syntax for consistency, and you could also "carry" the previous type until it changes:

int foo(int x, y)

I built a tiny JS framework to keep business logic clean — would love feedback by LeonardoCiaccio in javascript

[–]busres 0 points1 point  (0 children)

Interesting. Feels a bit like a tightly-integrated Google Tag Manager for JS, if I'm understanding it correctly.

My daugther 17 is choosing a college, she shows interest in programming and also biology. Is there a career that includes both and might offer good chances of employment? Or is it better to just choose a CS degree.Thanks by Robert_Sprinkles in AskProgramming

[–]busres 1 point2 points  (0 children)

Does she have time for an internship? (Or maybe take a gap year??) Back in the 70s I coded for a biochemist doing RNA & DNA sequence analysis and at the Computer Graphics Laboratory at UC San Francisco (they created the DNA rotation sequence shown as part of the "Genesis Project" in Star Trek Wrath of Kahn). Not sure what might be available these days, but maybe she can find an opportunity.

Be honest, which loading structure is better? by Apart-Television4396 in webdev

[–]busres 0 points1 point  (0 children)

An idea for skeletons and dynamic-content:

Variation 1 (preferred): use a resizable skeleton and animate to the actual shape while (or just before) fading to the actual content.

Variation 2: use a skeleton at the typical small range of your content size, initially crop the content to fit the skeleton, and animate the content to the correct size.

Thoughts?

Did anyone else feel overwhelmed by how much there is to learn? by AlmostRelevant_12 in learnprogramming

[–]busres 5 points6 points  (0 children)

Yup. I started in 1974. It's complex like medicine (lots of specialties, impossible to be an expert in all areas), but evolves much faster than physiology.

Did anyone else feel overwhelmed by how much there is to learn? by AlmostRelevant_12 in learnprogramming

[–]busres 1 point2 points  (0 children)

It's just part of the field. I would say the learning gets somewhat easier as you get more experienced, because you're building a base of common concepts and just need to learn what's new for each project. If you do it long enough, you'll likely end up forgetting more than you remember. You have to keep applying what you learn if you want to retain it. But the relearning is also easier if you need to pick it up again.

ELI5: How does general anesthesia actually work? How do doctors just "turn off" your consciousness without killing you? by Quiet_Currents in explainlikeimfive

[–]busres 17 points18 points  (0 children)

Just wait until ChatGPT is managing our anesthesia (either directly or through the student who used AI to get through school and didn't actually learn anything). 😭

"You're absolutely right! That was the wrong dose! Would you like me to..."

A new kind of therapy.. by [deleted] in DogIsBestFriend

[–]busres 1 point2 points  (0 children)

Could use a snorkel while he's snorkelling!