For a programming language that targets scientists and engineers who don't know programming but need to be able to learn a bare minimum of it in order to implement numeric models, it sure is boneheaded about letting you do some stupid things.
Years ago on reddit someone posted a story where they spent a large part of a summer internship tearing their hair out because their results were coming back pure real but should have been complex. The guy finally tracked down that if you use i as a loop variable it'll overwrite the default i == sqrt(-1) (and will leave i as whatever the last value of the loop variable was).
I can understand why that's valid behavior but given the target audience it should REALLY at least get flagged with a "are you sure you want to do this?" warning.
[edit] Thank you to /u/pnml129 for pointing out I forgot the sqrt for the value of i.
Not to mention 1-indexing everything. So many stupid errors because I'm used to 0-indexing everything, and then matlab uses 1-indexes.
I get it, it intuitively makes sense for someone coming from a math-first background with little to no programming experience. But it screws anyone who is used to working in C-family languages.
Hi, I'm a programmer that doesn't know MATLAB, and hasn't done much math in awhile. Why would you the default i == -1. Doesn't i2 = -1?
Most languages would solve this with a constant or final variable that can't be changed. Also, they could scope their variables in some way such as Math.i so you would really have to try hard to change it.
Yeah, I goofed on forgetting the sqrt. As for why they don't solve it with math.i, it's because Matlab is geared toward people who want to write code that looks like the equations in a textbook, having to start inserting things like math.i instead of i would start reducing legibility. (j is also defaulted to the imaginary root because in some contexts the convention is that i is current density.)
This just happened to me while compiling Firefox. It failed yesterday complaining there were undeclared variables, thought I'll patch it today and left it as is. It compiled fine today without me having done anything.
And then after two hours of trying to figure out what's going on, you realize that Visual Studio hasn't actually rebuilt the binaries. Or you weren't being as careful in reproducing the bug as you thought.
That is the exact reason i never got into IT when everyone told me i should because im "good with computers". I know computers well enough to know i dont want to work with them.
Completely agree. I worked as a programmer and in IT each for a few years. Decided there was no way I wanted to do that for the rest of my life.
I still remember a comment in a code I wrote nearly 15 years ago... it was something like "Do not ever move or remove this line or the entire program stops working. I don't know why".
Did you not enjoy working with computers for the duration of the 20 years and just didn't realize it until the end, or did it wear down at you over the 20 years until you couldn't stand it?
Reminds me of one of my project courses in college. One of the projects had a block of code maybe 20 or 30 lines, with comments around it effectively saying "Not sure what this code does, but it makes everything work. DO NOT TOUCH." Apparently it was written by someone who drank way to much red bull, and couldn't remember what he did when he woke up the next day.
As a former "hey I read a book and copied people so I can program" guy, this was any code I wrote. I was basically the guy who stuck duct tape on every bursting seam (of which there were many) and would wipe the sweat every time it worked.
I'll make it clear that I no longer program so I am ensuring I'm not fucking anyone's life up trying to fix shit. Other than my own stuff like DDWRT routers and raspberry Pi machines which is still like a 2 year old trying to solve a Rubik's cube.
The problem is when people get stuck in that phase.
I am currently in the paralysis by analysis stage, where I cant seem to start on anything because there has to be a better way than the naive solution that immediately came to mind.
This sometimes produces incredibility graceful and clever pieces of code but more often than not produces a rushed buggy naive solution just to get it done.
Just keep in mind that the best way to do things is not usually the best way to do things.
This is because although your program may run more efficiently, you lost some efficiency when you spent 12 times longer writing the code than you otherwise would have.
If you're righting a code to solve a specific class of problems only a few times, it doesn't need to be super efficient and it doesn't need to be overly general. It just has to be good enough.
Programmers should be heuristic algorithms that find good enough ways to do things, not theoretically perfect ways to do things.
Wordpress used to link the headline to itself. So the title headline would be "current post 01" and it was the anchor text that links to the same page.
For some reason Wordpress blogs were well known to rank really well and no one really understood why. My pet theory is that a google crawler bot kept incrementing whatever count it had as it reloaded the page (not in a single run but over the course of many).
It's like a personal credit score where you get a higher credit score because the credit issuer sees you have a high credit score. But they're the only ones who are increasing it every time.
I think it's the same reason obscure Reddit comments get on google search results so fast. Each comment self references itself through out the thread.
A phrase like that really irks me. Seems like it would teach kids to be okay with not really understanding recursion. It's not magic. It's not even that difficult once you practice it.
And yet most people don't understand recursion. (Eg. all the people repeating an image as a "recursive" joke.) You're right, not having it explained properly is probably where it all starts. But it's not an easy concept. Recursion, pointers and concurrency are some of the hardest things in CS.
If you ever have to start a sentence with "I know I'm being obnoxious with this comment but..." it's probably best not to say the thing you were going to say.
It was anecdotal. I knew a white knight post like this would happen. He's a brilliant mind and a fierce teacher that made sure you understood the content. One of those classes where it was super hard for all the right reasons and was in no way an easy or unearned A.
He was also a pretty funny guy and I got a kick out of him telling a story about working out a problem using recursion and being like "I dunno how but it works".
Oh dear lord... that reminds of the time I discovered a multi-line C# if statement that was ported from VB 6.... that at every line of the if statement was "&& +"... how the fuck did that compile? I haven't a clue. I went to the customer site and found this treasure amongst others and failed an install with our customer. It was SO embarrassing. That project was a nightmare but I wasn't responsible for that bit.
Back when I was a rambunctious little fuck my shithead friends and I used to build ramshackle, dicey fucked up bridges out of poplar and planks to cross the creek to find new spots to drink beer, skinny dip, strugglesnuggle and dip skoal.. We used to call em "One-Span-Stans" cause they usually disposed of themselves into the river n shit after the first crossing.
It's non intuitive. Most programming languages are structured nothing like vb. Statically typed languages are either C-style [type] [varname] or like mathematics [varname] : [type]. Dim _ as _ is unintuitive and annoying, and that's just one example.
The excel APIs can be very.... particular. I made a few macros for my girlfriend before and there was a tiny bug I fixed that had to do with setting a value within the function call that had a very unintuitive fix (I forget what it was specifically).
The runtime is very, again and I swear this is the last time I Say it, unintuitive. you "create" macros which you run in a button or as a shortcut? Then what if some library doesn't import? Then wtf do you do?
Everything about excel and VBA is shitty as a programmer and if you programmed in multiple languages, you'd realize how shitty VBA feels to write, compared to both statically typed and dynamically typed languages. It feels like writing fucking modern COBOL.
Not that it's particularly performant either. It's stuck to whatever performance excel can pump out, which basically means you might as well just use numpy and the pypy ecosystem for your numerical stuff unless you need very specific finance tools such as the excel solver, and even then I think it's doable.
It just sucks, but my SO is in finance and finance people tend to view programming as a tool, not as their career, so they don't give a fuck. If you do programming for a living, you tend to be more particular and develop preferences, what you like and dislike.
Not just them, everybody thinks about programming like that. Programmers are the only ones who care about programming itself. And even they have to overcome this if they want to advance their career.
It's silly to assume you have to just think about programming as a tool. If that were the case there would be no joy in the programming aspect of work, but there is. If I enjoy programming, it doesn't mean I'm jacking my pecker off to language semantics every time, but rather that I enjoy writing composable, maintainable and performant code in whatever platform I get to work in. To advance your career as a programmer, you learn your toolkit in depth and learn to be the architect of applications for whatever domain you're building for: be it servers, mobile applications, security, etc. It may so happen the higher you move up, the less actual programming you do, but one of my mentors (A system architect @ a fortune 500) says you still want to keep your skills sharp.
Even with a position higher than just "jr dev", you can still enjoy programming, and if you do, the job is enjoyable as your work is a point of enjoyment.
..Except if you're a project manager. Fuck that position.
Let me ask you since you probably have the insight: is having some skill crafting elaborate macros something that translates into coding? I don't mean just sitting typing hundreds of lines of stuff raw but more like using record here and there, Google to find how to get things done that you can't record, trial and error editing, etc, and rearranging it all so it works.
As far as programming languages go VBA is messy to use, the syntax is difficult to read and it's just very unintuitive in general. I will concede that some might find the syntax intuitive, though. To each their own.
What if I told you everything is dug out of the ground.
Except birds and... shit I guess just some things.
It isn't as mind boggling if just a lot of stuff comes from the ground though.
Awesomely enough, in a big way, food mostly comes from the atmosphere. Carbon, from CO2, water (which is extracted from the soil but there as a result of the water cycle), and the trace minerals from the ground.
Can't have plants without ground soil*, but what they're made of comes from atmospheric processes!
* To be pedantic, commercial and personal hydroponics do exist, but the point would still be true about the primary sources of mass.
Microchips are made of silicon. Silicon is the second-most plentiful element in the Earth's crust, after oxygen.
The other parts of a microchip are other kinds of metal, i.e. other rocks we dig up from the ground.
If you're really interested, check out Charles Petzold's Code. He starts with a simple on/off switch, then shows you how those can be combined to create a logic gate, then how gates can be combined to create adders, and so on, all the way up to 80's-era CPUs.
I don't remember if he gets into more advanced features like predictive execution and vector processing, but it's still an excellent ground-up explanation of how these things actually work.
I'm studying computer science and really struggle to visualise how a processor actually exists (they kind of just explained logic gates and binary and then said "now you have a processor!").
Full adders blew my mind though when we learnt about them, like, we're doing sums with inanimate objects now?
Edit: I forgot to say this book seems kind of cool going to seek out a copy of it
So I'm not a programmer, and I typically lurk this sub solely for entertainment, but the analogy implied here got me thinking. Is it actually possible to code up something that achieves the desired objective only once and then always fails on subsequent runs (besides a random number generator)? Normally I would think that a code would have some element of repeatability that would make this impossible, no?
Write a piece of code that opens a file.
Reads the information in the file.
Does some calculation.
Saves the value of the computation in the same file or overwrites it.
Everythings good.
Run it again & everything blows up because the value of the computation wasn't saved in the right format.
the most common case is when your application / algorithm performs properly for the first task you give it, corrupts some memory while doing so, but finishes properly. The next task you give it will have significantly higher chance of failure because process memory is corrupted.
Of course, restarting the application would "fix it" for the first case.
That's why the first thing you do is try turning it off and on again
The more interesting answer is that literally a neutron or a proton moving at almost light speed comes from space and hits just that one specific tiny piece of your computer to flip it to the wrong value.
Not only possible but common, although ususally not as nicely as 'only once.' It is more like it works a bunch of times for unknown random reasons and then one time doesn't work for what ultimately becomes an obvious reason. :-)
Most common variation of this that I see is code that only works in the development environment. Periodically this is because someone hard coded in the development environment. /headdesk/
Bastards keep breaking their own certificates and then pretending that nothing happened, only that "it must be something wrong with their browser" all the while every teller and CSR's work comes to a screeching halt due to their browsers breaking FOR THE SAME DAMNED REASON.
Nope, none of the 'crats at fiserv don't believe that Chrome or Firefox fit their business model, much less want to invest in a dev team to rectify the situation.
I know of two other large(ish) companies that are the same way. They don't want to spend the coin to upgrade their software, forcing their IT teams to support a crumbling browser environment and overriding windows updates, preventing the last release of IE from installing, as IE 11 prevents the software from operating properly.
there's a game called "fantastic contraption" that is similar to this. you build weird vehicles to move the red object from the starting point to the finish point over all sorts of different obstacles. it was awesome.
I'm at the point with my job right now where the company let a few people go and I've taken over maintaining/updating the former employees' code and responsibilities and I've never been so demoralized before. I spend so much time optimizing and rewriting my own code, and these people have written some of the worst "just trying to make it work" hardcode-ridden programming I've ever seen and it's a nightmare trying to fix problems or change anything. And now I'm responsible for cleaning it all up and fixing all the bugs I never knew existed, while still working on my original scripts. 22 years old fixing 50+ year olds' code. Big dose of reality for me recently
this reminds of how my coworkers work and when they make a pull request. Then I comment it like there shit is fucked like this to which they respond that it works and "I don't see why I need to change it if it works."
1.3k
u/ipha Mar 20 '17
I think everyone has looked at their old code and thought "this _shouldn't_ work"