Yes, but I doubt you had write code to factor a quadratic equation because it's a solved problem and you have libs that will do it for you.
Imagine if you had been given an exercise of such a low level nature for every single topic you might touch in IT in the future. You would have had to code a function to do UTF8 decoding, JPEG rendering, TCP/IP error correction, font rasterization, ray tracing, PEG parsing, an USB driver, data diffing, model training, etc.
Also, you don't learn much about programming by creating a function to factor a quadratic equation. You seldom learn about types, side effects, algo complexity, or even about collections, iteration, branching, memory, debugging, etc.
You just learn to badly translate a very specific, narrow problem to the language you use.
> Yes, but I doubt you had write code to factor a quadratic equation because it's a solved problem and you have libs that will do it for you.
Actually, I have, because I've done a fair bit of embedded development and "toss this massive lib on" is not always a reasonable solution. Inferring the structure of plant in controls is often a polynomial factoring problem and it's not something that one tosses Singular or FLINT at on small hardware. But aside from that...
Factoring a quadratic by hand is something I expect a CS major to know how to do, because they might very well be doing algebraic manipulation to develop solutions to real world problems.
And someone who knows how to factor a quadratic by hand knows a number of formulaic (suboptimal) steps to perform it-- the exact kind of things that's easiest to translate to code before you have gotten into that mindset of explicit thinking.
So--- declare and manipulate variables to do the quadratic formula. OK, what if we want to confine ourselves to integers, what can we do? Can we loop and search solutions in some meaningful way like a human would?
It's a completely reasonable space to explore as an early programming problem for someone who's familiar with it.
I'm teaching a secondary student to program right now. In his core math class he's doing a lot of trig. In turn, we're doing a whole lot of exercises like "make these dots chase the other dot using atan2 and sin/cos".
> Actually, I have, because I've done a fair bit of embedded development
Can't argue there :)
> Factoring a quadratic by hand is something I expect a CS major to know how to do
Agreed, I'm more concern about teaching programming while asking such a task. Once you have solid foundation, you can have valuable insights by doing this exercise about float based maths, moving variables around, naming things, translating maths to code. But before that, I think it would hinder learning.
> And someone who knows how to factor a quadratic by hand knows a number of formulaic (suboptimal) steps to perform it-- the exact kind of things that's easiest to translate to code before you have gotten into that mindset of explicit thinking.
I disagree, because it takes 2 abstracts things and mix them together. It's a harsh first step. As a teacher, I get better results when I map coding to some concrete reality first. Later on, yes, you can mix.
> I'm teaching a secondary student to program right now. In his core math class he's doing a lot of trig. In turn, we're doing a whole lot of exercises like "make these dots chase the other dot using atan2 and sin/cos".
This is what I'm talking about. I have terrible results with those for anybody who doesn't really love maths. But creating small games and analysis the text of their favorite song are instant hits.
> This is what I'm talking about. I have terrible results with those for anybody who doesn't really love maths. But creating small games and analysis the text of their favorite song are instant hits.
He def doesn't love math. But he just finished the swarm thing and it's awesome.
I can't think of a single time I've needed to implement a linked list but knowing how to do it is still useful.
A quick search tells me that factoring quadratic equations is covered around grade 8 or 9. I'm guessing that the instructor assumed that everyone would have enough math to know how to do this or quickly refresh their memory so they could focus on the programming aspects and not the problem solving.
> Yes, but I doubt you had write code to factor a quadratic equation because it's a solved problem and you have libs that will do it for you.
It is not totally unreasonable to expect students in an intro to CS course to have some basic competency in algebra (university dependent). Giving them a problem in a domain they're already familiar with (or that where familiarity can be expected) lets them, in theory, focus on the algorithm/data structure side without having to also be taught the domain. Most of the exercises in a first CS course are solved with libraries (standard in some languages, or 3rd party in others). That doesn't mean it's not useful for developing the knowledge the course is aiming for.
Do you also think we shouldn't teach arithmetic and should only teach using calculators? (You may, actually, I know people who think that way.)
It's silly to make a universal statement like that, that's why I qualified it in my own. Whether or not math should be present in the assignments depends on the university and the background of its students. MIT's SICP could use calculus in its course because the students were either also in calculus or had already taken calculus when they got to the course. It was expected in their situation. Waterluvian, helpfully, clarified that the course they were talking about was for non-CS majors, so whether or not a basic algebra concept is appropriate would depend on the background of those non-CS majors. Are they all STEM majors or 99% STEM majors? Then you can assume they know algebra. Are there more humanities and arts majors? Then you can't, or shouldn't.
Besides, most intro to CS courses also include basic algorithm analysis (that may not be true for the non-major version of the course) which means the course will require the use of at least arithmetic, probably some algebra, and some basic calculus. So why not write programs that make use of math when you're already assuming the students are competent in basic math?
At least at the universities I was familiar with, a non-major first CS/programming course was generally targeted to STEM, but not CS, majors, so again familiarity with algebra would be a reasonable assumption (at GT, these were taken by the various engineering majors and used Matlab as the language of instruction, I think they previously offered Fortran).
Apple no, but law makers should require a licence to use those. This is not a tech that anybody should be able to use on a whim. Too much potential for abuses.
Not to mention the more there are, the bigger the cake for a nation that want to get control of the biggest offline spying network of all time. Somebody is going to crack that thing sooner or later. There will be an NSO for airtags.
There is no analytics. No ads. It just sits there, costing a few $ in hosting and doing it's thing. It's been running for years, just for the sake of it.
Even subtitle ads break your focus from the content, give bad incentives, unfair leverage, etc.
If ads were not here, most junk content in the internet would not exist because people would not pay 20 cents to see it. They pay to see it with ads, because it's a price they don't pay consciously, nor can they assess the consequences clearly.
I'm for the total and complete ban of ads. A content can't exist without it? Ask people to pay. If they don't, it means it didn't have real value. Let it die.
Worse, ads create a huge asymmetry of power in the favor of those who already have it. If you can throw a lot of money to ads, you can gain on the competition. Local small shops can't do that, so ads promotes way more coca cola than organic carrots.
Besides, the people publishing ads have an agenda that almost never align with the customers interest. People say there are ads they want to see, but the reality is that even those ads are not trying to make you more knowledgeable. They try to sell you something.
We have thousands of communities of experts in stuff, testers, consumers, bloggers, than can inform you. You don't need ads to know about something.
Society as a whole would be better without it.
Newspaper would be more objective, streets would be more beautiful, content would be more qualitative.
What about all those youtubers that couldn't exist without ads ?
99.99999% of them are crap. The youtube frontpage is a trash can.
A minority is good, but in the new adsless society, some of them would survive in a different way. Some would not, but the benefits are more important. Just like the US didn't keep thralls because "think of the economy".
Finally, the ads lead to websites to promote engagement at all cost, which fuels fake news, outrages, and tribalism on social medias. Ads are a burden to the human species.
And I say that... as a person who gets a lot of revenue from ads.
> Because let’s say it, everybody loves YAML. YAML is everywhere.
Nope. Nope, nope, nope.
I know a lot of people, including myself, who hates YAML with a passion.
First, they hate the format itself. It's very easy to introduce hard-to-find typos. Plus it has multiple versions, no way to tell which one you use, and depending of the parser that ends up eating the file, you may get weird results. It's way worse then just the "Norway problem". Typically, a bad monday morning could look like this:
It's a terrible, terrible format, that has too much variability, and way too many foot guns. Especially since typo-writing humans are supposed to edit those with their little clumsy hands.
But worse, YAML is mostly declarative, so no complex system can be described in it. Here we come to the second reason people may hate it: it's usually turned into an even worse DSL.
A very limited, badly designed, half documented and tested DSL with almost no tooling to write or debug the stuff. And each project has a different DSL, of course.
Take Ansible. If your playbook is more than 10 lines, it becomes a pain to write because you are basically using a programming language embedded into a markup language. You have no print() or breakpoint to dive into the mess it does. It has to reinvent ways to pass values around since there are no functions with references to parameters nor return values.
Mind you, this DSL calls Python under the hood, so they could have just exposed a declarative, idempotent Python API, but no. The entire world was required to recreate syntax highlighting, snippets, go-to-definition and so on for it. Which will never be good compared to the infra for real languages.
There are few reasons to decide to use YAML, apart from "this is the only rich format supported out of the box by this system that has comments". Which I totally get, but still.
If one can, use JSON, TOML or XML depending of the case, if we need only values.
And if we need more than values, let's either define a clean, restricted API with a full blown programming language, or, if the use case requires it, use CUELang (https://cuelang.org/).
CUELang is cleaner than YAML on all points, even for just data. It can provide a schema, can validate the data with that schema. It can embed logic. It can import and export from YAML and JSON so you stay compatible with the entire devops world.
And it's not Turing complete, but has useful constructs to repeat, branch and reuse code.
Maybe it's just me, but I read this as a joke. As much as we dislike YAML it's not really something we have the luxury of ignoring, especially in the infrastructure field.
To add on top this. I started by supporting other DSL such as Json. Then I realized it was adding burden on me in terms of documentation since people would ask me for different examples.
Use a jsonschema, and validate your configs. You can have similar problems with most other formats, and the best way to make sure your configs are going to do what you expect, is to validate them.
Like anything new, people had a hard time with it at the beginning.
I remember that I got a home assignment in an interview for a PHP job. The person evaluating my code said I should not have used UTF8, which causes "compatibility problems". At the time, I didn't know better, and I answered that no, it was explicitly created to solve compatibility problems, and that they just didn't understand how to deal with encoding properly.
Needing-less to say, I didn't get the job :)
Same with Python 2 code. So many people, when migrating to Python 3, suddenly though python 3 encoding management was broken, since it was raising so many UnicodeDecodingError.
Only much later people realize the huge number of programs that couldn't deal with non ASCII characters in file paths, html attributes or user names, because they just implicitly assume ASCII. "My code used to work fine", they said. But it worked fine on their machine, set to an english locale, tested only using ascii plain text files on their ascii named directories with their ascii last name.
That's in general a problem with dynamic languages with weak type systems. How "Your code runs without crashing" is really really != "your code works". How do people even manage production python! A bug could be lurking anywhere, undetected until it's actually run. Whereas in a compiled language with a strong type system, "your code compiles" is much closer to "your code is correct".
A type system can refuse to turn a `bytes` into a `utf8str` until it's been appropriately parsed.
(It doesn't even need to be a very good or strongly-enforced type system - Go makes it dangerously easy to convert between `[]byte` and `string` by other-type-system standards, and yet everything works pretty well. It's enough to hitch your thinking and make you realize you need another step.)
But this is not a matter of UTF-8 in the code, rather a matter of UTF-8 in the input or output. How does compiling a program ensure that it is robust on a range of inputs?
> How does compiling a program ensure that it is robust on a range of inputs?
This is quite literally the job of a type system: to impose a semantic interpretation on sequences of "raw bits" and let you specify legal (and only legal) operations in terms of the semantic interpretation rather than the bits.
There are a number of mitigations, so those kind of bugs are quite rare. In our large code base, about 98% of bugs we find are of the "we need to handle another case" variety. Pyflakes quickly finds typos which eliminates most of the rest.
This is the difference between people who embrace static typing and everyone else. A static type lover hears that 98% of your bugs are of the "we need to handle another case" variety and says, "well, that means you could have gotten rid of 98% of your bugs with better typing".
No, what I mean is that an additional key comes in (with the json or similar hash) and we now need to do some thing with it, or something different than we thought we were supposed to with it. Typing is not going to fix it because the full cases were unknown at development time.
How is it anything but the truth? The express purpose of static analysis, like a type system, is to catch bugs before running your code. That pretty clearly means that code that successfully compiles is closer to being correct than code that doesn't.
The parser assures your code is grammatically correct; the type system assures your code is semantically consistent, which is usually a much stronger guarantee, and by most practical measures will be closer - often much closer, and for total functions on total types, sometimes all the way - to "logically correct".
Python 3 encoding management was broken, because it tried to impose Unicode semantics on things that were actually byte streams. For anyone actually correctly handling encodings in Python 2 it was awful because suddenly the language runtime was hiding half the data you needed.
Nowadays, passing bytes to any os function returns bytes objects, not unicode. You'll get string if you pass string objects though, and they will be using utf8 surrogate escaping.
And nowadays, lots of people left the Python ecosystem completely because the 3 upgrade was broken and raising so many UnicodeDecodingErrors for so long. I'm glad it's fixed but it cost too much.
(And it had nothing to do with UTF-8. Actually, it's at least partially caused by the CPython developers avoiding UTF-8 for poor reasons.)
I'd argue that the people correctly handling encodings in Python 2 were vastly outnumbered by the people that weren't, but were getting away with it because the code didn't outright crash. Now in Python 3 it crashes, which is a pain in the short term but better in the long run.
I don't really think it's better - certainly it was not better until many years after release when they started admitting their big mistakes.
But even today, codepoint indexing is too easy and doesn't crash so lots of code is still subtly wrong. Memory usage of a string grows 3x if you add a single emoji. Most libraries are still agnostic about whether they take bytes or str so you still get exceptions thrown with no easy solution. (The growing popularity of type hints is fixing this, but that's not really related to Python 3.)
My Slack name at work is "Τĥιs ñåmè įß ą váĺîδ POSIX paτĥ". My hope is that it serves as an amusing reminder to consider things like spaces and non-ASCII characters.
One of my friends is these days a colleague, with an utterly ordinary English name but his identity management data is full of spurious accents to check APIs do the Right Thing™.
I was delighted recently to stumble on a history of modern women course HIST1158 named Liberté Egalité Beyoncé and I immediately thought two things: 1. Why are our Computer Science courses given unimaginative names? and 2. What a useful test input, I bet some of our systems don't work correctly for this input even though an acute accent is hardly a bleeding edge feature.
I haven't been able to interest any Computer Science professors in fun names for their courses, but I was able in my test environment to name a COMP series course "Untitled Course Name" with a description explaining that "It is a lovely day in the village and there are only two hard problems in Computer Science".
What's wrong with configurable? Too much opportunity to bikeshed?
I figured yapf was not "new" which is why black won.
Starting about 5-6 years ago there was a push in the Python community to replace solved problems with new ones in what appears to me as chasing the JavaScript community.
Instead of consolidating on existing tools that worked well but had some rough edges to smooth out, numerous projects came about to reinvent the wheel.
There is no "best format". It's a matter of opinion.
Taste is something we cannot objectively agree, and in fact, people will end up arguing even about this very statement, offering what they think is an objective measure.
Bikesheding, yes. Hours lost in meeting, chat debates, documentation to write, linting configuration. To be redone for each project, team, etc. Worse even in FOSS where everybody will come in a ticket and complain. And after while, you do it again, because the debate is never settle even in the same team or project.
There is not way to take a team of 3 people, choose a style, and make it so that they are all 100% happy with it.
Black took the road of gofmt: you can't chose. And it won because of that: it saved people time and energy.
People realize the cost was not worth the satisfaction, which you are unlikely to get anyway. Let's just move on to what matters, it's good enough. Pareto.
> Bikesheding, yes. Hours lost in meeting, chat debates, documentation to write, linting configuration
Sounds like a team problem, I've been on plenty of teams that use clang-format for c/c++ and there have never been any issues like this. Team players know that (almost all) arguing over formatting is not a good use of time. (edit: in case not clear, clang-format is extremely configurable. Set a default config and live with it forever, that's how those teams work.)
> Black took the road of gofmt: you can't chose. And it won because of that: it saved people time and energy.
I don't see how this follows, if a team was dysfunctional enough to be wasting hours and hours of time before, I can't imagine why that wouldn't continue. It just shifts from "let's change this flag in yapf" to "let's switch to yapf because black looks ugly and gives us no options".
Well if it helps your team out then that's great, I just wouldn't expect that to generalize well. But who knows, people are weird, maybe more would give up fighting about style because of a tool change than I expect.
Yes, and also too hard to set up. It's extremely dumb, but I'm much more likely to use something I can't configure, because if I can configure it, I'm going to want to, and it'll take forever to make all those choices.
Very interesting, especially the method order part. I dislike the order you chose, and yet, I would be tempted to use it on my projects anyway, because being congruent is so important to me.
This is about how I initially felt with black. I didn't like some of the things it did, but I was happy to have a standardized opinionated formatter so I went with it. Was definitely the right decision.
It’s an unfortunate compromise with code formatters. As someone who takes code formatting really serious and puts a lot of manual thought into code formatting, code formatters almost always make my code worse, in my opinion, or at best unchanged outside of small errors like double spaces, etc. But it creates a standard that it loves everyone’s code towards, which is good., and also obviously alleviates the chore of manually formatting.
I just wish sometimes they were more configurable. For example, the Elixir formatter is quite opinionated on things but is generally not configurable.
I often wish they were _less_ configurable. Even Black's handful of config options are too many... Each one is a chance to pick a whole new color for the bikeshed.
That makes sense, but it's a problem when the formatter makes a rather opinionated choice and doesn't allow one to configure it. The primary example I'm thinking of in Elixir is comments for pipelines.
For example, if I use the pipe example on Elixir's landing page and add comments to it (obviously a contrived example):
"Elixir" # string to get frequencies for
|> String.graphemes() # Get all graphemes (i.e., character units)
|> Enum.frequencies() # Get the number of occurrences of each grapheme
This gets formatted by the Elixir formatter to:
# string to get frequencies for
"Elixir"
# Get all graphemes (i.e., character units)
|> String.graphemes()
# Get the number of occurrences of each grapheme
|> Enum.frequencies()
This is a rather strongly opinionated format stance, and as far as I know, it's not configurable.
Imagine if you had been given an exercise of such a low level nature for every single topic you might touch in IT in the future. You would have had to code a function to do UTF8 decoding, JPEG rendering, TCP/IP error correction, font rasterization, ray tracing, PEG parsing, an USB driver, data diffing, model training, etc.
Also, you don't learn much about programming by creating a function to factor a quadratic equation. You seldom learn about types, side effects, algo complexity, or even about collections, iteration, branching, memory, debugging, etc.
You just learn to badly translate a very specific, narrow problem to the language you use.