[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: 340
Thread images: 27

File: 1504351946302.gif (2MB, 500x352px) Image search: [Google]
1504351946302.gif
2MB, 500x352px
What are you working on, /g/?

Old thread: >>62278156
>>
>>62282576
First for D
>>
r8:
fn group_anagrams<'a, I>(strs: I) -> Vec<Vec<&'a str>> where I: IntoIterator<Item=&'a str> {
let mut map = HashMap::new();

for s in strs {
let mut key: Vec<_> = s.chars().collect();
key.sort_unstable();
map.entry(key).or_insert_with(|| Vec::new()).push(s);
}

map.into_iter().map(|(_, mut v)| { v.sort_unstable(); v }).collect()
}
>>
fuck opengl though
>>
>>62282581
> D
> Lain
Ohhhh yeaaah.
>>
>>62282618
Where my HKTs at
>>
God I feel stupid...
I spent almost 3 days reading through my code trying to figure out why it didn't work and it came down to a syntax error.
What compiler warning can I add, so it will catch this the next time I fuck up?
void should_warn_func(int var)
{
var = 3;
}
void what_func_should_be(int &var)
{
var = 3;
}
>>
>>62282608
I'll think about it actually, firstly I will improve on the text_io to include some common function macros

Then again, I don't think people will accept my RFC. They would have done it ages ago. It's just a waste of time
>>
>>62282634
never desu. people (of color) are already complainging about rust being too hard.
>>
>>62282640
Just use -Wall and -Wextra, Maybe -pedantic too if you really want to catch everything.
>>
>>62282760
>if you really want to catch everything
then you should use rust or ada
>>
>friend who is a programmer calls me a leddit faggot for going python as my first programming language

but i got python from /g/...
>>
>>62282640
That's not a syntax error.
>>
Can anyone explain to me document.body.childNodes[0]); in javascript? Thanks
>>
>>62282576
trying to get subversion to work
it isn't going well
>>
>>62282771
Stop LARPing
>>
>>62282771
I'm a rustfag too but >>62282640 is obviously learning C, you can't recommend him to use rust in this case.
>>
>>62282802
>4chan
>live action
>>
>>62282803
He's no Steve, he's just shitposting. Even his tripcode can tell you the story
>>
>>62282799
You get the first element of the body. What more needs explaining?
>>
I don't want rust I just want C with Lisp macros, unwind-protect, multiple inheritance and multimethods.
>>
>>62282828
Maybe you'll like Jai then.
>>
>>62282818
In this syntax:
document.body.insertBefore(this.canvas, document.body.childNodes[0]); 
>>
>>62282795
depends on what he's passing it
>>
>>62282841
>Jai
Isn't that a github blog?
>>
>>62282850
Insert the canvas at the top of the body. The canvas will most probably be the first visible element.

>>62282862
Nah it's a programming language made by John Blow https://inductive.no/jai/
>>
>>62282879
so it could be skipped right? I can just make canvas go first without all this childNodes[0]. Thanks a lot
>>
File: Jai.png (19KB, 474x221px) Image search: [Google]
Jai.png
19KB, 474x221px
>>62282879
>all these editor plugins, but no compiler
>>
>>62282895
Yeah if you put the canvas directly in the HTML code this can be skipped. But you're probably better of learning Javascript first.

>>62282908
Yeah it's weird. I'd understand an emacs mode since it's what Blow uses but the rest is just weird.
>>
Can we all agree that Eclipse is the best IDE?
>>
>>62282967
No.
>>
>>62282967
yes
>>
>decided to major in embedded electronics
>I'm shit at physics and math
How fucked am I?
>>
I was planning to teach myself C but a free Java course has become available to me. Can I learn both at the same time or should I just learn C after I finish the course?
>>
>>62282984
>suck at math
>still try to learn html, css and python
>>
>>62283010
You can learn C after Java, syntactically they are almost the same.
>>
>>62283010
Yes you can learn both but you might end up giving up on C, which is probably not a good thing.
>>
>>62282908
>>62282924
From what I understand, Jai is still in active development. Blow hasn't released any of the early versions. I don't think the website is official - just a collection of resources collected/created by fans.
>>
>>62283051
Great, thanks.

>>62283054
Why would I? I already know it's better.
>>
>>62282647

It's not "too hard" but it certainly is high friction.
>>
What makes Lisp so good? Is there a good book to learn it?
>>
>>62282771
Tell me rustfag, is there a specific data type for pointers? Or should I just use an usize?
>>
>>62283010
Java is very easy to learn once you understand C and very difficult to understand if you don't.
>>
>>62283098
The course starts tomorrow, it's either both at once or C second.
>>
>>62283076
C isn't better than Java. It's just different.
You might grow frustrated with C because writing the small kind of software that is written when you learn programming languages is faster in Java than in C.
>>
>>62283076
>I already know it's better.
Better in what?
You've got to perform manual memory management in C. Strings don't exist - there are char arrays, so you can talk about array manipulation rather than string manopulation.
>>
No languages with the following syntax:
name func(a int, b int) int:
return a / b if (b ≠ 0);
return b / a;
>>
>>62283108
I guess Java but honestly that sounds like a bad idea.
>>
>>62282978
>>62282981
>dpt
>>
I'm learning Rust. This thing is great.
>>
>>62283139
>return a / b if (b ≠ 0);
dumb python poster
>>
>>62283139
return b != 0 ? a / b : b / a;
>>
>>62283110
>>62283137
I guess I fell for /g/'s shilling. I think I'll try to learn both at once.

