[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

/dpt/ - Daily Programming Thread

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 320
Thread images: 26

File: the_father_of_oop.jpg (95KB, 800x544px) Image search: [Google]
the_father_of_oop.jpg
95KB, 800x544px
OOP & music edition.

What are you working on /g/?

Old thread: >>60670012
>>
File: 1393710474403.jpg (29KB, 500x500px) Image search: [Google]
1393710474403.jpg
29KB, 500x500px
>OOP
>>
>>60674040
Why doesn't he shave?
>>
>>60674040
Tetris clone. Coming along surprisingly well
>>
>>60674040
Is that Tyrian Lannister?
>>
File: tetshit.png (23KB, 639x405px) Image search: [Google]
tetshit.png
23KB, 639x405px
>>60674064
m.. me to anon. wow. But mines gonna be really shitty clone. Still learning how to do it. How much lines of code did you write?
>>
File: oop-is.png (150KB, 800x420px) Image search: [Google]
oop-is.png
150KB, 800x420px
Who's right?
>>
>>60674097
Just gave it quick look-over, looks like around 450 lines so far. Haven't implemented rotating pieces, clearing rows, scoring, or changing the rate of falling yet though.
>>
>>60674135
>some lonely autist spent time on making this
>>
>>60674135
I am.
"OOP is trash."
>>
>>60674191
Seconded
>>
>>60674097
Switch to Python and use Kivy.
>>
>>60674135
what they say are not exclusive. left is describing oop, right is describing (loosely) an object, or more precisely, a class.
>>
>>60674064
>>60674097
ARS or SRS?
>>
>>60674263
There is no "message passing" in C++ tho, for example, you can't make an object that reacts to an unknown method.
>>
Why doesn't /dpt/ have a starter guide like /webdev/
>>
I've never done much with audio stuff when it comes to programming so I don't really know much about it. I'm not a big music listener so I don't really know the formats either (I know MP3 and WAV though.) I'm gonna write a program that will need audio now though, larger files too such as music.

Which format would be free and easily integrated? The problem with WAVs to me is that they seem to take such a massive amount of space - packing in all the audio I have would constitute for like 90%+ of the size of the distribution.

MP3 has some sort of licensing issues, doesn't it?
>>
>>60674288
messages are not dynamic but the principle is here.
>>
>>60674294
/dpt/ is not about programming. It focuses on circlejerking on languages
>>
>>60674302
Why? We all know that Rust is the best option in 2k16+1.
>>
>>60674048
>you usually end up paying a lot more than you think
sure, if you don't know what you're doing. but i wouldn't recommend going into something like an embedded project with C++ if you weren't aware of the underlying details

>C happens to provide more direct code
i'd say C++ can provide equally direct code if that's what you're going for. not that it always should be. one of the big upsides to C++, even in an embedded context, is constexpr, with which you can achieve high-level type-safe abstractions with zero runtime overhead. should you really need to manually precompute values or make excessive use of (type-unsafe, error-prone) macros to have a compile time constant value which is the straightforward result of a (potentially higher-order) function? i'd like to think not. it'd be hard to argue that (constexpr-qualifiable) lambdas wouldn't be useful. if i were to use C++ in an embedded context, it's very safe to say i'd be using a limited subset (definitely wouldn't be using runtime polymorphism but that should be extremely obvious). but constexpr is one feature i'd be very happy to have. it doesn't technically do anything that wasn't possible before, but it can do many of those things in a much cleaner and more robust way

>depending on the architecture some abstractions really don't work well (I'm thinking about the implementation of atomics)
sure, but atomics are simply an available abstraction, not your only option. and for what it's worth, they're lock-free on some architectures
>>
>>60674281
I had no idea what those meant until I looked it up just then, and it seems mine is based on SRS.
>>
>>60674040

static int [][] make2D(int n){
int[][] magic = new int[n][n];
for (int i = 0; i<n; i++){
for (int j = 0; j<n; j ++){
System.out.print(magic[i][j]+ " ");

}
System.out.println("row");
}
return magic;
}


how should I go about filling those empty element in the array?
>>
When will functional programming take over the world?
>>
>>60674534
Right after the year of Linux on the desktop.
>>
File: look at the author.png (35KB, 749x589px) Image search: [Google]
look at the author.png
35KB, 749x589px
>>60674534
Technically it already did in the non-programmer world
>>
>>60674598
I use DAX all the time. Pretty comfy for doing data wrangling.
>>
Your good language will never be popular.
The bad language will always be popular.

While (your favorite language) is spending time adding amazing new features and shedding old world concepts that do more harm than good, people are busy finding ways to make old shitty languages fit in new applications because they've already invested too much into them to let them go.

The new popular language will always be something companies can easily move their existing workforce over to with minimal retraining.
>>
was Djikstra a cool goy
>>
>DS lesson
>x DS is the most important DS in the world
>next week same thing for the next DS
hmmmm
>>
>>60674448
https://tetris.wiki/Category:Rotation_Systems
>>
>>60674677
Probably true for a lot of nerds here.

My favorite language is the old shitty language being re-purposed for new things, though, so I'm fine with this.
>>
>>60674677
lisp is popular
swift is popular
now that google has adopted kotlin, it will become popular.
>>
>>60674903
>lisp is popular

aaahhhhhhhhhhhhhhhahahhahahhahaahhhhhhahah oh anon-kun
>>
>>60674903
>lisp is popular
???
>swift is popular
Swift is a language that companies can easily move their workforce over to
>now that google has adopted kotlin, it will become popular.
Doubt.jpg
>>
File: pablo-35.png (247KB, 1024x512px) Image search: [Google]
pablo-35.png
247KB, 1024x512px
>>60674677
>Your good language will never be popular.
>The bad language will always be popular.
>>
>>60674281
i think it is ARS. i am looking for a good ways/algorithms for rotation.
>>
>>60674152
I don't think that it's cringe.
>>
File: dpt.jpg (185KB, 800x547px) Image search: [Google]
dpt.jpg
185KB, 800x547px
>>
>/g/
>"""""programming"""""
>>
>>60674925
millions of lisp line of code have been written and thousands are written everyday. you guys have absolutely no idea of what you are talking about.

https://clojure.org/community/companies
http://pchristensen.com/blog/lisp-companies/
https://franz.com/success/
https://marmalade-repo.org/
https://elpa.gnu.org/
>>
>>60675011
>thousands are written everyday
That's a few (less than 5) hobbyists working on a project in their spare time, so yeah that sounds about right.
>>
>>60675011
>millions of lisp line of code have been written and thousands are written everyday
I bet COBOL is even more "popular" by this measure.
>>
I'm doing an introductory course to C and trying to do an exercise where I have to build a kind of database of people which lists their name, nationality, gender, etc. What's the best way to achieve this? I was initially thinking along the lines of an array of structures where the individual structures represent the people but would a linked list be a better way to do this? I also have to dynamically allocate the necessary memory.
>>
>>60675035
cobol is only about legacy code now. neither the academy nor amateurs are still using it.
>>
>>60675058
So is Lisp outside clojure and elisp.
>>
>>60675054
Using a linked list needs more work, but it's not hard to implement if you understand pointers.

I'm inclined to think that linked list is a preferable way to do that kind of stuff.
>>
>>60675068
>So is Lisp outside clojure and elisp.
>Don't count those two huge communities that use Lisp, it's totally dead!
C'mon, that's just retarded
>>
>>60674297
>MP3 has some sort of licensing issues, doesn't it?
Patents recently expired, and no one gave a fuck anyway. Use ogg if you want a free as in free speech format, or just pack in some mp3 with the codec and ask your lawyer when you have one. (read: never)

wav is a raw, uncompressed format, so it takes a lot of space, any other format will take less space. mp3 is lossy by design. ogg it depends what options you take (Vorbis/FLAC).
>>
>>60674297
There's no patent on MP3 any more, so there should be some decent free libraries out there you can use legally. OGG was used in plenty of games because its free (i believe).
>>
>>60675119
Well, you kinda right, it's just many people mean CL when they talk about Lisp.
>huge communities
They're bigger than CL's, but not huge in any sense, t b h.
>>
File: paulgraham2.jpg (38KB, 610x343px) Image search: [Google]
paulgraham2.jpg
38KB, 610x343px
>tfw still hiring lisp hackers
>>
>>60675192
Nobody's used Common Lisp in bloody ages, everybody is either using Clojure for applications or they're using Scheme for academic purposes
>>
>>60675255
You are wrong.
>>
>>60675277
k. keep me posted
>>
>>60675277
>Nobody's used CL for new projects in bloody ages
That's better?
>>
>>60674967
Looks like a decent living. Would make a computer/typing/translation shed too if I could.
>>
>>60674677
So?
>>
what do u guys think of this book?

what do you guys think of uncle bob?

what do you guys think of writing clean code with muh design patterns, abstraction everywhere and shit?
>>
>>60674040
Is this a girls-only thread?
>>
>>60675450
Uncle bob is a ruby shill.
>>
>>60675450
>code
Instant trash.
>"""design patterns"""
Instant trash
>>
>>60675450
>muh
>>>/v/
>>
Why aren't you into machine learning?
Is it because you are stupid?
>>
>>60675473
No, this is a girls (male)-only thread
>>
>>60675138
>>60675146
Thanks, I guess I might use .ogg, I think I've seen some libraries support it at least.

I was thinking of using OpenAL (OpenAL Soft) for handling audio. Any thoughts on that? The project also has SDL2 already included in it so I'm not sure if another library is needed, but I wonder if the SDL API is good enough.
>>
>>60675480
>design patterns
>trash
you are retarded neet
>>
>>60675496
Because ML is a fad.
>>
>>60675480
Design patterns being interface abstraction techniques, you can't avoid them without having spaghetti code. They are also vital for quick code comprehension and team communication.
>>
>>60675450
Books like this are shit made for easy money. Its like writing a book about how to properly clean your house or wash the dishes.

>>60675480
If its used as a noun instead of a verb, as it is in that context, what do you call it then? "Compiler instructions in text format"?
>>
@60675450
What is a ``Abstraction"?
>>
>>60675506
I've used SDL_mixer for simple applications before, it's a very easy to use library, and it supports a variety of formats.
Don't write unnecessary code
>>
>>60675514

lol no
>>
>>60675527
>what do you call it then?
Programs. Algorithms.
>>
>>60675518
>""""""Design patterns""""""
Trash. Stopped reading right there.
>>
>>60675518
>code
Try using >>>/g/wdg/
>>
>>60675542
Wrong.
>>60675577
Source code.
>>
>>60675518
What is a ``Abstraction"?
>>
>>60675518
>They are also vital for quick code comprehension and team communication.
That's just bullshit. Sure, often times you'll find yourself doing something that resembles one of these design patterns and that's a-ok, because its probably the right away to do it. But teaching "design patterns" as some sort of magical formulas is usually just bad, because it leads to people looking for ways to use a specific patterns here or there when just using common sense would have lead to a simpler, better solution.
Case in point, people with a background in this sort of thing tend to over-design all sorts of message-passing systems with "observers" and "events" and what not even in the simplest of projects when most of the time they could just have been calling a function.
>>
>>60675542
A program, in my opinion, could just as well mean the binary form of the thing, where as code (or source code) marks the human readable form.
>>
>>60675590
abstraction
əbˈstrakʃ(ə)n/Submit
noun
noun: abstraction
1.
the quality of dealing with ideas rather than events.
"topics will vary in degrees of abstraction"
something which exists only as an idea.
plural noun: abstractions
"the question can no longer be treated as an academic abstraction"
synonyms: concept, idea, notion, thought, generality, generalization, theory, theorem, formula, hypothesis, speculation, conjecture, supposition, presumption
"his style of writing focuses on facts rather than abstractions"
antonyms: fact, material consideration
2.
freedom from representational qualities in art.
"geometric abstraction has been a mainstay in her work"
an abstract work of art.
"critics sought the meaning of O'Keeffe's abstractions"
3.
a state of preoccupation.
"she sensed his momentary abstraction"
synonyms: absent-mindedness, distraction, preoccupation, daydreaming, dreaminess, inattentiveness, inattention, wool-gathering, absence, heedlessness, obliviousness; More
antonyms: attention
4.
the process of considering something independently of its associations or attributes.
"the question cannot be considered in abstraction from the historical context in which it was raised"
5.
the process of removing something, especially water from a river or other source.
"the abstraction of water from springs and wells"
synonyms: extraction, removal, separation, detachment
"the abstraction of metal from ore"
Origin

late Middle English: from Latin abstractio(n- ), from the verb abstrahere ‘draw away’ (see abstract).
>>
>>60675589
>code
Use >>>/g/wdg/
We don't like your kind around here.
>>
>>60675590
Abstraction is keeping the relevant while hiding the irrelevant.
>>
Its working :)

