/dpt/ - Daily Programming Thread

What are you working on, Sup Forums? And what color thigh-highs are you wearing? Old thread:

Fuck OOP, FP for life

>how to tell if someones a neet

>someones
how to tell if someone's a pooloo

i think i just came up with a new, unbelievable modulus algorithm with a ton of entropy like you wouldn't believe

C++ is a horrible language. It's made more horrible by the fact that a lot of substandard programmers use it, to the point where it's much much easier to generate total and utter crap with it. Quite frankly, even if the choice of C were to do *nothing* but keep the C++ programmers out, that in itself would be a huge reason to use C.

In other words: the choice of C is the only sane choice. I know Miles Bader jokingly said "to piss you off", but it's actually true. I've come to the conclusion that any programmer that would prefer the project to be in C++ over C is likely a programmer that I really *would* prefer to piss off, so that he doesn't come and screw up any project I'm involved with.

C++ leads to really really bad design choices. You invariably start using the "nice" library features of the language like STL and Boost and other total and utter crap, that may "help" you program, but causes:

>infinite amounts of pain when they don't work (and anybody who tells me that STL and especially Boost are stable and portable is just so full of BS that it's not even funny)
>inefficient abstracted programming models where two years down the road you notice that some abstraction wasn't very efficient, but now all your code depends on all the nice object models around it, and you cannot fix it without rewriting your app.

In other words, the only way to do good, efficient, and system-level and portable C++ ends up to limit yourself to all the things that are basically available in C. And limiting your project to C means that people don't screw that up, and also means that you get a lot of programmers that do actually understand low-level issues and don't screw things up with any idiotic "object model" crap.

So I'm sorry, but for something like git, where efficiency was a primary objective, the "advantages" of C++ is just a huge mistake. The fact that we also piss off people who cannot see that is just a big additional advantage.

But I'm sure you'd like it more than git.

C isn't OOP either

Did you just assume my programming preference?

this is a programming safe space for all programmers check your binary privilege

>What are you working on, Sup Forums?
I am procrastinating on a few things

>And what color thigh-highs are you wearing?
I'm not wearing any thigh-highs at all!

butt-blasted neets detected

>I'm not wearing any thigh-highs at all!
Your name is Ruby; so that's a lie. I bet they're red.

We all know Ruby programs nude

chmod +777 (you) like the little whore you are

hi /dpt/
what is the most artisan and organic programming language?

I've got some regex for pulling IDs from eroshare and imgur URLs using Python