>>62283147
I've met middle schoolers who knew the basics of Java, how bad can it really be?
>>
>>62283168
Java's easy to understand. That's why it's popular. I don't think anyone would criticize it for being overly complex. It's bad because of all the boilerplate.
>>
>>62283183
Will knowing Java help me learn C?
>>
how many universities did you apply to for grad school? i'm thinking of just applying to CMU and a good local university. i'm only going to attend if i get a particular scholarship i'm aiming for offered at both though
>>
>>62283010
happen to think about same shit back then
but ended up learn c++

never got idea to learn 2 languages at once
whats the fucking point
>>
>>62283205
A little bit.
>>
>>62283205
Yes.
>>
>>62283089
usize is an unsigned int the size of a pointer, like size_t in C. It doesn't have a (void) pointer type or anything like C though. Generic unsafe allocation is usually cast to u8.

You probably want Box; it depends on what you're trying to do.

>>62283168
>I've met middle schoolers who knew the basics of Java, how bad can it really be?
You can teach a middle schooler to write hello_world and for loops in any language pretty easily. If you're going to do a deep dive on Java, it would behoove you to understand C first.
>>
>>62283205
Yes but not as much as knowing C will help you learn Java.
>>
>>62283205
in a very limited sense. you'd have to google 'how to print in C' every other minute, so not really
>>
File: Capture.png (11KB, 273x241px) Image search: [Google]
Capture.png
11KB, 273x241px
Which is best?
>>
>>62283275
Git bash.
>>
>>62282640
Learn to use fucking asserts

https://www.youtube.com/watch?v=Y0XpL8j6MdM
>>
rate my game:
https://fghj2.neocities.org/gra/index.htm
>>
>>62282623
We need a new api.
Not vulkan. An opengl replacement that's meant for just (relatively) trivial applications. No compromise between the performance enthusiasts and people who care about the api being convenient. Give driver authors silly amounts of freedom.
And good error messages.
>>
>>62283265
>>62283269
I asked the teacher if we could learn C instead, he said he'd have to check (a few people are going for some exam). Hopefully it works out.

>>62283228
>>62283231
>>62283269
Otherwise I guess I'll do it this way.
>>
>>62282760
Pedantic doesn't catch it.
>>62282795
In my real code, I am setting the reference inside the function instead of returning it, but if it isn't a reference, I don't set the variable.
I know it is valid syntax, but it doesn't behave as I want it to and it is far too easy to miss a single char in a large project. To me, it would be equivalent to using
if(var = 5) always_run();

It is valid, but it warns me if I would ever type something like that.
Is there really no such option?
>>
>>62283205
Significantly.
But they differ a lot as far as programming languages go. They both allow for imperative styles of programming though so you will absolutely have a lot to gain from either.
>>
>>62283275
Netbeans by a country mile.
I could say eclipse, but lacks many tools, like remote working and it has many stability issues.
Randomly hangs or usually hogs 1 thread at 100% for nothing.
>>
>>62283083
What's the difference?
>>
>>62283334
>I asked the teacher if we could learn C instead
they're different paradigms, you can't just swap them out
>>
>>62283337
Use all my options.
tmp.c: In function 'should_warn_func':
tmp.c:1:27: warning: parameter 'var' set but not used [-Wunused-but-set-parameter]
void should_warn_func(int var)
^
tmp.c: At top level:
tmp.c:5:30: error: expected ';', ',' or ')' before '&' token
void what_func_should_be(int &var)
^
>>
>>62282640
GCC or clang?
>>
>>62283337
Stop using mutation.
>>
>>62283379
BBC
>>
>>62283375
Yeah, I'm confused as to what kind of teacher is going to cover Java or C and Java at the same time, but somehow C by itself is a special order. That's a really weird arrangement.
>>
>>62283375
It depends. The exam could just involve writing a piece of code in whatever language you want.
>>
>>62283418
See my original post
>>62283010
I'm going to teach myself C.
>>
File: stupid uvs.png (76KB, 802x632px) Image search: [Google]
stupid uvs.png
76KB, 802x632px
here is a thing
>>
>>62283433
Don't try to learn both at the same time.
>>
>>62283459
I'm going to learn C after unless the teacher can miraculously teach C instead of Java.
>>
>>62283317
Asserts might have helped if I knew what to check for.
The problem is that once I found the error, it was simple to fix, but finding the error was the problem.
I had an assert in the function, but that didn't help me as the variable was set, but not the reference like I wanted.
>>
>>62283449
why is it upside down
>>
File: astolfqt.png (1MB, 926x1007px) Image search: [Google]
astolfqt.png
1MB, 926x1007px
Python standard library got ported into Nim
https://github.com/Yardanico/nimpylib
>>
>>62283378
I did.
The "int &var" is legal in C++, it allows you to use the reference of a variable.
#include <cassert>
void should_warn_func(int var)
{
var = 3;
assert(var != 0);
}
void what_func_should_be(int &var)
{
var = 3;
assert(var != 0);
}
int main()
{
int var = 0;
what_func_should_be(var);
assert(var != 0);
var = 0;
should_warn_func(var);
assert(var != 0);
return 0;
}