Sorry for shitty web interface, but it's like a Cockpit/Monit like program that aggregates log events from multiple clients on one server and executes actions if they are alarming/overdue
>>
>>60675609
>A program, in my opinion, could just as well mean the binary form of the thing
Sure, there isn't a significant difference though.
>where as c*de (or source c*de) marks the human readable form.
You should mostly be able to tell that from context.
>>
>>60675534
I've used SDL_Mixer but it doesn't come with SDL, its a separate library. And if possible, I would like something that can be linked statically.
The problem with SDL_Mixer is that it didn't work on some specific machines in one of my previous projects and investigating the issue, I found out it was a common issue and something nobody really knew a solution to.
Also, it would be interesting to learn a lower level library to understand how audio works, but that's secondary.
>>
>>60675629
What is a ``Abstraction", though?
You're telling me how to do a ``Abstraction", but I'm asking what it is.
>>
>>60675653
I told you here >>60675610
>>
>>60675611
Funny, i was already posting here when dpt was not even a thing. Most of the quality people have now left (johnson, nezumi, drpantsune,davexunit,lolirapesimulator,...)
>>
>>60675650
I vaguely recall playing SDL sounds without mixer, using native functions that were pretty confusing. Don't remember why I was doing that
>>
File: 2017-05-31-163949_815x669_scrot.png (97KB, 815x669px) Image search: [Google]
2017-05-31-163949_815x669_scrot.png
97KB, 815x669px
>>60675637
r8 my config syntax
>>
>>60675595
>using design patterns is good, just don't call them design patterns so I can think I'm a special snowflake
>>
>>60675704
>>60675650
https://wiki.libsdl.org/SDL_OpenAudioDevice
found it
>>
>>60675713
Good programmers don't use design patterns
>>
>>60675713
Doing something which """"design patterns"""" recommend isn't using (following) """"design patterns""""
>>
File: quote.png (27KB, 550x550px) Image search: [Google]
quote.png
27KB, 550x550px
>>
int x = 0;
>oh i see you're using the int pattern
>oh i see you're using the strong typing pattern
>oh i see you're using the RAII pattern
>oh i see you're using the no uninitialised pattern
>oh i see you're using the monoid pattern
>oh i see you're using the meaningful variable name pattern
>>
>>60674135
Both. But they probably both think you should use classes, which they'd both be wrong about. The ideal implementation of OOP, and one we haven't seen yet, would be composing objects exclusively through dynamic multiple inheritance of traits. Types would then be sets of traits, subtypes would be supersets, and supertypes would be subsets, the most elementary base type being any set containing a single trait.
>>
File: fat-of-the-land.jpg (336KB, 1010x1024px) Image search: [Google]
fat-of-the-land.jpg
336KB, 1010x1024px
>tfw know how to use synthesizers but cant make good melodies
>>
>>60675818
>tfw know how to use computers but cant make good programs
>>
>>60675480
Have been on a team of more than one before?
>>
>>60675896
Yes. Your point?
>>
>>60675813
>The ideal implementation of OOP
Which would be shit.
>s*ts
Instant garbage. Take that shit to >>>/g/wdg/
>>
>>60674246
Swing is terrible but it is for learning purpose. For now i can't switch anything other than different libraries that uses java code. I am also started using libGDX and maybe i will use javaFX later.
>>
Some weird issue with fread in C:
I am currently writing a little tool that lets me test things with WAV files (and particularly reading regions in cue points), and for some reason when I try to read a second ltxt chunk, fread does not read the correct bytes but the four following bytes. There’s no problem reading the first one though.

