/dpt/ - Daily Programming Thread

What are you working on, Jow Forums?

Last thread:

Attached: 1486137983812.png (853x621, 56K)

Other urls found in this thread:

dl.suckless.org/slcon/2013/slcon-2013-4-nsz-the_costs_of_abstraction.webm
adventofcode.com/2018/day/13
adventofcode.com/2018/day/15
yanniss.github.io/117-15/oopsla01.pdf
twitter.com/NSFWRedditVideo

nth for Nim!

Reminder that dynamic typing isn't actually real and static type systems are a superset of unityped type systems.

ummm McAfee keeps deleting my C .exe files as soon as soon as I tried to run them

turn it off?

gib babby programming challenges/tasks plox

Attached: 22m_84945859f14aec137edda796faaa7431.jpg (1056x1080, 702K)

maybe your C compiler is infected and produces malware
like Visual Studio was known to inject microsoft malware into EXE files (telemetry)

please stop replying to /sqt/ posts.

nah, just McAfee is being ultra chad protection mode today it being monday

well I was going to tell you what I was working on over the weekend but I wont now.

Attached: 1548020984592.jpg (401x500, 32K)

im currently learning c for understanding how some interesting things such as st ghc and *nix written
is it worth to learn see blus blus after?

Attached: jlxln7at6x911.jpg (750x578, 45K)

dumb frogposter

>is it worth to learn see blus blus after?
Learn LISP or Scheme before C++
The correct order is:
C, Scheme, C++

Reminder that C is the only serious programming language.
dl.suckless.org/slcon/2013/slcon-2013-4-nsz-the_costs_of_abstraction.webm

Attached: 1526965794262.jpg (2248x4000, 657K)

Is float actually faster than double on modern x86 CPUs?

*segfaults*

True. Such languages actually have untyped variables. The Ruby man page is clear on that.
FEATURES
Ruby's features are as follows:

Interpretive
Ruby is an interpreted language, so you don't have to recompile programs written in Ruby to exe‐
cute them.

Variables have no type (dynamic typing)
Variables in Ruby can contain data of any type. You don't have to worry about variable typing.
Consequently, it has a weaker compile time check.

Why do Suckass fags preach about minimalism, yet use X?

Yes, quite noticeably. Being smaller, vector instructions can "fit" more individual numbers in a single instruction.Try and see for yourself.

if you're doing operations on multiple floats at a time

C++ is a badly designed language. Learn it too early and it'll tarnish your ideas of good programming language design.

Computer science is the study of abstraction.

wrong

fuck off you disgusting piece of shit

why do you care about Suckass being not minimal?

this

Don't tell that to Ctards.

>C
>not abstract

Ctards believe their language is somehow low level and does not abstract anything.

I want her to pee on me

die

Ctards don't know a thing about compilers, abstractions, or programming languages.

I will, after she pees on me. Though not immediately, I will take my precious time to bask in the glory of course.

I'm pretty new to programming and I just learned about OOP, like classes. I'm having a hard time with it because I don't see much value in using classes yet. Outside of the braindead simple printing examples in tutorials and such, I don't see anywhere where I would want to use classes.
This is a bit strange because with basically everything else I've learned I've been able to figure out many places to use them, but with classes I just have absolutely no idea.

just use them like structs desu, fuck OOP

Encapsulation is good. Having a clearly defined interface to something makes it easier to use correctly.
Try to avoid class inheritance. On the other hand, use interface inheritance a lot.

C is great for learning all 3 of those

Ironically, Ctards still don't know anything about them.

I am pretty damn useless at my job, but everyone likes me, so lots of my wrongdoings or slackening goes magically unnoticed.
Should I have gone for manager, instead of developer?

It's probably because you haven't programmed something complex enough that makes OOP actually useful. Check out this challenge from last year's advent of code. adventofcode.com/2018/day/13

The problem is that you have a bunch of carts on a big map and you're asked to move them around and see what happens. All the carts move using the exact same logic, so it makes sense to use OOP to make a cart object.

