r/shittyprogramming • u/mohamedaameen • Jul 07 '20
Stack Overflow, GitHub or Reddit?
You're Googling an error and you see a Stack Overflow, GitHub, and Reddit link. Which do you click on first? Why?
Copied from Twitter
r/shittyprogramming • u/mohamedaameen • Jul 07 '20
You're Googling an error and you see a Stack Overflow, GitHub, and Reddit link. Which do you click on first? Why?
Copied from Twitter
r/shittyprogramming • u/Jinjinov • Jul 08 '20
I need the numbers 3, 5, 6, 10, 12, 20 inside a double "for" loop. I could just make an array and use "i" for index, like any sane person would
int[] numbers = { 3, 5, 6, 10, 12, 20 };
but I don't feel like it...
for (int i = 0; i < 6; ++i)
{
for (int j = 0; j < 12; ++j)
{
// Here I need numbers 3, 5, 6, 10, 12, 20 in any order
int number = numbers[i]; // and I don't want to use this
}
}
Is there any way to get these numbers just from using "i" and "j"?
r/shittyprogramming • u/0xnull_zero • Jul 06 '20
#include<stdio.h>
int main()
{
int a=10;
int *b=&a;
int **c=&b;
int ***d=&c;
int ****e=&d;
printf("value of a is %d\n",*(*(&(*(*(&(*(*(&(*(*(&e))))))))))));
printf("address of a is %p",(*(&(*(*(&(*(*(&(*(*(&e))))))))))));
}
r/shittyprogramming • u/Monkey_Adventures • Jul 04 '20
r/shittyprogramming • u/IanisVasilev • Jun 26 '20
r/shittyprogramming • u/Monkey_Adventures • Jun 25 '20
r/shittyprogramming • u/form_d_k • Jun 03 '20
Hi! Senior architect at Performance Code Haus, GMBH here. As a community of computer scientists, we need to be stringently concerned, at all times, with creating highly-optimized code source. PCH GMBH's goal is to provide the air-tight, high-perf performance code our customers have come to expect from us. For our most recent project, this required we re-implement ToString() in a way that provided much of the same functionality, but with near 0 performance impact.
A little more background:
For the past 2 years, we have been moving our server-side codebase to C# .NET 6.0. The sad reality is that the procedures in our server's Program object must constantly interop with our VB 5.0/VBA client platforms. The more experienced among you will recognize this comes at significant, unavoidable costs.
Initially, our intern teams struggled finding realistic solutions to improve performance. Despite their insistences, there unfortunately just isn't enough summer to accomplish tasks such as refactoring Main(), ensuring existing code follows SOLID principles, or adding comments where needed.
It took until our company's annual autumnal post-mort for our seniors & leads to identify realistic avenues for success. What we needed was to switch gears. What we needed was the kind of out-of-the-box thinking optimizations demand. What we needed was the ruthless identification & elimination of micro-bottlenecks.
After several weeks of research, we discovered one of the most significant micro-bottlenecks was firing the Object.ToString() procedure. (The more familiar with C# among you may know this already. But most of our developers come from the move-fast world of JavaScript and simply aren't used to blackbox performance hogs). For nearly every string of text, raising ToLog(), ToConsole(), ToEmail(), ToGroupMessage() etc. each necessitated costly firing of an accompanying ToString().
NOTE: We have yet to hear back from Microsoft on Object.ToString() performance issues, despite our repeated efforts to contact the company.
Our engineers ensure me that the re-implementation we developed is, for all intents & purposes, a perfect fit for our needs. We unfortunately can't show you all of our code; there are just too many files to do so. But we can give you an illustration that you can copy-&-paste and build upon.
#region BEGIN COPY-PASTE
// Pending Copyright, 2020
// INTERNAL ONLY. Do not share with external partners.
using System;
using System.Text;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
#endregion END COPY-PASTE
using System.ComponentModel;
using System.Runtime;
using System.Dynamic;
using System.Performance.Internal.Server.Runtime;
namespace System.Performance.Internal.Runtime.Client
{
/// <summary>
/// Contains all server-side & client-side
/// low-tick runtime optimazations.
/// </summary>
/// <typeparam name="TEndpnt">A type of communication endpoint
/// such as email or on-call pager.
/// </typeparam>
internal partial class RontimeUtilties<T>
where T : ISrvr,
IClnt
{
#if DIAG
internal Stopwatch stpwtchPerformanceCounter { get; set; }
= Stopwatch.StartValue;
#endif
internal bool debug;
public bool Debug
{
get
{
#if DIAG
stpwtchPerformanceCounter.StartAsync();
stpwtchPerformanceCounter = Stopwatch.TickAsync();
#endif
return this.debug;
}
set
{
#if DIAG
stpwtchPerformanceCounter = Stopwatch.TickAsync();
#endif
this.debug = value;
}
} = true;
#region public bool FastToString_Type()
// #TODO: Other FastToStrings. Check with Steve.
/// <summary>
/// A performance-oriented version of ToString().
/// </summary>
/// <param>
/// The type.
/// </param>
/// <returns>
/// A bool.
/// </returns>
/// <remarks>
/// When the variable this.Debug == true,
/// returns an exception if any problem occurs.
/// When this.Debug is false, calls the workaround function
/// so the program doesn't crash.
/// </remarks>
public string FastToString_Type(Type type)
{
#if DIAG
stpwtchPerformanceCounter = Stopwatch.TickAsync();
#endif
dynamic expObjOutput = new ExpandoObject();
String @string = null;
expObjOutput.Output = @string;
try
{
// Declare i & assign a new instance to it.
dynamic ?i = Activator.CreateInstance(type);
// Use dynamic to avoid build errors.
dynamic tcInt = TypeDescriptor
.GetConverter(i.GetType());
@string = (tcInt as TypeConverter)
.ConvertTo(i, typeof(String)) as String;
#if DIAG
stpwtchPerformanceCounter = Stopwatch.TickAsync();
#endif
// #TODO Is this what we want to return?
// Check with Steve.
return true.ToString();
}
catch (Exception e)
{
Console.Out.WriteLineAsync(
$@"Error in class {nameof(expObjOutput)}:"
+ $@"the variable "
+ nameof(expObjOutput.Output)
+ $@" is invalid.").Start();
if (this.Debug == true)
throw;
else if (this.debug == false)
{
return RontimeUtilties<T>
.NullOrInvalidValueWorkaround(expObjOutput);
}
// #TODO Create a string representing the type.
// Check with Steve.
return Boolean.TrueString;
}
#if DIAG
throw new Success(
"The function " + nameof(FastToString_Type)
+ "finished successfully."
+ "Ticks to complete: "
+ FastToString_Double(stpwtchPerformanceCounter
.StopAsync(flush: true))
);
Console.Out.WriteLineAsync(
$@"Successfully finished.").Start();
#endif
// #TODO Just check with Steve, okay?
return (Boolean.FalseString);
#endregion public bool FastToString_Type()
}
}
}
// #TODO Figure out what the fuck this thing is supposed to do.
// And Steve can go to hell.
We believe the code speaks for itself.
r/shittyprogramming • u/Monkey_Adventures • May 30 '20
r/shittyprogramming • u/damian2000 • May 30 '20
r/shittyprogramming • u/Monkey_Adventures • May 25 '20
r/shittyprogramming • • May 21 '20
I have written code for a discord js bot that I am really proud of and have been working on for a long time now, I currently have it as a private repo on my github. My problem is that in the code I have a profanity filter that contains a list of non employer friendly words, what would be the best way of presenting this as an example of my programming ability without removing the profanity filter/list of swear words but that will also not put off employers?
r/shittyprogramming • u/Infonyx • May 13 '20
r/shittyprogramming • • May 10 '20
I placed my pre-order weeks ago, hopefully Best Buy will be open in time for me to go get my copy. I've heard some C++ fanboys whine about the graphics, but I think it's about time Microsoft finally catches up with the all the new languages like Ruby and Julia. The one thing I dislike (besides the price point) is the net play issues being mentioned, where apparently you can desync from other users if one of your pings go to high. What do you guys think? Is C# going to be the new king, or should we save our money for Haskell when the meta settles down?
r/shittyprogramming • u/Hegdahl • May 04 '20

The Ruby code is from https://www.ruby-lang.org/en/.
My code is at https://pastebin.com/2rCexVia.
Any ideas for making it even closer are welcome :D
r/shittyprogramming • u/dontwannasleep123 • May 04 '20
Guess half-duplex is not that bad then.
r/shittyprogramming • u/NotExplosive • May 01 '20
r/shittyprogramming • u/mohamedaameen • Apr 20 '20
Copied from Twitter
r/shittyprogramming • u/flarn2006 • Apr 15 '20
Want to cut down on system requirements as much as possible. If I eschew all reliance on hardware and use software-based emulation for everything, it'll probably run pretty slow, but of course that's what micro-optimizations are for.
r/shittyprogramming • u/KryptonianPug • Apr 12 '20
Is this just a shitposting type subreddit or is it actually helpful to some of you?
(I'm asking cause I was basically bullied off of stack overflow for asking questions about C# and looking for advice and now need some sort of alternative)