[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: 332
Thread images: 33

File: pyo.jpg (90KB, 1080x1080px) Image search: [Google]
pyo.jpg
90KB, 1080x1080px
what are you writing?

previous >>56800999
>>
A reply to this thread
>>
>javascript talk in my city has reached its limit of 160 signups
this has gotten out of control
>>
I broke my avr project once again.
And I don't even have an oscilloscope to check where exactly it hangs.
>>
Working on my image handling library for Rust, writing documentation and tightening the API, and improving performance where I find issues.
>>
#define/**/install/**/0[x]=045;p(j);p(k);for(;;){++l;m++;++q;r++;
#define gentoo if((l-44)>>6){p(l);p(l);break;}}m|=3;q^=27;p(m); \
r+=6;t>>=2;t+=7;p(t);p(q);p(m);p(r);p(l) ;p(s); t++;p(t) ;p(10);}
#define/**/i/**/int/*/a/ /b/ /c/ /d/ /e/ /f/ /g/ /gif/ /h/ /hr/*/
#define/**/c/* */char/*/k/ /m/ /o/ /p/ /r/ /s/ /t/ /u/ /v/ /vg/*/
#define/**/Anonymous/**/1[x] b-1;i Thu b;j+=4;k++;i a=// /vr/ /w/
#define/* */b/* */=0144/* /wg/ /i/ /ic/ /r9k/ /s4s/ /cm/ /hm/ */
c x[2];i j b,No b,k b,l b,m b,q b,r b,s b,t b;main(){ //lgbt/ /y/
#define p(o) printf(x, o) //3/ /aco/ /adv/ /an/ /asp/ /biz/ /cgl/


Anonymous 07/07/16*(Thu)*11;25;11*No*55458155;

install gentoo


Wrote hello world in C.
>>
>>56806905
>what are you writing?
Time for pancakes

>/dpt/ frequenters will get this

https://github.com/enfiskutensykkel/cuda-rdma-bench-advanced

Some minor features left to implement and of course a README that makes sense, but would say around 95% done.
>>
I want to learn Haskell because I found the name cute, where should I start?

I know C and a little bit of Phyton
>>
>>56807083
>you will never have three programming languages named after you
>>
>>56807016
Nice, what's its name?
>>
Anyone know how to send raw HID stuff in windows like HIDraw on linux?

Fucking piece of shit windows validates the hid packets with the HID descriptor before sending them so I can't send anything that's not in the HID descriptor.
>>
>>56807176
picto
>>
Is this very unstable to add to repo?

 #[testing]
#Include = /etc/pacman.d/mirrorlist
>>
>>56807241
Did you try with hidapi?
>>
a micro ethernet/ip stack
>>
>>56806905
What is he doing?
>>
>>56807380
Yes, it uses the normal windows HID api so there wasn't any difference.
>>
>>56807486
I guess you're fucked then, you'd probably need a custom driver like the libusb one.
>>
>>56807466
Doing the toot
>>
toying around with algorithms in go to prepare for interviews
alternately boring and frustrating. fun every once and a while
>>
>pick up algorithms book
>it's all math
>even the psuedocode is next to useless because it's so far removed from any programming language that they force you to learn THEIR syntax

Wikipedia is so much better for learning algos, they even keep their examples in C.
>>
>>56807878
you need to be able to read math if you consider yourself a computer scientist and not just a koder

someone post kode with karlie pictures i'm on a new pc and i dont have any
>>
>>56807887
It's not even math math, it's all weird symbols and they spend more time obsessing over the big O rating rather than the implementation

what is there to understand in big o?
Either your runtime grows with it's input size in a predictable way or it doesn't.
>>
>>56807878
this is the kind of computer science book i like. i'm evangelizing kleinberg-tardos for this reason
but if you don't, you should look at sedgewick's algorithms in {c, c++, java}
still, it's going to be hard to analyze any of this if you don't like math somewhat
>>
File: Adlermosaik.jpg (3MB, 1598x1909px) Image search: [Google]
Adlermosaik.jpg
3MB, 1598x1909px
Memes aside, is python a good place to start with programming?

Since my city has a large video game Industry I plan on taking a job in that field, what would be the best languages to learn in order to better my chances?
>>
>>56807962
In my opinion learn C and then C++
Interpreted languages are next to useless for game dev.
>>
>>56807962
>muh gaymes
Python is an ok language to start with. It's easy and you can do small things quickly with it. However, you want to be one of the retard clique, so you'll want a strongly-typed language instead. Pick up C++ for gamedev.
>>
>>56807916
>It's not even math math, it's all weird symbols
those weird symbols are math. everyone can read x = 2
>Either your runtime grows with it's input size in a predictable way or it doesn't.
if the size of your input is n and the time it takes for the answer to be computed is t, t = 2n grows with input size predictably just like t = 2^n. do you understand why those 2 orders of growth are different? plug in 500 for n on both of them in a calculator
>>
>>56806991
I fixed it. Partially.
Cool.
>>
MS-DOS Simulator for university
C++
>>
File: angular2.png (7KB, 300x168px) Image search: [Google]
angular2.png
7KB, 300x168px
I'm working on something in Python and Django. I'm thinking about using Angular 2 for my frontend. Has anyone whom has used Angular 1.x fucked with it? Typescript seems okay, and version 2 just came out, but it seems newfangled and tedious.

>>56807962
Yes.

C++, XML, at least some HTML. Possibly Lua. Do your research.
>>
>>56807916
>>56807995
assuming you're a college csci student also go ahead and start learning greek letters, capital and lowercase. put all the symbols you see and you don't know on flashcards and memorize them
>>
File: google metronome.jpg (34KB, 1048x445px) Image search: [Google]
google metronome.jpg
34KB, 1048x445px
Yesterday anon gave me a tip if you search 'metronome' google would give you a web app metronome. Pretty neat, but i want to learn how to build one myself so i tried to look at how it's done. This turned out to be more difficult than i'd hoped. Of course the code is near impenetrable, but i can't even save it offline and have it work, which makes revers engineering it almost impossible for me.

Can anyone offer any help or insight or tips into this problem?

This is a longshot, i know, but one can always ask. I'm also going to post this in the web dev general to see if anyone there might have any help to offer.
>>
>>56807962
>Memes aside, is python a good place to start with programming?
The memes originated from truth. Python is a poor man's language.
>>
>your api can't even get interMenstraulBleeding anaylitics.

What's your excuse android ""devs""?

https://developer.apple.com/reference/healthkit/1627060-healthkit_constants/1665100-category_type_identifiers
>>
>>56806905
who is

>she
>>
Is it reasonable to write a web API in C++, or should I just use Python? I don't need high performance, I just want something that just werks.
>>
>>56808206
it's pyo hyemi
>>
>>56808055
you really don't need flashcards to learn greek letters that's the most autistic thing I've ever heard
>>
>>56808239
akariboobs anon is doing it in c, iirc
>>
>>56808131
go to google.com and click view page source

they obfuscate their code to the point where you just can't use it, you're better off starting from scratch
>>
>>56808264
Do you mean the Akari avatarfag?
>>
Learning Android

and

Learning how Perlin (Simplex) Noise works. Doing some experiences on Javascript+Canvas.
>>
File: mehfeelsalrightiguess.jpg (38KB, 480x347px) Image search: [Google]
mehfeelsalrightiguess.jpg
38KB, 480x347px
This weeks lesson is in debugging shit code
something im actually decent at.
>>
>>56808239
>write a web API in C++
Why reinvent the wheel? Look up Wt, PoCo, ffead, Tntnet (might be outdated).
>>
>>56808131

You sleep and play a sound on a loop. The only difficult part should be calculating how long to sleep, as you have to take into account the length of the soundbyte file. But honestly, it's just basic math, a slider, and playing audio. What aren't you getting?
>>
>>56808289
He's the best anon in this thread
>>
>>56808131
Javascript. onTimeout function to implement a loop (update, like in games). Beep every X seconds. Voilá, a metronome.
>>
>>56807962
Python is good to learn and good language because it's easy and fast to write programs in.
Execution speed doesn't matter because Moore's law and JIT. Type checking is for people who need hand held to write a safe program.
>>
>>56808324
He is indeed, even though I dislike avatarfagging. He suggested composingprograms.com (no shilling intended) which I'm currently reading. It's a really good read.
>>
>cant even remember ternary operators

is there any hope for me as a programmer
>>
>>56808379
I didn't even know them by name, but I use them consistently. Don't worry, a year ago didn't remember them either.
>>
>>56808300
I didn't plan on reinventing the wheel. Their implementations are light years ahead of what I can produce in a short period of time.
I'm just looking for something that allows me to easily write a web API.
>>
>>56808405
Thanks for the hope anon
>>
>>56808243
suit yourself. you could spend 2 hours learning them and know them for life or not, up to you
>>
>>56808278
>go to google.com and click view page source
Obviously, that's what i did. I was going to do it from scratch, but i thought i might learn some tricks by looking at how they have done it.

>>56808307
The thing i'm having trouble getting is how to play the sound, but mostly how to generate the sound to play.
>>
im writing a basic tcp file transfer program but have ran into a bit of an issue

the program asks for a port to use, but if you ctrl+z/(exit out of terminal) without going through the programs "exit" function (which flushes/closes the socket), the port is unusable until i turn restart the internet/my computer. the port is still being used even if the program is long exited, assuming since it never flushes/closes

can anyone think of a way to not have that be so cumbersome
>>
>>56808506
No, what I mean is go to google.com (click the link if that's too hard) and then when you're on the front page, look at the source code.
>>
I need to develop a quick GUI in Python.
So, i tried but it took so effort in GTK.
Then I've discovered Glade, work well.
Is there some layout/container with fixed positions?
Can i have two or more container in the same window?
>>
>>56808517
You can kill the process holding the socket: http://superuser.com/questions/127863/manually-closing-a-port-from-commandline#127865
What you described is normal behavior for any program killed that way.
>>
>>56808535
Yes. That's what i did.
>>
Can somebody please post some of those programming challenges pics? Just started programming and need more practice, but can't find those pics like at all. Thanks.
>>
>>56808517
Not sure which language and library you're using, but in case you're dealing with BSD sockets you could try setsockopt with SO_REUSEADDR and/or SO_REUSEPORT. You could also try catching signals using signal.h, but I have no exact knowledge of how that works.
>>
>>56808593
https://better-dpt-roll.github.io/
>>
>>56808592
I thought you said you looked at the source code for the metronome, which is something else. My bad then, not sure what you're gonna reverse engineer on the front page though.
>>
How much texture can I load in a 512mb or 1024mb video card?
I'm not talking about the max texture size, I'm talking about the total size of all the textures currently loaded in vram.
>>
im using Throws Exception and Catch Exception, but its not catching NumberFormatExceptions

i was under the impression that "Exception" was the highest you could go so it would catch anything, is that wrong?
>>
>>56808631
I tried to look at the source code for the metronome, but i couldn't even find that. I had to begin somewhere, so i looked at the web page source code.
>>
>>56808739
Stop worrying about what other people do and just build it yourself.
Your solution will probably be much simpler than their JS-framework laden mess.
>>
>>56807962
I started with C, 3 weeks later moved to C++ and had a glance for month or so with Java and C#, returned to C++ for good 6 or so months, started to develop stuff for uni with OpenCV and C++, heard about the Python meme stuff, tried it, actually wrote web spider for less than 20 minutes from scratch, and better it for no more than another 20 with some libraries.

Now doing OpenCV and CV in general with Python only.

>Point is, learn C and/or C++ for the general purpose language and OOP
>Learn them well, so you can appreciate higher abstract language later on
>Learn them well, so you can debug, improve, optimize your code down the line
>Once you do that, you can pick any higher language and actually start to build useful stuff x10+ times more faster and efficient than before

Also, you can use Python for C++ wrapper, which is really nice.

>tl;dr learn this:
>Fundamentals of C
>C++ and OOP + multi threading
>Python

In this particular order.
>>
>>56808765
> just build it yourself.
Yeah, i'm in the process of figuring out the web audio API. But i'm kind of a noob, if that wasn't obvious, so it's been slow going.
>>
>>56808727
NumberFormatException extends RuntimeException which extends Exception which implements Throwable.
You fucked up somewhere. Post code.
>>
>>56808242
cute as heck phamalam
>>
>websocket server
>200-400 MB RAM on moderate load
>refactor synchronisation algorithm to client-side
>25 MB
This is the best feeling.
>>
Gonna make a personal blogsite and going to build the backend with a microservice architecture. Each microservice is going to do something different (for example ones going to serve up data using a service writtein inn C#, and another is going to be written in node). Like I'll have a cooking section, blog section, pictures section.

Mostly for practice and getting dank jobs in the future
>>
>>56808873
As long as you remember that you've just pawned off the workload to someone else, not done some brilliant feat of optimization.

Then again, you could also say is what you've done is distributed computing, which makes it sound a lot nicer.
>>
>>56808873
rip client
>>
I always feel like a retard when trying to use new libraries.
>http://dispatch.databinder.net/Dispatch.html
>We’ll start with a very simple request.
>Can't get it to work
T-thanks
>>
File: 1466544326223.jpg (32KB, 557x612px) Image search: [Google]
1466544326223.jpg
32KB, 557x612px
>>56808347
>Execution speed doesn't matter because Moore's law and JIT. Type checking is for people who need hand held to write a safe program.
>>
File: 22179268.png (1MB, 800x800px) Image search: [Google]
22179268.png
1MB, 800x800px
>>56808983
>>56808950
It is not actually a high CPU or RAM usage operation, but a matter of state synchronization. I have a database with a guaranteed consistent state. On page load a client sends a request to the backend and receives a snapshot of this state. Then it opens a websocket connection to the server, which opens a change feed on the database (if one is not open already) and passes these state-altering messages to any listening clients. This is where the problem arises. What if any state change happened in the interval between the initial state fetch and connection to the change feed? Or what if a client disconnects and needs to catch up to the server's state?

My original solution was to keep the entire replication log buffered in the server's memory, so it can quickly resolve any of the connecting client's missing messages before subscribing the client and send the missing ones before any new messages are sent. Of course when you have a replication log of potentially several hundred thousand messages, it can lead to quite a lot of RAM.

So instead of blocking the change feed on the client, I refactored to have the server send out the current progress counter to the client on subscribtion. The client then compares this counter to the one it gained during the initial state fetch and checks, if any messages are missing. If there are any, it will block any new received messages from being handled by buffering them and request from the server a specific slice of the replication log, that it needs. When all the missed messages are handled, it can handle all the buffered messages and then just listen for new ones like normal.

So it's not at all an offload of a CPU or RAM bottleneck, but of the blocking elements of the synchronisation algorithm. Networking is fun.
>>
https://developer.mozilla.org/en-US/docs/Web/API/OscillatorNode

What's an 'interface' in JavaScript.
JS doesn't have classes per se, so it's not like Javas interfaces or sepples pure virtuals, is it?
>>
>>56809264
sounds elegant
>>
>>56809265
Does it really matter what it's called?
>>
>>56809265
"interface" here refers to the statically typed API the browser implements.
>>
>>56809370
>statically typed API
I don't know what this means.
>>
>>56809440
The browser isn't written in JS. So it needs to define a static way for JS to communicate with the relevant parts of the browser aka interface.
>>
I have a couple C projects I'm working on.

1. I'm writing a C program that requests the name of any cartoon character from the user, then does the following with that name (use printf for each):

a. Displays it enclosed in double quotes.

b. Displays it in a field 24 characters wide, with the whole field in quotes and name at the right end of the field.

2. I'm also writing a C program that requests from the user the number of miles traveled and the number of gallons of gasoline consumed. It should then calculate and display miles-per-gallon, showing one place to the right of the decimal.

Any help would be nice.
>>
interface vs abstract classes

whats the difference???
>>
File: 1447870401905.jpg (114KB, 970x880px) Image search: [Google]
1447870401905.jpg
114KB, 970x880px
>>56809469
>The browser isn't written in JS

Yet
>>
>>56809500
An abstract class has some definitions.
>>
>>56809488
I'm not doing your homework?
>>
>>56809469
AudioContext.createOscillator(), for instance, returns and object that conforms to the interface OscilatorNode?

An 'interface' is the same as what i would call a 'class' in c++?
>>
>>56809531
Do you literally fucking not know what an interface is in any fucking language?
>>
>>56807994
what is your problem with games?
is it useful to make you feel like a srs person and stop thinking about your permavirgin status?
>>
>>56809552
You have to be 18+ to post on 4chan
>>
whats the point of oop when it just makes everything slower
>>
>>56809548
I thought i did. Since you're asking so nicely, maybe i don't.
>>
File: fed6.jpg (63KB, 420x960px) Image search: [Google]
fed6.jpg
63KB, 420x960px
>>56809564
great argument mr srs man
>>
>>56809572
>It makes code reusable.
>>
ayy senpaitachi, any of you had a paid programming job while at uni? im bored as fuck with uni and i want to do some actual programming in an actual company
>>
>>56809528
It's not homework.
>>
>>56809587
so does copy and paste
>>
>>56809572
makes things easier to make
>>
>>56809615
nigga u dumb
>>
>>56809572
There are rare cases where doing things with objects (in the conceptual sense - things that can send and receive messages) is clearest.

Standard implementations of OOP all suck and 99% of OOP code sucks. But it's not entirely useless.

>>56809587
There's a lot of things that make code reusable.
>>
>>56809584
This boy needs to get himself a pair of real trousers, a pair of proper shoes, and grow a bear, and he'd look a proper distinguished gentleman instead of a 'tard.
>>
>>56809627
nigga u dumb
>>
>>56809607
it couldn't more obviously be homework, or some arbitrary task given to you at the very least.
>>
>>56809639
nigga u dumb
>>
>>56809607
it's obviously homework mate
>>
>>56809687
see copy and paste works
>>
>>56809685
Maybe it's self assigned?

Although the way it's specified, i kind of doubt it in this case.
>>
>>56809685
I'm self-studying C and I read the chapter but I'm stuck on these exercises.

Please don't say something discouraging. I'm trying to learn the language.
>>
>>56809632
>grow a bear
While impressive, I'm not so sure that'd make him "gentlemanly".
>>
>>56809739
kek
>>
I wrote a random image generator, but it segfaults when the height and width are less than 211.
>>
>>56809824
It would certainly make him some kind of manly.
>>
>>56809875
if (height < 211 && width < 211){
// TODO: add kludge
}
>>
>>56809932
Oh I wasn't looking for help I was just posting what I was doing, thanks though
>>
>>56809943
That was a joke.

You should be finding the root cause, not adding a kludge.
>>
>>56809488
i don't care if it's homework, but i think you should consider how you would ask a friend (lol) in person about this
the first thing your friend is going to ask is what you've done so far. do you know how to read in a string from the user? can you then print it out?
>>
>>56809960
I used gdb and when I use anything less than 211 it says that memcpy.s is missing.
>>
>>56809488
>>56809685
>>56809776
>>56809997
Here you go mate, I went ahead and implemented number two for you. Let me know if you have any questions :)

#include <stdio.h>
#include <stdlib.h>
#define _ float /* ____(______) #sprintf("%d", _______) */
#define __(____) atof(____) /* return (double)__________ */
_ ___(_ ____, _ _____){return ____/_____;}
____(char *p){int i;for(i=0;i<17;i++){printf("%c", p[i] - 4);}}
main(int c, char **a){printf("%.1f", ___((_)__(a[1]),(_)__(a[2])));
____("$qmpiw$tiv$keppsr");printf("\n");}
>>
File: 1459487588767.jpg (78KB, 340x314px) Image search: [Google]
1459487588767.jpg
78KB, 340x314px
>>56810055
>>
File: 2368.png (41KB, 1539x314px) Image search: [Google]
2368.png
41KB, 1539x314px
I'm using Box2D and LiquidFun.

I get a java.lang.NullPointException at the line
 mParticleDebugRenderer.render(mParticleSystem, LibPractice.PPM, cameraCombined); 


Does anyone know what's wrong?
Everything that's normally in a box2D render method is in another class.

No idea what the problem is.

If I remove the problem line, it compiles fine.
>>
>>56810055
it's so fast how did you do this
>>
>>56807962
Yes. Learn Python. Python is a great place to start with programming. It's more important that you learn how to program than it is to learn the ins and outs of C and C++, which have become very specialized languages (i.e. performance-critical applications). Python lets you learn how to do neat things with programming relatively easily, since it has a HUGE standard library. You can even write games in it. You can always learn C and C++ later.

Also, just so you know, I'm fluent in Python, C, C++, and Haskell, and have played around in a bunch of other languages too, so I know more-or-less what I'm talking about.

Another thing: if anyone on here tells you that Python is too easy, or babby's first programming language, understand that it's not the syntax or concepts of a language that should be hard, but the design of the application and the abstractions used. Only go for the harder-to-use tool if you really need that extra performance in exchange for spending 10 times as long building the application.
>>
>>56810142
How did you learned Haskell? I'm looking for some tips
>>
>>56810055
what does this actually do though? not the guy but I'm wondering cause I see people post these all the time but I'm too lazy to check it out in a VM
>>
>>56810055
Sorry bro but I know you're shitting me. Most of that has not been brought up at this point.
>>
>>56810164
>>56810159
Compile it, you mongs. The code works. You can see that the only library functions used are printf and atof. What do you think is going to happen, your computer is going to blow up?
>>
pls no
https://isocpp.org/blog/2016/09/announcing-diversity-tickets-for-meeting-cpp-2016
>>
>>56810199
nah im good mate
>>
>>56809599 anyone?
>>
>>56810154
lyah
>>
so /dpt/, do you call it a bodge? a kludge? a "hack"?
>>
how do i make an assert statement in javascript?
>>
>>56810204
Nice. Finally I can get something worthwhile out of my trap attire.
>>
>>56810142
>since it has a HUGE standard library.
I kind of feel this is the reason DOESN'T let you learn how program.
You don't really learn if it's all been done for you. At least i don't.
>>
>>56810295
Protip: You can't.
>>
> C programming

How do I modify a global variable from within a loop.
I want my loop to swapsmade++ but it says its undefined despite been declared outside the loop
>>
>>56810360
Did you remember to initialize it?
>>
>>56810383

Yes, it is initialized outside, int swapsmade=0
>>
>>56810271
a kludge is a stupid ugly solution to a problem.
a hack is an ingenious elegant solution to a problem, utilizing a resource or construct in a manner it was not intended to be used, and is likely to come back and bite you in the ass later.
never heard of a bodge, but it sounds like botch, which is a failed attempt to solve a problem.
>>
>>56810271
Those are different things.

A hack is a unique, but potentially elegant workaround.

A kludge is a workaround with few redeeming qualities, other than the fact that it fixes a very specific case (often by simply preventing the case from occuring).
>>
>>56810360
post code
#include <stdio.h>

int swapmade = 0;

int main(void)
{
int i;
for (i = 0; i < 100; i++) {
swapmade++;
}
printf("%d\n", swapmade);
return 0;
}

http://ideone.com/LRaAB5 works fine
>>
>>56810399
Post code
>>
>>56810204
>https://diversitytickets.org/events/46
i do enjoy seeing a code of conduct near the top of every programming site where once there might have been useful information
>>
>>56810271

Hack:
float Q_rsqrt( float number )
{
long i;
float x2, y;
const float threehalfs = 1.5F;

x2 = number * 0.5F;
y = number;
i = * ( long * ) &y; // evil floating point bit level hacking
i = 0x5f3759df - ( i >> 1 ); // what the fuck?
y = * ( float * ) &i;
y = y * ( threehalfs - ( x2 * y * y ) ); // 1st iteration
// y = y * ( threehalfs - ( x2 * y * y ) ); // 2nd iteration, this can be removed

return y;
}


Kludge:
if (userid == 69) { //man I dunno DB is corrupted on this guy or something
return;
}


Bodge:
Fuck if I know. Made up bullshit.
>>
>>56810421
WTF, are u trolling us? Read something about "scope".
>>
>>56810441
>>56810406
https://www.youtube.com/watch?v=lIFE7h3m40U
>>
>>56810446
excuse me? that code's exactly what the guy wanted to do
>>
>>56810252
>>56810164
>the marker will recognize someone else wrote this, please re-do my assignment
>>
>>56810102
he probably wrote it in another language that compiled to C in a very optimized way
>>
>>56809488
how do you not feel embarrassed asking something like this when you can google it in 5 seconds, this is the most basic something can get
>>
>>56810480
shine on you crazy diamond
>>
>>56809488
Anyone?

#include <stdio.h>
int main(void)
{
char ch;

printf("Please enter your favorite cartoon character. \n");
scanf(&ch);
printf("Your favorite cartoon character is &ch")

return 0 ;
}

Am I doing it right?
>>
Holy fucking shit.

My code compiles, and I'm actually competent at OOP.

:')
>>
>>56810532
Buster Baxter
>>
>>56810532
>Am I doing it right?
Let me answer your question with a question: does it compile?

The answer to both questions is no.
>>
>>56810154
https://stackoverflow.com/questions/1012573/getting-started-with-haskell

https://github.com/NICTA/course

https://www.seas.upenn.edu/~cis194/fall16/
>>
>>56810545
Sure. Post proof.
>>
>>56810532
>Am I doing it right?
Why don't you compile and round your code, and find out?

/dpt/ is not your personal compiler
>>
>>56810532
Welp, looks like school is back in session.
>>
>>56810154
I like this book
>>
>>56810315
It's good for learning general program construction, not so much for learning algorithms, parsers, etc.
>>
>>56810545
I've never met anyone who's competent at OOP. The moment you start to be competent make you start breaking out of objectthink.
>>
>>56810055
hahahaha
>>
>>56810591
>It's good for learning general program construction
So is C.
>>
File: bobmarley.jpg (32KB, 598x436px) Image search: [Google]
bobmarley.jpg
32KB, 598x436px
>just finished my entire weeks worth of course work in 5 hours
>>
>>56810578
>>56810553
>>56810267
thank you guys
>>
this
http://pastebin.com/cBMFdTHy
Started learning recently and its been really fun
>>
File: 1462997860281.jpg (26KB, 720x575px) Image search: [Google]
1462997860281.jpg
26KB, 720x575px
Opinions and maybe some tips on Java from long time programmers?
Also if (you) could suggest any books that you found useful for it.
>>
>>56810626
Kurwa
>>
>>56810603
Sure, but it's way easier for newbies to not have to think about pointers, memory management, etc while learning about basic constructs like variables, loops, conditionals, etc. That extra knowledge can always be layered on top after a base is built. Especially for people that don't already have the "programming" mindset.
>>
>>56810532
>char ch;
This is a single character, like 'A' or '2' (not "character" as in "cartoon character"). Your favourite's name is probably longer than one letter.

>scanf(&ch);
Read how scanf works:
http://www.cplusplus.com/reference/cstdio/scanf/

You also probably don't want to use scanf for this since a name could easily have whitespace characters in it ("Spongebob Squarepants") and scanf'ing a string will stop at the first whitespace character. But if that's all you've learned, they might just expect you to only use simple names for this assignment.

>printf("Your favorite cartoon character is &ch")
Also read how printf works:
http://www.cplusplus.com/reference/cstdio/printf/
>>
>>56810532
You will never be employed as a programmer, unless you're a woman and claim sexual harassment against every manager who questions your competence. If you're looking for a role model in that regard, feel free to look up Zoe Quinn.
>>
What's the best free (preferably open source) PHP server?
>>
Can we just stop using the term "OOP"? Either it means using objects everywhere, in which case it's obviously stupid, or it just means using objects. Objects are a tool to be used when appropriate (which is to say rarely) so the existence of the term "OOP" is either redundant or simply wrong.
>>
>>56810614
Intro to Databases course detected.
Oh wait, no, that would be the ENTIRE courses lab work in 5 hours.
>>
>>56810661
I appreciate you correcting me where I went wrong. Thanks anon.
>>
any favorite books on operating systems or networking?
>>
Just took down an entire chan

whoops
>>
>>56810659
But you don't. You learn the basic constructs first, just like any other language, and then you learn pointers and memory management.

>That extra knowledge can always be layered on top after a base is built.
That's what i'm saying.
>>
Why is almost everyone in this industry so fucking narcissistic?
>>
>>56810532
E M T
M
T
>>
File: 1463757835171.png (945KB, 1024x1024px) Image search: [Google]
1463757835171.png
945KB, 1024x1024px
The only language that I really like is C.
Am I fucked /dpt/? People say that you need to master at least 5 to become a "good" programmer.
>>
>>56807017
>>
>>56810786
autism
>>
>>56810786
only when they are behind a computer screen
>>
>>56810809
Not as long as you make an effort to actually branch out.
>>
>>56810809
just be one of the pasty 40 year old white guys who gets put in a hidden shed at tech startups
>>
File: 1440372343909.gif (153KB, 255x224px) Image search: [Google]
1440372343909.gif
153KB, 255x224px
>>56810436
>https://diversitytickets.org/events/46
>Proudly built by RubyMonstas
>>
>>56810809
If you know C, you pretty much know C++
if you know C++, you pretty much know the syntax for java & c#
if you know java, you can pretty much figure out how javascript works in a few weeks maybe
>>
are there any good, free php servers?
>>
>>56810360
have you tried static global variable?
I'm not a C guru but I remember that a static global variable retains its changed value

otherwise you could use a pointer which is probably the best choice
>>
>>56810935
>If you know C, you pretty much know C++
No.
>>
File: 1473936493717.png (45KB, 290x415px) Image search: [Google]
1473936493717.png
45KB, 290x415px
>tfw you put subtle references of your waifu in your code

is there a better feeling than this /dpt/? especially when companies/people use your stuff
>>
>>56810935
>If you know C, you pretty much know C++
You got it the wrong way round.
>>
>>56810946
yes
>>
>>56810982
>is there a better feeling than this /dpt/?
having friends
>>
>>56810532
This gave me an idea.
What if I wrote an extension that executed code in a post with inputs being replies to that post. Anyone have any idea what the language should be?
>>
>>56811079
Actually, after posting, I think I'll make it a Lisp. It would be a good opportunity to learn Lisp, and introduce others to functional languages.
>>
>>56811079
already been done

https://www.reddit.com/user/CompileBot
>>
>>56810786
It's extremely easy to get attention based on how much you shill your work. It's probably the easiest industry to see the Peter Principle hard at work. It's also an industry that for all its resources still doesn't have enough people who know how to effectively teach others, so it's also easy to become a "guru" which plays into everything mentioned previously.

To be fair, it's most apparent with languages that are heavily associated with the web (JS, Ruby, Python) and SO. It's not too prevalent in academia, moreso in the workplace and that's only because of how many people make up the workforce in comparison to academia.

>>56810982
Tiro finale!~
>>
>redhead
>japanese
sure
>>
>>56811079
but anon how will it deal with users too retarded to put code blocks around their code
>>
>>56811097
Wow, I guess I'll look for something that's never been done yet.
>>
>>56811018
>>56810977
how did both of you take this bait when the last line of his post is literally
>if you know java, you can pretty much figure out how javascript works in a few weeks maybe
>>
>>56811137
that's the idea

it's called reinventing the wheel for a reason
>>
>>56811133
It only accepts code blocks obviously
Maybe it should be:
#!/bin/whatever-the-fuck
Code goes here
>>
>used to see anti-OOP fanatics on /dpt/
>thought they were just stupid and dismissed them
>started using a non-OOP lang
>mfw
>>
>>56811150
Compiler error. Didn't get past the first error.
>>
>>56811304

In this moment, I am euphoric. Not because of any phony god’s blessing. But because, I am enlightened by my intelligence.
>>
>>56811304
I'm not really anti-OOP. Most pro-OOP people will agree that "OOP is a tool to be used when appropriate and most people just use it inappropriately" when you point out that most OOP code is garbage. It's hard to be against that. That said, it takes some experience using a language with very little support for OOP to realize that, while OOP is usually not the right way to go, there are cases where it's nice.
>>
>>56810846
Dream of one day being this guy
>>
>>56811334
shit-tier compiler
>>
yo quiero aprender c pero el syntax no esta en espanol
porfavor, como cambia el syntax a espanol

no quiero estar escribiendo "printf" o "for"
es mejor "ponerf" y "por"
>>
File: 4_471.jpg (23KB, 305x384px) Image search: [Google]
4_471.jpg
23KB, 305x384px
>>56811021
>>
Would this
http://pastebin.com/amaqBTp4
be an example of over-use of inheritance and a good use of polymorphism? Worth noting multiple things inherit from DataBaseValue, International, and Intellectual.
I've never really used Inheritance extensively before, because of all the hate surrounding it.
>>
>>56811437
#define PRINTEARF(argumentos) printf(argumentos)

No estoy seguro si esta correcto.
>>
>>56811382
This, really.
>>
>>56811502
you doxxed yourself
>>
>>56811437
Aprende ingles puta :DDDD
>>
File: Forever blowing bubbles.jpg (72KB, 559x599px) Image search: [Google]
Forever blowing bubbles.jpg
72KB, 559x599px
Cant get my head around bubble sort in C.

Why is a second for loop added with j ?
why isnt one enough ?
Also, after it reaches the last element in the array, how does it go back to the start and start sorting again for a second pass through ?
>>
>>56811525
I don't really care if my name is posted on 4chin, it's not like I'm a trip
Also googling that name just pulls up some actor, so I think I'm good anyway
>>
>>56811529
This
>>
>>56811382
>>56811509
That said, I am very strongly anti-"picking one or two tools and only using them religiously". If your personal interpretation of OOP means "my only unit of abstraction is the object as defined by Java" (which is definitely the majority interpretation of OOP) then you can go fuck yourself.
>>
>>56811437


tämä on Englanti puhuva board

Terveisin,
GTPq
>>
>>56811561
oho
>>
>>56811549
the first 2 entries are your facebook and your home address lol
>>
>>56811541
I suggest you read more about bubble sort
>>
>>56811559
Multiparadigm language or bust. A mix of imperative, OOP and functional-ish, where appropriate is best.
>>
>>56811561
ebin hahaha :DDDDDD
>>
File: 1474786956904.jpg (81KB, 720x579px) Image search: [Google]
1474786956904.jpg
81KB, 720x579px
What programming language should I learn if I want to hack the FBI?
>>
>>56811549
Try duckduckgo
>>
>>56811586
I have just the language
https://tour.dlang.org/
>>
>>56811601
Haskell
>>
File: es.png (22KB, 831x516px) Image search: [Google]
es.png
22KB, 831x516px
>>56811587
Torilla tavataan :DDDDD
>>
>>56811586
Yup, this is why I'm enjoying learning Swift.
>>
File: s.png (7KB, 556x375px) Image search: [Google]
s.png
7KB, 556x375px
In my course, when can use Microsoft Excel or R (programming language) to plot data.

which one should i use?
>>
>>56811610
https://www.rust-lang.org

fixed it 4 u
>>
File: 1449296905346.jpg (96KB, 792x558px) Image search: [Google]
1449296905346.jpg
96KB, 792x558px
>>56811570
>>56811587

fugg benis :DDDDD
>>
>>56811601
Binary
>>
This code compiles:
 void kek() { return (void)"wat"; } 
>>
I want to learn Go. Give me some good reasons to learn the language.
>>
>>56811643
Why don't you just give it a go
>>
>>56811580
My first result is Michael Cudlitz's wikipedia page and there's a facebook page for the name farther down
's not like it matters, my facebook doesn't crop up until several pages later


At any rate, how does that code look? Is that a good structure for a DB entry? that DataBaseValue object exists on a DataBaseEntry object that contains the entry, a unique ID, and an identifier for the type.

>>56811586
Can you give an example of a language that actually does this?
>>
Do you need some pre-programing learning?
I don't know what a compiler is. should I learn some basics first instead of pickin a book and going to the terminal?
>>
>>56811643
it's literal trash
>>
what functional programming language has good tooling?
>>
>>56811430
True enough.
>>
>>56811674
A compiler compiles itself.
>>
>>56811670
>Can you give an example of a language that actually does this?
>>56811626
Also any ML or Lisp.

Haskell is close but it doesn't take the right approach to purity IMO (which is linear types).
>>
>>56811626
Rust be all like "look, I'm different so I must be special right?"
D be all like "here's everything you're used to but better"

This was a good read:
https://www.quora.com/Which-language-has-the-brightest-future-in-replacement-of-C-between-D-Go-and-Rust-And-Why/answer/Andrei-Alexandrescu
>>
>>56811502
hello Max-mason Cudlitz
Age: 20
Address: 4221 Allott Ave
91423-4303

CA, Sherman Oaks

Phone: (818) 398-7741
>>
>>56811670
There have already been a few examples posted in replies.
>>
>>56806905
I'm having a go at possible interfaces for my replacement of c++ standard library. I hate STL with passion and don't want to use it with any of my future projects.

Also fuck RTTI and exceptions, write C with classes!
>>
>>56811706
>Rust be all like "look, I'm different so I must be special right?"
Rust isn't different for the sake of being different, it's different because it understands that the conventional way of doing things sucks in many areas.
>>
>>56810810
>it doesn't print fizzbuzz
Confirmed, /g/ can't do fizzbuz.

>>56807962
LITERALLY
STOP
POSTING
THESE
QUESTIONS
IN
DPT

HOLY SHIT SOMEONE ASKS THIS IN LITERALLY EVERY THREAD AND EVERY TIME EVERYONE REPLIES AND STARTS A SHITSTORM
dpt is so shit
>>
>>56811749
why even use c++ at that point?
>>
>>56811753

Though it does take some direction from its influences -- for instance, its insane level of verbosity is clearly an homage to C++.
>>
>>56811601
http://hacklang.org/
>NSA with LOVE
>>
>>56811805
>insane level of verbosity
Like?
>>
>>56811749
Have you tried Go? No exceptions there.
>>
>>56811813

Have you ever seen a Rust program?
>>
>>56811706
>>56811805
Is everyone here just stupid or have none of you actually tried Rust and formed objective opinions about it?
I don't really think Rust is going to be a successful language but it doesn't have verbosity even close to C++, and it certainly isn't doing things different just for the sake of being different.
>>
>>56811846
Yes.
>>
>>56811674
You don't need to know the basic-basics of how things work at a low level, to start, but general knowledge is good. Essentially a compiler is what takes your code and turns it into a runnable format (for an example, an executable binary on Windows, a program in Linux, a .jar file for Java, or any other number of formats that you can run)
Some languages don't need to compile, and can just be run using their interpreter (This is actually sort of what Java and several other languages do, even though they're compiled they're just compiled into different code that's able to be interpreted by their interpreter, which is why you need Java to run .jar files)

I'd recommend starting with C# if you're just starting programming, it's not too difficult to get into and it's relevant.

>>56811643
Why do you want to learn go?
>>
#include <iostream>

int main()
{
int x=0;
std::cout << x++ << ' ' << x++ << std::endl;
}

Output:
1 0

Why is c++ so shit, /dpt/?
>>
>>56811753
> tries to be different in a good way
> still uses <> as type annotations containers
>>
>>56811883
>bikeshedding
>>
>>56811851
>>56811857

Alright, truthfully, I'm just memeing. I just think the safety requirements are excessive for most requirements. It requires a more thoughtful design process that I'm not a fan of.
>>
>>56811864

thanks, I was thinking on C -> python
>>
>>56811897
>It requires a more thoughtful design process that I'm not a fan of.
B-but type systems hold your hand! Only shitty programmers like strong static typing!
>>
File: JIMMY LIVES.jpg (16KB, 179x241px) Image search: [Google]
JIMMY LIVES.jpg
16KB, 179x241px
Is the Haskell meme past its peak or still rising ?
>>
>>56811643
Do you want to write a server, daemon or CLI tool? Learn Go. That's the language's niche and it's pretty good at it.
>>
>>56811897
it won't compile if your program would have done something you wouldn't want (memory leaks, dangling pointers, data races, the list goes on)

what's excessive about that?
>>
>>56811670
Read the thread + Go, JavaScript, Rust.
>>
>>56811771
binary size, speed and I like to have some oop features while writing for embedded

>>56811839
no templates either and that's a big thing for me
>>
>>56811940

It also won't compile if you try to do something that works in every other language under the Sun. The borrow checker is giving me an ulcer.
>>
>>56811704

What compiled the first compiler ?
>>
>>56811918
go away datafag
>>
>>56811940
>>56811971
You need to learn how to structure code so that the borrow checker doesn't end up being too conservative. It's not hard, it's just a completely new concept. The only people who complain about having to work against the borrow checker are people who can't be bothered to actually try to understand it.
>>
>>56811981
Me
>>
>>56811981
Someone wrote it in assembly.
>>
>>56811988
>>56811971
this. once you get it into your brain-compiler, it's smooth sailing. it should take less than an hour or two for someone who isn't retarded
>>
>>56811981
And how did guys who wrote google search for their problems if there was no google???
>>
>>56811988
>The only people who complain about having to work against the borrow checker are people who can't be bothered to actually try to understand it.

It definitely requires a conscious effort, though. Unless you started on Rust, it's just not something that's ingrained in your programming psyche, so to speak.

If I made a better effort to understand, it probably wouldn't be as bad, but learning is for nerds.
>>
What kind of projects are you guys working on in Rust?
>>
>OscillatorNode method: start()
>Schedules a sound to playback at an exact time. start may only be called one time and must be called before stop is called or an InvalidStateError exception MUST be thrown.

So every time i want to start and stop playback i have to create a new oscillator object?
What the hell? Why?
>>
>>56811870
you are shit for not knowing the standard
>>
>>56811897
>I just think the safety requirements are excessive for most requirements.
I think that this is true, but more importantly because there are few applications of a fast systems programming language that doesn't routinely need to do questionable operations that Rust rejects.
If you want a high level language, a GC is actually *not that bad*!! If you know anything about generational GC you'd know that GC can actually speed up other aspects of a program's performance, of course at the cost of the collection phase.
Rust just isn't worth it and nobody wants to learn it because it's too complicated.

>>56811940
There are a fuckton of magic objects in the standard library (like Cells and Box's and Vec's) that have to be safely implemented in order make most programs even possible. And then the programmer has to learn all of their concepts. The borrow checker itself is pretty simple but the infrastructure that you need to learn to make things useful around it is cumbersome.
High level languages should ideally be able telling the compiler "what" to do rather than "how", and Rust's borrow checker takes a step backwards (albiet not as far as C)
>>
Python is awesome.
>>
>>56812047
i'm writing a game.

2k LoC right now. in C++ at this point i would be pulling my hair out. in Rust i have no such issues. it's still as great as day one
>>
>>56812062
No.
>>56812084
No.
>>
>>56811870
I know exactly why it's doing that, get out of here with your b8
>>
>>56812081
>there are few applications of a fast systems programming language that doesn't routinely need to do questionable operations that Rust rejects.
Just because you need to dip into "unsafe" a few times doesn't mean you've completely undermined the reason for Rust to exist. If 90% of your code is "safe", only that remaining 10% (including the use of unsafe blocks themselves) can ever cause a memory error. That's a massive gain.
>>
>>56812081
>There are a fuckton of magic objects in the standard library (like Cells and Box's and Vec's) that have to be safely implemented in order make most programs even possible.

You said it better than I did. That's what I was thinking about when I was formulating my original post.
>>
>>56811870
Argument evaluation order in C and C++ is unspecified for some godawful reason.
Usually it's in reverse, which is counterintuitive on its own, but technically it could be in a fucking spiral pattern if C++ wanted to fuck you up.
>>
>>56811961
Interfaces can approximate the functionality of C++'s function templates. This is how they implement sorting for arbitrary types. Any type that has these three methods can be sorted with the standard library's sorting function.

type Sorter interface {
Len() int
Less(i, j int) bool
Swap(i, j int)
}
>>
>>56811981
>>56812117
Alright smarty pants. Why is it doing this
#include <iostream>

int main()
{
int x=0;
std::cout << ++x << ' ' << ++x << std::endl;
}

Output:
2 2
>>
File: canuck-the-cuck.jpg (109KB, 650x650px) Image search: [Google]
canuck-the-cuck.jpg
109KB, 650x650px
>>56812105
yes
>>
>>56808242
Dude wtf I thought I was the only hyemi fanboy in the world
>>
>>56812136

And yet the Rust devs have cautioned against people describing their projects as x% safe/unsafe, or 'only x SLoC unsafe!'
>>
>>56812154
Nah.
>>
>>56812047
Just published 0.2 of my image handling library on crates.io, now I can go back to do whatever I was doing before.

I think it was an X11 window manager or something.

I'll probably do a clean up pass on some of my old projects.
>>
>>56812158
Because it doesn't matter to anybody but a contributor. Unsafe code is not an excuse to say that memory errors might happen, it's programmers taking responsibility to ensure that they don't rather than being able to simply assume that they won't.
>>
>>56812081
what is so cumbersome about the borrow checker?

as many immutable borrows as you want at the same time

only one mutable borrow at a time, and no mutable + immutable at the same time.

sometimes you may need to specify a reference's lifetime in relation to something else (most of the time "this reference lives as long as that reference")

you just learned rust! good job
>>
>>56812151
interfaces are significantly less powerful than parametric polymorphism
>>
>>56812163
yah
>>
>>56812190
here's lesson number 2 - ownership:

foo // moved
&foo // immutable borrow
&mut foo // mutable borrow

you're a rust grandmaster now
>>
>>56812210
Nope.
>>
>>56812190
Did you not read my post? I said that the borrow checker itself is simple
Try to implement a runtime GC for an interpreted language in Rust and then tell me if the borrow checker is cumbersome.

>>56812206
...which are technically a subset of dependent types
>>
>>56812222
yep
>>
>>56812081
But in Rust you don't tell the compiler the "how", it tells the compiler the "who".
>>
File: Screenshot_2016-09-27_16-30-30.png (43KB, 305x110px) Image search: [Google]
Screenshot_2016-09-27_16-30-30.png
43KB, 305x110px
>>56812153
>>
>>56812189

Only Rust developers use Rust software, so I don't find that argument compelling.
>>
>>56812232
Nein.
>>
>It is often said that AudioBufferSourceNodes have to be used in a "fire and forget" fashion: once it has been started, all references to the node can be dropped, and it will be garbage-collected automatically.

This is wreaking havoc on my mental model of the audio routing graph. Graphs should not change shape several times a second.
>>
>>56812190
Borrowing "too much" is probably the biggest cause for grief. It would be nice to be able to write foo.x and foo.y and have the borrow checker track the fields separately, but as it is you have to destructure before borrowing manually.

>>56812249
The user of a library, given a safe API, should be able to assume that the library has been implemented correctly. Whether it uses any unsafe code at all is only important to somebody who is trying to track down and fix a bug in that library, if it's implemented incorrectly.
>>
Is there a good Rust IDE now?
>>
>>56812299
yes, emacs - syntax highlighting, auto-completion, on the fly error checking with underlines, etc

or you can use atom and a plugin

or intellij plugin

or visual studio plugin
>>
i thought atom was a bad meme
>>
>>56812346
It's a decent Free editor imo.
>>
>>56812346
It is. Lel type polymorphic CoffeeScript.
>>
>>56812321

I tried the IntelliJ plugin a while ago and it was hot wet garbage.
>>
>>56812299
you can always use vim + youcompleteme
>>
New thread:
>>56812538
>>56812538
>>56812538
>>
>>56812544

I prefer emacs.
>>
>>56812563
>>56812543

https://github.com/rust-lang/rust-mode
https://github.com/racer-rust/emacs-racer
https://github.com/flycheck/flycheck-rust

or if you're using spacemacs just add the `rust` layer to the layer list
>>
>>56808023
I used angular 1.4. directives are nice, lots of reusability, URL routing could be better. dunno about v2, also never used TS before.
Thread posts: 332
Thread images: 33


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