Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Search - "what ifs"
-
Why is the ternary operator such a hated thing? I constantly hear people saying it's less readable, confusing, etc.
I think it's a beautiful, useful, and important operator and I use it constantly wherever readability won't be much affected.
How can you justify a repetitive if/else structure over a ternary, given that you're sure you're not going to put anything else in the ifs?
Whatever happened to DRY?
Whatever happened to KISS?
If those guidelines are what you code by, what's the excuse not to use it?
Because you can't read it as well? Familiarity breeds comprehension and legibility, my dudes.15 -
Worst:
One fine Friday night in early '97 while drinking with my buddies I got a page from work. Called the office to understand what the problem is.
*shit I can't fix this over the phone, and buddy here doesn't have a PC so I can't dial-in via PCAnywhere*
Told told the users "Ok I'll be there in an hour and a half. Stop all the running jobs and start the backup"
*figures I still have 1hr to spare so continues to down fair amounts of O-be-joyful with buddies then hailed a cab to office*
I arrived in office 1.5hrs later (2am) exactly as I predicted and went straight to work. Initial checks confirmed my suspicion of the issue so I wrote the appropriate SQL to get started:
'drop table foobar'
***The specified table (foobar) is not in the database***
I looked at foobar and figured out immediately why I got the error, then corrected the SQL and ran again:
'drop database foobar'
***Database dropped***
*What the FUCK!!! You fucking drunk!!! What did you fucking do? What if I disappear to another country, work as a waiter or something*
After a few moments of panic and a good deal of 'What ifs' I calmed down, looked to the users and made up some bullshit "Some of the indexes are corrupted, we need to restore from the backup"
Best:
I wrote most of my '94 midterm project during weekends where me and my buddies were drunk
https://devrant.com/rants/783197/...2 -
Is it just me who sees this? JS development in a somewhat more complex setting (like vue-storefront) is just a horrible mess.
I have 10+ experience in java, c# and python, and I've never needed more than a a few hours to get into a new codebase, understanding the overall system, being able to guess where to fix a given problem.
But with JS (and also TS for that matter) I'm at my limits. Most of the files look like they don't do anything. There seems to be no structure, both from a file system point of view, nor from a code point of view.
It start with little things like 300 char long lines including various lambdas, closures and ifs with useless variables names, over overly generic and minified method/function names to inconsistent naming of files, classes and basically everything else.
I used to just set a breakpoint somewhere in my code (or in a compiled dependency) wait this it is being hit and go back and forth to learn how the system state changes.
This seems to be highly limited in JS. I didn't find the one way to just being able to debug, everything that is. There are weird things like transpilers, compiler, minifiers, bablers and what not else. There is an error? Go f... yourself ...
And what do I find as the number one tipp all across the internet? Console.log?? are you kidding me, sure just tell me, your kidding me right?
If I would have to describe the JS world in one word, I would use "inconsistency". It's all just a pain in the ass.
I remember when I switcher from VisualStudio/C# to Eclipse/Java I felt like traveling back in time for about 10 years. Everyting seemd so ... old-schoolish, buggy, weird.
When I now switch from java to JS it makes me feel the same way. It's all so highly unproductive, inconsistent, undeterministic, cobbled together.
For one inconveinience the JS communinity seems to like to build huge shitloads of stuff around it, instead of fixing the obvious. And noone seems to see that.
It's like they are all blinded somehow. Currently I'm also trying to implement a small react app based on react-admin. The simplest things to develop and debug are a nightmare. There is so much boilerplate that to write that most people in the internet just keep copying stuff, without even trying to understand what it actually does.
I've always been a guy that tries to understand what the fuck this code actuall does. And for most of the parts I just thing, that the stuff there is useless or could be done in a way more readable way. But instead, all the devs out there just seem to chose the "copy and fix somehow-ish" way.
I'm all in for component-izing stuff. I like encapsulation, I'm a OOP guy by heart. But what react and similar frameworks do is just insane. It's just not right (for some part).
Especially when you have to remember so much stuff that is just mechanics/boilerplate without having any actual "business logical function".
People always say java is so verbose. I don't think it is, there is so few syntax that it almost reads like a prose story. When I look at JS and TS instead, I'm overwhelmed by all the syntax, almost wondering every second line, what the actual fuck this could mean. The boilerplate/logic ration seems way to off ..
So it really makes me wonder, if all you JS devs out there are just so used to that stuff, that you cannot imagine how it could be done better? I still remember my C# days, but I admin that I just got used to java. So I can somehow understand that all. But JS is just another few levels less deeper.
But maybe I'm just lazy and too old ...4 -
TL;DR you suck, I suck and everybody sucks, deal with it....
------------------------------------
Let me let off some steam, since I've had enough of people hating on languages "just because"
Every language has it's drawbacks and quirks, BUT they have their strengths also. Saying "I hate {language}" is just you being and ignorant prick and probably your head is so far up your ass that you look like an ass hat. With that being said, every language is either good or bad depending on the developer writing in it. Let's give you an example:
If I ware to give you a brick and ask you to put a nail in a plank, can you do it? Yes, it will be easier if you do it with a hammer, but you have a brick, so hammer is out of the question. If you hit your thumb while doing it... well... sorry, but it is not the bricks fault - it is YOU!
JavaScript, yes it has a whole lot of problems, but it works, you can do a ton of stuff and does a good job at that, it is evolving through node and typescript (and others, just a personal pref), BUT if you used js when you ware debugging that jquery (1.0) plugin written in the free time of a 13 yo, who copy pasted a bunch from SO, well, it is not js' problem - deal with it. Same goes for PHP, i've been there where you had a single `index.php` with bazillion lines of code, did a bunch of eval and it was called MVC, but it also is evolving.. thing is all languages allow you to do some dumb stuff so YOU have to be responsible to not fuck it up (which you always DO btw, we all do). Difference is PHP/JS roll with it because the assumption is that you know what you are doing, which again - newsflash - you don't.
More or less I would blame that shit on businesses which decided to go with undergrads to save money instead of investing in their product, hell, I am in a major company that does not invest that doesn't care a whole lot about dev /tech stuff and now everybody's mother is an engineer - they care about money, because investors care about money (ROI) and because clean code does not pay the bills, but money does.
If we get all of the good practices and apply them to each language every one of them has it's place, that is why there is no "The Language", even if there was, we STILL ware going to fuck it up and probably it was going to be even worse than where we are now.
Study, improve, rinse and repeat... There are SENIORS and LEADS out there that are about 25-30 and have no fucking clue about the language, because they have stuck up their heads up the ass of frameworks and refuse to take a breath of clean air and consider something different than their dogmatic framework "way" of doing things.. That is the result you are seeing. Let me give you a fresh example to illustrate where I am at atm:
Le me works with ZendFramework 2.3-2.5 (why not, which is PHP5+ running on PHP7 [fancy, eh]), and little me writes a module for said project, and tries to contain it in its own space, i.e not touching anything outside of the folder of the module so it is SELF-CONTAINED (see, practices), during 2-3-4 iterations of code review, I've had to modify 4 different modules with `if (somthing === self::SOMETHING_TYPE)` as requested by my TL, which resulted in me not covering 3 use-cases after the changes and not adding a new event (the fw is event-driven, cuz.. reasons) so I have to use a bunch of ifs in the code, to check a config value and do shit. That is the way of I am asked to do things I hate what I've done and the fact that because of CR I have lost case-coverage, a week of work and the same TL will be on my ass on monday that things are now "perfect".
The biggest things is "we care about convention and code style"... right.... That is not because of the language, not because of me, not because of the framework - it is some dude's opinion that you hate, not the language.
New stuff are better, reinventing the wheel is also good, if it wasn't you would've had a few stone circular things on your car and things ware going to be like that - we need to try and try, that is the only way we actually learn shit.
Until things change in the trade, we will be on the same boat, complaining about the same shit over and over, you and me won't be alive probably but things will not change a bit.
We live in a place where state is considered good, god objects necessary (can you believe it, I've got kudos for using the term 'God Object'... yep, let that sink in). If you really hate something, please, oh god I beg you, show me how you will do it better and I will shake your hand and buy you a beer, but until then, please keep your ass-hurt fanboy opinion to your self, no one gives a shit about what you think, we will die and the world will not notice...6 -
I never thought clean architecture concepts and low complicity, maintainable, readable, robust style of software was going to be such a difficult concept to get across seasoned engineers on my team... You’d think they would understand how their current style isn’t portable, nor reusable, and a pain in the ass to maintain. Compared to what I was proposing.
I even walked them thru one of projects I rewrote.. and the biggest complaint was too many files to maintain.. coming from the guy who literally puts everything in main.c and almost the entire application in the main function....
Arguing with me telling me “main is the application... it’s where all the application code goes... if you don’t put your entire application in main.. then you are doing it wrong.. wtf else would main be for then..”....
Dude ... main is just the default entry point from the linker/startup assembly file... fucken name it bananas it will still work.. it’s just a god damn entry point.
Trying to reiterate to him to stop arrow head programming / enormous nested ifs is unacceptable...
Also trying to explain to him, his code is a good “get it working” first draft system.... but for production it should be refactored for maintainability.
Uggghhhh these “veteran” engineers think because nobody has challenged their ways their style is they proper style.... and don’t understand how their code doesn’t meet certain audit-able standards .
You’d also think the resent software audit would have shed some light..... noooo to them the auditor “doesn’t know what he’s talking about” ... BULLSHIT!9 -
so... 9 years ago we had this super awesome codebase. 1 file, complete logic COPIED to be used in ui and service/daemon. I scrolled to the middle of the file and there was no source. it was out of bounds of my monitor to the right because of nested ifs. ok... what the fuck!! the worst part: I had to implement a new FEATURE into this mess. 2 days. I said it would not work as expected because the feature was not thought through. but project said let's gooooo! ok there I was, a junior with an impossible to implement feature and a codebase from hell. I've implemented something, all night long. next day it was the problem of the consultants. they called me, I told them why it's impossible that this would ever work, they understood and talked to the customer. he accepted the solution. WTF?! anyway, in those days I thought about quitting developing software as my daily job....4
-
-- What if JavaScript never existed?
-- What if HTML was a programming language?
-- What if our data online isn't abstract but physical?
-- What if geeks have their own country?
-- What if humans exist and we are the aliens?
-- What if the internet is state-owned?
-- What if we could download food just like every other downloadables?
-- What if my VSCode won't kill me when switched to light theme?
-- What if there was no gender and the word "female" is just an alias for "male"?
-- What if bugs could find and fix themselves?
-- What if there's no need for an account password?
-- What if Linux was owned by Microsoft?
-- **What if I could tell my boss that I'm tired of his fucking job without actually telling my boss? This is the actual what if.**27 -
Just started teaching my brother some programming. He is the type of guy that is always outside and almost never uses a computer.
So after teaching him a lot on dictionaries, ifs, etc. I ask him to make a dictionary app.
This is how he proceeds to name his variables:
var theOne = new Dictionary
var f***face = Console.ReadLine()
if (theOne.Contains(f***face)) {
var faffaf = Dictionary[f***face]
Console.Write(faffaf)
}
(Note this is simplified C#)
This is after I told him a few times that you should name your variables so others can understand what they are.5 -
Tired of all those timetables, application, motivational quotes ...
Coded my own assistant : Robo1100
Still full of ifs but properly understands what I mean (I don't have s very wild vocabulary )
Can I call it artificial intelligence?
Some of his features:
- determining current tasks according to date and time
- tracks the task and show you how many percent you've done
- plays different musics according to your mood (if you start nagging he'll play motivational rock and so on)
- does simple calculations for you
-gives you simple informations like time , whether,...
- remind you the events of the day
- reads a rsnfom cool quote at startup
- most importantly speaks with s human voice
-...
Any recommendations?7 -
When I’m getting to 100k MRR, if I have any developers but me, I’m gonna spoil them. I mean making them obscenely spoiled. Here, take your 4 times the market salary. Enjoy the culture and never leave.
Why? Because my architecture approach makes products that don’t need many devs, plus I don’t like making useless features. Every product has a scope. Every scope can be completed. “There are always tasks” notion is wrong.
Also, because to me 1000% and 10000% margins aren’t different at all. Those who seek MOAR and MOAR money, amassing more money than they can ever spend, do it out of fear.
I don’t have any kind of fear. Those who looked their death straight in the eyes don’t fear materialistic misfortunes.
My favorite word is “enough”. I speak it to myself several times a day, over and over, like a mantra. It helps me overcome but-what-ifs that plague people to the point of using next.js just to make trivial saas apps that can be replaced by Excel in one week of work.8 -
StackOverflow locked my account. I'm hoping someone here might be kind enough to help me with a bash script I'm "bashing" my head with. Actually, it's zsh on MacOS if it makes any difference.
I have an input file. Four lines. No blank lines. Each of the four lines has two strings of text delimited by a tab. Each string on either side of the tab is either one word with no spaces or a bunch of words with spaces. Like this (using <tab> as a placeholder here on Devrant for where the tab actually is)
ABC<tab>DEF
GHI<tab>jkl mno pq
RST<tab>UV
wx<tab>Yz
I need to open and read the file, separate them into key-value pairs, and put them into an array for processing. I have this script to do that:
# Get input arguments
search_string_file="$1"
file_path="$2"
# Read search strings and corresponding names from the file and store in arrays
search_strings=()
search_names=()
# Read search strings and corresponding names from the file and store in arrays
while IFS= read -r line || [[ -n "$line" ]]; do
echo "Line: $line"
search_string=$(echo "$line" | awk -F'\t' '{print $1}')
name=$(echo "$line" | awk -F'\t' '{print $2}')
search_strings+=("$search_string")
search_names+=("$name")
done < "$search_string_file"
# Debug: Print the entire array of search strings
echo "Search strings array:"
for (( i=0; i<${#search_strings[@]}; i++ )); do
echo "[$i] ${search_strings[$i]} -- ${search_names[$i]}"
done
However, in the output, I get the following:
Line: ABC<tab>DEF
Line: GHI<tab>jkl mno pq
Line: RST<tab>UV
Line: wx<tab>Yz
Search strings array:
[0] --
[1] ABC -- DEF
[2] GHI -- jkl mno pq
[3] RST -- UV
That's it. I seem to be off by one because that last line...
Line: wx<tab>Yz
never gets added to the array. What I need it to be is:
[0] ABC -- DEF
[1] GHI -- jkl mno pq
[2] RST -- UV
[3] wx -- Yz
What am I doing wrong here?
Thanks.17 -
So I had this conversation yesterday while fixing yet another Windows laptop for someone else.
Other Guy = OG
Me = Me (Duh)
OG: So what are your plans after your apprenticeship?
Me: Uh, I'll probably start somewhere that's e-commerce related, kinda like my current company but somewhere else.
OG: Uh have you thought about being your own boss?
Me: Well yeah, but I wouldn't know how to attract customers and shit
-- This is the moment shit gets real
OG: OH BTW I heard that Germany is lacking AI developers, you should do that! It earns you shitloads of cash!
Me: Uhm.. well, that might be true b-
OG: There's no but dude, it's free money, you're smart.. I mean you can fix any computer, right? AI will be just as easy
Me: It's not like-
OG: Duh, don't make yourself look so bad I know you can do it!
Me: B..But I'm not interested in it at all
*silence for 5 seconds*
OG: Well.. I guess you do you then
After that we continued to have random chit-chat about his job and experience (He's a mechanic)
God I hate when people throw buzzwords around and try to convince other people to do what *they* want.
No, I don't want to develop a structure of 1000 ifs/elses, I'd rather keep doing what I'm doing, thanks!6 -
How to meditate, Kiki way:
1. Lay completely motionless
2. For every thought your brain generates, ask “Where did it come from?”
It’s difficult first time, but then you get used to it.
For me, anxiety manifests as itchiness and pressure in the heart area. But when I think in this specific way, anxiety shuts up, and my heart feels… actively good? Not a heart orgasm or something, just the feeling you get when you take off your bra after a long day, but condensed in one area.
Thinking this way is like reading a history book. History doesn’t tolerate what-ifs, and thus, the opinion of your anxious part — a so-called internal critic — becomes irrelevant. At least, I think it’s how it works, I’m not a therapist or something.
Everything I analyze traces back to my mother. I mean EVERYTHING. What a manipulative bitch indeed. You probably missed that, here it is: https://devrant.com/rants/9940652/...
Meditation became a bad word recently. It’s something you hear from self-help gurus and other scum alike. Despite that, here is the simple way to meditate that works. Use it!67 -
I think I had another insight.
Long story short, you're not the main character. You're not an NPC either. You're a spotlight!
Looking at yourself in the present doesn't make sense. You're not gonna understand yourself this way. In general, you're nothing but a history. In the present, you're an unbiased observer reading a history book.
This way of thinking is hard to pick up, but in a nutshell, for every emotion you feel, ask yourself: "Where did this feeling come from?"
This framework immediately takes the guilt away. It is what it is, the history doesn't entertain what-ifs. Once you memorize your own history word by word, only then you can really understand yourself and be free of trauma.15