The assert inside the functions will succeed as the variable is set inside the function.
The first function will also succeed in the main function as the reference is given, so the function input is used as an output.
The other function will fail as the var in the function is a separate variable on the stack.
>>
>>62283603
Call me when it'll have STD.
>>
>>62283330
>We need a new api
>Not vulkan. An opengl replacement that's meant for just (relatively) trivial applications
this is a job for a software API. implementing another hardware API which could be far more easily implemented using any one of the existing APIs in software would be ridiculous, especially now with Vulkan which more than fully encapsulates the functionality of OpenGL and sits at just the right layer of abstraction to act as an ideal backend for a "simplified/cleaned up OpenGL" kind of API
>And good error messages
this is another thing that a software API can provide. Vulkan's validation layers address this far better than OpenGL, and while you're quite right that Vulkan is not suited or intended for trivial applications, a more approachable framework implemented using Vulkan as a backend would be able to propagate this benefit to its users
>>
>>62283089
of course there is:
https://doc.rust-lang.org/std/primitive.pointer.html
>>
File: 1501786001871.gif (1MB, 290x221px) Image search: [Google]
1501786001871.gif
1MB, 290x221px
>mfw I want to switch from teaching C to teaching Python to my newb
He's not going to love manual memory management, he even barely progresses at all.
>>
>>62283691
inserting all warnings from the man page and removing everything that is c/c-obj only seems to show there is no such warning.
>>
Reminder that it is 2017 and none of the shilled "modern" languages supports natively built-in SIMD.
>>
File: rust-antifa.jpg (96KB, 703x707px) Image search: [Google]
rust-antifa.jpg
96KB, 703x707px
>>62283877
>>62283089
>>
>>62283963
I don't give a fuck about politics and everyone who does is a CIA nigger desu
>>
>>62283947
https://godbolt.org/g/Lua1Ka
>>
>>62283947
https://godbolt.org/g/QyRJQR
>>
>>62284046
Yes? Did you have something to reply?
>>
>>62284089
https://dlang.org/spec/simd.html
>>
>>62284089
D's by far the best attempt at it but it's still far from satisfactory.
>>
>>62282576
Last night, as I was tossing and turning, wishing I could fucking go to sleep, I had a realization about why there are all of those macros in the beginning of the Linux kernel and started to think about if there is another descriptor for those reusable chunks of code that don't require, and benefit from going without, the stack overhead that a subroutine normally uses...
>>
Could anyone explain to me why I can't push in my local project to my github?
Names shouldn't make a difference right?
Like the repository has a different name than my local project.
>>
>>62284157
you tell us, why can you not?
>>
>>62282803
do not pin this on c, that is c++
& in function declaration params is not allowed even in c11 last i checked, and for good reason.
>>
>>62282803
That's clearly Javascript, look the var keyword is highlighted.
>>
>>62283907
>He's not going to love manual memory management
did you at least explain to him what memory is conceptually

based on the text you posted AND the picture you sound like a bad teacher and probably a retard?
>>
>>62282908
Post yfw people realize all of it was just for a kickstarter scam.
>>
>>62283475
>be more careful and systematic
>concentrate more on the types of the code
>avoid mutation unless it is definitely necessary

If you don't want to constantly shoot yourself in the foot, either stop using C++ or learn to become a much more careful programmer
>>
>>62284232
We went through 3 first chapters of K&R a half of year ago. The reason he barely progresses any further is he's jobless and yet he's always in search of work because you can't NOT work more than six months in year.
Call me what you want, though. Maybe I'm really that bad.
>>
>>62284357
>yet he's always in search of work because you can't NOT work more than six months in year.
wat
>>62283907
>>mfw I want to switch from teaching C to teaching Python to my newb
> He's not going to love manual memory management, he even barely progresses at all.
all my wat
>>
>>62284382
>wat
If he'll be jobless more than six months in year, he has to pay $230 "to take part in funding government social expenses".
>all my wat
I really feel desperate now. I want him to get out of that shithole or at least start to live better there, but there's no progress at all.
>>
>>62282576
Learning how to use a double pointer to dynamically declare a two-dimensional array in C.
I watched four or five video lessons and learned very little, then on the last one everything just clicked into place.
>>
>>62284532
type** pointer;
pointer = (type**)malloc(n*m*sizeof(type));
>>
>>62284532
Why? Just allocate a flat array of w*h size and then convert between 1d and 2d points when accessing it.
>>
>>62283947
C++ compilers do support automatic SIMD vectorization in some cases on some targets and depending on compiler flags, but it's not something you can just apply wholesale. a language could expose intrinsic SIMD types, but there would be caveats to using them, and the language would realistically have to expose non-SIMD versions not just for when extensions are unsupported but for use within the same applications as the SIMD types. SIMD operations are all vector operations, so mutating individual vector components with scalar operations requires pulling them from the vector register with a separate ops. if you go back and forth between vector ops and scalar ops on components, the cost of the loads/stores can actually outweigh the benefit of vector operations. you can, of course, avoid this by mindfully ordering/batching operations, and this may align with some use cases more naturally than others. but this isn't really something compilers can do for you in nontrivial cases without making some pretty hefty assumptions which would introduce other problems. also worth mention that for native applications you can't always safely assume the target supports SSE/AVX/etc, and using ops from those extensions on a machine which doesn't support them will crash the application. and runtime branching to test for support at every vector op is hardly ideal (this is one of the very rare cases where VM/JIT actually holds a distinct advantage over native). x64 includes SSE and SSE2, though, so there's that
>>
>>62284532
Why people think they can learn coding by watching vids. What happened. Are we doomed?
>>
>>62284580
I think it is because a lot of other things can be learned this way.
Learning a written language through speak is slow as fuck though
>>
>>62284556
That's not how it works.
>>
File: 1501101630033.jpg (64KB, 500x300px) Image search: [Google]
1501101630033.jpg
64KB, 500x300px
Please explain to me
>>> 6/2*(1+2)
9
>>> 6/(2*(1+2))
1
>>> 6/(1+2)+(1+2)
5
>>
>>62284634
How, then?
>>
>>62284646
6/3+3
>>
>>62284646
python 2.7

