[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: 323
Thread images: 34

File: random_number.png (7KB, 400x144px) Image search: [Google]
random_number.png
7KB, 400x144px
I fucked it up the last time, edition

What are you working on, /g/?
>>
File: 1477014524080.jpg (40KB, 500x384px) Image search: [Google]
1477014524080.jpg
40KB, 500x384px
Nothing.
>>
>>57256927
>closed source.png
>>
I don't even know what indirection means.
>>
>>57253186
>Being ABLE to name a bunch of functions the same seems like it's bad practice, but I've never worked on anything that big, I guess.

Generally speaking you shouldn't name multiple functions the same thing, but consider if you were using other people's code. For example, let's say you're making a game and using a graphics and a physics library and both libraries have a Shape class. You'd want to use libraries that are contained in namespaces so that there's no naming collision between graphics::Shape and physics::Shape.
>>
another try: what are some programming books with personality?
>>
>>57257096
>what are some programming books with personality?
LYAH

also: Stroustrup
>>
File: 1464542237759.jpg (161KB, 414x615px) Image search: [Google]
1464542237759.jpg
161KB, 414x615px
>>57256927
DELETE THIS ONE TOO

FUCK THESE THREADS
>>
>>57257142
I agree.
We need to make room for tech support thread #0291090121983
>>
>>57257135
>Stroustrup
so much that it's worth reading a book on c++?
>>
>>57257041
It's laughable to design a programming language today without a namespace system. Yet C still stands, namespace-less in its shitty global namespace "easy to link" glory...
C really needs to die.
>>
File: What-Am-I-Doing-With-My-Life.gif (1MB, 236x161px) Image search: [Google]
What-Am-I-Doing-With-My-Life.gif
1MB, 236x161px
>>57256603
>memory error
>>
>>57257157
Not if you don't care about learning c++.
Bjarnes books have Bjarnes personality.
>>
>>57257159
>namespaces
mylib_func1(int a);

If you're really autistic, you can fashion together your own namespace system with preprocessor concatenation
mylib(func1) (int a);
>>
>>57257159
Namespaces are overrated because standard practice seems to be to not really use them, i.e people recommend never using "using namespace" and always use fully qualified names like "foo::func()" in which case they function the same as prefixes like "foo_func()".
>>
Anyone know about any techniques for solving systems like this?
f(s, t) >= t + 1
f(s, t) >= f(s - 1, 1)
f(s, t) >= f(s - 1, f(s, t - 1))
>>
>>57257232
>preprocessor concatenation
Never. Fuck you.
>>
>>57257244
>i.e people recommend never using "using namespace"
Only at the top level of a header file where it pollutes anything that includes the header in question.
>>
>>57257041
> Being ABLE to name a bunch of functions the same seems like it's bad practice
It means that you aren't prevented from using two libraries in the same program because they both decided to use the same name for a function or type.

And unlike the C approach of choosing a prefix which is used for every function and type, you aren't forced to use the prefix repeatedly. With a namespace, you can either use qualified names, or you can bring either individual names or the entire namespace into the current scope.

It also makes it fairly straightforward to provide multiple versions of a module, each using the same names but in different namespaces, then write code which works with whichever version you bring into scope.
>>
>>57257232
>>57257244
>mylib_func1(int a);
>foo_func()
Yeah, and wouldn't it be great if libraries adhered to that? Ever taken a good look at ncurses?
Especially: library headers redeclaring their own fixed width integers without appropriate guards, and now you're forced to either manually delete code out of an external libraries header or just suffer through trying to get just the right combinaton of #includes per file.

Also, code written in a namespace doesn't need to append the name of the namespace when accessing other functions declared in that namespace, which is helpful but not as stupid as "using namespace".
Racket's (require) system is actually pretty cool too, it allows you to selectively import/export symbols, import symbols with a user defined prefix (per module).
e.g.
"foo.rkt"
#lang racket
(provide foo)
(define (foo) "wow")

"bar.rkt"
#lang racket
(require (prefix-in f: "foo.rkt"))
(define (bar)
(string-upcase (f:foo))
>>
>>57256927
QUICK WRITE A PROGRAM THAT BREAKS THE CAESAR CYPHER IN C
>>
>>57257261
It couldn't be simpler.
Though at this point, you might as just use prefixes.

#define mylib(fn) mylib_##fn

int mylib(func1)(void)
{
return 0;
}

int main(void)
{
mylib(func1)();
}
>>
>>57257295
Racket's module-based import and export system is literally the best thing I have ever used. It's so easy and so common-sense that you'd think every other language would use something like it.
>>
>>57257312
I said "Fuck You". Let me add "Fuck Off" to that.
>>
>>57257249
Okay, making some headway. I guess what I need is "higher order disunification".
>>
>>57257306
>doing your homework for you
I'm 100% sure theres code on rosettacode that does exactly this. Would you like me to find it for you?
>>
>>57257244
> people recommend never using "using namespace" and always use fully qualified names
Those aren't the only options.

"using namespace" at file scope is something of a blunt instrument. Using it within a more restricted scope is less of an issue.

But it's usually preferable to have using declarations for individual names. Apart from not "polluting" the current scope with a ton of names, of which you'll only be using a small fraction, searching for a name will find the corresponding using declaration, making it easy to discover what a name refers to.
>>
>>57257330
I'm sure if you're autistic enough, you could always write your own pre-preprocessor so you could write something like
#define :: _
int mylib::func1(void)
{
return 0;
}

int main(void)
{
mylib::func1();
}
>>
>>57257249
>>57257333
Wait, nevermind, this just seems to be SMT.
>>
>>57257433
Shut the fuck up about preprocessors.
>>
>>57257447
Preprocessors are awesome, fuck you.
>>
>>57257451
Preprocessors are the spawn of satans polyps.
>>
File: 2016-10-26_20-38-31.png (2KB, 188x41px) Image search: [Google]
2016-10-26_20-38-31.png
2KB, 188x41px
http://pastebin.com/RKXEwMiG

Good idea or best idea?
>>
>>57256927
I'm a novice in C, and have colleagues that are trying to convince me to drop it and switch to C++ Is it true? Is C bad because it's old? Is C kill?
>>
>>57257573
C++ is a lot easier to understand after you understand how C works.
C++ is much much better than C for writing applications that aren't bare bones, at the expense of being really fucking complex. On the surface C++ doesn't even look that complex but it really is.
>>
>>57257573
Are you an operating systems programmer?

If yes, stay in c.

Do you actually want to produce a functioning piece of code that would be used in massive amounts of environments?

If yes, go to c++
>>
File: don't grope the miku!.jpg (179KB, 512x512px) Image search: [Google]
don't grope the miku!.jpg
179KB, 512x512px
>>57257573
All the software running on your computer is written in C, don't be a dumb fuck.
It's C++ that's dying and quickly becoming irrelevant in favor of C for low level work and Javascript for high level applications programming.
>>
>>57257249
Okay, it's just Presburger arithmetic + uninterpreted functions, which is in general undecidable, but I can live with that and approximate.
f(s, t) = t + 1 + x
f(s + 1, t) = f(s, 1) + y
f(s + 1, t + 1) = f(s, f(s + 1, t)) + z
>>
File: this.gif (2MB, 125x100px) Image search: [Google]
this.gif
2MB, 125x100px
>>
>>57257616
>Javascript for high level applications programming
I'm going to fucking puke

Lisp, come back please, we need you in these dark times.
>>
Previous thread: >>>57252068

>>57257629
That's pretty neat. Reaction diffusion?

>>57257639
Do you walk around throwing up at everything you see?
>>
>>57257648
>Do you walk around throwing up at everything you see?
I overt my eyes.
>>
>>57257616
Damn. You must be puttin your dealer's kids through college.
>>
>>57257648
It's a gif rendering of a predator-prey simulation. Black pixels are prey, red are predators.
>>
>>57257697
Is the automata random or just the initial state?
>>
>>57257249
>>57257617
>>57257439
>>57257333
Thanks for the updates.
>>
>>57257704
initial state and automata
>>
>>57257697
Lotka volterra? Nice.
>>
>>57257697
they are mating away from the predators. nice.
>>
>>57257658
Well, have you at least seen the new additions we have in ES6/7 that make JS less awful? Obviously it's not FP, but it's better.

For example, this is valid JS today:
let sum = arr => arr.reduce((a,b) => a+b)


>>57257697
Interesting. Visually, it has a lot in common with (very) noisy reaction-diffusion systems.

https://en.wikipedia.org/wiki/Belousov%E2%80%93Zhabotinsky_reaction#/media/File:The_Belousov-Zhabotinsky_Reaction.gif
>>
>>57257697
make the red pixels cop-blueish and you have a /pol/-program.
>>
Irrelevant but I want to ask experienced programmers, how was it like when you first started programming? Is it supposed to be overwhelming abit at first?
>>
>>57257883
No.
>>
>>57256927
I'm working on getting C++ proof so I can learn algorithms with Robert Sedgewick.

#include <iostream>
#include <vector>
#include "vector.h"
using namespace std;

void magicPony();
int main(){

vector<int> fireStorm(5);

for (auto& name : fireStorm){
cout << value << endl;
cin >> name;
}

for (auto name : fireStorm){
cout << integer << name << "." << endl;
}

magicPony();
return 0;
}

void magicPony(){

vector<double> prDru(3, 3.14);

cout << messy << endl;
for (auto p : prDru){
cout << p << " ";
}
cout << endl;
cout << endl << topkek << endl;
}



Having fun with C++ now...
>>
>>57257913
there's a c version of the book too
you can still save yourself
>>
>>57257883
It was a little overwhelming and very confusing, because I was trying to learn QBASIC from a book about Applesoft Basic. The differences kept tripping me up.
>>
>>57257883
I don't remember. My first experiences were learning by example from sources I found myself (freeware QBASIC games, discount software books and similar) rather than formal courses and that was a long, long time ago.
>>
>>57257913
>#include <vector>
>#include "vector.h"

This seems like a dad time.
>>
>>57257367
You know what, as a complete fuck up in life, even i would not sink as low as that faggot.

Even a total psychotic emotional wreck like me could solve the fucking caesar-cypher.
Ive fiended for drugs, ive lied, ive lashed out at the world in anger.

But i could still solve the fucking caesar-cypher. Easily. In fact ill do it now.

Thanks anon.
>>
next programming assignment is in prolog. what am i in for?
>>
>>57256927
I'm working on a media player in python, just for the fuck of it.
Never used any GUI with python before so It's teaching me that. Playing around with eyed3 and PyQT atm. I have it pulling and storing a list of relevant files, moving them when appropriate (user choice).

It's pretty functional as an audio player right now, desu. Making the UI cleaner and more aesthetic. Moving onto videos next.

School has me making an RPC server/client in python. Pretty easy, no worries.

At work I've been automating as many of my daily maintenance chores as possible (sys admin) so I have more time to fuck around.
>>
How many KiB is too big for an extremely basic terminal chess game?
>>
>>57258178
0x40
>>
>>57257573
C will teach you the basics that C++ will hide away but when C++ breaks or you want to do something very low level, lacking the C knowledge will hurt you badly.

But past old school embedded or OS programming, C++ is the dominant language.
>>
>>57258255
Binary is smaller than that, memory is at 178kB
>>
>>57257096
Istvan Reitner C#
>>
Been writing a lot of C this semester. Decided to give Python a try. This shit is comfy as fuck.
Next thing is to add a motivational quote to image. Will check back in
from bs4 import BeautifulSoup
import urllib2, urllib, urlparse
import os


IMAGE_SAVE_PATH = "/Users/anon/Desktop/space/"

def get_first_image_url():
headers = { 'User-Agent' : 'Mozilla/5.0' }
url = "http://www.reddit.com/r/spaceporn"

html = urllib2.urlopen(urllib2.Request(url, None, headers)).read()
soup = BeautifulSoup(html, "html.parser")

return soup.find("a", {"data-event-action":"thumbnail"})['href']

def download_image(url):
split = urlparse.urlsplit(url)
filename = IMAGE_SAVE_PATH + split.path.split("/")[-1]

urllib.urlretrieve(url, filename)

return filename

def change_bg(image_path):
command = "osascript -e 'tell application \"Finder\" to set desktop picture to POSIX file \"" + image_path + "\"'"
os.system(command)

def main():
url = get_first_image_url()
filename = download_image(url)
change_bg(filename)

if __name__ == "__main__":
main()

>>
>>57258299
m8 is this in russian
i'll just have to trust you
>>
>>57258352
it's a siren's song
>>
NEET here. I've decided to dedicate the rest of my life to developing an AI gf. Where do I start? Is there a go-to text for foundation AI principles?
>>
>>57258352
I learned in python and adored it. I then switched to C/C++ due to speed.
I started a new job and everything is in python now, and I've grown to resent it. I hate dynamic typing and I hate strongly typed. How it it handles globals has started to rustle my jimmies as well.
Been learning rust sporadically the past few months and I'm quite enjoying it over C++
>>
>>57258396
This program is slow as fuck, but I'm just going to run it as a cron job daily. It is useful for little programs like this, but I could not image writing enterprise software with dynamic typing. Just too much fuckery going on.
>>
>>57258390
http://aima.cs.berkeley.edu
>>
>>57258396
Large-scale Python projects are such a pain that I hope never to take another Python job again.
>>
>>57258420
also, if you want to get something together in a hurry first:
the latest startup meme is "intelligent" messaging bots so see if you can find a tutorial for that. it should be for retards and in javascript
>>
Does anyone else get fucking annoyed by UNIX regexes where some special characters are escaped and some aren't?
grep -o "is\?\.4c\(ha\|d\)n\.org/$1/[0-9]\+\.\w\+"
>>
Just completed the http://cscircles.cemc.uwaterloo.ca python3 course and really enjoyed it. What now?
I feel comfortable with most of the syntax but I'm still not fluent enough to, say, complete most of the dpt roll challenges.

Required reading? More interactive courses?
>>
>>57258553
Make something
>>
reminder javascript is the best language for functional programming
>>
>>57258878
*Pascal
>>
have you made a piece of software that you make use of regularly?
>>
File: file.png (252KB, 500x333px) Image search: [Google]
file.png
252KB, 500x333px
> *walks into your office*
> "I'd like to be referred to as they/them"

What do you do /g/?
>>
how big does a program have to be to warrant storing it on git?
>>
>>57258934
do not acknowledge existence of said creature, it is a glitch in the matrix
>>
>>57258925
>>57258946
stop pretending to be multiple people kid
you're in over your head
>>
>>57258952
I'm not trying to pretend to be two different people, I'm just asking questions out of curiosity
>>
File: file.png (240KB, 852x480px) Image search: [Google]
file.png
240KB, 852x480px
>>57258951
>Anon, this is HR, we're gonna need to talk.
>>
>>57258512
Use POSIX extended regexes, which doesn't require you to escape +, *, ?, etc.
>>
>>57258973
yes, any programmer worth their shit has made a utility application that they use regularly, because why else would you bother?

also i feel you're confusing git the revision control system and github, an unrelated git host
>>
>>57258975
Said no HR in the real world ever.
>>
>>57258946
It's functional and well documented is my idea.
>>
>>57258979
Holy fuck, thank you, should have read the man page more carefully.
>>
>>57259003
I dunno, I'm not creative or smart so everything i need to do, there seems to be an app or website that does it for me.
>>
>>57259041
Is there anything you do repeatedly on your computer?

You can start by learning how to automate it.
>>
>>57258815
Okay, I promise to make something today.
But I still want to learn more
>>
>>57259060
You learn best through making something.
>>
>>57257135
Strouts books feel like a child showing yiu around his room, telling you about each of his toys and the lore each one in the scope of his bedroom.
He feels somewhat excited about the language or atleast that's how I feel when reading c++ programming principles and practises.
>>
exp evaluates to TRUE (when exp <> 0 and exp <> NULL )
What does <> mean? It's explaining if statements in mysql.
>>
>>57259350
<> is the legacy version of !=
>>
>>57259350
i don't know SQL but I assume it means not equal
>>
Is webdev the most advanced form of programming? I mean, any codemonkey could program a computer that's right in front of him, but only a webdev can program a computer that's thousands of miles away.
>>
>>57259718
you connect to a remote computer over ssh and it feels identical to the computer in front of you.

what a stupid fucking post.
>>
>>57259727
Sure, if you ignore the fact that you're programming on a command line interface.
>>
>>57259758
That's what he said, identical
>>
>>57259758
Is that supposed to be impressive or something?
>>
>>57259774
>>57259775
You codemonkeys just wouldn't understand with your Visual Studio and your Eclipse.
>>
>>57259718
I don't see the point to this post. I write non web-related c++ in vim over ssh across the USA all the time.
>>
>>57259788
>complain about command line
>call others IDEfags
>>
>>57259718
>Web developers are responsible for all of the research and developing that went into computer networking
I bet you don't even know what the TCP/IP stack is, not to mention the more advanced shit like MBGP, MPLS, OPSF, and the other billion abbreviations.
>>
>>57259788
I seriously hope you're not doing web development over ssh and pushing your changes live on your web server.
>>
>>57259809
Of course not. I edit it in place on my production server.
>>
>>57259822
You're supposed to test all changes on your local machine before you push to your production server.

You're at least using git, right?
>>
>>57259834
Stupid codemonkey shit. I just make sure that I don't make mistakes in the first place, then I don't even have to worry about version control.
>>
>>57259855
I mean, I guess it's fine when your website is just some static webpages, but as soon as you start making non-trivial dynamically generated websites, you won't be so cocky anymore.
>>
>>57259874
Nice assumption but I run a social media website that serves over 2 million concurrent users
>>
>>57259891
>i run a social media website
You're ruining the world
>>
>>57259891
Gookmoot?
>>
File: idinahuy.png (184KB, 392x766px) Image search: [Google]
idinahuy.png
184KB, 392x766px
>>
how do non-english speakers program if everything is in english?

do they learn english or do they just mentally abstract that "while/for" means a loop and "if" is a conditional statement?
>>
>>57259920
And a ching chong nip nong to you, too
>>
>>57259940
:^)
>>
File: code.png (1MB, 635x803px) Image search: [Google]
code.png
1MB, 635x803px
>>57259934
Japanese programming
>>
>>57257249
>>57257617
>>57257439
>>57257333
Best blog of the day
>>
>>57259957
worst blog of the month
>>
>>57259934
I'm finnish, and from the ~100 coders I've met there was one who didn't use english documentation for his code/comments. I don't know about Indian coders or other big non-english language groups.
>>
In C hastag, what's the difference between a Console app and Windows form app?

What would you write instead of console.write in a windows form application?

Our school makes us code in Winform and this becomes very confusing for a tech illiterate like me when I'm trying to look for tutorials online since most c sharp things are written in console.

Sorry for my poor england.
>>
>>57258512

There comes a point where it's insane trying to do this at a shell and people should just write some readable Ruby or Python.

Not that regexes are ever totally readable.. but you can do a lot better than doing them in bash.
>>
File: finland.jpg (909KB, 1982x1724px) Image search: [Google]
finland.jpg
909KB, 1982x1724px
>>57259972
can finnish people even speak finnish?
>>
>>57257249

Microsoft Z3.
>>
File: 1475664033489.jpg (68KB, 633x758px) Image search: [Google]
1475664033489.jpg
68KB, 633x758px
>tfw you've been programming your entire life without really understanding what metaprogramming is
>>
>>57260011
pajeet

pls
>>
>>57260011
It's okay, anon. Nobody really understands what metaprogramming is. It's just one of those buzzwords that floats around.
>>
>>57260043
why reply to yourself?
>>
>>57260054
pajeet

pls
>>
>>57260011
java# programmer detected
>>
>>57260118
H-how'd you know?
>>
>>57260349
the fact you can't program at a higher level
>>
>>57260378
? Java is already the highest level
>>
>>57260438
enteresting
>>
Could you hypothetically make a weak-typed, compiled language?

(I guess the reason why Python can be weak-typed is because it can set types during run-time, whilst compiled languages cannot.)
>>
>>57260438

the highest level of programming
and the lowest level of human dignity
>>
>>57260665
People consider C to be weakly typed, considering that you can give the middle finger to the type system and use char pointers and unions.
I guess that you're probably thinking of dynamic typing.
>>
>>57260665
Yes. It's called JavaScript.
>>
>>57260665
Python is not weak typed. Python is strong typed.
>>
>>57260665
>>57260861
Also python is compiled. So yeah..
>>
>>57260861
(You)
>>
>>57258934
Fire them.
>>
>>57259718
You're an idiot.
>>
>>57260973
>you're
>>
In C hastag, what's the difference between a Console app and Windows form app?

What would you write instead of console.write in a windows form application?

Our school makes us code in Winform and this becomes very confusing for a tech illiterate like me when I'm trying to look for tutorials online since most c sharp things are written in console.

Sorry for my poor england.

In C hastag, what's the difference between a Console app and Windows form app?

What would you write instead of console.write in a windows form application?

Our school makes us code in Winform and this becomes very confusing for a tech illiterate like me when I'm trying to look for tutorials online since most c sharp things are written in console.

Sorry for my poor england.
>>
So I have collision detection in 4 variables,
collideLeft, CollideRight, CollideDown, and CollideUp.

Im comparing a rect which is moving around with xMv, and yMv variables, with the edges of the screen's rect.

the collision is fine and everything, but i'm just trying to get the xMv and yMv inverted when colliding with anything, what do I need to do for this?
>>
>>57260866
No, Python is interpreted.
>>
>>57261012
go ask /agdg/
>>
>>57260992
Winforms is a template that includes references and the namespace System.Windows.Forms, among other things.

This clss allows you to make GUI applications.
>>
>>57260759
That is interpreted, you fucking retarded.
>>
File: 1407905937240.jpg (23KB, 500x375px) Image search: [Google]
1407905937240.jpg
23KB, 500x375px
>>57261023
>Implying they could solve an actual programming problem
>>
>>57261046
not for the last decade
https://en.wikipedia.org/wiki/V8_(JavaScript_engine)
>>
>>57260759
>>57260866
>>57261017
>>57261046
With JIT compilers and whatnot, the line between interpreted and compiled became a lot more blurry.
You could really argue that any language is compiled or interpreted.
>>
>>57260665
Lisp.
>>
>>57261113
exactly. But python jitters are common for python specifically.
>>
>>57261121
So? The reference implementation is interpreted.
>>
File: 1477566646639.png (108KB, 357x368px) Image search: [Google]
1477566646639.png
108KB, 357x368px
>tfw too intelligent to learn math
>>
>>57261133
Stop trying to force this stupid meme, you fucking redditor feelfag.
>>
>>57261125
So?
>>
>>57261148
Exactly.
>>
>>57258280
People are slowly moving to C++ for embedded by the way.
>>
>>57261138
That's exactly how memes get made.
Shit memes.
>>
>>57261113
By that logic then interpreted languages wouldn't have to run on top of a virtual machine. Obviously they do. Deal with it.
>>
File: 1476523440953.jpg (43KB, 600x600px) Image search: [Google]
1476523440953.jpg
43KB, 600x600px
>tfw too handsome to program
>>
>>57261251
in 2016 cppcon they showed graphs which suggested othewise. People who were doing embedded with C++ are declining but users of C were rising.
>>
>>57261278
that talk was so fucking cynical

It actually put me off of using C++ for embedded
>>
I am trying to get the deprecated DirectMusic interface working somehow. I kinda get why it's such a clusterfuck with them trying to make it compatible to C, but the documentation is still a piece of ass. How the fuck do you create an IDirectMusic8 object if you don't want to use COM?
>>
File: shootme.jpg (50KB, 736x588px) Image search: [Google]
shootme.jpg
50KB, 736x588px
Learning Node.js for a programming assignment as part of a job application

Picture related is how I feel about this.
>>
>>57261278
I don't see any situation in which I would choose to use C++ for embedded applications (aside from my employer telling me I had to)
>>
File: 1473876701479.gif (1MB, 300x300px) Image search: [Google]
1473876701479.gif
1MB, 300x300px
>>57261316
Tell them to fuck themselves and learn Phoenix instead. Elixir is the future of programming.
>>
>>57257609
That's such bullshit. There's really not much of a difference between the two. Personally, I feel that using C++ is bad because, to quote some famous person I can't remember the name of, it makes you feel smart when you're doing something really stupid. If you know how to avoid that and aren't doing anything high performance or such, you may benefit from the STL or other C++ only libraries, maybe destructors and certain other features. But really, you can do anything in either of them in about the same effort unless we're talking something very specific here.
>>
>>57257913
>using auto

Why the fuck are you using that? Is obsolete!
>>
I am learning to code in Python.
What I was not being able to find is, that I can't import a py file into shell and use the functions inside of it.
What do I do in order to make it work?
>>
File: ihatec.png (42KB, 800x577px) Image search: [Google]
ihatec.png
42KB, 800x577px
trying to read in a csv, but im getting this error.
when i comment out the while, it works

i assume i have to malloc(), but i have no idea how to c, since i'm coming from java/c#
>>
>>57261358
>Elixir

I've been looking at that out of curiosity, my first attempt at fizzbuzz without knowing much about that language yet

fb_result = fn
0, 0, _ -> "FizzBuzz"
0, _, _ -> "Fizz"
_, 0, _ -> "Buzz"
_, _, n -> n
end

fb = fn
n -> fb_result.(rem(n,3), rem(n,5), n)
end
>>
>>57256927
I just finished a book on how to program in C.


struct nigger {
double worth; /* 3/5ths unless miscegenated */
int price;
char *slave_name;
char *african_name;
bool freed; /* set false until 1865 */
};

>>
>>57261392
>everybody uses C++17
>>
>>57259934
German here.
>mentally abstract that "while/for" means a loop and "if" is a conditional statement?
Did this until I was fluent in English. They're simple concepts, the vocabulary you have to learn is limited and tutorials in my native language exist for pretty much any programming language.

My comments, code etc are all in English nowadays unless I'm writing something newbies are going to be looking at (writing a small Python tutorial for fellow students right now) in which case I use German comments to explain shit.
>>
>>57261537
> int price
> int
>>
>>57261795
Slaves were expensive, and even back then the cents didn't matter on slave price.

Your comment pretty much proves you are an imbecile.
>>
>>57261795
>not being paid by nigger slaves in an indivisable form of currency
step up your game cracka
>>
>>57261837
Then explain to me why televisions and similar articles nowadays are priced silly things like $899.99.
>>
>>57261851
That didn't happen in the slaveholding days. Slave cost hundreds of dollars in 19th century dollars. There were no calculators, so people didn't do 0.99 bullshit. Interest also wasn't compounded continuously because of the lack of computers.
>>
>>57261537
>not having a list of the nigger's specialties
>>
>>57261873
Back in the slaveholding days they also didn't program in C.
>>
>>57261897
>not being steampunk
>>
>>57261881
>lists
>C

stop misnaming concepts
>>
>>57261995
You can create lists in C
>>
>>57262041
LIST MY ANUS
>>
>>57262041
no you cannot

you can chain pointers to struct types or you have an array of types, but you cannot have "lists" of any kind
>>
>>57262108
>create a structure X
>"it's not X, it's just a buncha pointers"
>>
>>57262108
Just because it's not built in doesn't mean it's not a list.
That's retarded.
>>
>>57261995
>>57262041
>>57262108
>>57262126
>>57262133
http://www.cplusplus.com/reference/list/list/
>>
>>57262126
I don't understand what you're trying to say. Are you implaying that the concept of "list" exists in C? Can you point me where in the ISO or ANSI specifications I can find a reference to this "list" you speak of?

>>57262133
Lists do not exist in C. It's not retarded, it's a fact.
>>
>>57262165
On top of not being an official document published by either ISO, ANSI or any other similar body, this webpage is about C++ and not C. C does not have a concept of list.
>>
>>57262165
list does not mean C++ linked list
>>
>>57262165
C++ has lists in it's standard library, so what?
>>
>>57262181
>>57262184
>>57262185
https://gist.github.com/mycodeschool/7429492
>>
People who wants lists should use LISPs.
>>
>>57262170
You can make a structure that acts like a list and is structured like a list. Therefore you can make a list in C. I did not say there are built-in lists.
>>
>>57262108
what do you think lists are you fucking imbecile?
>>
>>57262199
What's that supposed to prove? That's not a list. You could replace every instance of "list" with "warblemarble" and everything would work exactly as it does. Lists do not exist in C. C does not have a concept of list. All that webpage shows is a piece of C where someone is interpreting chained struct pointers to represent something which C does not have a concept of.
>>
What is faster in C?
typedef struct {
int something;
char *name;
} A;

typedef struct {
int something;
char name[256];
} B;
>>
Do people frequently use those data types like int_fast32_t from <inttypes.h>?

Say I need to store numbers that could go up to 100,000, but I want the compiler to choose the fastest way to do it (because nanoseconds matter right?)

I feel like I'm turning my printf format strings into unreadable spaghetti now that I have to use those PRIdFAST32 macros everywhere there's a number.
>>
>>57262202
Lisp is shit
>>
>>57262238

Wrong!

t. DJT
>>
File: 1473827539441.gif (2MB, 320x240px) Image search: [Google]
1473827539441.gif
2MB, 320x240px
>>57262241
I do not know who this DJT is, but he is a fool
>>
>>57262199
>global variable instead of parameters
would have flunked CS 101

>>57262202
Way too verbose and lacking in libraries.
>>
File: donald-trump-39.jpg (4KB, 128x128px) Image search: [Google]
donald-trump-39.jpg
4KB, 128x128px
>>57262249

Oh, I think you know him well.
>>
>>57262227
how many structs do you allocate? in what kind of algorithm are they used?
>>
>>57262205
Lists do not exist in C. You cannot use the word "list" when talking about a C program, because the concept of "list" does not exist in C. You can interpret a piece of C code to be a "list", but I can as easily interpret it to be a chained hash monkey rope tree set banana spiral array and I'd be correct.

>>57262207
From the point of view of the C specifications: they're not anything.
>>
File: trump you have to get out.png (79KB, 349x334px) Image search: [Google]
trump you have to get out.png
79KB, 349x334px
>>57262249
(((Hal Abelson)))
>>
>>57262256
>lacking in libraries.

The only people who believe this are people who aren't using modern LISP/Scheme dialects like Racket.
>>
>>57262219
You're an idiot who doesn't know what an ADT is.
>>
>>57262262
>How many structs do you allocate?
A lot but they're stored sequentially in a circular buffer
>>
>>57262267
>I can as easily interpret it to be a chained hash monkey rope tree set banana spiral array and I'd be correct.

What's the performance of that data structure? I've never heard of it.
>>
File: Top cuck.jpg (325KB, 860x700px) Image search: [Google]
Top cuck.jpg
325KB, 860x700px
>learned bunch of new functions yesterday
>already forgot them
>>
>>57262227
Neither in any meaningful way just from those code you posted.

if you have to allocate space for *name on the heap for each structure then B will likely be faster, but if you're passing around lots of Bs then you're copying that array every time as well.
>>
>>57262275
You're a rude person who thinks he knows what he's talking about when he probably hasn't even read any of the C specification documents.

Lists do not exist in C.
>>
>>57262229
why do you need 'fast' ints?
don't use them unless you have to squeeze every last bit of performance out of a function (GIVEN that using a normal int is a major drawback). other than that you're only making your code unreadable and effectively waste your time.
>>
>>57262260
>>57262271
Are you saying DJT's wall is going to be a linked list, rather than a contiguous block?
Sounds shitty
>>
>>57262298
nobody has said that lists exist in C, only that they can be implemented in C, and therefore you can say you will store a list of a nigger's specialties in a program written in C, contrary to >>57261995's complaint
>>
>>57262291
>remembering functions

Nobody does that. Aside from a few key ones, you're going to have to RTFM when you need to do something.
>>
>>57262331

It was basic stuff. HTML shortcuts.
>>
>>57262331

You are working as a programmer, are you?
Dont tell me you have nothing in your hard drive and look up every second function.
>>
>>57262279
>A lot
what is a lot? a few thousand? one million? how are they used? (see >>57262292)
>>
>>57262331
Remembering functions is great, especially in Haskell
>>
File: argument levels.jpg (60KB, 567x565px) Image search: [Google]
argument levels.jpg
60KB, 567x565px
>>57262267
>lol words don't mean anything cuz I can just call them something completely unrelated
>>
>>57262349

I remember a bunch of them, but I don't remember everything.

All you REALLY need to remember is fine dining and breathing.
>>
>>57262395

So the trick about being a programmer is to get the general idea and to know how to find the stuff you do not get (usually through Curryoverflow)?
>>
>>57262323
We're going to doubly chain every border-hopping Paco we can gather to construct the wall, and Mexico will allocate the space for it.
>>
Today I made a new programming language.
It's worse than brainfuck.
>>57262318
>>
>>57261483
fixed
>>
File: disgusted hitler.jpg (25KB, 214x265px) Image search: [Google]
disgusted hitler.jpg
25KB, 214x265px
>>57262199
>global variables
>merging ADT, implementation and user interface
>>
File: Untitled79.png (111KB, 1920x1080px) Image search: [Google]
Untitled79.png
111KB, 1920x1080px
I'm working on my IPAM/DNS interface
>>
>>57262412

I mean, it used to be that you had to crack open a reference manual, but in general, you can get away with stackoverflow.
>>
>>57262431
Looks really clean, did you use any frontend libraries or is it all custom css?
>>
>>57262430

I hope you only need one list. :^)
>>
>>57262420
Looks more like a Turing machine than a language.
>>
>>57262474
it's clearly based off brainfuck.