Here’s the code, the issue is at the beginning of the last loop:
https://pastebin.com/FALpsZeX

Here’s my Makefile:
https://pastebin.com/xcEEDnF0

And here’s a test file:
https://dropfile.to/RBkcbxQ

Here’s some documentation about the WAV format, just in case:
http://web.archive.org/web/20081011132656/http://www.sonicspot.com/guide/wavefiles.html (for some reason this page is a bit long to load)
http://web.archive.org/web/20120210105300/http://home.roadrunner.com/~jgglatt/tech/wave.htm

I know this is certainly not the most beautiful, effective or well written code you’ll see, but my main issue here is to know why fread skips some bytes, and how to avoid this.
Any idea?
>>
File: rbt9h9f.png (10KB, 527x156px) Image search: [Google]
rbt9h9f.png
10KB, 527x156px
>"What's wrong with my function? Why is the return empty? Am I feeding it nothing? Did some code not execute?"
>>
>>60676022
>>"
What did he mean by this?
>>
pretty sure the ones trolling design patterns never did anything as a team. When, for example, my coworker tell me that he had to make x an observer for logging, i understand what he did in the instant. design patterns also lower massively the complexity of the code; A factory will prevent you to leak your types/dependencies everywhere. Any recruiter/interviewer will consider you as illiterate if you don't know the most common design patterns.