Sorry forgot language...
>>
>>62284646
Multiplicative operands are associative from left to right.
>>
>>62284660
>6/3+3
also five
da fuq?
>>
>>62284089
>>62284046
BTFO
>>
>>62284646
you must be 18+ to access this website
>>
>>62284556
is that any different from this?
type** pointer;
pointer = malloc(n * sizeof(type*));
for (int i = 0; i < n; i++) {
pointer[i] = malloc(m * sizeof(type));
}
>>
>>62284686
How?
>>
>>62284646
Nothing to explain, just basic order of operations.
6/2*(1+2) = 6/2*3 = 3*3 = 9
6/(2*(1+2)) = 6/(2*3) = 6/6 = 1
6/(1+2)+(1+2) = 6/3+3 = 2+3 = 5
>>
>>62284658
int stack[n][m];

int *(heap[m]) = malloc(n*m*sizeof(int));
>>
>>62284665
Thank you.
>>
>>62284646
Not using glorious LISP
(/ 6 (* 2 (+ 1 2)))
>>
>>62284646
>infix operator languages
lol
>>
>>62284694
Not you, the one who claimed there's no SIMD in modern languages
>>
>>62284692
What you posted actually works. It's a jagged array though.
>>
>>62284532
>>62284556

this
>>62284557
better cache locality
>>
>>62284705
>((()))
Is it worth it?
>>
>>62284697
How is the last line different from my solution?
>>
>>62284713
When I did it the first way I kept getting a runtime violation error when I tried to write to it.
>>
What do you boyos think about Kotlin?
>>
>>62284784
I don't need to target the JVM so it's useless to me.
>>
>>62283275
VS( if you use VC++ more than any other compiler ,also while on windows obviously) > Jetbrains products > Netbeans > Eclipse
>>
File: 1502906675545.png (133KB, 622x626px) Image search: [Google]
1502906675545.png
133KB, 622x626px
>>62284688
>>
>>62284784
PoS that doesn't fix anything.
>>
>>62284646
>>>/middle-school
>>
>>62284765
In the first example you're dereferencing whatever uninitialized value is in the space you malloced.
>>
>>62284646
Division and multiplication have the same priority (like addition and subtraction).
Multiplying a scalar to a fraction always mean you multiply it to the numerator.
None of your examples are wrong, but you can use parenthesis if it makes it easier for you to read.
>>
>>62284580
I guess I'm more of an auditory learner. Hearing a proper explanation of what was going on helped me to understand where a written explanation wasn't helping.

>>62284697
Can you do this in C if n and m aren't known at compile time?
>>
>>62284894
With C99 you can do the first, not sure about the latter.
>>
>>62284814
I don't dereference anything, what are you talking about?
>>
>>62284926
*(ptr + n)
ptr[n]

These are identical in C. Arrays convert implicitly to a pointer to their first element.
>>
>>62284983
u wot
(type**) is not dereferencing, it's type casting.
>>
>>62285124
Not yet, but what happens when you use it?

type **pointer_a;
pointer_a = (type**) malloc(n*m*sizeof(type));

type *pointer_b = pointer_a;[0];
type val = pointer_b[0] // dereferencing an uninitialized "pointer"
>>
File: feels bad man.gif (2MB, 680x467px) Image search: [Google]
feels bad man.gif
2MB, 680x467px
>>62282576
>What are you working on, /g/?
Getting my life back together.
>>
information or a book on programming with audio files

for example an image, you can zoom a portion of it, make it white and black, emboss it, blur it etc.

what sort of things can you do to some audio is what im trying to find
>>
>>62285178
If it's important, I could use calloc instead of malloc.
>>
A systems programming language with type inference, traits, lambdas (and general anonymous trait objects), higher kinded types, limited dependent types for dynamically sized types, modules, and hygienic macros.
>>
>>62285247
Then you'll dereference a NULL pointer (probably). The problem remains the same.
>>
>>62285252
How are you handling memory management
>>
>>62285282
Like C, but even simpler. No hints like const, restrict, or volatile. This means the programmer is responsible for optimizing away memory accesses with temporaries.
>>
@@62285367
Do you get off on saying meaningless things and tricking undergrads into giving you (You)s?
>>
>>62285367
I see absolutely no problems with this
>>
>>62285261
Oh well, now I see, thanks.
>>
>>62285389
I'm considering having a feature like Go's defer to reduce duplication of resource destruction code among different branches, but that's as far as I'll go.
>>
File: 1497788381199.png (4KB, 183x275px) Image search: [Google]
1497788381199.png
4KB, 183x275px
>Do you get off on saying meaningless things and tricking undergrads into giving you (You)s?
>>
>>62285406
How will you avoid all the other problems C has with MM
>>
>>62285425
he does
>>
>>62285431
Which problems? I'm not concerned about safety.
>>
>>62285456
Guess I got nowhere else to go with this then
>>
>>62283275
Emacs
>>
>>62283907
>newb
?