of course it looks like a fucking turing machine.
>>
>>57262350
Few millions of struct, I'm trying to find the best way to store a graph for testing text-mining algorithms.

Also, should I store a list of pointers in each nodes or every relationship as a matrix?
>>
is a calculator turing-complete?
>>
>>57262465
Not op but definitely bootstrap.
>>
>>57262465
It's AdminLTE, which is based on Bootstrap.
On top of that I use Angular.
I don't like writing front-end that much, so this is pretty good.
>>
>>57262492
c does not have a concept of a calculator
>>
>>57262503
milhouse is not a concept in C either
>>
>>57262483
What i mean is, there has to come some point where you can't reasonably call it a language anymore.
>>
>>57262515
I suppose.

Does an artist make art? Or does art make one an artist?
>>
>>57262412
Being a good programmer isn't about memorizing programming languages. It's about understanding how to design good programs, i.e. how to break a real-world project down into a series of discrete tasks that are amenable to computing, then implementing them in an efficient and maintainable way. You'll get to know the parts of the standard libraries for your most common languages just by using them regularly, but it's a poor use of time to just memorize random functions.
>>
>>57262532
Spontaneously: the latter.
>>
>>57262567

Ah, okay.
And w-where do I learn that? :*>

Should I apply for an internship right away, after I learned the basics of a language?
>>
>>57262578
either way nobody knows if it's really art or not.
>>
So I always see pictures of coders with like pro hacker tier Linux dev boxes. What do I need to set something like that up? I already loaded Ubuntu onto my computer. I want like the black with green text shit.
>>
>>57262684
ctrl + alt + F1
>>
>>57262581
You learn it by reading books about programming, not about programming languages. Then you write lots of programs, look at other people's programs, and learn from your mistakes.
>>
Have you ever tried to build something like:
unlocking door by using raspberry pi, opencv face recognition etc?
>>
>>57262703
Haha, yeah, I'm not falling for that. It probably breaks my RAMs or something.
>>
>>57262736
Literally google what it does.
>>
>>57262736
It switches to a virtual terminal, i.e. you will just have a CLI running in a framebuffer. Ctrl + Alt + F# will select one of the different # tty's.