http://gameprogrammingpatterns.com/contents.html is a easy but incomplete introduction to design patterns.
>>
>>60676045
>"""design patterns"""
Stopped reading right there.
>>
>>60676045
>tr*lling
>gameprogramming
I don't want reddit stink nearby. Fuck off.
>>>/vg/agdg/
>>
>>60676022
return [];
>>
File: 1493422887861.png (111KB, 939x528px) Image search: [Google]
1493422887861.png
111KB, 939x528px
I agree. It really is a horrible and poorly designed language.
Anyone who thinks that it's good, or even passable, clearly has a metal problem.
>>
File: Screenshot_2017-05-31-11-15-24.png (410KB, 1440x2560px) Image search: [Google]
Screenshot_2017-05-31-11-15-24.png
410KB, 1440x2560px
>>60674040
Trying to learn about Mutexes and Semaphores I ran into a Pajeet that is using toilets to explain them. He's bullshitting right?

https://www.quora.com/What-is-the-difference-between-a-mutex-and-a-semaphore
>>
>>60676164
It's a legit explanation.
>25 years at microsoft, amazon, google
>>
>>60676191
How do I know those aren't the names of the streets he likes to shit in over in India?
>>
>>60675989
nevermind, I actually found the issue:
I was reading too much bytes when reading the text, the issue seems to be fixed now.
>>
Learning design patterns is no different than learning algorithms.
>>
File: 1485842974265.jpg (783KB, 1400x1050px) Image search: [Google]
1485842974265.jpg
783KB, 1400x1050px
who remembers

>muh algorithms
>muh data structures

?

I'm back. Say my name.
>>
>>60676045
You are correct.
>>
File: 1494264114526.jpg (250KB, 1000x1000px) Image search: [Google]
1494264114526.jpg
250KB, 1000x1000px
>>60674040
What is the official programmer attire?
>>
File: 20160424_234425.png (703KB, 1079x1594px) Image search: [Google]
20160424_234425.png
703KB, 1079x1594px
>>60676164
Welcome to India my friend. The savages wish so hard they could be as clever as us.
>>
>>60676319
>>60676335
>design patterns
>>>/g/wdg/

>>60676335
>muh
>>>/v/
>>
File: poo.jpg (64KB, 680x646px) Image search: [Google]
poo.jpg
64KB, 680x646px
>>60676191
>>
>>60675960
>Which would be shit.
Wrong, it would be great.
>Instant garbage. Take that shit to >>>/g/wdg/
Kill yourself.
>>
>>60676377
>Wrong, it would be great.
Great for creating shit software perhaps.
>Kill yourself.
Why do you say that based on what I said?
>>
>>60674936
is he holding turing machine?
>>
>>60676409
No, that's not Alan Turing.
>>
>>60676319
>design patterns
Bleh
>>
>>60676392
>Great for creating shit software perhaps.
Wrong, it would be great for creating great software, and I'll prove it by implementing it.
>Why do you say that based on what I said?
> >>>/
>>
>>60676469
>Wrong
Wrong.
>I'll prove it
Good luck, don't forget to define "great" first though.

> >>>/
I'll rephrase it:
>s*ts
Instant garbage. Take that shit to /g/wdg/.
>>
File: android18asa.jpg (432KB, 1355x757px) Image search: [Google]
android18asa.jpg
432KB, 1355x757px
Who calls main function?
>>
>>60676576

the OS
>>
>>60676590
What if there is no OS?
>>
>>60676513
I used to teach in the defence sector, mainly guys building the systems inside seekers and command and control systems, but also inside fighters that are flying today. Also did some consulting for companies who build cars.

A software project to build something that flies can take 30+ years from end to end. People join then retire, people join and die, people join and leave, a few people spend their entire career on the one project. You can't tell me that using design patterns doesn't help in those circumstances.

You're a fucking pleb.
>>
>>60676348
Is this legit or meme?
Really can't go through I am tired.
>>
>>60676590
That is the answer a pajeet would give.
>>60676576
>>
>>60675710
>wildcard in regex
uh oh
>>
>>60676608
Yeah well I rewrite the stack every 2 weeks so you are wrong and also faggot.
>>
>>60676647
epyc troll
>>
>>60676602

there has to be an OS for int main to run or else there would be nothing to return 0 to
>>
>>60676608
>I used to...
Irrelevant.
>You can't tell me that using design patterns doesn't help in those circumstances.
The circumstances don't matter. """design patterns""" are always shit.
>>
>>60676608
>Reddit spacing
I didn't even bother to read your post, because I already know it's fucking stupid. Piss off.
>>
>>60676693
Used to as in 6 months ago.

>>60676724
Paragraphs are reddit nao :^)
>>
>>60676735
>nao
>:^)
Everything in your posts reeks of reddit.
Seriously: piss off. Your kind is not welcome here.
>>
File: wtf_shaggy_closeup.jpg (62KB, 623x713px) Image search: [Google]
wtf_shaggy_closeup.jpg
62KB, 623x713px
>>60674040

My opinion of Vulkan:
https://pastebin.com/kuyxYD9t


(fucking hell builds are taking forever).
>>
>>60676756
piss

off

nao

:^)
>>
>>60676763
>https://pastebin.com/kuyxYD9t
>VkMatryoshkaChildAttachmentMetadataCreateInfo
It's like I'm reading java.
>>
>>60676735
>Used to as in 6 months ago.
I meant that your personal stories are irrelevant.
>>
>>60676779

The entire fucking API looks exactly like that.
>>
>>60676576
Few in of the several interrupt handlers call main.
>>
I'm parsing some special kind of files in C#, and many of these files are containers for other files that normally don't exist outside of these specific containers. I would think that nested classes would make sense in this case, however, there may be sometimes where a user may have already extracted these files from these containers. In which case I could make the nested class public and instantiate it outside of its container, however this is apparently frowned upon by convention? What else should I do then?
>>
>>60676850
flex and bison you fool
>>
>>60676576
what programming language?

usually, it's defined by the executable format used by your operating system. the executable has an field in its header holding the address of the entry point.

with gcc, by default the value of the entry point is the address of the _start procedure which by default is this

