Please dont take this seriously guys its just a dumb meme I haven’t written a single line of code in half of these languages
PHP -> Problem -> Replace the developer -> Solution.
Yes PHP was bad in 5.x, in 8.x if things go bad it’s just the developer who’s bad.
Someone do java hahaha
Problem -> AbstractProxyFactory<SolutionProvider<BaseProblem>>
C --> segfault --> new problem
Sry, the best I can do on mobile
🙉 it’s perfect!
It’s good
Python one is accurate. Most of our problems are solved by importing a library and writing the line, librarySolver.importedFunction.SolveMyProblem()
def main(): Print(‘thanks librarySolver’)
deleted by creator
Advent of code 2023 day 24 part 2. Z3 solver saved the day on that one.
Now I have PTSD every time I see an hailstorm.
So many solver solutions that day, either Z3 or Gauss-Jordan lol. I got a little obsessed about doing it without solvers or (god forbid) manually solving the system and eventually found a relatively simple way to find the intersection with just lines and planes:
- Translate all hailstones and their velocities to a reference frame in which one stone is stationary at 0,0,0 (origin).
- Take another arbitrary hailstone (A) and cross its (rereferenced) velocity and position vectors. This gives the normal vector of a plane containing the origin and the trajectory of A, both of which the thrown stone must intersect. So, the trajectory of the thrown stone lies in that plane somewhere.
- Take two more arbitrary hailstones B and C and find the points and times that they intersect the plane. The thrown stone must strike B and C at those points, so those points are coordinates on the line representing the thrown stone. The velocity of the thrown stone is calculated by dividing the displacement between the two points by the difference of the time points of the intersections.
- Use the velocity of the thrown stone and the time and position info the intersection of B or C to determine the position of the thrown stone at t = 0
- Translate that position and velocity back to the original reference frame.
It’s a suboptimal solution in that it uses 4 hailstones instead of the theoretical minimum of 3, but was a lot easier to wrap my head around. Incidentally, it is not too hard to adapt the above algorithm to not need C (i.e., to use only 3 hailstones) by using line intersections. Such a solution is not much more complicated than what I gave and still has a simple geometric interpretation, but I’ll leave that as an exercise for the reader :)
That is a great explanation of how you solved it, thanks! I should go back to it and conquer that puzzle properly without a solver. Or at least try.
missing the stage of C where it’s all incomprehensible bitfucking with comments like “this works, i do not know why it works, do not touch this”
I had this in CSS.
CSS isn’t as bad these days if you use Flexbox. Debugging floats and absolute/relative positioning was a nightmare in comparison.
On the other hand, it made webpages way less flexible.
Like yesterday (i have the browser not in fullscreen, for reasons) on my 16" fullhd notebook, webdev couldn’t imagine that someone would use his site in a ~1000px browser window, sidebars left and right, the main content about 20 characters wide squeezed inbetween. So i pressed f12 and deleted the sidebars. But the content was still 20em wide, because of flexbox.
C should show some overflow corruption of the problem graphic.
Real fast inverse square root algorithm hours
That one is not that complicated if you don’t think about the math. It’s basically just if we interpret the float as int and add a magic number we have a good estimation.
From what I remember at least, it’s been a little while since I implemented it.
IIRC also relying on how floating-point is basically scientific notation and the most-significant bits are the exponent.
And most importantly, relying on how a sloppy answer works just fine. The most important skill in game development is cheating.
The most important skill in game development is cheating.
Makes me feel better about my own game dev attempts lmao.
I was more thinking of the comments which are pretty much exactly what you said (“incomprehensible bit hacks” followed by “what the FUCK?”)
python is like that. someone waay smarter than you have already done this 10 years ago.
That’s true of basically all problems you deal with in programming. Unless you’re truly bleeding edge you’re working on a solved problem. It’ll be novel enough that you can’t out-of-the-box it but you can definitely use the tools and paths everyone else has put together.
Part of why I like kotlin as a language. It has so many tools built right in.
Idk I still like writing my own stuff purely pythonic when I can. Pythons syntax is the most “fun” and “natural” for me so I find it fun. Like doin a sudoku puzzle
I can’t get over the load-bearing whitespace.
Python whitespace is child’s play compared to yaml, which I have the displeasure of having to interact with on the regular
Yaml is honestly just a terrible terrible format that is neither good for humans nor good for machines.
I agree, whether or not it is good or bad, or readability concerns over nested braces. I fundamentally hate invisible delimiters. If it matters, make it visible. We have so many ascii characters, why not just borrow a few?
Indentation is visible, and much more so than braces.
Whitespace is not visible. It is the absence of something that is visible. Whitespace should be used for the comfort of the reader, not to determine scope. Are you proposing that a " " character is more visible than “{}”? The fact I must quote it to make what I am discussing even apparent speaks for itself. I’m not arguing that indentation is bad, far from it. In fact, the flexibility of using indentation purely for readability, makes code more readable.
This is the best way I’ve ever heard this described lol. You get used to it so fast, it’s really simple. Just indent your code like you’re supposed to 🤷🏻♂️
At least untill someone sneaks a tab in your spaced code, and you don’t know how to make your code editor show the difference, or it doesn’t support showing the difference.
Only soln is to write Python to read the bitstream and detect several white spaces followed by a tab or vice versa
That sound like a you problem really, detecting this is quite simple because any editor worth their salt will literally lint you an issue saying that tabs and spaces are mixed and the thing literally won’t be interpreted. If your editor can’t show white spaces, chances are you are one google question away from discovering that it actually can do that easily.
The more I code the less I mind the tool and the more I hate the ones using it wrong.
That will give you an extremely clear error when you run the code. Also, any IDE worth its salt should be able to fix that for you.
Even the error message you get from C++ for missing a semicolon is harder to understand and fix than this.
Does “like you’re supposed to” mean with tabs, or with spaces?
Because if someone else disagrees you are not going to have fun with their code.
PEP8 is clear about that.
Arguments on first line will not compile unless using precise alignment to function name
UGH!
Just-- yech!
Who TF codes with tabs? All the editors I know input spaces when pressing tab anyway.
I would not have fun in any language if someone inputted actual tabs and their tab size was different from mine. Chances are my linter would have told me, regardless of language used!
I have worked with OS projects in C and not even those were tab formatted.
Why the fuck does anyone use spaces when tabs mean everyone uses the same tab size as you? That’s what they’re for!
Yeah, okay. Tell that to every code editor’s defaults and every open source projects source code that I have read.
Encountering tab indented files is like encountering ANSI encoded files or /r/n newline’d files. It’s not how it should be done. Sorry.
Spaces are there to ensure that everyone sees the same, tabs have issues with internal indentation of function declaration and the sort. Yeah it indents like correctly, but then you do need spaces to indent vertically called functions correctly and it always ends up being a cluster fuck. Spaces are a standard for a reason.
Technically tabs are just spaces, so if you wanna play it safe use two spaces… probably. 😂
The problem is that Python programmers tend to think the job of readability is done just by indentation. This is wrong, and it shows in all sorts of readability issues. Many of which are in official docs.
Yeah pythonistas just group bad code into “non-pythonic”
It’s basically a credo if you aren’t familiar but Python is preeeetty explicit about formatting recommendations and whatnot so there’s really no excuse for poor Python practices/non-pythonic code
Then what the hell is this shit?
class argparse.ArgumentParser(prog=None, usage=None, description=None, epilog=None, parents=[], formatter_class=argparse.HelpFormatter, prefix_chars='-', fromfile_prefix_chars=None, argument_default=None, conflict_handler='error', add_help=True, allow_abbrev=True, exit_on_error=True)
This is a mess. None of this ascii vomit is useful or enlightening.
I got it from the argparse docs, which is a core module. But really, this is just the way Python docs are generated. Every class doc has an ascii vomit like this at the top, and my eyes hurt every time I see it.
I can’t see what you’re referring to
Same could be said about people that
don’tthink that indentation is not important for readability. Both are important, but if you really care about it defining an auto formatter and customising it for whatever consensus the team has is the only way to operate anyway.Same could be said about people that don’t think that indentation is not important for readability.
You should really avoid double negatives. What you actually said was "Same could be said about people that think that indentation is important for readability“, which makes no sense in the context of the rest of your post.
And I’m not saying this just to be a dick about grammar. I mean, obviously I am, but not just that. If your English isn’t readable, then I don’t trust your Python, either.
My bad, I deleted part of the comment to rewrite it and forgot part of the original. And as you probably guessed I meant for it to be a single negative.
Good thing this is a casual forum and not a work environment where I would reread my code with care haha. There’s a reason linters exist in code editors, it’s for people like me.
PHP: Problem ->
real_solution_for_real_this_time()
(real_solution_i_swear()
is unsafe and deprecated)PHP: Problem -> Laravel -> Solution
Ahem: Problem -> Laminas -> Solution
Eh, your statement is accurate for PHP4 and still relevant up to PHP5.2… We’re on PHP8.3 now and PHP8.0 is now out of security updates. I know it’s trend to hate on PHP but you’ve got to at least update your materials to var-vars… it’s like knocking node for having
substr()
andsubstring()
.trend to hate on PHP
2 years ago I tried to give a drupal project the ci/cd makeover (i.e. containers, test-deployments, reproducable builds, etc)… that’s when my hate was freshly renewed.
At this point I think it’s ok to let a dead language die and move on to something else (anything else, really)
mysql_real_escape_string
OK rust made me laugh
Yeah that one got me too. Rust has tons of c libs wrapped in safe rust.
I was mainly thinking about how so many Rust projects advertise very loudly that they’re written in Rust. Like, they would have
-rs
in the name, or “in Rust” as part of their one-line description. You rarely see this kind of enthusiasms for the the language in other languages. Not a bad thing by the way! And also there’s the “rewrite it in rust” meme, where people seem to take perfectly functional projects and port them to Rust (again, not a bad thing! Strength in diversity!)Check Julia then, .jl everywhere
Yeah, no python package has “py”, JavaScript “.js” or java “java”. None at all.
For Python I think there’s an actual point though: A lot of Python projects are user friendly wrappers for pre-compiled high-performance code. It makes sense to call something “py<SomeKnownLibrary>” to signal what the library is.
Well, it’s the same in rust, that’s why I agree more with the first interpretation.
There is an existing solution in C/C++, just make some binding and call it *.rs
Both python and rust use py and rs in the same way, to signal that it’s the python/rust version of that library.
Of course, there are exceptions, but that’s what usually happens.
I’d even say Rust is python but gone through
format!("{}-rs", problem)
It’s ironic that the illustration for JavaScript is probably the most realistic and best solution IRL. In the sense that a lot of what problem solving is (which is a big part of software engineer) is breaking a big problem into smaller problems. And you continue doing this until each problem is solvable in a short period of time.
JavaScript sucks though as a language.
JavaScript is a great language until you ask it to do more than toggle a div or send a request to the server
I thought it was a jab at all the NPM packages
Each npm package import will be future maintenance hell.
None of us is as dumb as all of us.
Typescript is amazing though.
Typescript is wasted on JS. Currently getting a JS certification while porting an action script 3 project to JS, ActionScript 3 was the better language.
I dunno we run and service serval large application running with React TS as the client with C# Entity Framework for the Server with SQL and wrapped up nicely in GraphQL.
I guess I have to defend this one. I personally think Typescript is the better language compared to typed Python or Ruby (two comparable languages based on how they are all used). Modern Javascript actually have a lot of nice language features, the only issue is the lack of types. Typescript doesn’t entirely solve the problem but it’s a decent attempt at it. A good typescript repo is decently readable, testable and performant enough for most use cases.
You’re completely correct. But what I meant by that graphic is “poor solutions leading to more problems”, not “breaking down problems into smaller ones”. It was inspired by a cube drone comic that made the same complaint, but I can’t find that particular comic now
for the ones missing the marvelous HTML, I gotchu bro:
<problem />
Obligatory “Hyper Text Markup Language is a markup language, not a programming language”
HTML+CSS Has been turing complete for some time now.
See, you added the CSS part, that was not part of the original comment.
that’s fair but, they are quite intertwined
Which is why it was just an obligatory comment from pedantic me. Just a light correction.
Add css, and the problem looks really pretty now
Problem
deleted by creator
The line between problem and solution for C should be 30 miles long.
It lacks a lot of malloc() 🤣
and not enough frees
…with 19 bugs 9 of which are exploitable.
And one bug that one person found once but is not reproducible
So the developers claim, but the users still encounter it, and the bug report stays open for 22 years … possibly more.
Why must you hurt me this way.
Perl:
Problem -> $ @ % <=> <> =()= => ; qw() ])} select(undef, undef, undef, 0.25) =~ tr/.?\w\sREg3xfr0mhe|l/foo/g; $|++ &homebrewedFunction(%$ref, $_ , @_ ) -> solution
Source: I mainly code in perl. I like it, but I’ll be the first to admit that it’s not a beautiful language.
I was about to make an entry for lisp here, but I don’t have enough parentheses to draw the path to the solution.
https://www.foo.be/docs/tpj/issues/vol4_4/tpj0404-0015.html
The Perl Poetry Contest - The Perl Journal, Winter 1999
#!/usr/bin/perl
#
# asylum.pl
# by Harlclose (youreyes);
bind (yourself, fast);while ($narcosis) {
exists $to($calm);
not calm;
}accept the, anesthesia;
seek the, $granted, $asylum’
and wait;stat ically;
unlink and listen (in, $complicity);
for (a, little) {
system (“sync hronicity”);
}Be honest: you just mashed your fist on the keyboard, didn’t you?
I personally never understood how anyone could find Perl appealing or even “good” to program in, probably because I could never understand wtf the code was meant to do
Over the top tone: “Pretty sure that won’t compile.
$EVAL_ERROR
modulo what you get from the filehandle called=
isn’t an lvalue that can be put through the Goatse operator that I’m aware of.”But seriously(?), I’m almost certain that’s not how that would be parsed.
=
isn’t a valid bareword, so Perl would choke on the spaceship operator not being a term… I think.After testing… It’s worse. I think it’s parsing
<>
as theglob
operator and=
as a filespec.For those who don’t know Perl:
Because of its appearance,
<=>
really is called the spaceship operator (at least, when it can be parsed as an operator and not whatever happened above).=()=
by comparison has unofficially been called Goatse. If you don’t know what Goatse is, find out at your own risk. If you do know, you can see why this particular pseudo-operator was given that name.And if you’re still reading,
=()=
is a pseudo-operator because it’s not actually parsed as part of the syntax. It’s literally an assignment operator=
followed by an empty list()
followed by another assignment operator=
, providing list context to the outside of the equals signs that wouldn’t otherwise be there.[Why are you still still reading?] Context is important in Perl. If a function returns a list of values (which is something Perl functions can do) and you try to store the result in a scalar variable, replacing the usual
=
with=()=
will store the number of elements returned rather than the last element of the list.It’s not supposed to be compilable. It’s more intended as a list of weird looking (but valid and useful) perl stuff.
As for the goatse operator, I’ve mostly used it for counting amount of regex matches.
Oh, and I forgot the diamond operator. Added.
Perl is write-only code. Larry Wall raised a monkey’s paw and asked for a language that works the way programmers want. So most Perl is the first thing someone tried, unfiltered by rigid syntax putting your thoughts in order, compiler warnings bringing side effects to mind, or even names forcing you to decide what a variable is. An uncommented Perl script is raw brain patterns displayed as ASCII.
Thank god it runs like crap. We’d be in so much trouble if it was fast. Optimized C isn’t exactly gorgeous, but any project that compiles proves someone looked at the code more than once.
I love the term “write-only code”, it’s perfect. I used to love Perl as it felt like it flowed straight from my brain into the keyboard. What a free and magical language.
So it turned out I had ADHD. Took meds, went back to C/++ with renewed appreciation, haven’t touched Perl since as it horrifies me to look at it. What a nightmare of dangling references and questionable typing. Any language that allows you to cast a string to a function and call it really needs to sit down and think about what it’s doing.
So it turned out I had ADHD.
Genuine LOL. Yeah… yeah, that’s Perl in a nutshell. Creating Perl: ‘why aren’t all languages like this?!’ Editing Perl: ‘oh.’
I believe
eval
would like a word with you…As I said,
C/++ with renewed appreciation
No such thing as eval in non-interpreted languages. Unless you’re crazy enough to invoke the compiler and exec() the result.
I used eval too in my Perl days which is why I specifically called it out. IMO any time you see eval used there should be another, more proper way to do it.
I was joking, and definitely agree with you. I don’t think I’ve used
eval
since my first programming course in uni.Edit: Except for monkey hacks for laughs of course.
I was hired twice to write Perl, both times switched my department to something else after a few years.
Perl is good for command line processing, and absolutely god awful read-only magic hacks. Nothing else.
Perl is fine, provided that you never have to touch someone elses code.
Or yours
No. My code is perfect. It’s all of the others who write bullshit.
- Every perl dev ever
deleted by creator
Java:
Problem -> NullPointerException.
Great! The problem is lost in the memory. That means it doesn’t exist anymore right? Right?
More like
Problem → new ProblemSolverFactory().createProblemSolver().solveProblem();
deleted by creator
Exactly. And configured by 5000 lines of brittle XML.
XML is great because while most config formats compromise on either being human-readable or machine-readable, XML solves this problem by being utterly incomprehensible to man and machine alike 😍
Is xml really that unreadable for machines? I enjoy xml as a format, because I can generally just convert it to an s-expression and easily manipulate it as a tree.
But you repeat yourself.
Needs more
Beans
andAbstractFactoryFactory
And then it throws a NullPointerException.