Your GUI (X display) will still be running, on Ubuntu its usually on 7 or 8 (Ctrl + Alt + F7 / F8 to get back to the GUI)
>>
>>57262764
Don't do this, it will break the internet
>>
>>57262272
Speaking of a lisp with libraries, have you heard of hy lisp?
>>
>>57262581

Books about software architecture & design, books about algorithms and problem-solving, etc.
>>
>>57257616
>Javascript for high level applications programming.
And then you get stuff like Atom...
>>
>>57262782

I hadn't before, but it certainly looks neat.
>>
>>57262785

Mkay.
Sadly, there is no course in my university that requires to read these books. So you have to learn it by yourself.
>>
>>57262532
Does sucking dick make a faggot? Or does being a faggot make him suck dick?
>>
>>57259972
>I don't know about Indian coders or other big non-english language groups.
I'm pretty sure English is an official language in India.
>>
>>57262802
this really made me think
>>
>>57262794
>So you have to learn it by yourself.

If you aren't doing hobby projects, you won't end up being a particularly good programmer.
>>
I want to kill myself.
But, I want to work towards that goal with programming.
What do you suggest as my last, final project?
>>
>>57259973
In a Windows form application you have elements on your form, which have strings as properties you can change.
>>
>>57262828

Cyberattack on a CIA server.
Suicide by cop, basically.
>>
>>57259994
Ye, the picture is a bit of a hyperbole.
>>
Just learned java to learn android programming. Now my phone actually feels like its worth $699.
>>
>>57262870