It simplifies things because now you're just keeping track of abstracted "cart objects". The movement logic is all handled internally by these objects and you don't have to really keep track of it. Instead you can focus on what you really want to track which is where collisions are taking place.

There's a follow up challenge to this which operates similar but adds a lot more complexity and rules to follow. adventofcode.com/2018/day/15
You need someway to abstract out the complexities of these objects so that they're just an "object" that operates internally.

I've been trying to think about a way to do a Markov Chain simulation (polymerisation example in last thread) using matrices instead of if statements. Can't figure out how I would go about this. Was thinking about generating random matrices and using these as the steps. Seems like it would be faster in terms of being able to be more parralel.
>any ideas Jow Forumsmen?

>Try to avoid class inheritance. On the other hand, use interface inheritance a lot.
class inheritance is faster than interface inheritance

yanniss.github.io/117-15/oopsla01.pdf

Management involves going to a lot of meetings and conforming to gant charts. Better to stay a rich developer with less things to worry about when you go home.

Why wouldn't you just use some basic data structure to hold records of carts and then update the structure using pure functions? I don't see how using OOP semantics adds anything here

singly inherited methods dont need to be virtual
multiply inherited methods always do

If you update something, the function is not pure.

That was a bad choice of words, obviously the root variable containing the data needs to be mutated, and using pure functions wasn't even central to the point I was trying to make, use them where it makes sense.

OP here, thanks.

because OOP grants you the power of polymorphism by overriding methods

existentials and closures are at least as powerful while being simpler and more basic

hmmmm

Attached: kk.png (699x701, 269K)

Yuck, it works but I really wish generics were handled better in mainstream languages. Interfaces is ok but something like typeclasses would make more sense so that you wouldn't need to shove any functions into your records if you don't wish to.

no idea what an existenial is
closures aren't really simpler
people seem to have a hate-boner for OOP and act like other methods of polymorphism are superior when they all do basically the same thing

typeclasses are the same shit except you write your code in a different place

Yep, not much difference in practice but like I said they're just nicer(tm)

Hello, can you recommend me a book about writing drivers in Windows?

sounds like baby duck syndrome to me