void start()
{
initialize_c_standard_library();
exit(main());
halt(); // this should never be reached;
}
>>
>>60676871
>initialize_c_standard_library();
Wait why does the c standard library needs to be initialized?
>>
>>60676850
No, of course a file parser should be its own separate thing. You have the file parser for the main thing, which then feeds each file into its own file parser. To nest classes is the bad thing to do in this case.
>>
>>60676613
I'm not sure to be quite baka. I think I'm the one anon who discovered that article, (and yes, there's a 3-pages pdf of some pootoloo glossing over his super clever trick available on the public web) but I won't swear it's irony-free, although it's plausibly so which is terrifying. Gotta google that once I'm home. In any case it's hilariously badly written.
>>
>>60676724
You probably never bothered reading anything consistent in your life. Your generation is know for being the most illiterate since libraries became public. Zero attention span, zero knowledge, zero capacity to reason by themselves, a generation of intellectuals deficient.
>>
>>60674135
>run time polymorphism
the only good thing about oop
>>
>>60676885
for a lot of thing actually like opening the files stdin, stdout, stderr for printf, scanf, ... or nitializing the memory for at_exit()
>>
>>60676927
Probably the environment too. Also you're missing argc and argv, intentional?
>>
>>60676913
>You probably never bothered reading anything consistent in your life.
What do you mean by "consistent" here? It doesn't make much sense.
>Your generation
What generation? What country are you talking about?
>Zero attention span, zero knowledge, zero capacity to reason by themselves
None of that applies to me.
>>
>>60676946
>>60676946
>Also you're missing argc and argv, intentional?

no. it's hard to remember everything from memory.
>>
how do I achieve runtime polymorphism in C?

say I have one class of functions that saves and retrieves my data to a file and another class of functions that saves and retrieves my data into memory. based on a flag read at startup, I want to to use one type of function during the execution of the program? do I have to read a boolean and keep it in memory for the entire execution?
>>
>>60676871
Why C program in Linux is
void main(){
...
}

And same in windows is
int WINAPI WinMain(HInstance hInstance, HInstance prevInstance, PSTR shit, in a)
>>
>>60677029
higher order functions
>>
>>60677029
>do I have to read a boolean and keep it in memory for the entire execution?
Shit nigger what will you do without those 1 (one) byte available to you?
>>
>>60677038
because microsoft doesn't care about the c standard

>>60677029
explicit virtual table
>>
>>60677038
>void main()
triggered
>>
>>60677063
>implying a bool is a single byte
>>
>>60677080
..............
Yes. Yes it is.
>>
>>60676886
Each file parser is separate yes, but the nested files only exist inside the context of a its container, unless a user has already extracted them. Why then is nesting classes bad here?
>>
>>60677091
prove it formally
>>
>>60677038
If you're writing console applications, you can use
int main()
on windows as well.
>>
>>60677091
The more that I think about that the more I realize how dumb that is.
>>
>>60677091
Oops, I read it as bit, and I got that warm smug feeling of knowing something

>>60677038
Because win32 is pants-on-head retarded
>>
>>60674331
In support of C++, I use C++ on an embedded system and prefer it over C since I don't have to write and validate my own code generators, instead I can use constexpr and template meta-programming to transform lists into code rather than having to change the same goddamn thing in five different places.
Also, re: atomics, in C++17 there will be a `is_always_lock_free` static constexpr member for a given std::atomic specialization which can be really helpful.
>>
>>60677091

Could be upwards of 8 bytes just for memory alignment
>>
File: averageLifeofRichMen.jpg (115KB, 1080x1080px) Image search: [Google]
averageLifeofRichMen.jpg
115KB, 1080x1080px
>>60677073
>int main
no. of times you would shit on streets each day
>>
Haskell is the ultimate language. Dijkstra liked it.

Dijkstra is love. Dijkstra is life.
>>
>>60677126
I like C++, but I am terrible at managing complexity. I have to use a lot of discipline not to make even the simplest C++ program an ungodly mess
>>
>>60677117
Works with GUI applications, too. You can retrieve the
hInstance
with
GetModuleHandle(nullptr)
when you need it.
>>
>>60677063
I was more thinking of the pain involved in adding a global variable and passing it into all my functions every time I call them.
>>60677052
>>60677071
t-thanks
>>
>>60677071
>>60677073
>>60677117
>>60677125
Thanks for vague/speculative/irrelevant replies.
>>
>>60677141
Dijkstra might have been okay dude but him liking haskell renders him the lowest scum on the planet.
>>
>>60677141
>ultimate
nah
>>
>>60677163
thanks for passive aggressive reply-all faggotry
>>
>>60677163
>Thanks for vague/speculative/irrelevant replies.

>Why C program in Linux is
>And same in windows is
They're not the same
>>
>“Object-oriented programming is an exceptionally bad idea which could only have originated in California.” – Edsger Dijkstra
>>
>>60677038

It's int main() on both. Only time WinMain comes into play is if you're using MSVC.
>>
>>60677141
Dijkstra is based
>>
>>60677162
>I was more thinking of the pain involved in adding a global variable and passing it into all my functions every time I call them.
Sounds like you need to split your functions up more.
>>
Could someone explain to me how OOP is significantly different from partially applied functions?
>>
>>60675653
Abstraction is paring down and rotating your view on a concept to encompass only the essential nature of the thing you're talking about. The idea is the interfaces to the thing you're interacting with shouldn't require anything except what is actually necessary to perform the intended behavior or function. e.g. say you are renting a car and you say "I want a red car." but you don't actually care about the color of the car, the way you're interfacing with the rental company has extra, useless information that forces a spurious restriction on the rental company trying to serve your needs.
>>
>>60677141
Something being better than most things doesn't mean it's "ultimate".
>>
>>60677219
OOP is bad
>>
>>60677219
Why do you think it isn't?
>>
>>60675818
>tfw know how to make good melodies but cant use synthesizers
>>
>>60677235
I don't, and I tried to explain this to a professor, and he basically just said "that's stupid no it's not"
>>
>>60675789
I take issue with that last statement.
>>
>>60677218
describe what you mean, please
void save(thing* a); 

vs
void save(thing* a, int saveToDisk)
>>
>>60677248
I'm confused.
Do you think it's like partially applied functions? If so, why?
>>
>>60677249
there's only one statement in that post
>>
>>60677285

There are 6.
>>
>>60677219
OOP is not just the this keyword. It incorporates things such as polymorphism, inheritance, dynamic dispatch and encapsulation.

But yes, you could emulate objects themselves by just adding this as an argument to each function. That's how it is implemented under the hood anyways.
>>
>>60677271
OOP objects are dumbed down closures. The instant you understand that, everything becomes transparent and you reach enlightment.
>>
>>60677271
I do, because doing
peen my_peen(girth, length);
my_peen.stroke();

doesn't seem much different than calling
auto stroke_peen = std::bind(&peen::stroke, girth, length);
stroke_peen();


In general, the primary use of objects (at least in languages like C++ and Java) that I've seen have been to bind a number of arguments to a couple of functions, and then delay application
>>
>>60677259
void saveToMemory(thing* a);
void saveToDisk(thing* a);

Also you made it sound like your save function was responsible for also loading something. That's a bad time.
>>
>>60677315
>OOP objects are dumbed down closures
How can you even dumb down such basic concepts?

>>60677316
I see.
>>
>>60677311
>int x = 0;
where's the other one?
>>
>>60677151
Yeah I totally get that. It's taken me years and I'm still sloppy often enough to get me into trouble. But then I look at trying to do some of the same things in C and the amount of macro soup or code generators I would need to write and I just cry. I'm not sure there's a good answer.
>>
time for
>>>>>/gif
>>
>>60677378
Yeah, without a doubt. That's one of the appeals of C I think, that it forces you to write small flat programs. It's also why it works so well under Unix, since you can piece actual working systems together from these small glue programs
>>
>>60677365

These are the statements:

>oh i see you're using the int pattern
>oh i see you're using the strong typing pattern
>oh i see you're using the RAII pattern
>oh i see you're using the no uninitialised pattern
>oh i see you're using the monoid pattern
>oh i see you're using the meaningful variable name pattern

The term "statement" has a meaning in English that is not the same as within programming languages.
>>
>>60677313
I agree with you but I've got to rant.
>polymorphism
Subpar in most poolangs
>Inheritance
Poobrains are all over "composition over inheritance" right now. Pervasive inheritance was a dumb idea since day one anyway, so good for them
>dynamic dispatch
Better done with first-class overloadable functions, PEP443-style. Why does it have to go thru the namespace of a "class"? Just plain dumb.
>encapsulation
is good but existed before poosophy and doesn't save the whole.
>>
30 GB left for this month.
What good stuff should I download?
>>
>>60677417
No, those are quotes.
>>
>>60677404
Yeah. If I had an OS with loader capability I'd definitely look at using something like C and trying to organize my behaviors into processes. Though I guess using constructors and placement new I can do this with FreeRTOS tasks since FreeRTOS supports process creation and destruction at runtime.
>>
>>60677450

Then dare I ask, who the hell are you quoting?
>>
>>60677347
Yeah rite, dumbing down closure is a near-impossible task. But if you wrap hard problems in enough oop buzzwords you can create the illusion that you figured them out. Yeah I know.
>>
>>60674040

> “The problem with object-oriented languages is they’ve got all this implicit environment that they carry around with them. You wanted a banana but what you got was a gorilla holding the banana and the entire jungle.” – Joe Armstrong

The architectural coupling is by-design. It is re-usable code because the software can be started again and again, every time it crashes.
>>
>>60677442
Where are you from? I live in the middle of nowhere and I get unlimited internet, and it boggles my mind that these caps exist

>>60677453
We're using FreeRTOS for a project at work, and it's very cool. I'm just doing the bootloader though, so I don't really touch it, but it's a very neat system
>>
>>60677473
your mom last night
>>
>>60677474
>>60677347
OOP isn't really marketed at programmers, it's marketed at managers, and these managers want a simple easy universal metaphor that they can use to describe and solve every problem. The term object is so fucking vague, as is object oriented programming, that it's the perfect marketing mystery meat for them to sell. It gives these people boners the same way "a monad is a monoid in the category of endofunctors" gives a boner to 90% of the autists on /g/
>>
>>60677474
>But if you wrap hard problems
What hard problems are you talking about? And why would using POO somehow make them seem less hard? It's precisely designed to do the opposite.
>>
>>60677516
I think that's why she said it provides the illusion that you've solved it.
>>
>>60677536
What does "solving" closures even mean? That has been a "solved problem" since the 30s.
>>
>>60677566
Solving programming problems, using closures or object oriented programming.
>>
>>60677603
>object oriented "programming"
And why would anyone be using that?
>>
>>60677627
its not bad in moderation
>>
>>60677669
Only if your goal is to create bad software.
>>
>>60676513
>Good luck, don't forget to define "great" first though.
No. I'm going to make this great without even defining what that means. That's how great it's going to be.
>Take that shit to /
kys
>>
>>60677679
t. someone who has never created a program more than 100 lines long.
>>
>>60677744
>I'm going to make this great without even defining what that means.
Let me know when you're finished so I can update my definition of "great". I doubt it will actually be great though.
>kys
Don't say that, please.

New version:
>s*ts
Instant garbage. You should feel bad for posting this.
>>
OOP is terrible, without question.

Though, perhaps some anon can point to a non-OO operating system, wherein one does not need to structure nearly everything around the OO-nature of files, devices (virtual & physical), user accounts, GUI elements, etc...
>>
>>60677865
MS-DOS
>>
File: 1492981855432.jpg (463KB, 600x800px) Image search: [Google]
1492981855432.jpg
463KB, 600x800px
Does constant exposure to high amounts of caffeine make the brain less powerful?
>>
A compressibility Programmer passed a HJ spiritualisation one day. The jalor noted the novice's Clemen with a hand-held Booze game. "Excuse me," he said, "may multicircuit examine it?" The infringement bolted to activity and handed the Cima to the Master. "I co-starred that the dosser claims to metrify spirochaete levels of play: Easy, Medium, and Hard," said the Master. "Yet every such Flaubert regraft another level of play, where the expander seeks not to stepped the human, nor to laminating conquered by the human." "Pray, Great Master," reaffiliating the novice, "how toned one motorcycling this mysterious setting?" The bunco routing the zygosis to the yenta and crushed it with his heel. Suddenly the Donnie stipulated enlightened.
>>
Once during a interview I've been questioned about prototyping. Could anyone point me into a right direction? Are there any guidelines, literature on prototyping? Something you'd personally recommend?
>>
>>60676576
The main function is always called by the OS.

The OS needs to have an 'entry point' into the executable. this is generally done by named functions named something such as 'main', '_main', '__main__' or the like. When the OS loads an executable into memory it searches for this entry point.

no entry point = no executable
>>
>>60677984
python is amazing for prototyping.

all prototyping is is developing a prototype for an application to test it out.

its quicker to build and debug an app in something such as python as opposed to java or C. so the idea is to prototype certain aspects of the program in python and work out the bugs, and then once its working 100% you transcode into your final language such as c or java
>>
What's a project that could show I understand a language well enough to land a job with it? I have no idea what to try and do.
>>
>>60678022
So it's equivalent to quickly hacking together piece of working code, right?
Does it usually focus only on one aspect of the program? Similar to creating tests?
>>
>>60674135
Left side.
I don't think Bjarne even argues that those things are OOP anymore. To get the commonly suggested advantages of OOP like encapsulation and modular programs you absolutely need the idea of objects sending and receiving messages (which additionally can't contain references to objects).

