/dpt/ - Daily Programming Thread

What are you working on, Jow Forums?

Previous thread:

Attached: OOP_sucks.png (496x366, 30K)

Other urls found in this thread:

youtube.com/watch?v=pzouxmWiemg
github.com/plexinc/plex-media-player
twitter.com/AnonBabble

Attached: a templeos qa tester.jpg (250x250, 6K)

assert(filename);

Not my problem.

I can't for the life of me understand how operations on them work; for example, I've seen things like:

array[whatever++]
and
array[whatever]++

and I just cannot wrap my head around how I'm supposed to interpret these things and when pointers get involved it just becomes a clusterfuck that torments me

Forgot to add:
A - B;
A B - C;
A B-C;

bookInFile :: Filename -> Maybe Book

array[whatever++] is the same as array[whatever]; whatever = whatever + 1;

REEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE

ok that was good, I needed that. Phew. It really is hard to program when you have 80 IQ.

You're thinking like a C programmer. Try learning a Lisp.

arr[i++] gets you the data at index i and then increments i.

arr[i]++ gets the value x at index i and then gives you x++

An array must be accessed by an index or *(start+offset) (that is misuse). A pointer is actually a memory value, so it can be shifted around. An array name is fixed, and [] is an accessor function which is almost the same as *(array+offset) or *(array + dimension*multiplier + lesser_dimension_offset). I say almost because there's some niche technical details for extern and stuff, but in most cases, the memory access is similar to pointers.

In bad practice, an array implicity turns into a pointer when pushed into a declaration, but the declaration still needs some information that it's an array. There can be more precise declarations like array[5][5]. a little less like array[][5] (the reason the first can be missing is because although we don't know how many, we can be certain they are 5 apart).

>language has null
>this is somehow OOP's fault

Attached: 1527391814123.jpg (971x565, 87K)

What can I do to learn more programming languages?
I'm familiar with concepts and I know JS, PHP, SQL, and Bash scripting. But finding things to write seems to be hard for me. I want to learn more Python and C but I don't wanna be writing Hello World™level stuff all the time or just constantly doing programming challenges.

Attached: 1521157343876.jpg (775x720, 80K)

A weird case which I'm biased towards: Basic fax files (T4, T6). It's more for EE than CS since it's... low level. Fax used to be entirely analog (literally clockworks), so it's interesting how they adapted it as things moved forward. T4/T6 is a basic understandable compression scheme, and there's some ways to optimize it, so you can get a little taste of those ideas.

Exceptions are a mistake.
Change my mind.

No that's pretty much a given in /dpt/. Monads are clearly the cleanest, tersest and safest way to handle errors.

sudo make an exception

They actually make sense in a code monkey environment where you have to assume half the people don't know what the fuck they are doing.

it seems like 80s OOPfags loved the concept of null therefore it's in most languages from that time and newer ones too.

I suggest you identify a real-world problem you have and try to build a solution for it.
If you can't think of anything like that, try building a profitable phone app or website.
Building anything real-world is going to take you places exercises won't.

make: *** No rule to make target 'an'. Stop.

stop learning programming languages and just build stuff
if you are creatively dead, just take a common game/tool/service and put am extra gimmick on top

That may depend on the context.

But exception handling is a monad.

It's an implicit one, which makes it unsafe and unclean (like implicit mutable state)

Monads get quite messy if they become part of another monad. Hence the need for monad transformers.
youtube.com/watch?v=pzouxmWiemg

It's the goal to build stuff. But I tend to have trouble thinking of problems that I'd like to solve. Like, what do I make? I can't just plop down and write with no direction. Maybe I'm just not creative enough. I dunno.

Will check it out.

Alright, Mr. Pedantic, unchecked exceptions bad, checked exceptions good.

>monad transformers
>not distributive laws

Attached: y5mi1ax7.png (500x460, 35K)

Checked exceptions are much less manipulable than error monads. Also the only language I know of which has them is Java.

I don't get it, it doesn't support it?
It "looks ugly" and "is unreadable."
No, I don't get it either. It's both concise and readable.

