[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
/dpt/ - Daily Programming Thread
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 255
Thread images: 34
File: 1462186280080.png (755 KB, 939x603) Image search: [Google]
1462186280080.png
755 KB, 939x603
Previous thread: >>54334087

What are you working on, /g/?
>>
File: smug_anime_face.jpg (39 KB, 724x720) Image search: [Google]
smug_anime_face.jpg
39 KB, 724x720
>>54339493
First for C.
>>
Second for C
>>
File: 1420229460495.png (300 KB, 485x354) Image search: [Google]
1420229460495.png
300 KB, 485x354
https://www.youtube.com/watch?v=QM1iUe6IofM

Daily reminder that OOP is shit.
>>
Can't spell oops without OOP
>>
>>54339557
Can't spell you are gay without you.
>>
Rust best language
>>
Java
>>
>>54339600
>https://www.rust-lang.org/conduct.html
rust gayest language
>>
>>54339493
He actually posted a shot of his nude passed-out self?

wow.
>>
people still posting in old thread lol
>>
>>54339635
They're having a shitstorm going on. Good times.
>>
File: C o C.png (6 KB, 505x74) Image search: [Google]
C o C.png
6 KB, 505x74
>>54339628
threadly reminder
>>
>>54339628
Thankfully the coc only applies to mozilla-controlled shariah zones. If you look at most rust projects (not all though admittedly) they distance themselves from that shit.
>>
>>54339629
>I woke up at the hospital and the doc had a great sense of humor which really helped. I vaguely remember him kneeling down and whispering in my ear, "You look like my 5 year old down there."
holy shit lmfao
>>
File: 1460751987629.jpg (34 KB, 1280x720) Image search: [Google]
1460751987629.jpg
34 KB, 1280x720
>>54339592
ad hominem
>>
>>54339650
it's a huge detriment to the language. it's the main reason why i wouldn't even consider using it (that, and the lack of advantages over C++).
>>
>>54339693
Can't spell a non-straight without anon
>>
>>54339707
>that, and the lack of advantages over C++
Honestly, pretty much any language is better than C++.
>>
>>54339707
Memory safety?
>>
>>54339709
Anon is indeed straight
>>
>>54339707
>it's the main reason why i wouldn't even consider using it
I also thought this way until I actually decided to give it a chance out of desperation as every other language is so shit.
>(that, and the lack of advantages over C++).
That couldn't be further from the truth. Not only are programs with memory-related errors illegal in rust, which alone is a ridiculously huge advantage over C++, but it also features many ML-like constructs like destructuring binds and match clauses, functional record updates, immutability by default and Option-based erroring. On top of that, it uses a smalltalk-like approach to extensibility as opposed to the Algol-approach, which is significantly more flexible and allows "remote maintenance" by patching structures from other modules to add new traits to them.
Not only that, but like C, it doesn't require a runtime.

All of this while retaining close-to-native speeds.
>>
>>54339766
>muh rust is like ML
rust is verbose as shit
>>
>>54339778
No, it really isn't.
>>
>>54339760
speak for yourself
>>
>>54339778
>rust is verbose as shit
It's far less verbose than C++.
>>
>>54339792
operator overloading + functional C++ + macros = compact
>>
>>54339778
Which is a good thing.

THE most difficult thing in programming is debugging and long term maintenance.

I'll happile trade off a few keystrokes for understanding wtf does the code do faster.
>>
>>54339813
>which is a good thing
no

>debugging
not any easier
>>
>>54339778
I don't care for Rust, but verbosity is a good thing, particularly when you can also be concise within the same language.

More explicit = less assumptions = less things happening 'in the background' that you have to just know.
>>
>>54339809
= disgusting
>>
>>54339809
I see you've never used any of these. Also all of these are supported by rust anyway, except significantly better and less verbosely.
>>
File: 1450438221996.jpg (52 KB, 620x330) Image search: [Google]
1450438221996.jpg
52 KB, 620x330
If OOP is so bad why does everyone use it?
>>
Maybe Im being stupid but can someone tell me why my txt is not opening. Its in the same directory as the project.
string main1()
{
string line;
ifstream myfile ("test.txt");
if (myfile.is_open())
{
line="Open";
return (line);

}

else line="Closed";

return (line);
}
>>
>>54339923
Babyduck syndrome, and it's still better than C-style procedural.
>>
>>54339923
OOP is good as fuck it's just /dpt/ neckbeard memers that are too stupid to understand it and it may be useless TO THEM because they only write tiny little fizzbuzz tier apps that don't need to scale
>>
>>54339934
>Maybe Im being stupid
Try "retarded".
>>
File: popularity of oop explained.png (107 KB, 1163x674) Image search: [Google]
popularity of oop explained.png
107 KB, 1163x674
>>54339923
>>
>>54339923
OOP isn't inherently bad, that's a false assumption.
>>
>>54339969
epic meme
>>
>>54339970
It's a conditional question, and by answering the corollary you've affirmed the truth of the condition
>>
>>54339824
Well the opposite opinion seems to be more popular at this particular time.

You don't need to use rust for all your programming, but when doing anything that needs performance + memory safety, you can choose that, and when you only need memory safety use a more concise garbage collected lang.

I see no reason not to.

>>54339923
Lots of literature, lots of training, lots of timeproven "patterns", developer availability, that lead to long term manitainability.

>>54339962
I have a quality fizzbuzz for you in Java
https://github.com/EnterpriseQualityCoding/FizzBuzzEnterpriseEdition

>>54339498
Did it work in the end?
>>
>>54339962
How is OOP inherently scalable?
>>
>>54340018
developer availability.
>>
File: tetris.webm (552 KB, 640x480) Image search: [Google]
tetris.webm
552 KB, 640x480
Ask your favorite programming literate anything (IAMA).

>>54339923
Because it's what works best.

>>54339792
adding cmd args together.

rust
use std::env;

fn main() {
let args: Vec<_> = env::args().collect();
let a = args[1].parse::<i32>().unwrap();
let b = args[2].parse::<i32>().unwrap();
println!("{}", a+b);
}



C++
#include <cstdio>
#include <cstdlib>

int main(int argc, char *argv[]) { printf("%d\n", atoi(argv[1]) + atoi(argv[2])); }


(  ̄ー ̄)
>>
>>54340038
That makes absolutely no sense.
Do you know what scalable means?
>>
>>54340018
Abstraction.
>>
>>54340043
>int main(int argc, char *argv[]) { printf("%d\n", atoi(argv[1]) + atoi(argv[2])); }
You're fucking arguing for C++, not C. Use modern C++ style.
Also, atoi is fucking shit. It has no way to handle errors.
>>
>>54340043
Why didn't you post something cute?
>>
>>54340045
How is abstraction scalable?
It seems that you're randomly throwing buzzwords at me, hoping that it will answer the question.
>>
File: 1462158681166.png (90 KB, 963x866) Image search: [Google]
1462158681166.png
90 KB, 963x866
Hey /dpt/,
We've started a slack group with the aim of organizing the studying of books related to CS/math/philosophy.
This Sunday we finished past projects and are starting some new ones, namely:
1)SICP
2)Networking
3)Goedel, Escher, Bach
4)Set Theory
5)Logic II
https://docs.google.com/spreadsheets/d/1A_zbRf7YoiY_454INuLXEuSuW3ro0rZtaGJtnIb4XNw here's the schedule.
If you're interested, then leave your email here (making a fake one is recommended, needed only for an activation) and I'll send an invite.
>>
>>54340043
>C++
>Posts C code
>>
>>54340018
>>54340063
obvious, you can use the said abstraction to build independent and opaque objects where one object = one process/thread/task
>>
>>54340083
Maybe try reading a good book that has any kind of insight into anything real or abstract next time
>>
>>54340094
It's both, anon
>>
>>54340018
encapsulation
>>
>>54340101
That literally has nothing to do with scalability.
>>
>>54340123
see >>54340063
>>
>>54340044
It means that your startup can scale your product and userbase beyond a garage proptotype.