but it isnt, anon. its built with chinese child labour and sold for thrice the manufacturing cost.
>>
>>57262229
>Do people frequently use those data types like int_fast32_t from <inttypes.h>?
>Say I need to store numbers that could go up to 100,000, but I want the compiler to choose the fastest way to do it (because nanoseconds matter right?)
No, they are 100% useless.
Compiler already does it regardless of int type you use (especially signed integers since overflow is undefined, so the compiler is completely free to widen them however it wants)
>>
>>57262884
>Android phones
>profit margin
pick one
>>
>>57262884
Id probably pay double. This is probably the most useful thing I own right now. Though I still need to learn the native c++ stuff so I can program in a language Im comfortable in.
>>
One of my uni modules this semester requires giving some sort of presentation. I decided to do a 45-60 minute Python introductory workshop for my fellow students, none of which have ever worked with Python before. They're all EE Master's students.

What would be a nice small example program I can write with them? "Hello world" and the turtle are a bit too basic and I've been working on computer vision so long now that I have no idea what is obvious / easy to grasp for a newcomer and what isn't, so I run the risk of losing everyone within 10 minutes and getting results that are basically witchcraft to everyone else.

Preferably something I can do with just numpy and matplotlib, that introduces most standard functions in Python and that produces some visual output (CLI I/O is functional but not very attractive to newbies).
>>
File: 1477520649417.jpg (54KB, 460x540px) Image search: [Google]
1477520649417.jpg
54KB, 460x540px
on my WIP resume:
>Languages: Java, C++, C, SQL(not really a language i know), Scheme, PHP, Python
because of the nature of my university's computer science course, we use lots of different languages and learn few in-depth by the course work alone. which ones of these should i master well enough to include on a final resume? i hear that if you're applying to companies like google, they'll expect you to be able to do challenges in any program you list
>>
>>57262298
>Lists do not exist in C.
Yes they do.
struct foo = { a, b, c, d };