Imgur ID regex
^(?:.*/)?([a-zA-Z0-9]{5,7})(?:[/?#.].*)?$

Eroshare ID regex
^(?:.*/)?([a-zA-Z0-9]{8)(?:[/?#.].*)?$


Are these ok? I use regex.search(url).group(1) and it works so far, I've run a program using these against 2000+ URLs without error.

My regex knowledge is shit though, every time I need a new one I have to look up all the symbols and shit again or I find something on StackOverflow.

>I am procrastinating on a few things

I am procrastinating on everything by playing with my art thing.

I recently realized that OOP is mostly a meme and that half the shit they teach you about it falls apart the second you build anything even remotely complex in the real world.

What do?

Ignore that missing curly bracket on the second group of the Eroshare regex, a typo.

I have no thigh-highs. I only wear black crew socks, and right now, I am not wearing any socks at all.

This is ultimately correct unless I am not programming at home.

...

>I am not wearing any socks at all
l-lewd

Haskell better not be a fucking meme language like Lisp (I like the syntax and features, but just try getting shit done in it) or I'm gonna shitpost so hard.

Only language who adopted the Contributor Covenant:
>>Open Source has always been a foundation of the Internet, and with the advent of social open source networks this is more true than ever. But free, libre, and open source projects suffer from a startling lack of diversity, with dramatically low representation by women, people of color, and other marginalized populations.
>Part of this problem lies with the very structure of some projects: the use of insensitive language, thoughtless use of pronouns, assumptions of gender, and even sexualized or culturally insensitive names.
>Marginalized people also suffer some of the unintended consequences of dogmatic insistence on meritocratic principles of governance. Studies have shown that organizational cultures that value meritocracy often result in greater inequality. People with "merit" are often excused for their bad behavior in public spaces based on the value of their technical contributions. Meritocracy also naively assumes a level playing field, in which everyone has access to the same resources, free time, and common life experiences to draw upon. These factors and more make contributing to open source a daunting prospect for many people, especially women and other underrepresented people. (For more critical analysis of meritocracy, refer to this entry on the Geek Feminism wiki.)

No it isn't. OOP actually works well for medium to large programs in teams of programmers who know what they are doing not just one guy trying to make a complex project who doesn't know what he is doing.

Haskell has one major flaw, which is it's bad at the kind of reason why you'd use C or ASM, i.e. explicit memory management, allocation, cleanup.

I'm working on a binary tree in C, the function that creates my tree out of an array of numbers is finished, rate my shit code
Node *createTree(int a[], int size) {
Node *start = newNode(a[0]);
Node *temp = start;
for(int i = 1; idata < a[i] || temp->data > a[i]) {
if(temp->right == NULL && temp->data < a[i]) {
temp->right = newNode(a[i]);
break;
}
if(temp->left == NULL && temp->data > a[i]) {
temp->left = newNode(a[i]);
break;
}
if(temp->data == a[i]) printf("Threw out duplicate entry!");

if(temp->data < a[i])
temp = temp->right;
else if(temp->data > a[i])
temp = temp->left;
}
}
return start;
}

>not C89
shit

change createTree to use dynamic memory allocation

make it work with non-numeral values by having a comparison function as an argument. see function pointers

my Nodes are all dynamic, if that's what you're talking about
Node *newNode(int data) {
Node *n = (Node*) calloc(1, sizeof(Node));
n->data = data;
return n;
}

what advice do you guys give to beginner programmers

It's probably for the better that you not know what else I'm not wearing.

Name one platform that people give a shit about that doesn't support C11.

Read code.
Write code.

See if you can figure out how to do it recursively, it makes a lot more sense to do it that way

avoid python and java like the plague

wouldn't that cause a shitload of overhead with all the function calls you'd be making

>Name one platform that people give a shit about that doesn't support C11.

There's no C11 for the Motorola 68000. How am I supposed to do modern Amiga programming?

try hard and dont give up at all

probably a good idea to ignore people who are opinionated, unless they're successful. Python and Java are great languages that you should verse yourself in.

...

>Python and Java are great languages that you should verse yourself in.

Ignore that person.
He is wrong and will never admit it.
This is what happens when you are taught Python or Java as one of your first languages or your first languages that depart from what you're used to.

What is the simplest/sanest script language/library/shell for dealing with Windows filepaths. When I was using Python I had to copy some C hack from Stackoverflow to deal with long paths.

Powershell?

Doubt it, you can compare the iterative and recursive methods if you want to see performance. The thing to really be looking for is possible stack overflows.

Get used to the fact that everything you write for the first few years is going to be garbage, but keep practicing anyway.

>Name one platform
I can't name one but I know many exist that don't have C compilers that support C11 or even all of C99's features
ANSI C is still the standard for portability

>Tfw learned Java as my first programming language but I find it very difficult to program in functional programming languages that do not all think in objects

How do I untrain my mind from this mindset that everything has to be objects? I can't even go basic algorithms anymore in functional languages because of it.

What it do?

wow weird

>what color thigh-highs are you wearing
Program is literally not doing what I tell it to do.

Every time you see something, think "value" or "type" (in some systems they're the same)

"value" not "object"

one way is to write some high level abstractions, because they're by definition as far from objects as possible

@58832934
No (You) for you.
You're clearly trying to get someone to ask what you're talking about, but honestly, I don't care.

My only really experience with recursion is in a java class I took in highschool, I remember we were learning recursion at one point and everyone's programs would end up running slower and slower as it worked through some list of shit

Racket has good pathing utilities.
(simplify-path (expand-user-path "~/pictures/favorites/"))
;=> #

>OOP is only for dumb assembly-line coders
checks out

@58832944
that counts as a (You), thanks!

@..
no i'm not

this meme picture it is not true and you know it if you ever did OOP before

Learn C. Read The book. Do exercises.

why C from any other language?

Every large OOP codebase I've seen either:
1) Breaks the rules of loose coupling and/or high cohesion
2) Has an absurd number of layers of abstractions that make it incredibly difficult to find the code that actually does shit, due to how many levels of indirection there are
3) Is partly procedural, partly OOP (this generally seems to be the best 'OOP' code)
4) A mixture of 1 and 2

If you can point me to an open source repo of what you would consider "good OOP code" I would appreciate it.

It teaches good practises

Apache TomCat is a good example of good Java code

Because you have to walk a tightrope every time you make a program. If you fuck up even slightly, shit blows up. Other languages are usually more forgiving.

The Photoshop plugin interface is stupid complicated. :-|

Depends on what the problem at hand is. If you do a naive implementation of the Fibonacci sequence recursively, it'll get slow as fuck pretty quickly since you'll end up repeating the same calculations over and over again. Creating a binary tree recursively on the other hand shouldn't cause significant slowdown, but I don't know the numbers on that.

Which makes you as sloppy as maki's blowjobs. C is great for beginners

Modern Amiga is on PowerPC, not Motorola 68k; and furthermore, GCC supports both. Presumably, you can just compile GCC 5 or higher and binutils for the appropriate target triplet, and you'll have a working C11 compiler for the platform.

Windows filepaths don't really need to be treated much differently from Unix filepaths. Windows will not complain if you use forward slashes for everything.

Powershell is a cunt with unusual paths though

Why should beginners use more forgiving languages? They should be made to think before they type.

>Learn 3 or 4 different languages
Preferably ones that are quite different to each other - it doesn't really count as 2 languages if you learn Java and C#. This will allow you to see what aspects of programming languages are similar - which constructs can you generally expect to find, etc. Learn a high-level managed language like Java or Python. Learn a low-level unmanaged language like C. Learn a scripting language like Lua. Learn a functional language like Haskell, Scala, or Scheme. This will make it incredibly easy for you to pick up a new language when you need to and help you understand computer programming better. And I don't mean "learn" as in "master". You don't even need to learn the whole language (I have friends who write production C# and don't even come close to utilizing the entire language). I just mean put a couple months into them and write a few toys, though if there's something unique about the language then don't avoid it.