If you mean scalable-performance-wise, OOP sucks, particularly if you go for parallelism, but success is barely about that in the first place (most of the time).
>>
>>54340063
Say someone writes 100 lines of code that does a thing.

They make this thing easily interacted with by creating a shorthand to just give the thing the relevant information.

Someone else uses this thing 5 times in another section of 100 lines of code in various ways. You've already saved 500 lines here.

Say someone else uses this whole section of code that uses that other section of code a few times.

It starts getting exponential.

Now, that's just an example of how it saves massive amounts of boilerplate. The idea behind the objects themselves is to put the boilerplate behind an easy-to-understand concept of a 'thing' so that accessing, modifying, and doing things in general are much more sane.

That's not to say that OOP concepts can't be used insanely and cause more problems, though.
>>
>>54340125
>>54340131
scalability in this context = ability to build and maintain large and complex software applications with hundreds of programmers working on it at a single time
>>
>>54339934
you should delete that return line inside the if statement.
>>
>>54340140
If you wanted to save lines of code you'd be using functional concepts
>>
>>54340133
>>54340143
Yes, I was talking about scaling in terms of performance.
Stop trying to redefine the word.
>If you mean scalable-performance-wise, OOP sucks, particularly if you go for parallelism
In the world of multi-core CPUs, parallelism is very important.
>but success is barely about that in the first place (most of the time).
I don't know what you define "success" as.
>>
>>54340177
The point is putting those lines of code behind an understandable abstract concept of a thing or idea.
>>
>>54340177
nice meme

functions should generally be "pure" if possible, that's just common sense

but basing the entirety of your program around functions and explicit state is shit and doesn't solve anything over OOP
>>
>>54340188
>Yes, I was talking about scaling in terms of performance.
>Stop trying to redefine the word.
>>>/g/wdg
>>
>>54339528
I was watching the video for so long I didn't even notice the thread die, so repost:

Here, have another (You).

I like the guy in the video, especially how he's throwing massive barbs at Java whilst still trying his best to praise the things it actually did "right" (especially compared to what else was available at the time).
Forced objects and classes really is cancer.
If android development on C# wasn't such a hacky mess I'd be all over it.
>>
>>54340177
And so we're closing in to the heart of the discussion.

Functional is awesome, but it's not easily relatable to by noobs.

OO is a great metaphore to express code in. The most difficult thing in programming is conveying meaning to other humans (or your future self). OO makes that a little simpler, expecially if they're noobs. It's just easier to construct a mental model of the codebase in peoples minds.

OO has more success (I don't claim it's better) because it's more understandable.
>>
>>54340140
>Someone else uses this thing 5 times in another section of 100 lines of code in various ways. You've already saved 500 lines here.
What you just described was a function.
>The idea behind the objects themselves is to put the boilerplate behind an easy-to-understand concept of a 'thing' so that accessing, modifying, and doing things in general are much more sane
The idea of objects is to encapsulate state. The whole point of all of this shit is about the management of state.

>>54340210
Fucking google the word. Tell me what definition it gives.
>>
>>54339965
Can you tell me why?
>>54340176
I know its not needed. But I put it there when I couldnt figure out what was wrong with the logic. The return statement doesnt change anything.
I cant figure out why it wont open. Im guessing its the framework.
>>
>>54340198
reminder that the majority of "advances" in OOP languages and libraries are largely specific instances of FP concepts
>>
>>54340245
>https://en.wikipedia.org/wiki/Scaling
>Scalability, a computer's or network's ability to function as the number of users increases.

You can't have that if only one person can unserstand and modify the codebase. You need a team.

OO works great for teams.
>>
>>54340271
Jesus fucking christ, you can't be serious.
Here is your (You).
>>
>>54340254
you can have OOP with a dash of FP. but pure FP is mostly reserved for neckbeard toy programs
>>
File: sfs4e7o.webm (515 KB, 720x720) Image search: [Google]
sfs4e7o.webm
515 KB, 720x720
>>54340094
This is valid and standard C++ code. Using c++14 would not be much verbose.
#include <iostream>
#include <string>
using namespace std;
int main(int argc, char *argv[]) { cout << stoi(argv[1]) + stoi(argv[2]) << endl; }


>>54340055
Sorry
>>
>>54340282
>a dash
kek

>iterators, ranges
>exceptions
>async, lazy, optional
>generics, ADTs, tuples
>structured binding, pattern matching
>higher order list operations
>>
>>54340233
>OO is a great metaphore to express code in
Only in the most contrived examples. How is "ThingFactory" and "ThingMangaer" representable in the real world? It's not. It's just some pointless structure that OOP forces onto you.
>It's just easier to construct a mental model of the codebase in peoples minds
Hundreds (or thousands) of objects and their interactions to NOT easy to model in your head. OOP spreads state and complexity all over the place, making it very difficult to reason about.
>>
>>54339493
I am starting to learn python,i make my programs in notepad++ ,is there a better text editor for windows?
>>
File: to death.png (586 KB, 1062x888) Image search: [Google]
to death.png
586 KB, 1062x888
>the best book you can buy to improve your programming skill is a fucking thesaurus rex
>>
>>54340281
Picture this.

You're an enterpreur. You have an idea.

You won't be doing the coding (no time for that), but doing the enterprisey stuff (fundraising, marketing, design, etc.)

You'll be hiring developers (a whole team of developers) to bring the idea to life so your sales can operate, etc. etc.

What technologies do you place your bets on? Language X because "that's what I like", or langauge Y, because it will be easy to deal with (at the very least) developer turnover.
>>
>>54340358
You are completely misinterpreting the definition of scalability, to twist it into your own stupid definition.
For example, you have two servers, "server a" and "server b".
With maybe 100 clients, both servers perform about the same.
With 10000 clients, server a performs much better than server b.
Therefore, server a is more scalable than server b.

It has nothing to do with adding more Pajeets to your team.
>>
>>54340395
adding more pajeets is also scaling
>>
File: hue.gif (497 KB, 245x200) Image search: [Google]
hue.gif
497 KB, 245x200
>>54339528
>Busting through the walls like the koolaid guy
>>
>>54340395
>servers
>>>/g/wdg
>>
>>54340453
>server == webserver
>implying that writing server software actually has anything to do with webdev
>/g/wdg
>>
>>54340474
/wdg/ is for backend shit too fuck off fag

you're the only one that autistically want to argue about "the one true definition" of scaling
>>
>>54340395
I'm not twisting it, wikipedia is giving me at least 5 different *aspects* of scalability
https://en.wikipedia.org/wiki/Scalability