That is a list in C (initializer list, see 6.7.9)
>>
What would be something impressive to make in C, with about a day of time?
>>
>>57262884
I don't think you understand how expensive it is to manufacture a modern smartphone. protip: it's nothing like manufacturing modules like standardized PC components.
>>
>>57262828
AI
>>
>>57262932
why not make a script that tests if everything in a directory meets some type of requirement (as the input), and deletes it if it doesn't? or something similar. i like scripts because i can see how they're useful, though idk if an EE student would even use linux. do they?
>>
>>57262942
>impressive
for you? hello world
>>
>>57262973
No, most stick to Windows because proprietary simulation software and shit. Those few that do use GNU/Linux typically shy away from the CLI; they like their clicky mouses. Plus that sort of program can be implemented in like 10 minutes with shell commands.
>>
>>57262942
wouldn't call it impressive but make a multithreaded producer/consumer. hint: if it produces until the stack is full, then consumes until it's empty, and repeats, you probably did it wrong senpaitachi
>>
>>57262999
you can use shell commands in python
>>
>>57263019
My point is, I can do "delete file from folder if criteria are met" in pure shell scripting with no python at all.
>>
>>57263028
anything you do can in python you can do without using python
>>
>>57263073

true for any programming language
>>
>>57263073
They can do file operations without any extraneous programs or programming. Shit's boring for someone who isn't trying to automate every repetitive thing. What I'm looking for is something that is _relatively_ easy to understand for EE Bachelors, that produces graphical results.
One idea I had was simulating a simple transmission line simulation (transmit bit stream from A to B using X modulation, simulating effects like phase jitter and noise and how that influences the bit stream at the receiver.
Another idea was to implement an image compression algorithm similar to jpeg and demonstrate how losses are introduced.
But I think both of those are already too complex for the time frame I'm given and won't interest most of them. They're fucking normies, most of them.
>>
>why use a shell script when you can use python to call shell scripts, python's just epic like that xD
>>
>>57263222
Why use Python when you can just grow up?
>>
>>57263222
Why use Python to call shell scripts, when you can use a shell script to execute a Python program that calls a shell script that executes a Python program that calls a C-implemented function?
>>
File: 1445448687491.jpg (123KB, 500x500px) Image search: [Google]
1445448687491.jpg
123KB, 500x500px
Good IDE's for Python?
>>
>>57263283
Sublime Text
>>
>>57263283
Just use a text editor.
>>
>>57263283
nano
>>
>>57263283
>good
>python
>>
>>57263291
nah, that shit is for plebs
>>
>>57260963
underrated post
>>
>>57263085
that was my point
>>
>>57262937
gtfo and kys john snow of C
>>
>>57263396
>john snow
who
>>
File: jon snow.gif (2MB, 640x360px) Image search: [Google]
jon snow.gif
2MB, 640x360px
>>57263423
>>
>>57263447
>channel 4
original fucking naem
>>
>>57263073
That's not a justification for doing it in Python.
>>
>>57263222
you don't use python to call shell scripts, you use python to do system calls. though you can do both
>>
File: coderetard.png (41KB, 1249x224px) Image search: [Google]
coderetard.png
41KB, 1249x224px
Just started programming and I'm doing this little java exercise. I'm trying to get it to just print the results but when I call the method it gives me this box instead. how to fix
>>
>>57263575
it would seem like your system.out is blueJ
>>
>>57263575
>bluej
fill in those boxes? so type in an integer number for totalVotes, and two floating point numbers for candidate1Share and candidate2Share

Then I guess it will run just that function with the values you provided and display a console window for the System.out.format calls.
>>
NEW THREAD!!

>>57263655
>>
>>57263623
That sounds like it could be the problem as something similar was working in the lab but not on this home computer

>>57263642
The point of the method is to calculate those boxes using code n shit earlier in the program.
>>
>>57263623
for you
>>
File: be7.jpg (31KB, 600x436px) Image search: [Google]
be7.jpg
31KB, 600x436px
>>57262267
Holy fuck you're stupid
>>
>>57261537
 
(defstruct nigger
(price 3/5)
(slave-name)
(african-name)
(freed nil))
Thread posts: 323
Thread images: 34


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