>There is no such thing as a silver bullet and anyone who says otherwise is selling you snake oil
Yes, some paradigms/tools/frameworks/languages are more effective in certain circumstances than others, but you're never going to find a language that is optimal for all possible use-cases. This ties into the first point, which is has the nice effect of keeping you from boxing yourself in with one language.

That said, there is nothing wrong with using a tool that isn't best for the job for learning/fun purposes.

they should learn an easy language like Haskell instead

>Modern Amiga is on PowerPC

???

>furthermore, GCC supports both. Presumably, you can just compile GCC 5 or higher and binutils for the appropriate target triplet, and you'll have a working C11 compiler for the platform.

Didn't know that.

this.

they'll be wondering wtf is going on when they switch from a dynamic to static language

Use blender, nerd

Should Java be taught as a first programming language? Why or why not?

Because everybody should be able to learn how to kode :)
Mean old C >:( is too hard for my pansexual otherkin SO

I'm writing a custom bootloader for custom 64 bit kernel

who /elite koder/ here

>too bloated
>verbose as fuck
>makes you lazy
>smells like curry
no

I'm doing image filters. Someone here mentioned a program that hosts filters a long time ago, but I never really looked into it.

I forget what it was called now.

No.
We would all agree that Java is trash - with one notable exception. Java programmers.

Java is a cancer on the brain.
Once one starts liking Java, they're gone.
It's not them any more. You can't convince them.

>I'm doing image filters
still? damn bro...

No, it's pretty content about Unix style paths.

I am becoming incredibly powerful...

That's not unusual though. I'm taking about long paths with spaces, brackets, and everything that's explicitly allowed.
Also how's that botnet?

>???
If you are saying you want to program for "Modern Amiga", then I am assuming you are referring to Amiga OS 4.1 Final Edition Update 1, which can only be run on custom PowerPC hardware.

>GTP posting an anime gril
Did I shift universes by posting in that bog thread?

>Also how's that botnet?
every time.

>long paths
As long as it's small enough for NTFS not to bitch at you, it's fine.

>spaces, brackets, everything else
Like any shell on any modern operating system, Powershell is going to see two things separated by spaces, and treat them as two separate arguments. When one argument is enclosed in quotes, it ignores all other syntactic rules, and treats it like a single string. For some characters, you will need to use escape characters. Powershell is okay with that. Again, I will continue to note not to use backspaces for separating directories.

>how's that botnet
It is contained in a Virtual Box instance, where it can do no harm.

>Virtual Box
BOT
...
NET

>GPL
>Botnet
Explain.

who comfy here? and by that i mean comfy chair, comfy laptop, comfy drinks, comfy keyboard, comfy lighting, comfy OS, etc. EVERYTHING is comfy. Comfy desk, comfy stereo, etc. I need my set up and home to be comfier.

>the call that saved OS dev

I've got a comfy dildo up my ass, does that count?

everything i own is comfy :^)