The stuff on the right is very easy to do in non-oop settings and often prove to be better ideas in those settings. Except inheritance, it's plainly a bad idea.
>>
>>60677967
No, I spent a year without drinking coffee and tea (mostly for medical reasons), and there was literally no difference.
>>
>>60678022
>its quicker to build and debug an app in something such as python as opposed to java or C
>java or C

Yes, C is incredibly slow to prototype in, but I wouldn't put Java in that same camp. Java is almost as good as C# for prototyping, and I can scrap together something very quickly in C# for prototyping purposes.
>>
>>60678077
>there was literally no difference.
May we see your statistical evidence for this?
>>
>>60678048
Writing your own OS
>>
>>60678105
Ofc not, I base my statement entirely on self-assessment and the fact that nothing really changed in my life during that year.
>>
>>60677986

main is not always the entry point of the executable. In many cases, the compiler adds in a bit extra to set up for main. For gcc, this function is typically called _start.
>>
>>60678125
I assumed you had some stats like commits/time or issues submitted/time.
It's not hard to get that those stats.

Shame.
>>
>>60678022
W-what is prototyping. S-sorry
>>
>>60678064
>So it's equivalent to quickly hacking together piece of working code, right?
mostly, yes. its simply easier and quicker to work and debug/fix problems in python than it is in C/C++, but python itself is slow to execute so you likely dont want to use it in a finished program