I do think that what I'm toalking about *is* the more important aspect in the real world.
>>
>>54340501
Sure, all of the /wdg/fags are contributing patches to programs like NGINX
>>
>>54340520
>NGINX
>Nginx (pronounced "engine x") is a web server.
>web server
>WEB server
lol fag
>>
Where have all the good /g/ents gone
and where are all the /g/ods?
>>
>>54340297
Thank you, I've had a bad morning.

I smiled at that.
>>
>>54340232
>If android development on C# wasn't such a hacky mess
Nigga, Xamarin is easy as shit to work with.
>>
>>54340629
the API is 99.99% the same as on android
>>
>>54340666
*the android API is 99.99% the same in xamarin as in java
>>
>>54340666
>>54340681
I'm not exactly certain as to what point you're trying to make.
>>
>>54340692
android is a hacky mess regardless of the language
>>
>>54340698
Oh, fair enough.
>>
File: baka_big.png (2 MB, 2000x2000) Image search: [Google]
baka_big.png
2 MB, 2000x2000
>>54339528
I like this video because it validates my opinions.

I only wish that he had valid points and the video as a whole wasn't an inane mess of straw-man arguments against bad design, rather than OOP.
>>
https://play.google.com/store/apps/details?id=eu.depa.captionr

Mine
>>
>>54340759
looks shit
>>
>>54340759
Did you have to give it a meme name, though?
>>
>>54340793
At least he links to the github repo
>>
>>54340629
>>54340666
>>54340681
>>54340698
Sounds about right. If you were allowed to actually use C# features how you want to, there would be an advantage over using Java directly.
But since you are ultimately forced to do things their way sooner or later, I find it marginally less clunky to just work with Java directly using Android Studio.

I should note I have the advantage of not actually requiring anything to be cross platform here, there is a desktop version of the software but it has a completely different feature set.
The PC version is the "full" application if you like, and the android build is the "lite" version, so we don't even bother trying to have similar interfaces or share much between the two.
There are shared libraries that both types use of course, but accessing these through any language doesn't change much (well maybe not having to use JNI would be nice).
>>
>>54340759
Looks cool.

What are the terms of the Vision API?
How much does it scale?
Can the ads pay for it?
>>
>>54340842
>If you were allowed to actually use C# features how you want to
I'm actually curious, can you give an example of this?
>>
File: JU83l2K.png (21 KB, 686x423) Image search: [Google]
JU83l2K.png
21 KB, 686x423
>>54340857
https://www.microsoft.com/cognitive-services/en-us/computer-vision-api

I sure hope no one spams his app...
>>
>>54340859
Well basically, writing procedural code where it makes sense and not touching fucking objects every 5 seconds.
It's more a problem of how tightly the Android API is nested into the Java™ thought process.
It doesn't really matter if you use another language that you find easier to work with, ultimately you have to think the Java™ way to get things working.
>>
>>54340876
Well that's unfortunate.

sigh, scalability, scalability...
>>
>>54340018
It allows compartmentalizing operations on data and the data that is being operated on, and allows transparent code reuse during extensions, i.e. via subclassing (all method names are the same so you can trivially refactor the codebase to use a descendent, and all code that works on the parent also works on the descendent).

In pure procedural code, you'd have to modify every function in the base module to account for a new type of data, in OOP code you only need to subclass in your own code, no need to change any source, and you can then send your class into modules that are completely unaware of the real type of your class.
>>
>>54340083
>slack
>>>/reddit/
>>
>>54340857
5000 calls a month, I made multiple accounts obv

No, ads can't pay for it. It doesn't matter, I'm not doing it for the money tbqh
>>
>>54340759
>DP Development
JAJAJAJAJAJA
>>
>>54340876
lel you'd need an ad on each transaction just to barely break even
>>
>>54340759
>depa
https://www.youtube.com/watch?v=jjnrLt3VuSM#t=1m52s
>>
>>54340043
In rust, .unwrap() is used to panic! if the option is None. Instead, .expects("message") can be used to display an appropriate message. It's a very effective erroring mechanism.

Now let's fix the C:
#include <cstdio>
#include <cstdlib>
#include <cassert>

int main(int argc, char *argv[]) {
int a = atoi(argv[1]);
int b = atoi(argv[2]);
long al = atol(argv[1]);
long bl = atol(argv[2]);
float af = atof(argv[1]);
float bf = atof(argv[2]);
assert(al == a);
assert(bl == b);
assert(abs(float(b) - bf) < 1e-8);
assert(abs(float(a) - af) < 1e-8);
//Note: we still don't know whether or not a and b successfully parsed at this point, we merely assume these tests are good enough. These functions have undefined behavior when they fail to parse, so these tests are all necessary. How wonderful, C!
printf("%d\n", a + b);
}


I spared you the part where we go and generate useful error messages at each possibility.

Please, wear a tripcode!
>>
>>54340759
the text formatting in the description is fucked

<b>1.4.0</b>
BIG UPDATE!
&bull; Faces are now recognized and the age and gender can be told
&bull; Captionr can now tell if a picture is <i>inappropriate</i>