I want to make more than 1 oc. for dpt points

Attached: isthisbait.png (1118x838, 24K)

this meme is really shit, anone

Attached: DzAFzEaU8AAfOqg.jpg (620x640, 50K)

>Maybe

Attached: shrug.png (456x399, 203K)

to reach /dpt/ satori you have to edit anime girls to be holding programming books

Attached: 1549915329553.png (790x960, 1.01M)

struct Rectangle{
int x,y,w,h;
}
struct Rectangle Rectangle(void x, int y, int w, int h){
struct Rectangle ret = {x, y, w, h};
}
struct Rectangle rectangle = Rectangle(NULL,NULL,NULL,NULL);

will still compile

???

Attached: laughs.jpg (240x210, 6K)

>void x

Attached: Dx6DKuPWkAAmNDe.jpg (679x424, 59K)

do you have a tool/service/game that you use every day?
what would you change to make it better?
then just do that

VB is better than most new languages. specifically, case-sensitive programming languages make everything else harder.
>You keep having to switch between upper and lower case when typing, causing RSI in your poor little fingers as you reach for the inconsiderately located Shift key.
>You are much more likely to make mistakes – are you sure you meant to typeDateOfBirth, or should it have beendateofbirth?
>When you accidentally leave Caps lock on, it really matters.

The only possible benefit is that you can use more combinations of variable names, that is, you can use more of one of the few infinite resources in this universe…

Pascal*

>do you have a tool/service/game that you use every day?
Plex I guess. You know what I should do? It's open source right? I've always wanted a way to change the subtitle and audio settings for every episode in a series without having to parse through every episode and change them individually.

Maybe I'll take a look into that.

Attached: 1522988218942.gif (191x199, 224K)

Is there a reason why there is a distinction between . and -> with C++ pointers?
I have never felt it could cause confusion, but I always have trouble getting the order manually

>Is there a reason why there is a distinction between . and -> with C++ pointers?
nope, but people will defend it to death anyway because it's C++

if you ever get it wrong then it's clear you don't understand pointers well enough

implicit dereferencing is cancer. Though it may have been better for * to be a postfix operator in hindsight.

Yeah, it will give you a (0,0,0,0) sided rectangle, because (int)(NULL)=0

Fuck me, I actually can't do that.
From their website:

>What parts are not available for contribution?
>Anything done in the web-client. This includes:
>Changing / adding to the UI. (Note that we are investigating theme/skin support.)

Bullshit. It's a thought at least.

looking at VB code makes me naseous.

Attached: 1550923755722.jpg (1280x720, 178K)

Cont.
Modern languages were written by academics. It shows. Consider this table of C# symbols and their VB equivalents:
>Test if two conditions are both true
&& vs and
>Test if one or other condition is true
|| vs or
>Test if a condition is not true
! vs not
>Concatenate two strings of text
+ vs &
>Test if a condition is true within an if statement
== vs =

Which column looks like it was designed by a real person?

>implicit dereferencing is cancer
yep there we go

That is the single worst shill I have ever see for a programming language. Case sensitivity? who gives a shit.

>void x

Attached: face.png (1252x1012, 77K)

obj->data is shorthand syntax for (*obj).data

so, basically, -> is just telling you that you are using an indirection. which is good

Because to access the members of a pointer you have to derefence it.
doing "." is just using a constant offset
t. Clet

you mean this?
github.com/plexinc/plex-media-player
it's gpl, so it's free as in freedom

The first three examples are alright, but the last two are shit.

What the fuck is wrong with javascript? Like who wrote this? Why did it become so popular? It hurts my eyes

that's not javascript, that's just plain java

REEEEEEEEEEEEEEEEEEEEEEEE

They picked the worst symbol for it though, . Is easy to type, just press it with your pink finger. -> needs you to type at the top of the keyboard, then shift, then at the bottom, all for one operator. Why the fuck k did they think that's a good idea for something used to much?

they're pretty much the same thing though