An existential lets you hide some type information. There's a more restricted version of this in Java using ?. I could go into more detail but existentials aren't strictly necessary (though they're quite useful). Basically all you want in this case is something like std::function. Now you could implement that using void*, or using OOP virtual methods, or using existentials. Or you could have it as a language feature.
Closures are very simple, it's just a function. It's one of these "basic" building blocks like a struct or a union.
The problem with OOP is it combines all of these things with its notion of object and internal logic, when this isn't necessary.

is there no point anymore in learning C to do actual noticeable projects?
does anyone even makes desktop software or everything became web app except for few big softwares like photoshop etc.

Huh? Having a preference is baby duck?

"People write this ugly pointers-and-array kind of code which they then think is more efficient. It often isn't."

Attached: bjarne-bldl-opening.jpg (897x429, 52K)

Of course anything that can be programmed using OOP principles can also be programmed without using them. It's just a matter of style and readability. Personally I like that all the methods of an object are all in one spot or at least easy enough to find. If you're doing everything just with functions, data in, data out, it can be more difficult to keep track of.

cart.tick() seems pretty straightforward. You can tell cart is an object and you're calling it's tick method. There's nothing else it could be.

tick(cart) is more ambiguous. "cart" can be anything. Is it a boolean? string? struct? How can you be sure you're giving tick() the right data in the right format? Especially if you don't write the program yourself.

And if you're using an IDE typing "cart." should pop up a list of suggested methods and properties, whereas typing tick( will probably just give the declaration "tick(cart)" which isn't as helpful.

Again it all comes down to preference really.

a closure is a function with an attached context

Yeah, I know.

>tick(cart) is more ambiguous. "cart" can be anything. Is it a boolean? string? struct? How can you be sure you're giving tick() the right data in the right format? Especially if you don't write the program yourself.
that's what a type system is for dumbass

Noted.

Your words are empty, this is either a provocation, or your terrible nonsense, fucking degradant.

Attached: иван.jpg (480x360, 21K)

We have zero-costed abstractions. (Your words are empty, this is either a provocation, or your terrible nonsense, fucking degradant.)

It's nice to know a bit of C to get an idea of what programming was like before languages came with abstract data structures by default and before you could just import 90% of your project. C is just a bit too cumbersome to actually use as a daily programming language since more modern languages can accomplish the same thing with much shorter and more readable code.

Lots of desktop apps are created, especially if you're into using open-source software. If you're into proprietary stuff then yeah most have switched to web apps since you can't pirate those.

Attached: C grugs.png (1200x699, 345K)

Not every language has a robust type system that will warn you that you're mixing types at compile time (if there even is a compile time). Many languages will allow you to program something that obviously won't work and will then only crash during run-time when you attempt to do it.

desktop applications still exist
mainly video games

>Not every language has a robust type system that will warn you that you're mixing types at compile time
any statically typed language will tell you when you're calling a method that object doesn't have and you the programmer will know that ahead of time because you know what type something is
where the fuck do people like you even come from
are you another Haskell and JavaScript programmer expert

He means that free functions won't warn you about this sort of thing but methods will.

all functions will
in a statically typed language
which is most OOP languages
why are you even talking about this if you've never used one

>equating static typing with pOOP
>bragging about using pOOP languages as if it's an accomplishment
My sides

Stay uneducated m8

>only open source and video games
my god, javascript and the internet will be the end of it all

The discussion is about OOP you stupid fuck
The big OOP languages are statically typed

The "big" languages you're probably referring to are also all-around terrible.

Smalltalk is dynamically typed.
Python is dynamically typed.
Ruby is dynamically typed.

there's probably alot of boring business software programmed in C++ if that's what you perfer
big desktop applications are all C++ too

apples and oranges
if you use dynamically typed scripting languages then that's what you're gonna get

C++

char *temp = (char*)"abc";

struct->voidp = &temp;

// Later

char* temp = (char*)struct->voidp;

Can someone tell me what I'm doing wrong here? Garbage is printed

>C is just a bit too cumbersome to actually use as a daily programming language
I dont agree.
even C elites expect 90% of the job to be library or API written by someone else.
That is simply wanting to shoot yourself in the ass.
With C if you want something to work you have to write it yourself and that a task nobody wants to do.

There's no practical reason to use C over C++

All of those are prime examples of pOOP. Also what are you using the term "scripting language" for?

I dont know,I use it because I have the time to use it and i cant be bothered to learn a new language.

You're casting it to a char* not a char** (which is the type of &temp).

Also, if &temp is a local variable it may be going out of scope.

You probably just want to do struct->voidp = "abc"

I can respect that people who are paranoid about implicit memory allocation (kernel/firmware developers) choose to use C where things have to be spelled out.

The difference in ergonomics between the languages is palpable though. I don't know how long I would last if I had to go back to C.

you're setting char* temp to a double pointer.
replace struct->voidp = &temp; with struct->voidp = temp;
also for the love of god don't use void pointers in C++. they break type safety and they're much slower for generic functions

OOP doesn't make as much sense in dynamically typed languages for the reasons already pointed out
The "prime examples" of OOP are Java and C++
if scripting langs are using OOP that's their mistake, not OOPs

>OOP doesn't make as much sense in Smalltalk

Attached: confused-sakura.gif (260x200, 61K)

>is there no point anymore in learning C to do actual noticeable projects?
no

>dissing the father of OOP and shilling Java
You're a lost cause, quite frankly

Also, OOP doesn't make much sense in any language.

What is OOP and why is it bad

afaik OOP in Smalltalk pretty different to the ubiquitious version of OOP implemented in Java and C++
I'm not shilling Java, I'm saying it's popular

It helps nothing and gives the programmer useless busywork over just using functions and data structures like a normal person.

i seriously wonder if it's just the same people arguing about oop for years or if there's a steady flow of people that are new to the thread that discuss oop once they're comfortable and then never again.
seriously, almost every single thread over the past five years or something has discussed the same garbage; oop, c, haskell, dynamic typing, etc.
i haven't visited this thread in years and literally nothing changed

haskelltards are definitely the same people