etc.
>>
>>54340948
procedural code can have polymorphism without any OOP
not all polymorhpism is based on inheritance, and not all inheritance is tied to OOP
>>
>>54341245
Another tripfag to the filter.
>>
>>54341253
but his trip is literally invoke wtc
>>
>tfw your company stands up a vSphere ESX host with tons of resources for you to play in, like a big sandbox for a developer.
>>
>>54339528
Now you've got me watching his next video:
https://www.youtube.com/watch?v=IRTfhkiAqPw

A whole page of UML to make a 4 method game, jesus fucking christ OOP.
>>
>>54341534
It does scale to multiple players, tho.
>>
>>54341534
UML != OOP
>>
>>54341571
you could do it in less lines than whatshisface (the guy who got abused by OOP as a child) did and have it even more scalable without using classes
>>
>>54341534
>UML
>cascade development
>sublime cancer
Nice memes. Good to see that neither you or anyone who are against OOP have any idea what they're saying.
>>
>>54341603
I didn't say they are equivalent, just that they are often linked as many OOP users (or rather teaching staff) seem to like using UML.

In fact, I can't remember the last OOP textbook I saw that didn't suggest using UML or other "design techniques" to help you plan out a program.
BlueJ specifically comes to mind, it has a fucking UML class view built-in to what is meant to be a very basic, cut-down IDE.
>>
>>54341534
That vid is fucking terrible, tho.

People making toy examples to convey concepts, he goes and refactors them to hand-tailerd code.
>look at it it's shorter
that not the point.

Also,
>i just went to the search box and got the first couple results
Great fucking job
>>
>>54341665
i'm pretty sure it's not very common at all to use UML diagrams
>>
>>54341665
UML is good for teams.

By the virtue of the simple fact that it's better than nothing at all.
>>
>>54341665
>>54341684
I've used UML literally once when I was in an intro to Java class back in college.

t. C# developer for almost 5 years.

That's not to say we don't plan in other way for some basic design decisions.
>>
>>54341687
It's not. It's only good to summarize a reduced illustration of a hierarchy when bringing someone new to the team. Even then, nobody even knows UML anyway and use custom diagram formats intead.
>>
>>54340043
You broke the 80-col limit cumpai
>>
>>54341763
>2016
120-160
>>
File: matpleblib.png (13 KB, 408x127) Image search: [Google]
matpleblib.png
13 KB, 408x127
>>54339493

ive started deliberately screwing up import library naming conventions
>>
File: 1462054047256.png (231 KB, 368x320) Image search: [Google]
1462054047256.png
231 KB, 368x320
>>54341789
>not tiling your code
>>
>>54341817
python shitters everyone
>>
>>54341789
>what is having multiple files open adjacent to eachother
>>
>>54341835
>shitters
why are you still here
>>
>>54340083
[email protected]
>>
>>54341817
That's just wrong
>>
>>54341851
>what are tabs
>what is having a non-shit monitor
>>
>>54340083
Can I change to my actual email after I use a throwaway?
>>
File: jVlpFkh.png (165 KB, 518x258) Image search: [Google]
jVlpFkh.png
165 KB, 518x258
>>54341851
>what is a non-poverty monitor or multiple monitors
>>
File: indians4.jpg (246 KB, 1017x873) Image search: [Google]
indians4.jpg
246 KB, 1017x873
Need a sanity check:

Goal: mirror a database on another server nightly as another live database

One exception: 2 of the 100's of tables I'd like to ADD rows with a nightly timestamp, instead of mirroring and modifying the existing rows, a temporal table of sorts.

Is this insane? Doable? Best practice?

Basically, I want a data warehouse with verbatim data for the purposes of reporting off of a non-live DB.
>>
File: indians.png (5 KB, 235x117) Image search: [Google]
indians.png
5 KB, 235x117
>>54342029
>non-live DB
Non-application DB*
>>
File: Distros.png (939 KB, 2400x1297) Image search: [Google]
Distros.png
939 KB, 2400x1297
>>54341817
i too enjoy matplotlib

here's last months distrowatch stats on a well laid out pie chart
>>
In C++ should I define functions inside my class defs or define them later on in the code? I'm thinking defining them later on is a bit more elegant.
>>
>>54342052
F R A G M E N T A T I O N
>>
>>54341199
It looks good in the Google play store app and that's what matters
>>
>>54341817
evil

>>54342052
disgusting
>>
>>54342063
Later, that seems to be the most popular way.
>>
>>54341875
sent ;)
>>
Meanwhile on Facebook...
>>
>>54342849
>>>>54342372
>>
Where do I start with getting into this stuff? Total scrub here.
>>
C Question:

Let's say I dynamically allocate a two dimensional array like this:
uint8_t ( *array )[WIDTH] = malloc ( sizeof( uint8_t[WIDTH][HEIGHT] ) );


Now I want to have a function use it. What type should I use? Everything I've tried so far errored during compilation.
>>
>>54343231
You know, I'd say we need a sticky for this.