>>62283963
>selecting a language based on the opinions of its creators instead of its technical advantages
How does being a right-wing sjw feel like?
>>
>>62284556
https://gustedt.wordpress.com/2014/09/08/dont-use-fake-matrices/
>>
>>62282576
>types
Why did most languages fall for this meme? Sane people use untyped lambda calculi.
>>
>>62285527
Rather than making a safe but complex language (or one that requires lots of theorem proving mixed in with the code), I'm aiming more for a simple, unsafe language that is easy to verify informally or externally (for example, a back end might target a theorem prover rather than machine code).
>>
>>62282576
I'm polishing up a new build system for my electron APP based on webpack and electron-builder
>>
File: 1486841794741.png (709KB, 957x1518px) Image search: [Google]
1486841794741.png
709KB, 957x1518px
Who likes pegging here? I want to be pegged by my programming anime gf and the cuddle together.
>>
>>62285782
>the
*then
>>
I'm just getting started with scala and I'm running into trouble trying to save my REPL session. Here's the output:

scala> :save ~/repl-test.scala
java.io.FileNotFoundException: ~/repl-test.scala (No such file or directory)
at java.io.FileOutputStream.open0(Native Method)
at java.io.FileOutputStream.open(FileOutputStream.java:270)
at java.io.FileOutputStream.<init>(FileOutputStream.java:213)
at scala.reflect.io.File.outputStream(File.scala:66)
at scala.reflect.io.File.writer(File.scala:74)
.
.
.

That entry seems to have slain the compiler. Shall I replay
your session? I can re-run each line except the last one.
[y/n]


Any idea what's wrong?
>>
>>62285857
You installing and using scala in the first place.
>>
>>62285857
Does ~/repl-test.scala exist?
>>
>>62285782
My asian wife pegged me.
>>
>>62285782
kill yourself pedophile
>>
File: 1478472400758.jpg (32KB, 128x128px) Image search: [Google]
1478472400758.jpg
32KB, 128x128px
>>62285982
Why?
>>
>>62285857
I bet that it considers ~ as the name of a directory instead of your $HOME
>>
>>62285994
he's jelly about your existence
>>
Everything save for MATLAB is a code monkey.
>>
File: 1350594293765.jpg (111KB, 500x500px) Image search: [Google]
1350594293765.jpg
111KB, 500x500px
std::vector<MyType>* first = new std::vector<MyType>();
addShitToFirst(first);
std::vector<MyType>* second = new std::vector<MyType>();
// ?????

How do I copy the contents of first to second?
>>
>>62283369

Hard != tedious
>>
>>62286178
std::vector second = first;
>>
>>62286237
No, the vector is already made on the heap. This is library code I can not change. I need to copy the contents into my own heap-declared vector.
>>
>>62285782
does your anime gf know how to fizzbuzz in malbolge?
>>
>>62286178
std::vector<MyType> *second = new std::vector<MyType>(first);