One is for accessing by value the other is by reference. Do you not understand the difference?
. == from this MEMORY LOCATION, go to the offset and do stuff
-> == FROM THE MEMORY LOCATION STORED IN THIS VALUE, go to the offset and do stuff.

> not having a vim shortcut for inserting ->

>Why the fuck k did they think that's a good idea for something used to much?
You're talking about a language where every common function call is preceded by std::

have you ever heard of using declarations user

we just need better keyboards
a 0 #put 0 to a, now a=0 is true
a 0 #assignes a to 0, error.
a a 0 #put the lower of a and 0 in a
a a 0 #put the higher of 0 and a in a

yeah both are shit AND proliferated like cancer

>when you say something you heard in /dpt/ in class and the prof congratulates you

Attached: 1527188503615.jpg (800x779, 138K)

using exists but no C++ programmers seem to use it

I am starting to think that every one of you on here who criticizes C++ is just a shit programmer who doesn't know anything about it.

kek it doesnt even show the alt codes,
it was supposed to be using these

what was it

yea i bet u like that u lil slut

A NULL isn't implicitly casted to 0. I like bringing this up because it's an undefined behavior which really needs to stop. It's defined that a (void * )0 is implicitly casted to NULL, but NULL != 0 per spec.

= should be the equality test. := should be assignment. Pascal was robbed.

I still don't know why that is. It just werks.

Why would someone who has noticed the language is shit continue to learn it? It's like people complaining that people who don't like their favorite book hasn't read it till the end yet.

FUCKING HELLLLL

Attached: ree.png (364x256, 7K)

>Lisp is the most powerful programming language

You then get fucked in the ass by terone?

Jow Forums only supports some characters
it's completely arbitrary and oddly it doesn't sanitize it, malformed unicode is actually allowed

You can't notice it is shit if you don't at least know about namespaces/using, for example. Sure at certain point you can throw in the towel, but not in the first five minutes.

Also it's not shit, so you would just be objectively wrong as well.

based and redpilled

Attached: 1548845265761.jpg (633x356, 37K)

I am forced to work with C++ shit all the time and I see std:: all over the place, explain that

>implying min/max shouldn't be the same symbols as and/or
Do you even lattices?

no good C++ programmers exist, particularly at work where they're all ancient boomers

top kek

>You can't notice it is shit if you don't at least know about namespaces/using, for example
Of course I do
yet nobody uses it. Why? C++ code looks like ass. :: is horrible fucking syntax aswell

for an example of how arbitrary it is, Jow Forums allows ancient egyptian hieroglyphs, which most fonts don't actually support

still don't know why . wasn't used

>"good" C++ programmers
>I'm tired of C++, I'm going to move onto
>never gets anything done because modern languages are corporate grabs and CS jerk-off contests

>half-assing C++ programmers
>well since there's less competition, I'm just going to chug away forever, who gives a shit about longevity

>bad C++ programmers
>I'm going to go learn Python and work for math
>1 gigapajeets vs 1 kilowhites who wins?

Plot twist: it was your sociology professor and what you said was that men dressed as girls make the best programmers.

sauce

I would hazard it was the easiest to implement because nothing used it previous. Just read :: as //. A directory path. Once someone told me that it's like "holy shit that just became so much more legible"

That's what's great about Julia, you can define shit like this to make code actualy make sense, including binary operator, assignment operators, use any Unicode, plus it supports latex so you don't have to look up alt codes or other bullshit, you just type \Lambda, or x\_2 to write a lambda or a subscript.

Because every operation needs its own distinct operator apparently, even if it's retarded shit like :: and ->

-> makes sense, you want to keep pointers and values distinct

but you'll never confuse a type or namespace for a value

>you want to keep pointers and values distinct
you should already know it's a pointer by looking at the type of the variable

They propably just disable a specific character when someone makes some spam that fucks up the site using it. That's what they did with latex on sci, we used to be able to use latex to write outside the post box, change the threads background image, crash anyone's browser who went into the thread, make massive drawings using loops. It was so much fun back then but they disabled all those features as we found them.