Then again, literally no one can agree on what's good for starting.

Watch this:

You should start with C#, as it's going to be easy to learn, and also introduce you to many good tools available that make you an efficient agile-focused programmer. Furthermore, the language isn't a special snowflake with most of its syntax, so you won't have any issue learning C++ or Java afterwards. In contrast, while Python is easy to learn, the skills do not follow easily into other major programming languages.
>>
>>54343297
Thanks anon, I appreciate it; I did look in the sticky first as well, and was curious as to why there was nothing.
>>
>>54343289
sizeof( uint8_t[WIDTH][HEIGHT] )


Uhhh did you mean to multiply sizeof(uint8_t) by height?
>>
>>54343297
>>54343305
anon obviously meant "C# if you use windows, and C if you use a unix"
>>
>>54343377
Those aren't comparable at all, retard.
>>
>>54343390
yeah, but you should use the the language best integrated with the os
c# uses .net, and most unix programs are written in c
>>
>>54343289
Arrays of arrays considered shit, but anyway. How comes
uint8_t (*array)[WIDTH]
doesn't work, /g/?
>>
>340 pages into a web dev book
>see this in the first js chapter
carry on reading?
>>
>>54343289
First, what the fuck? If you want the size of a 2D array, you use:
 sizeof(uint8_t) * WIDTH * HEIGHT

Don't get fruity with the array syntax inside the fucking malloc() call, if you want to be that weird then use a fucking malloc for each row and use them separately.

Second, what in the name of the dark one makes you think having WIDTH in the declaration AND the malloc is a good idea?
>>
>>54343490
>web dev book
you knew what you were getting into
>>
>>54343366
No, that's really what I mean. I guess it's equivalent to
 sizeof(uint8_t) * WIDTH * HEIGHT
, but I think it looks a little more readable like that. It really doesn't matter I guess.

>>54343427
Ah, thanks that worked, seems kind of obvious now that I see it. By the way, I mainly use two dimensional arrays because I like the [][] indexation for convenience. I see how that is not optimal, but it's just too easy to lose sight when I use the index like [i * WIDTH + j] or whatever instead of [i][j]. If you have any other suggestions, I'm interested.
>>
>>54343502
it was o'reiley though
it's taught me pretty well so far actually
>>
>>54341900
yes, but there's no need to
the email is only needed for registration
also, the email is public to everyone on slack, so it's not recommended
>>
>>54343575
[email protected]
>>
>>54343575
Fuck off with your botnet.
>>
>>54343590
>>54340083
>>
hey /dpt/,

Where's a good place to ask some hardcore questions about opengl stuff? I might have some luck on stackoverflow, but is there any place better?
>>
>>54343636
Probably a specialized forum.

For example, I go to SQLServerCentral for my harder questions. There are some fucking wizards there.
>>
>>54343591
You don't even know what a botnet is
>>
>>54343636
>>>/vg/agdg might be a better place than this, but not by much.
>>
File: 1453651138545.jpg (57 KB, 601x577) Image search: [Google]
1453651138545.jpg
57 KB, 601x577
>>54343700
>>>>/vg/agdg might be a better place than this
>>
>>54343666
t. satan the botnet shill
>>
>>54339493
Python, verilog, and matlab.
>>
>>54343740
What did you do with your dignity?
>>
>>54343651
I guess I'll look up something like that.

>>54343709
might be worth a try i guess.
>>
>>54343745
Boiled and ate it.
>>
File: Wittgenstein.jpg (164 KB, 902x902) Image search: [Google]
Wittgenstein.jpg
164 KB, 902x902
>>54343505
sizeof(a[b][c])
is quite nice IMHO, it clearly underlines the order of indices. As for "considered shit", ideally I would just abstract the (i * WIDTH + j) part. It can't be done nicely in C obviously. The thing is, double arrays have these nasty characteristics of only allowing one dimension to be dynamic, to suggest syntactically that they aren't contiguous when in fact they are, and to be shit when iterated. But go on, don't rethink your entire plan over an anon's Ramblings.

Also fuck any language which needs syntactic sugar. When you program, language is the enemy of thought against which you and I battld to express our algorithms.
>>
>>54343745
What my job requires. Not personal preference.
>>
>>54343523
what fucking book
>>
>>54343781
>verilog