Invokes the copy constructor.
>>
>>62286253
Thanks!
>>
tfw working on a game
>>
>>62286271
I am also working on a game.
>>
>>62286271
>>62286295
tfw not working on a game
>>
>>62286271
>>62286295
What language?
What license? Got a repo?
>>
>>62282576
Why is this not working as expected?
int main() {
char* string[MAX];
while(1)
{
printf("Enter text:");
scanf("%s",&string);
printf("At index 0: %c\n",string[0]);
if(string[0] == '~')
return 0;
>>
>>62286381
pure javascript html5
>>
>>62286460
What license? Got a repo?
>>
>>62286381
C++, proprietary, private bitbucket.
>>
>>62286473
https://fghj2.neocities.org/gra9/index.htm
>>
>>62286459
What was expected?
What is the result?

>char* string[MAX];
You don't need the *

>&string
You don't need the &.
>>
>>62286271
Good, now get lost. Game developers are not programmers.
>>
>>62286489
>no license
>no repo

>>62286479
Please leave.

>>62286493
Sure they are.
>>
>>62286507
No.
>>
trying to write and condense a java program that returns either a 0 or a 1 (50/50 chance coin flip) in as little code as possible
[spoiler]I have no idea how to code in Java[/spoiler]
>>
>>62286519
Yes.
>>
>>62286519
>game developers are not programmers
yeah because physics engines just wish themselves into existence. john carmack would like a word
>>
File: Untitled.png (47KB, 1389x564px) Image search: [Google]
Untitled.png
47KB, 1389x564px
You can't call yourself a programmer without ever having made a graphical engine of your own.
>>
>>62286491
oh, i see. i expeted if I enter '~' , or any string that starts with '~', then the program should immediately end and return 0
>>
>>62286507
>Sure they are.
Most 'game developers' are drag&drop Unity users.
>>
>>62286544
>C++
>windows?
Cancer

>>62286558
These don't belong here indeed.
>>
File: Spongebob-and-Patrick-Laughing.gif (350KB, 500x344px) Image search: [Google]
Spongebob-and-Patrick-Laughing.gif
350KB, 500x344px
>>62286544
you shouldn't call yourself one either. That looks like shit lmao
>>
>>62286577
t. nodev
>>
File: Untitled.png (39KB, 1249x525px) Image search: [Google]
Untitled.png
39KB, 1249x525px
>>62286583
Let's see you make this in a more succint way, fuccboi.
>>
>>62286584
True, I do not call myself a "dev", this is a foul term. I call myself a "Computer Scientist" instead.
>>
>>62286596
>writing essays instead of programming
>>
>>62286619
I'm sure Dijkstra just sucked his algorithm out of his own dick instead of writing it down in plain terms first.
>>
echo >>62286577 1>&2 /dev/null
>>
>>62286630
He wrote it in formal logic, faglord.
>>
>>62286544
>LE AYMMUH MAKE A GAAAAAAAEEEAEAEAEM ENGEENE
>>
>>62286657
Are you okay, anon? Are you having a stroke?
>>
how does this work? it works correctly somehow, but i get a warning that config is uninitialized. if i initialize config to nullptr i get SIGSEGV.

AConfiguration *config;

AConfiguration_fromAssetManager(config, activity->assetManager);


struct AConfiguration;
/**
* {@link AConfiguration} is an opaque type used to get and set
* various subsystem configurations.
*
* A {@link AConfiguration} pointer can be obtained using:
* - AConfiguration_new()
* - AConfiguration_fromAssetManager()
*/
typedef struct AConfiguration AConfiguration;

/**
* Create and return a new AConfiguration based on the current configuration in
* use in the given {@link AAssetManager}.
*/
void AConfiguration_fromAssetManager(AConfiguration* out, AAssetManager* am);
>>
>>62286667
>not MATLAB
pleb code monkey
>>
>>62286665
IM HAVEEN A GAAAAAAAAAAAAAAEEEEEEEM ENGEENE BROSEPH

DUUUUUUUDE GAAEAEAEAEAEEAEMS MAAAAAAAAN
>>
>>62286667
oh and if i try to do

AConfiguration config;

AConfiguration_fromAssetManager(&config, activity->assetManager);


>error: variable has incomplete type 'AConfiguration'
>>
AConfiguration *config;

AConfiguration_fromAssetManager(*(&config), activity->assetManager);


this gets rid of the warning but how does it actually work? isn't config uninitialized?
>>
>>62286685
Someone call an ambulance! This anon is having a stroke!
>>
>>62286679
>MATLAB
Non-free crapware.
>>
>>62282618
Steve, why are you pandering to us degenerates? We are not worthy.
>>
>he calls himself anything other than a Code Artisan
>>
>>62286778
godware, there's Octave for poorfags
>>
>>62286806
Just use Scheme lol
>>
>>62282618
> Using .or_insert_with instead of .or_insert
Why?
>>
File: 1501161617280.jpg (37KB, 686x576px) Image search: [Google]
1501161617280.jpg
37KB, 686x576px
myVector->at(1) = otherVector->at(2);


Is this a legal operation? Will it do what I expect it to do?
>>
>>62286667
>>62286747
it seems you're supposed to initialize it with AConfiguration_new() before calling AConfiguration_fromAssetManager()? but the comments seem to suggest that you would create it twice? and it sure seems to work with the uninitialized pointer?
>>
>>62286875
Yes.
Probably anyway, depends on the types inside each vector.
>>
>>62286875
Dumb akariposter
>>
>>62286178

>new
Please don't do this. It's a vector. Its internal buffers are already heap allocated.
>>
>>62286874
.or_intesrt evaluates its arguments as every function does, meaning a new vector would be created every time, even if it's not needed.
>>
File: 1501608741123.gif (14KB, 309x318px) Image search: [Google]
1501608741123.gif
14KB, 309x318px
>>62286974
I like allocating large things with new and delete because I once made the mistake of passing a vector containing some delicate objects via stack which made them construct and delete a thousand times per second.
>>
>tfw to intelligent too implement a splay tree in C
>>
>>62286894
>>62286667
ok i get it now it it's UB and i can't just declare it on the stack because it's an opaque type
>>
File: file.png (43KB, 244x206px) Image search: [Google]
file.png
43KB, 244x206px
>>62287037
>>
>>62287029
Lrn2 move semantics.
>>
>>62287029
>>62286875
>>62286178
>>62285994
>>62285782
>>62283603
>>62282576
what do these have in common
>>
>>62287029

Pay attention to what the hell you are doing and learn from your mistakes. Pass your vectors by reference (const reference if the user won't mutate them) and allocate them on the stack of their owner.

And if you absolutely must use new, do it in a unique_ptr or shared_ptr.
>>
>>62287111
What is wrong with new in constructor, delete in destructor?
>>
>>62287029
>I made them construct and destruct by mistake
Yes that kind of issue is the cost of RAII aside from the programmer overhead of writing in that style.
>>62287069
Alleviated by move semantics with even more work.

C++ is a terrible language by design.
>>
>>62287021
Wait seriously? So it allocates every time? Huh, I guess that makes sense.
>>
you guys are awesome, better than stackexchange
>>
>>62286875
read the documentation you dumb nigger
>>
>>62287192
>stackexchange
Not a high bar but it depends on what you're after.
>>
>>62287174
What did you expect? It's not a macro.
>>
>>62282576
why common lisp
>>
>>62287256
it's the only currently supported lisp with enough libraries to not force you to reinvent the wheel every time you want to do something

sadly, it has lots of holdovers from the 80s which shouldn't exist anymore
>>
>>62287197
Please don't insult my girlfriend.
>>
Is there a clever way to implement by-name arguments, or are they just closures with some syntax sugar?
>>
>>62287279
> currently supported
> the latest standard is 25 years old
>>
Which of these is best to write my loonix programs?
>>
>>62287303
and it still has several popular implementations, so I'd say it's supported
>>
I have a motherfucking problem and no one on the web helped me. Can /g/ do it?
https://stackoverflow.com/questions/46072792/how-to-run-3-scripts-in-a-specific-order-in-a-website-and-how-to-modify-html-cod
>>
>>62287308
litebook if those are my only three choices.
>>
>>62287286
please tell your girlfriend to get a brain
>>
>>62287295
They spent like 10 years in the 60s trying to invent a non-retarded way to implement them in ALGOL compilers only to realize it was a dumb idea to begin with. But yeah, it's basically just weird closures.
>>
>>62287308
>more than 9 hours battery life
HOW
>>
>>62287338
Which would you chose if you had any choice?
>>
>>62287391
Absolutely any budget?
probably an XPS or something but i really dont keep up with laptops.
Try /sqt/ or go look an >>/g/tpg/ or something.
>>
>>62287440
>>>/g/tpg
*
>>
>>62287101
nothing
>>
>>62287335
>js
>>>/g/wdg
>>
File: NLByMNI.jpg (40KB, 700x777px) Image search: [Google]
NLByMNI.jpg
40KB, 700x777px
>>62285230
hang in there man,
>>
>>62287539
Shit, you are write. Thanks and sorry.
>>
Is SDL_Surface basically redundant because of SDL_Texture now?
What are each used for?
>>
>>62287585
I think Surfaces are used in your main memory and texture in your gpu memory.
I don't know SDL but I heard it an hour ago in a video
>>
>>62287633
Thanks!
Do you know of the advantage/disadvantages of each? Like when you should use one or the other?
>>
>>62287756
https://stackoverflow.com/questions/21392755/difference-between-surface-and-texture-sdl-general
>>
>>62287308
why do they even make laptops with 4gb of ram anymore? most new phones have 6gb at this point
>>
>>62287756
as I said, I don't know SDL so I can't really help you with that buddy.
>>
>>62287756
Use textures.
>>
What exactly are "64-bit builds" for Windows applications? Obviously there are some different build flags, the executables only work on some versions of Windows, but I've heard of developers *working* on 64-bit builds? What does this mean? Are there large differences in the WinAPI between archs? Or is the issue that most of these applications rely on shitty hacks that a change in pointer size would fuck up?
>>
>>62288006
It means they have to provide a second binary for 64-bit users because windows is a load of shit and didn't transition very well into 64-bit computing.
Even the internal name "WoW64" aka "Windows on Windows 64-bit" should give it away.
>>
>>62287813
Yeah, they still make 4GB laptops with 1366x768 screens and 500GB hard drives. They also charge $700 or so for such a laptop. Consumer electronics is a fucking shitshow.
>>
>>62288062
I know, I've been meaning to get a laptop but it seems you need to shell out $1k for anything reasonable. Is this why /g/ is obsessed with used thinkpads?
>>
>>62287952
Can textures only be written to once? As in can a texture change its contents without making a new one?
At the moment I'm making a texture using:
SDL_Surface *surf = SDL_LoadBMP(image);
SDL_Texture *tex = SDL_CreateTextureFromSurface(renderer, surf);

At the moment I'm not changing the contents of either; just displaying an image on screen, but if I were to change it, would I have to destroy the texture, clear surf, load another BMP then create another texture from it? Or is there a better way?
>>
File: file.png (146KB, 1024x878px) Image search: [Google]
file.png
146KB, 1024x878px
>>
>>62288096
textures are hardware accelerated, any modifications must be performed by the graphics card and that means the graphics card needs the instructions stored in VRAM before it can start.
This is why VBOs and VAOs became standard practice in opengl and immediate mode is now something emulated in software just for the benefit of older software.
>>
>>62288127
jesus christ
>>
>>62288127
So does this mean I need to learn python if I want a job?
>>
>>62288127
Nice nvidia graph
>>
>>62288096
idk how it works in sdl but in opengl (and you can use opengl directly with sdl) you have some different options like you can render to a texture using a framebuffer object or update part of a texture using glTexSubImage2D or use a pbuffer depending on what you're trying to do
>>
>>62288127
> % of overall question views each month
So the graph shows which languages requires the most help. Apparently python is terrible, as you need to look up anything.
>>
>>62288148
No, it means you don't learn python you just perpetually go to stack overflow
>>
>when a C API tutorial starts off by designing shitty C++ wrapper classes and has irrelevant glue code everywhere
>>
>>62288091
Because they are (or used to be) a great value. They aren't built shitcheap, they are easily upgradable, and there are plenty of aftermarket and OEM replacement parts out there.

I bought a NEW (Sep 2016) OEM 9-cell for my T420 last fall. The original intel wifi chip sucks mad dick, so I put in an atheros chip that I found on ebay for $15. I paid $150 for the laptop in 2014, immediately added a $30 4GB RAM module, a $60 SSD and it runs better than most of the laptops I've tried since then (muh fukin ULV processors).

If you do want to get one, get a used T430, the extra iGPU perf is recommended. And you can spend $20 on a T420 keyboard and exchange it for the shitty chicklet one they ship with the 430's. The keyboards are (almost) part compatible.
>>
>>62288096
You can render to a texture.
>>
File: 1503814885976.jpg (7KB, 251x190px) Image search: [Google]
1503814885976.jpg
7KB, 251x190px
>python is easier to use!
>has tons of complicated libraries
Is Python really easier if the time you spend on learning libraries you could spend on writing your own library and achieve the same result?
By the way, what is some good Python library to draw in SVG?
>>
>>62288604
python users are incapable of writing their own libraries, that's why they use python.
Also some things are entire projects in and of themselves, you don't need to implement everything, you wouldn't rewrite curl if you wanna write a downloader, right?
>>
>>62288604
>Is Python really easier if the time you spend on learning libraries you could spend on writing your own library
I bet I can read a doc page faster than you can write and test an entire fucking library.
>>
File: fit-garage.png (24KB, 508x530px) Image search: [Google]
fit-garage.png
24KB, 508x530px
What's the point of functional programming instead of OOP?
>>
>>62288679
cleaner
no run-time errors
no coupling
vastly more maintainable
>>
>>62288679
more fun desu
>>
>>62288604
python is a fucking joke. if you want to be a serious programmer you use C++ or if you're more of a normie than perhaps java or C#
>>
>>62288718
What's the point of OOP instead of functional programming then?
>>
>>62288738
>or if you're more of a normie than perhaps java or C#
nah
ill stick to C and python
>>
>>62288783
nobody knows
>>
>>62278926
"sequel" is ridiculous. at least "gooey" sort of matches the spelling of GUI
>>
>>62288783
its very brainlet friendly.
>>
>>62288718
>>62288805
Is there any reason to use a functional language isn't of just programming in that style in a multi-paradigm langauge?
>>
>>62288861
Multi paradigm languages usually make big compromises on functional features, especially in the type system.
>>
What is babbies first language? Java or Python?
>>
>>62288861
good functional languages don't leave any room to defy the paradigm and have much more focused features.
Doing a functional style in a non-functional focused language as the other anon said often leaves you with a half-assed variant.

That being said, I think D is still the best at this.
>>
>>62288900
BASIC
>>
NEW THREAD!!

>>62288947
>>62288947
>>
New thread:

>>62288936
>>62288936
>>62288936
>>
>>62288953
>>62288955
Nice job dumbasses
>>
>>62288861
multi-paradigm languages become a mess like c++ or scala
best to stick to a core paradigm
>>
>>62288900
java

https://docs.oracle.com/javase/tutorial/
>>
>>62288900
I honestly think that python is better for beginners - it was my first language - but now I refuse to program in it because of various problems in it
>>
>>62289014
and Java is my favorite language so I if you can deal with slightly-confusing error messages, go for Java! /dpt/ will help you with any compile problems you have.
>>
>>62282576
>I'm writing a file manager in C
>I don't know why
>>
 
someFunction() {
...
}
or
someFunction()
{
...
}
>>
>>62289158
second because its easier to read.
>>
>>62289158
first

second is ok in C
>>
>>62288805
Are there literally no benefits to OOP? Does /g/ agree that functional programming is the best and the one true way?
>>
>>62289226
>Does /g/ agree that functional programming is the best and the one true way?
Pure functional still lacks speed and proper memory management, but other than those two, yes.
>>
>>62289226
i don't
>>
>>62289014
C was my first language. I still program in it. I still program in Python too.

C -> Java (school, lol) -> Lua -> several assembly languages -> Verilog -> Go -> JS -> I don't even remember, Bash is among them -> Haskell -> Python -> J

They make you learn a lot of bullshit as a CE student.
>>
>>62282576
AND YOU DON'T SEEM TO UNDERSTAND
>>
File: loonix.png (594KB, 1702x684px) Image search: [Google]
loonix.png
594KB, 1702x684px
>>62287308
>comparing celeron quad core to core m3 dual core
>>
>>62289310
GHC isn't slow when you feed it well written Haskell. And I don't mean you have to give it asm.js-style tarpit code that happens to run well on GHC - to get most of the performance out of it, you just need some understanding of how GHC will evaluate your code. You can still write readable Haskell from there.

Memory management is a real clusterfuck though.
>>
>>62290584
GHC is slow compared to system languages no matter how great your haskell is.
>>
>>62290599
True, obviously I can't deny that compared to the best written C, the best Haskell always be slower by definition, and probably slower by 2x, maybe 3x. So, I guess you have to frame it in that mindset when we talk about saying "Haskell isn't slow". As in, I mean to say, "GHC will beat almost all of the dynamic languages and tie with a lot of the static languages that aren't systems level".
>>
Does anyone else have trouble easily reaching the ampersand key when programming? It's used for a lot of things like references, but Shift+7 seems like such an out of the way key combination.
>>
>>62290736
Here is a trick... press the buttons with separate hands
>>
>>62290734
Well also keep in mind, when someone calls a language slow, its most likely being compared to a c or sepples.

I think the first iteration language on Rust will give us a focus on speed though. People love functional programming but can't replace everything with it. So it's only a matter of time.
>>
>>62290736
my finger pecking skills from programming at a young age gave me wicked ampersand typing skills and RSI
>>
>>62290769
It depends on what context you're coming from. I can see in the Rust world obviously the basis for comparison is C. Coming back to my asm.js example, when the standards were being shuffled around, those people viewed the sacrifices necessary to get 2x slowdown as still getting us "fast": https://kripken.github.io/mloc_emscripten_talk/#/30

Keep in mind in the Python world, crazy slowdowns of 30x-100x are seen as normal and whatever slowdowns they get from cython are considered vast improvements.

And, as a final note, Haskell isn't meant to compete in Rust's ballpark since it will never be suitable for realtime systems. So that tends to factor into its languages it's used to compare against. As a very high level language, it's easy to compare it against other high level languages, which it often sees a big performance benefit against.
>>
>>62283275
IntelliJ by far, modern and simplistic, yet packed with features. I've tried NetBeans and Eclipse before but they're both shitty.
Thread posts: 340
Thread images: 27


[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.