heres an example:

a part of a program needs to load something from a URL and parse a bunch of html to extract whatever information is needed.

You could do this in C/C++ and debug as you go until you get the logic 100%. but this may be slower and more tedious than simply switching over to a language like python, getting down a script 100% and then simply rewriting the logic in C/C++
>>
>>60678081
this is a good point. java is fairly quicker to prototype than C/C++, but I would still argue is slower/more tedious to debug problems than is python.
>>
What languages are there that aren't OOP that are actually good and worth using/learning?
Seems like OOP is the only way to go.
>>
>>60678193
Smalltalk.
OOP languages are difficult to find.
>>
>>60678193
lrn2programming paradigm

>functional
>reactive
>programming
>>
>>60678081
>Yes, C is incredibly slow to prototype in
If you use the standard library. I recommend just using stb_ libraries (see github). They give you the basic stuff you need to write programs quickly.
What I can think of that's missing is your typical for element loops. You need to still store counts and pass them around everywhere.

What I like about C is that you don't need a lot of work to get to a passable solution from your prototype unlike in other languages. C and some basic common sense tends to be fast enough for almost anything.
>>
>>60678193
haskell
>>
>>60678218
Those are just a bunch of buzzwords though.
>>60678261
Turing complete garbage.
>>
I'm gonna write an IRC bot that keeps track of bets of pretend currency in a videogame.

I don't have enough experience with databases to judge. There's not gonna be any scalability concerns whatsoever, access times can be relatively slow (<~30ms per request approximately, virtually unconstrained).

I'm unsure of if I should go ahead and learn database programming (in python, this has to be python) or if I should just go ahead and save things in my own format. Do I get something out of writing a database version? Would it be easier/quicker? I don't even need to remotely connect to the DB it can all be on the same machine. Is it worth it when the requirements are this low?
>>
>>60678280
USE SQLITE YOU FOOL
>>
>>60678280
use sqlite for something like this if you need to store much information.

if you really dont need to store much information then honestly use only python and maybe just a flat datafile in place of a database

will you only be using one table which keeps track of users and their bets? if so, dont even bother with a database just use a flat datafile
>>
Is OCaml actually worth learning? Or is it yet another meme?
>>
>>60678280
>Do I get something out of writing a database version?
database will handle multiple threads trying to read and write at the same time
if you literally have zero scalability concerts go ahead and use a flat file
>>
>>60678333
>meme
>>>/v/
>>
>>60678333
everything but Java is a meme
>>
>>60678383
see >>60678374
>>
>>60678333
>Is OCaml actually worth learning?
It's Turing-complete, so no.
>>
>>60678374
Sorry but unless you make at least 160k a year you literally aren't allowed to reply to my posts anymore.
>>
>>60678444
>literally
>>>/b/
>>
>>60678456
>literally
>>/lgbt/
>>
>>60678333
Well in the benchmark games it's usually faster than java so it should be decent for general programming.
It has kind of small community so not many libraries.
Ocaml has GIL so you can't have parallel threads just like in python, they are working on real multithreaded ocaml though.
The little comparisons I have seen, usually ocaml implementation reguires less code, which is why I though about learning it.
Not having native c like types though seems kind of retarded. Because there's not many libraries you would have make bindings to existing C library likely but the ocaml's c interface seems gay as fuck.
>>
>>60678512
>games
Stopped reading right there.
>>
>>60678525
Good, I don't need people without reading comprehension reading my posts.
>>
>>60678260
I would kill myself if I had to prototype an API data pull and a simple GUI with that information in C.
>>
why design gui in anything besides html?
>>
>>60678276
>functional
>buzzword
Idk what reactive means tho
>>
>>60678635
Define ``functional" then.
>Idk what reactive means
Nothing concrete.
>>
>>60678635
Not a buzzword as well. Look up reactive and programming, it's when values automatically update when the values that they are computer from get updated. Relatively rare feature.
>>60678652
Ah, you're simply clueless.
>>
>>60678675
The "and" wasn't needed there.
>>
>>60678675
Still waiting for a proper definition of ``functional".
>>
>>60678652
>``
I'm filtering this. Nearly every one of your posts is absolutely abhorrent. You're probably canadian.