Disgusting, VHDL master race.
>>
>>54343770
try C++
>>
>>54339766
>Not only are programs with memory-related errors illegal in rust,
So are C and C++ programs.
>>
>>54343590
sent ;)
>>
>>54343795
Not at fucking all, not only are programs with memory-related errors perfectly legal in C and C++, they might even continue silently over the error, causing countless ridiculously hard to debug critical security flaws.
>>
>>54343848
When you're debugging, you can switch out for (slower) safer memory handling
>>
>>54343636
1. official opengl forums
2. nvidia forums
3. amd forums
>>
>>54343848
>not only are programs with memory-related errors perfectly legal in C and C+
They are not.
>>
>>54343960
Congrats, you're clinically retarded!
>>
>>54343960
int main() {
int *x = new int[300];
}
>>
>>54343969
Name one "memory related error" that would be considered legal C or C++.
>>
>>54343890
Not really. If your program works in a debug build with a custom allocator that does MM for you, then you have no guarantee that you don't have leaks out the ass in your production version that doesn't use MM. Thus, for debugging, you MUST NOT use MM unless it will also be used in production.
>>
>>54343984
Out-of-bounds accesses.
>>
>>54343956
thanks freind
>>
>>54344004
That would be undefined behavior, aka an illegal program.
>>
>>54343992
So your point is now just that the language allows you to manipulate memory unsafely?
>>
>>54344015
Congrats, you're clinically retarded.
>>
>>54344036
Time to backpedal now, huh?
>>
Taking the AP CS exam tomorrow /g/. Pretty sure I'll rock it but any tips?
>>
>>54344032
The point is >>54343848
>>
>>54344036
>Congrats, you're clinically retarded.
>>
File: 1445079305459.jpg (69 KB, 306x331) Image search: [Google]
1445079305459.jpg
69 KB, 306x331
>>54344015
Then why hasn't the police arrested it?
>>
>>54344046
Exactly, the language allows you to manipulate memory unsafely.
>>
>>54344062
An undefined program can identify as whatever it pleases. There's no such thing as an "illegal program", programs are programs and all programs are of equal value.
#exceptionswelcome
#prayforheartbleed
>>
How do I calculate an accurate ratio?
Making a party guest list program and I want to calculate the ratio of boys to girls, but I don't know to accurately do it
>>
>>54340083
>a group dedicated to circlejerking about theory books because we're all too incapable to actually implement anything
>>
>>54344183
boys / girls
>>
>>54344194
That gives me a single int. No, I need boys:girls, but rounded down the lowest whole int for each side
>>
how many C strings of length 10 are palindromes?
>>
>>54341170
>>54341076
>>54340768
found the NEETs who aren't able to actually program anything beyond Hello World
>>
>>54344206
divide by lcm
https://en.wikipedia.org/wiki/Least_common_multiple
>>
>>54344206
Should probably go back to elementary school if you can't figure that out.
>>
>>54344206
find the GCD using euclid's algo, divide each by the gcd
>>
>>54344219
wait, meant greatest common factor
was searching highest common denominator
>>
>>54340759
so you literally just made an android front end to microshaft's captionbot? is this legal?
>>
>>54344219
>>54344220
I know about LCMs, and that's what I was thinking. I just don't know how to go about implementing it

>>54344227
What is GCD?
>>
>>54344248
public api
>>
>>54344263
gcd = greatest common divisor = greatest common factor
same thing, different word
wikipedia/euclids_algorithm
>>
>>54344263
greatest common divisor / greatest common denominator / greatest common factor

the largest number you can divide them both by (and have them remain integers)
>>
>>54344207
Depends on what characters are allowed, and whether they have to form actual dictionary words/phrases or not.

The maximum available is [size of character set] ^ 5, assuming any character combination is allowed i.e. "aeio__oiea" is valid.
>>
Hey guys, sort of have a problem here.

I have three different char arrays, each stored within arrays (basically 10 different char arrays, each with a size of 20). Here's an example.

cout << "Please enter Manager's first name: ";
cin >> ws;
cin.getline(fname[i], sizeof(fname[i]));


What I need to do is pull single chars from each array and concatenate them into a new array of char arrays or an array of strings.

The end result of this program is taking in 10 first names, 10 last names and 10 SSNs. Then using this information, create 10 unique ID Numbers composed of the first letter of the first name, the first letter of the last name and the last four digits of the SSN.

I've been working on this for two weeks and cannot figure it out, and its the last part of the project I need to do.

Thank you.
>>
>>54344276
I don't need the greatest, I need the lowest.
>>
>>54344209
>Laughing at silly things and being productive are mutually exclusive

Are you under the impression that spending all day doing something means there must be a use for what you have produced?
>>
>>54344312
did you even read my post? you fucking retard

you have B for boys count, G for girls count
find the greatest common divisor, X
divide B by X to get b, G by X to get g
b:g is your answer
>>
>>54344312
you have some ratio x:y (or x = Ry)
you want to simplify it, so you consider that

x = kx'
y = ky'

kx' : ky'
x' : y' // the goal