yes! i just massaged prostate myself :3

i have the most comfy lair it has a comfy big couch with a big comfy chair and I have comfy pajama pants on and a comfy t shirt

If you are able to teach object orientation properly, yes. Java is alright.

Kinds of people that hate on Java:
1. NEETS (70% of the hatred):
You will find them to be expert on meme languages like hasklel and other bullcrap that has no practical value. Their brain was unable to grasp OOP so they must look tough by posting the most 1337 implementation of fuzzbuzz using functional programming.
2. Microsoft Shills:
It should be obvious. Microsoft saw the success of Java and couldn't stand Oracle. So they made a Java rip-off called C# and started the popular Java hatred meme. The NEETs described in category 1 took the bait and forgot how shitty C# itself is.
3. Lastly, the ""expert"" C kernel hackers who hasn't programmed anything but fizzbuzz tier pet projects. They like to pretend they are some kind of epic anonymouse programmer but as soon as you actually throw a real problem at them to solve they will disappear. They tend to forget the hard truth that no matter how much they study and work on C, they can never be even anywhere close to Linus Torvalds. Other common traits they've got:
>They have programmed a sophisticated web browser that doesn't work
>They tend to be hipsters - avoids GNU and pretend they are any (ANY) better programmers
>When faced with deeper C topics, they won't answer, because they don't know how to work with it.
>Post books they haven't actually bought
>Pretends to understand basic things like pointers while never used double pointers in life
>Resorts to namecalling, "Pajeet", "india", "curry" are the most favorite terms. Insecure about indian boogeyman taking their non-existent expert kernel hacker job
>Things Computer Science is actually any Science, doesn't admit only lowest of the low scorers choose CS while top scorers choose Physics, Chemistry, Pharmacy etc
>90% are dropouts and has ""problems"" with current academic curriculum. The rest are underage schoolkids. (example: OP of General C thread)

any ideas how to make a good lay down station? i sit at work all day and when i come home i dont want to sit the rest of the day some more. Looking to make something comfy. Like a comfy lawn chair customized to hold me laptop in front of me. I think that would be pretty comfy

Just checked this thread again, thanks for the help.
I already finished it my own way, but I appreciate the attempted spoonfeeding.
Also, your code seems to segfault at s[finish_index] = '\0';
It might be something I fucked up in the ~2 seconds I committed towards testing it.
Just thought you might want to know.

ya that does sound pretty comfy. I was thinking maybe just get some big pillows and lay on your bed with your laptop. That sounds comfy. Then you have a lot more freedom and space to move around and be comfy. Also if you get up and stretch every once in awhile it will make things comfier when youre trying to be comfy because it helps your muscles become more comfy.

omg bros do you know what would be really comfy? what about getting a giant bean bag chair to be comfy in? i know it sounds like its for kids but they really are comfy. I was thinking about getting comfy in one of those. Easy to move around the house to when you want to be comfy somewhere else. I call it flexible comfiness.

Sure you get this question a lot, however, what language should I start with?

I know a decent amount of c++ syntax, logic and just a lot of other pleb shit. I don't even know what I specifically want to write.

what i do is make a ``mound'' of bankets to lean back on then i lay back however i want to
for instance, right now i have my laptop on my stomach and my neck at a pretty small angle
other times i sit more upright such that i'm in more of a reclined position the mound
it's pretty sweet m8, very versatile

Trying to figure out rest api and json api for Wordpress