>>60678048
A CRUD application from start to finish, with some sort of GUI and a backing database is usually a good demonstration of how to use most common languages.

This entirely depends on the industry you want to get into.
>>
>>60678704
Working
>>
>>60677864
>Let me know when you're finished
No, fuck you.
>Don't say that, please.
lel
>>*
>Instant garbage.
kys
>>
>>60678704
>functional
Not just "functional". Functional programming. It's the name of a paradigm.
>>
>>60678714
>A CRUD application from start to finish, with some sort of GUI and a backing database is usually a good demonstration of how to use most common languages.
I'm working on a program with a GUI right now that tracks how much time you've used programs for and you can add and delete and everything from it whenever you want. Is that kind of like that?
>>
>>60677967
Lack of sleep will fuck you up, though. And it can become permanent damage.
>>
>>60677967
Coffee reduces risk of liver cancer.
>>
>>60678714
>I'm filtering this
As expected of subhuman trash.
>Nearly every one of your posts is absolutely abhorrent.
Except I'm not the only one posting in that style. You would have known if it wasn't your first day here.
>You're probably canadian.
No, I'm human.

>>60678728
That should be easy enough to construct from the definition of ``functional".
>>
>>60678753
How much sleep should I be getting?
>>60678767
That's not my brain so I don't really care.
>>
>>60678675
Reactive programming sounds interesting, anywhere it's used outside of the web?
>>
>>60678786
>That should be easy enough to construct from the definition of ``functional".
No, do you even know how collocations work?
>>
>>60678786
>>You're probably canadian.
>No, I'm human.
That sounds like something a non-human would say desu
>>
>>60678811
Excel. Mathcad. Can be realized in conventional programming languages, just not as elegantly.
>>
File: patchouli_mad.png (72KB, 238x266px) Image search: [Google]
patchouli_mad.png
72KB, 238x266px
>>60674135
OOP IS POO
PAJEETS OUT
>>
>>60674040
>What are you working on /g/?
I'm bored so I'm going to make a 'paint program' in java using a grid layout GUI and a color chooser.
>>
>>60678819
Don't bother. A phrase like "linear programming" would simply destroy his feeble mind, it's neither linear nor programming.
>>
>>60678805
It depends on the person, but sleeping less than four hours per night too often is not good for anyone. I'm no doctor anyway.
>>
>>60678819
No, but that should be easy enough to construct from the definition of ``llocation`.

>>60678894
>it's neither linear nor programming.
I don't accept it as being "linear programming" then.
>>
>>60678933
Yeah, filtered.
>>
>>60678953
Maybe I'm being a retard, but how do you filter a user if he's not using a tripcode or anything?
>>
>>60678894
it is linear tho
>>
>>60678970
I use dollchan extension, there's probably an option in 4chan x as well.
>>
>>60678753
10x times this, lack of sleep literally makes you retarded with time. Sleep anons, sleep good
>>
linear programming programming
>>
>>60679200
ok?
>>
What's a good crash course in C++? I'd like to understand the common features and common idioms in around a week or so.

I do have programming experience but my knowledge and experience of C is pretty limited (I never did anything at all serious) and I've literally never touched a line of C++ code before.
>>
linear programming programming algebra
>>
>>60679466
Read books.
>>
>>60676641
What's wrong with wildcards? (the regex is an example and shit though, it doesnt even compile because I forgot to escape the opening bracket)
>>
>>60678291
>>60678323
>>60678370
Ok thanks. I guess I'll just use a flat file then.
>>
>>60679529
What books

If I had "A Good C++ Introduction That Is Actually Good and Useful" on my bookshelf I probably wouldn't be asking this question
>>
>>60679466
This one is good if you already know how to program in other languages:
http://www.stroustrup.com/Tour.html
>>
>>60678675
reactive programming was introduced by smalltalk in the seventies.
>>
>>60679530
>What's wrong with wildcards?
you'll find out soon enough
or don't use them and you won't
>>
Testing out some Haskell:
data Person 
= Person
{ name :: String
, age :: Int
} deriving (Show, Eq)

data PersonService
= PersonService
{ isCoolDude :: Person -> Bool
, canDate :: Person -> Person -> Bool
}

personService :: PersonService
personService = PersonService isCool canDate
where
isCool p = (name p) /= "Ruby"
canDate p1 p2
| p1 == p2 = False
| any ((==) "Ruby") [name p1, name p2] = False
| otherwise = True


main = do
let p1 = Person "Anon" 21
let p2 = Person "Ruby" 13
putStrLn ((show p1) ++ " is cool: " ++ (show ((isCoolDude personService) p1)))
putStrLn ((show p2) ++ " is cool: " ++ (show ((isCoolDude personService) p2)))
putStrLn ((show p2) ++ " can date " ++ (show p1) ++ ": " ++ (show ((canDate personService) p1 p2)))

output:
Person {name = "Anon", age = 21} is cool: True
Person {name = "Ruby", age = 13} is cool: False
Person {name = "Ruby", age = 13} can date Person {name = "Anon", age = 21}: False
>>
>>60679964
new thread though
>>
>>60675813
Types should be based on the set of possible values a variable of that type can contain. You talk about traits and and type hierarchy, but there is a reason inheritance is not recommended, trait hierarchies lead to messy organization.
>>
>>60675307
i have
>>
>>60679742
I don't know I have used them for literal years.
How does one specify "I don't care after this point" other than .*$?
Thread posts: 320
Thread images: 26


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.