find k and divide by it (if it's already simplified, k will be 1)
k is the greatest common factor


believe euclid's algo is a recursive process that repeats this until k is 1
>>
>hey guys I have a really basic problem but im not sure how to do it
>here's how you do it
>that's not what I want

I think elementary education should be a pre-requisite to programming
>>
can't you solve the captcha by taking a screenshot of it, cutting out the images, then analyzing the google image search or that captionbot's answer?
>>
>>54344302
C strings end with null terminator, so if its a palindrome then it starts with one too, the answer is 1: all of the palindromes are equivalent to "" since they start with the null terminator
>>
>>54344423
but then they kind of aren't of length 10
>>
>>54344456
it's a trick question
>>
I'm an undergrad CS major who just finished up his first year of courses. So basically I know the fundamentals in Java. I realize this severely limits my knowledge of the field in general. What books would /dpt/ recommend to me at my current stage? Pls no bully
>>
File: thumbs.gif (545 KB, 256x199) Image search: [Google]
thumbs.gif
545 KB, 256x199
>>54344423
When referring to C strings, the null terminator is implicit.
If you say it's of length 10, people will assume that means a usable length of 10, and therefore an actual size of 11 bytes to allow for the null terminator.

>>54344423
That's still wrong, for 2 reasons:
1) C strings don't end with a null terminator, the char array representing it does however.
In much the same way that a union with padding physically contains padding bytes, but you wouldn't say that the types contained in the union themselves contain the padding.

2) A palindrome cannot have a length of 0, or even 1 for that matter, in the same way that 1 is not considered a prime number, because it only has one factor.
If you are going to argue that the null terminator is included in the length (because of course you are) then we aren't talking about strings at all, we're talking about byte arrays, which makes your entire point moot.

Nice try though.
>>
>>54344571
Ya got me, I just came up with it as a little trick question, suppose I didn't think through how I would ask it so that the "correct" answer was valid
>>
>>54344565
Design Patterns, by GoF
>>
>>54344565
>first year undergrad cs student
>java
lmao
>>
Why is learning OpenGL so hard?

I picked up the superbible and I was doing so well, up until you reach the halfway point, where it drops the fixed pipeline and dives into shaders, and then it suddenly assumes you know the ins and outs of GLSL for some reason.
>>
>>54344630
Yeah, I don't understand why nobody ever correctly explains the shader languages. Of course the idea is simple and you understand the syntax, but how does that help you understand potential bottlenecks and available datastructures, functions and macros?
>>
>>54339493
Has anyone tried to program in VR yet?
>>
>>54344707
lmao
Like just have vim and shit open in a vr headset? Would be neat to have a 360 degree workspace
>>
man, i could have done so many things, yet i've spent the past days on getting gui to work like i want it to... i'm almost there.
>>
File: js.png (20 KB, 214x383) Image search: [Google]
js.png
20 KB, 214x383
When I make my microcontroller project, I get these files. The chip I'm using has 2K of flash memory. Does this mean it currently has 2048−1474 = 574 bits free memory?

-rwxr-xr-x 1 user user   516 touko  2 22:09 main.bin*
-rw-r--r-- 1 user user 1939 touko 1 01:35 main.c
-rwxr-xr-x 1 user user 0 touko 2 22:09 main_eeprom.bin*
-rw-r--r-- 1 user user 13 touko 2 22:09 main_eeprom.hex
-rwxr-xr-x 1 user user 56 touko 2 22:09 main_eeprom.srec*
-rwxr-xr-x 1 user user 15246 touko 2 22:09 main.elf*
-rw-r--r-- 1 user user 297 touko 1 01:34 main.h
-rw-r--r-- 1 user user 1474 touko 2 22:09 main.hex
-rw-r--r-- 1 user user 17586 touko 2 22:09 main.lst
-rw-r--r-- 1 user user 12363 touko 2 22:09 main.map
-rw-r--r-- 1 user user 5944 touko 2 22:09 main.o
-rwxr-xr-x 1 user user 1470 touko 2 22:09 main.srec*
>>
>>54344816
dunno, have you tried turning it off and on again?
>>
>>54344816
you don't need to put the C files on it senpai
>>
>>54344816
>574 bits
bytes.
And I think it's more likely that main.bin is what will be loaded on the chip.
>>
>>54344728
>Moving any part of your body apart form your fingers and eyes when using vim

G I T G U D
I
T
G
U
D
>>
>>54334197
So i finally got myself to watch the vid.
I like his fonts.
>>
File: atomica.png (113 KB, 496x799) Image search: [Google]
atomica.png
113 KB, 496x799
Just started working on my mp3 player/manager again. Any suggestions or critique on how to make the UI better?
>>
>>54344816
Flash != RAM.
The program is put into flash, but you don't have the whole program loaded into RAM simultaneously.

Are you sure the 2K is the flash, or the RAM, because I would expect that to be the RAM (even ATmega328s have 8K of flash, 2K is ridiculous).
Also you may have a bootloader of some kind taking up space also, depending on how you flash it, so the hex file size alone is probably not enough information.
>>
>>54339934
Delete that else statement or remove that 1st return
It won't fix it but it'll be easier to read
>>
>>54344960
I like the name. How did you come up with it? Don't change the UI - it's clean and simple. Focus on adding features and functionality.

I have a request. For your shuffle function, could you make it so the playlist is re-shuffled once the loop has cycled? For smaller playlists, it's really annoying when the same songs loop back through, but I don't want to have to close my program to shuffle it again
Thread replies: 255
Thread images: 34

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

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.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.