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

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

Thread replies: 255
Thread images: 22
File: daily programming thread2.webm (2 MB, 600x338) Image search: [Google]
daily programming thread2.webm
2 MB, 600x338
old thread: >>55296311

What are you working on, /g/?
>>
File: it's a trap.png (873 KB, 1275x677) Image search: [Google]
it's a trap.png
873 KB, 1275x677
Thank you for using an anime image.

Why do people still use OOP?
>>
Where is VPS guy?
>>
File: 1417911861742 (2).jpg (9 KB, 145x119) Image search: [Google]
1417911861742 (2).jpg
9 KB, 145x119
>>55305159
Because it's easy.
>>
>>55305185
no, it's not
its an abstraction layer, it's no worse than a framework and just makes your program even more complicated than it should be, if you find defining 500 methods just to set a variable to 1 "easy" then you're fucked lad
>>
>>55305159
>Why do people still use OOP?

It works decently for a lot of problems. Obviously, it's flawed, but it helps get work done.
>>
>>55305230
It's a layer of abstraction on top of a hundred layers of obfuscation.

Abstract doesn't mean more complex. It just means different.
>>
>>55305159
Same reason they use functions.
Same reason they don't write code in assembly, or a hex editor, or a magnetized needle and a steady hand.
>>
File: akari a cute.gif (880 KB, 500x281) Image search: [Google]
akari a cute.gif
880 KB, 500x281
Let's try something new.
I made an anonymous push git repo!
No authentication needed for push or cloning!

git clone git://45.32.87.203/dpt-repo.git
>>
>Want to write a tiny (elf header and a handful of bytes) forkbomb
How do I test this without crashing my laptop every few attempts?
>>
File: haskell.png (354 KB, 905x460) Image search: [Google]
haskell.png
354 KB, 905x460
>Re(2016 + 2 - 3 + 1 + i)
>not using a functional paradigm
What's wrong with you, /g/?
>>
>>55305348
that's not how computers work in the real world, weeb
>>
>>55305444
Computers don't work
>>
c++17 sure looks nice.

if (init; condition) {}
switch (init; condition) {}

std::pair x(1, ":^)");
std::tuple y('a', 9, x);
// templated classes now work similar to templated functions so no more pair<...> x(), auto y = make_tuple(...), etc

auto &[a,b,c] = y;
// nicely unpacks tuples/structs/etc
>>
>>55305460
>functional
>expects it to work
that's why you're retarded
>>
What the fuck is a class? What the fuck is an object even supposed to be? What's wrong with just using structs?
>>
>>55305524
still no concepts
>>
>>55305578
that's a class
>>
How do I get good at C? I'm looking to get into embedded systems, so I feel like I should somewhat "master" the language. However I feel that solving your standard programming exercises in C is more tedious than it is educational.
>>
[butthurt intensifies]
>>
>>55305629
Right a datastructure in C.
Then beat it's performance in assembler.
The best way to master anything is to work out how it works underneath.
>>
>>55305348
I will do haskell stuff when there will be 1k core processors for concurency, good ram to keep up with immutable state shit and what not.
>>
File: 2016-06-28c-MoreJQ.png (2 MB, 1600x870) Image search: [Google]
2016-06-28c-MoreJQ.png
2 MB, 1600x870
Well, I finally got my menus finished after a trip to the bathroom and some Spaghetti O's

I also started on the fake conversation panel. It changes every time I click my waifu.

Gonna need to figure out a good randomization technique and lots of lewd shit she can say to me.

Also gonna have to set some thresholds for an image changer, so I can turn her into a hentai game... But I'm gonna have to pick some decent images. I'm not sure I currently have what I'll need.

Also, need to decide how I'm gonna handle the middle panel. I kinda wanna AJAX load some pages into it when I click links from the navigation menu.

Also considering the hentai game being /activated/ after a certain number of actions, and then it overlays onto the page. Now sure what I wanna do with the game yet, though, exactly. I'll need to sleep on it probably...
I'm also gonna have to really make a choice regarding how I'm gonna use that middle panel... Maybe that can be the game? IDK.
>>
>>55305751
4 hours for Spaghetti O's? Man, that must suck.
>>
anyone have any experience with free image. I cant tell if its converting things to bgra by default or if thats just how the image is formated.
>>
>>55305788
no, dude, I worked on it some more after I left, then I took a crap.

I also have OCD, so when I'm done on the toilet, I'll wash up for like 40 minutes.

THEN I got back to working on this.

So, say around 30 mins before bathroom ,1½ in bathroom, then around 45 minutes of eating and stuff, and another half hour coding some more. Also, chatted with a friend briefly and goofed around on a few DNews YouTube vids
>>
>>55305585
well some of its already usable

#ifdef CONCEPTS
template<class T> concept bool foo = requires (T x){ x*x; };
#else
template<class foo>
#endif
foo mul(foo a, foo b) { return a*b; };

int main() {
mul(1,2);
mul("test", "no");
}


g++ test.cc

test.cc: In instantiation of ‘foo mul(foo, foo) [with foo = const char*]’:
test.cc:11:18: required from here
test.cc:7:33: error: invalid operands of types ‘const char*’ and ‘const char*’ to binary ‘operator*’
foo mul(foo a, foo b) { return a*b; };
~^~


g++ test.cc -std=c++1z -DCONCEPTS -fconcepts

test.cc: In function ‘int main()’:
test.cc:11:18: error: cannot call function ‘auto mul(auto:1, auto:1) [with auto:1 = const char*]’
mul("test", "no");
^
test.cc:7:5: note: constraints not satisfied
foo mul(foo a, foo b) { return a*b; };
^~~
test.cc:7:5: note: concept ‘foo<const char*>’ was not satisfied
>>
>>55305835
well that sounds debilitating.
>>
>>55305891
you betcher ass it is.

But as a programmer, I will be able to live my life indoors and mostly away from people.
>>
30th for null references need to be a thing in C++ (rather than undefined behavior).
>>
>>55305988
They're called pointers, faggot
>>
>>55306012
I said C++, not C.
>>
>>55306028
>doesn't know C++ has pointers
ask me how I know you're a webshit
>>
>>55305159
>Why do people still use OOP?
You don't have to go over the top to use it like java forces you, it's very helpful when it would benefit the client greatly to have a simplified interface that is class specific.

Consider the pthreads api for C, you declare structs for the pthread itself, mutexes, semaphores, etc. The information for the structs is hidden using some clever compilation tricks so that the client doesn't access the data directly. Classes in OOP languages can instead encapsulate that data.

To start, you first use an interface to initalize the values, usually called pthread_[struct type]_init(bunch of variables or other structs) and then when you're finished using them you have to call pthread_[struct type]_destroy(struct). It's simple but constructors/destructors from OOP are great at managing that.

In addition, calling these seemingly independent functions from pthreads.h like pthread_join, pthread_create, pthread_cancel, etc. are much more simpler to utilize when they are called on the pthread_t you are manipulating rather than passing the pthread_t around.

And resource management when working with pointers is made so much nicer using OOP constructs.

That's just my opinion on why OOP is useful even if there's ugly shit like abstractMethodExceptionCatcherFactoryInterface and stuff.
>>
>>55306052
C pointers aren't the C++ way to do things.
>>
Lets have a programming collab
>>
>>55306077
>I'm retarded
>>
>>55306077
go ahead, just ask
>>
>>55306107
>>55306113
C pointers are less flexible.
>>
>>55305988
>null reference
thats what pointers are for. also the new optional type.

>>55306077
they are if you use them correctly.
>>
>>55306124
come on, ask
>>
>>55306124
How?
>>
File: 1438665228395.jpg (80 KB, 1140x475) Image search: [Google]
1438665228395.jpg
80 KB, 1140x475
>he's a softwareonly babby
>>
Java is the best programming language. It is well defined and it has so many libraries and support everywhere. Nothing can beat it. Pro tip you can't prove me wrong
>>
http://www.strawpoll.me/10614983
http://www.strawpoll.me/10614983
http://www.strawpoll.me/10614983
>>
>>55306157
dw, that was stupid.
>>
>>55306207
>You can either be a NEET or a normie.
Fuck off.
>>
>>55306392
Exactly what about us Entrepreneurs
>>
>>55306401
you're normies lad
>>
File: akari2.jpg (58 KB, 514x524) Image search: [Google]
akari2.jpg
58 KB, 514x524
>>55305335
I got a more memorable url!

git clone git://tempgit.mooo.com/dpt-repo

You can still include the .git part if you want.
>>
>>55306952
>tempgit.mooo.com
Neat! Also, I thought of a project.
>>
File: Empty-room.gif (605 KB, 360x360) Image search: [Google]
Empty-room.gif
605 KB, 360x360
>>55306952
Nice
>>
>>55306401
Fuck off normie. Go have sex with your girlfriend you fucking NORP.
>>
>>55305339
ulimits? VM? Docker?
>>
>>55307026
And if you guys want to talk, run the script in the git repo.
>>
What is the point of Docker? The while premise seems like complete overkill, designed for retards who can't set up systems correctly
>>
>>55306186
Scala can do everything Java can do and more
>>
I want to do something very simple.

Using batch script or python, how can I print the names of the currently selected folders from Windows Explorer?
>>
>>55305125
a c++ program that connects to websockets. I need help. I am using this library (https://github.com/zaphoyd/websocketpp) to connect to the websockets, but it only works with unencrypted websockets (ws://) instead of encrypted websockets (wss://). I am basing my project off of this example (https://github.com/zaphoyd/websocketpp/blob/master/examples/utility_client/utility_client.cpp), and cannot get the tls_handler to fucking work. I've followed what this fag said here (https://groups.google.com/forum/#!topic/websocketpp/SimAUzwZUVM), and it still doesnt work. After I did what he said, it basically gave me a generic 'could not connect' for both the encrypted and nonencrypted connection. If anyone knows what I'm talking about, please help before I kms.
>>
>>55307906
curl?
>>
>>55307943
i could use curl if I decided to say fuck the websockets, but I'm so fucking close it's killing me.
>>
Can someone explain this behavior in Python 3.5? I know C++, so I know how pass by value, pass by reference, and pointers all work. But I am confused about what's going on here because Python is new to me:

class ABC:
listOne = list()
listTwo = list()

def __init__(self):
self.listTwo = list()

a = ABC()
b = ABC()

a.listOne.append("One")
a.listTwo.append("One")

b.listOne.append("Two")
b.listTwo.append("Two")

print("a.listOne: ", a.listOne)
print("a.listTwo: ", a.listTwo)
print("b.listOne: ", b.listOne)
print("b.listTwo: ", b.listTwo)


Output:

a.listOne:  ['One', 'Two']
a.listTwo: ['One']
b.listOne: ['One', 'Two']
b.listTwo: ['Two']
>>
>>55307806
I need this because I want to paste a file into multiple selected folders. holy shit why is simple shit so difficult.
>>
>>55305159
Encapsulation, Inheritance, and Polymorphism
>>
>>55308113
listOne is a class level variable, therefore it's shared among all the instances of that class

listTwo is an instance level variable since you're setting it in the constructor, so the contents are specific to that instance
>>
>>55308167
>Encapsulation
Fundamentally flawed
>Inheritance
Shit
>Polymorphism
Not exclusive to OOP
>>
>>55305159
What programs have you made without OOP?
>>
Python never ceases to amaze me.
I just found out that "foo" in s is faster than s.startswith("foo").
What the fuck.
>>
>>55308113
Basically if you define variables outside of the methods, they're actually static members, not member variables.

As if:
struct A {
static std::list<std::string> one{};
static std::list<std::string> two{};

std::list<std::string> two{}; // let's pretend this is allowed

A(): two{} {
}
};
>>
Is it possible to hide the code of a python script?

I got memed my a company that is using python : they kept promising me I'll have a bonus at the end of my internship if I get beyond the original objective, which I did, and got nothing but the bare legal minimum.

I continued the project on my own and eventually managed to get something I can sell them for a fair price. Since they'll ask for a proof, I want to give them a sort of proprietary blob to prove my point and give them the source once I get my bucks.

I know we can do so in matlab but I never heard of such thing in Python.
Is rewriting the stuff in C, compiling it and calling the program in a python script my only solution? Feels overengineered.
>>
>>55308338
(To expand upon this, both are accessed with the dot but the latter is simply being overriden).
>>
>>55308378
IL or object code?
>>
File: python.png (6 KB, 620x95) Image search: [Google]
python.png
6 KB, 620x95
>>55308295
not really once the string starts getting bigger

not all that surprising on smaller strings either as operators are generally faster that function calls
>>
>>55308378
you can compile python to an executable, not sure how hidden the code is though
>>
>>55308444
object code I guess. https://wiki.python.org/moin/Asking%20for%20Help/How%20do%20you%20protect%20Python%20source%20code%3F says I should gibberish my variable and function names before I compile it into some .pyc and it should be enough but I think I'd better ask for other's opinion.
>>
why is Java so good?
>>
>>55305125
help me, /dpt/
>>55308548
>>
>>55308718
>>55308548
That's why the "Report post" exists.
>>
>>55308440
>>55308192

That's very strange but cool thing to know.

Another question: How do I type hint for lists of objects? Like if I had a list containing ABC objects, how would I type hint to them? I'm using PyCharm.

In this case, the type hinting works for the single object, but not a list containing that object:

def tester(ABCObject, ABCList):
'''
:param ABCObject: Takes a single instance of an ABC
:type ABCObject: ABC
:param ABCList: Takes a list containing ABC
:type ABCList: list
'''
>>
>>55308718
Not your personal army
>>
>>55308759
Nv, figured it out. It's
''':type ABCList: list[abc]'''
>>
>>55308536

it would be hilariously easily to reverse engineer, it can be decompiled to something pretty close to the source.

>>55308378

understand that anything can be reverse engineered, it just depends on how much effort one is willing to put in.

with that said, how worried are you that they will try to cuck you? the case might be that simply obfuscating the shit out of it might be enough. or you might have to rewrite it in C and employ a bunch of anti-debugging techniques.
>>
>>55308732
mods/janitors are too slow. let's make it annoying for shitposters.

>>55308786
this is not only about me, you will benefit from this too, but OK, whatever floats your boat.
>>
For fun, I want to create a python program that will collect all the data while I play Overwatch.

Preferably, I'd like the data to be the amount of keystrokes entered, internet speed, characters chosen, specials activated, life of player, etc.

Are there any anons that can provide input on how to get started with this in Python? I'm not even sure if I'd be able to do this, as surely Blizzard has some sort of authentication feature that would stop my python program from doing this.

Not sure if this is over my head, but I'm just curious as to how one would do this.
>>
>>55308834
>Not sure if this is over my head
it almost certainly is
you either need to cause the game to load a .dll you create, either at runtime or by creating a remote thread in the process which calls LoadLibrary
or you can read the data out of the game from your process with ReadProcessMemory

either way you need to reverse at least a little of the game to figure out where the data is located
which means you also need to know at least some x86 asm
>>
>>55308827
>this is not only about me, you will benefit from this too, but OK, whatever floats your boat.
I don't benefit because I don't go to dumb shit threads like speccy or desktop so I don't see any of that shit anyway. Likewise, their existence works as containment because it keeps speccy retards from shitting up my serious discussions.

If you want to post somewhere where users actively prevent certain discussions, reddit or voat are prime candidates for you to go to.
>>
File: kek.png (16 KB, 508x295) Image search: [Google]
kek.png
16 KB, 508x295
>>55307906
bump please? I'm about to kms.
>>
File: 1463629402893.jpg (114 KB, 970x880) Image search: [Google]
1463629402893.jpg
114 KB, 970x880
>>55305125
So I'm about to finish this "Illustrated WPF" book, on what should I focus next if I wan't to develop LOB/Enterprise applications? Databases, git gud at this framework?

I'm working on a couple of personal projects just to practice and to show, but pointers to what do next will be helpful.
>>
>>55308882
Well fuck. Maybe I'll play with some other ideas before I try to attempt this. Not sure how difficult this is, but considering I'm asking these questions I'm going to say very.

Thanks for your input.
>>
>>55308732
>>55308786

>>55308827
thanks fags, someone reported the thread and it was deleted >>55308548
ironically, they aren't this fast when I report useless/spammy threads.
>>
>>55308802
>understand that anything can be reverse engineered
Yeah, I know, but I believe they'll realize that it would be cheaper to help me repay a part of my student loan than paying the man-hours to reverse engineer instead of working on their own tasks. (or he'll just cuck another intern into doing it for him)

>with that said, how worried are you that they will try to cuck you? [...] you might have to rewrite it in C and employ a bunch of anti-debugging techniques.
As much as he can I guess. Since I don't know the extend of decompyle I guess C is the safest solution.
>>
>>55308920
it's not as bad as it sounds, but if you're not coming from a C or C++ background then it's probably going to be a while before you're at that point
>>
>>55305629
https://www.amazon.com/Expert-Programming-Peter-van-Linden/dp/0131774298/

http://c-faq.com/

http://www.literateprogramming.com/ctraps.pdf

http://www.rmbconsulting.us/a-c-test-the-0x10-best-questions-for-would-be-embedded-programmers

http://www.tutorialspoint.com/cprogramming/cprogramming_interview_questions.htm
>>
>>55309011
Thanks again brotha.
>>
>>55309043
Oh, how could I forget the clockwise/spiral rule?

http://c-faq.com/decl/spiral.anderson.html
>>
>>55305159
I bet none of the fags on /g/ can tell me what "OOP" really means.
>>
>>55309145
upvote
>>
>>55309145
Yeah, that is damn neat-o.
>>
>>55309259
structs with function pointers, right?
>>
>>55308577
JVM
>>
>>55309317

Yes.
>>
>>55309368
Phew, was pretty on edge there.

Luv ya <3
>>
Any disadvantage to using GLFW instead of rolling my own thing? I'm writing babby's first OpenGL visualizer, not sure if I should bother fucking around with WinAPI.
>>
>>55309462
WinAPI isn't cross-platform
>>
>>55309561
sure it is since linux user who cares about running software is also running wine
>>
>>55309462
none I can think of. GLFW is pretty lightweight and easy to use. Also cross platform
>>
What are the advantages of functional style? Why wouldn't you just use object oriented style, which is the correct way to do things?
>>
>>55309582
None of the programs I have on my linux requires wine.

I aint runnin that shit nigga
>>
>>55309660
So, GCC and tux racer?

systemd is gonna have wine in it by 2017
>>
File: betauprising.jpg (17 KB, 316x239) Image search: [Google]
betauprising.jpg
17 KB, 316x239
>>55309708
>systemd is gonna have wine in it by 2017
DELET
>>
>Tfw programming is so difficult and it's too hard to program a full functioning good game

WHY LIVE?
>>
>>55309786
bro you could make snake or flappy bird in half a day
you can do it!
>>
>>55309786
Working with SDL and Sepples to make vidya just for fun almost made me drop programming. (I like C++ btw)
>>
>>55309814
Drop C++ and stick with C, seriously
>>
>>55309798
Those are not good real games

>>55309814
Those are not good tools to make a game

SIGHHH
>>
>>55309823
My favorite lang is C, so simple, cute, and small. But sadly employees in my area only gives shit for Java, Node, and C#. So I sticked with C#.
>>
>>55309870
Same here in Canada it's all Java everywhere you go no escape from Java.
>>
>>55309852
nigger what
snake was fucking fun for like 10 years
how about tetris? that shit is still fun now
you could make a good polished tetris in like 3 days
>>
>>55309883
shit games would not play / 10
>>
>>55309317
Nope.
>>
>>55309907
I agree with this guy writing a bunch of if statements checking if the snake touches the wall or itself and adding one to it's length and redrawing it on a canvas for each frame is not fun to program or even play

A real game like dark souls would be too difficult to program
>>
>>55309949
What about it is difficult to program, exactly?
>>
>>55309967
boss combat interaction
>>
>>55309999
Are you... are you serious right now?
That's like a generic ass problem.
>>
>>55310023
yup it would be the hardest part
>>
>>55310035
But you didn't actually tell me what the problem about it was, you just pointed out a mechanic and said "hurd".
>>
>>55310046
okay what do you think would be the hardest about a game like that?
>>
>>55310062
The programming? Not much. The hardest part of making the game is the assets. One good programmer could write all the game logic in Dark Souls (and probably did), but you need a shit ton of work to build the tools that manage the assets and let your level designers do their thing.
>>
>>55308167
the Polymorphism in OOP languages is dogshit compared to haskell
>>
>>55310281
>Polymorphism
>ever
Literally why? If you need polymorphism, that's a failing of your program architecture and you should rethink it.
>>
I think I may start using Rake for building C and C++ programs... or at least experimenting with it to see if it is useful for, say, cross platform development.
>>
>>55310303

Why not? Polymorphism makes a number of problems easier to reason about, and there is literally nothing wrong with it.
>>
>>55305125
Nothing because I never programmed in my life.
>>
>>55310356
you probably shouldn't use inheritance at all
composition is superior
>>
I'm about to write a simple program in C that requires random data that I'm going to store into an array. Rather than do rand() i'm thinking why not just not initialize the array and use the random junk. I don't need any guarantees or anything. viable?
>>
>>55310387
>viable?
yeah
keep in mind that it will work better in release mode because compilers will often do things like automatically initialize memory to 0 if you pass debug flags
>>
>>55310382

Why not both?
>>
>>55310356
It doesn't make any sense to duplicate code in that manner. (And templates duplicate a shit ton of code).

It's more reasonable to compose the types you need.
>>
>>55310426
I already answered that
because composition is superior
>>
Ruby loves traps
>>
>>55310469

Have you not considered the possibility that composition and inheritance may be more useful in different situations?
>>
>>55310590
yes, I have considered it.
>>
>>55310430
Haskell polymorphism doesn't involve templates
>>
>>55310623
Haskell polymorphism isn't real polymorphism.
>>
>>55309708
Tux racer is a great game and don't you dare make fun of it!
>>
Why do Haskell programmers always are talking about the language features and not the things they're building with the lang itself?
>>
>>55310738
Because no one has ever written anything in Haskell.
>>
>>55310738
because they are noobs
>>
Has anyone ever written anything useful in Java?
>>
>>55310795
No one's ever written anything useful, period. It's all just a means to help to bourgeoisie leverage increased productivity into more power for themselves, while the common man suffers.
>>
>>55310576
Traps love Ruby
IYKWIM
>>
>>55310815
What are you a commie?
>>
>>55310862
>commie?
yeah, probably
which explains the now-deleted thread asking us to inform on our neighbors
>>55308718
>>55308548
>>
>>55310911
Capitalism is superior
>>
>>55308295
If you have to ask what's faster you shouldn't even be using Python, faggot. It's a fake inefficient language.
>>
>>55310615

And why have you come to the conclusion that composition is better than inheritance in all cases?

>>55310722

Go to Steam, look in the "Steam OS + Linux" section. There are literally thousands of games for Linux.

>>55310795

Are there any useful mobile applications?

>>55310845

I would think traps would be more fans of Python than Ruby...
>>
>>55310654
why not?
>>
>>55310988
name 3 useful Java mobile apps
>>
>>55310988
>And why have you come to the conclusion that composition is better than inheritance in all cases?
there are an infinite number of cases
so, rather than "all cases"; it is more accurate to say that composition is better than inheritance in "all considered cases"
>>
>>55311014

Termux
Clover
Newpipe

>>55311036

You can prove something true for all x in s, where s in an infinite set. All cases possible vs all cases that one will actually encounter is a meaningless distinction.
>>
I'm using python right now.
I'm fairly new to programming.
How do I make and destroy objects dynamically, so I don't have to do this
obj1 = ObjClass(initStuff)
obj2 = ObjClass(otherInitStuff)
>>
Who wants to write a 50,000 line java enterprise application for a lot of money together ?
>>
It's only been a day since I started using Java and I already want to go back to C# because of how much basic shit Java is missing or implemented horribly.
>>
>>55311309
>Thinks Java is bad

Spotted the shitty programmer please go
>>
>>55311309
Basic shit like what?
>>
>>55311131
that is true
I made the distinction because I haven't done the formal proof
"all considered cases" is all I actually care about
>>
>>55311131
https://www.youtube.com/watch?v=qObzgUfCl28

I've been playing music from ~2009 all day. those were the days.
>>
File: 1463500292996.jpg (42 KB, 256x259) Image search: [Google]
1463500292996.jpg
42 KB, 256x259
So I have a big project for school and I'm not really a good programmer. Where do I start making my design? I need to make some mockups and some UML diagrams. I kinda know how to make class diagrams but I can't seem to figure out how to make decisions on what classes to make and which ones to connect it to. Also I have no idea what sequence diagrams are
>>
>>55310654
It's parametric polymorphism done right.

f :: (a -> b) -> (b -> c) -> (a -> c)


When we disallow non-total functions, there is only one implementation of this function. You don't even need to write tests. There's only one thing it could do.

But in languages with shitty implementations of polymorphism, like C++ and Java, it could do literally anything. It's even worse in something like Python, where you don't even have the type signature.
>>
have you read code complete? how does one read a book like that? i'm used to read math books because that's what i study, but that book has no exercises, there's no obvious way to practice. if i read it, i'm going to forget most of it in half a year. sicp is different, it has a bunch of difficult exercises
>>
>>55311482
People rave about that book like it's an absolute must read for any programmer

And it might be, but I got half the way through it and felt like I wasn't getting anything out of it at all, so I stopped reading.
>>
File: groovy.png (81 KB, 600x600) Image search: [Google]
groovy.png
81 KB, 600x600
So is Groovy basically like the bastard child of Java and Python, with a cool logo?

Because if so I'm sold
>>
>>55311256
pls respond
>>
>>55311541
how so? did you think everything there was obvious, you didn't appreciate the content or something else?

have you read similar books? any recommendations? i think i'm an okay programmer, but i don't know what the best practices for big projects are
>>
is SICP a meme book?
>>
>>55311576
That's the normal way to create new objects, either using the new operator and/or calling a contructor.
The objects are destroyed automatically by the GC.
>inb4 that good joke about python not having a GC.
>>
>>55311576
that's the standard way to do that. what do you need? why do you want to destroy objects? i don't think you're at a point where you're going to need to manage memory yourself
>>
>>55311648
meant to reference >>55311576, >>55311256
>>
>>55311460
pls help me
>>
>>55311617
>>55311648
but I want an indefinite supply of objects but I don't want to do the classic
int x;
int xx;
int xxx;
int xxxx;
>>
>>55311577
almost all of it is common sense
it's sort of like a text book in my opinion, where the authors goal is sometimes only to take up as many pages as possible
you can easily sit down and read 80 pages and feel like the author hasn't yet actually said anything

another similarly highly praised book that I've read is The Pragmatic Programmer
it's better in my opinion; there are some gems in there that you will take with you
so I can at least see why it's highly recommended
>>
>>55311460
>>55311665
explain what you are suppose to do for your big project. What is it about?
>>
>>55311593
computer science is not a science and it isn't really about computers either
>>
>>55311675
containers
>>
>>55311675
google the term "loop" and the term "array"
>>
>>55311694
Will I learn to actually be a good programmer to build a real application from SICP?
>>
>>55311719
thanks mate, that did it
>>
>>55311675
where are you learning from? you need to use a very basic data structure called a list here. do something like "list = []; list.append(object1); list.append(object2); list.append(object3); ..." where objectk is the kth object you want there. all your stuff will be in list and you can access them by index: list[0] == object1, list[1] == object2 and so on. although i don't usually use indexes when i write python

what's the code tag here?
>>
>>55311797
I actually have all my objects in a list, I think I'm doing it wrong, it works, but it looks ugly
obj1 = obj(stuff)
obj2 = obj(stuff)
obj3 = obj(otherStuff)
obj4 = obj(otherStuff)
list = [obj1, obg2, obj3, obj4]
>>
>>55311797
i'm not sure what you need, but don't do obj1, obj2, etc. do objects = [obj(stuff), obj(stuff), obj(otherStuff), obj(otherStuff)] and access them by index: objects[0], objects[1], etc

what's the code tag, friend? how do i put stuff in that white square?
>>
>>55311911
why the fuck am i fucking up the references. meant to reference >>55311847
>>
>>55311694
That's the Lisp school. Other schools of thought would disagree with that statement.
>>
>>55311911
thanks I get it now

>what's the code tag, friend? how do i put stuff in that white square?
<code></code> with [] instead
>>
>>55311933
What is the Java school of thought?
>>
>tfw your code is now too big to just scroll through it all and have the part you were going to edit basically jump out at you
I've been both looking forward to and slightly dreading this moment, and now that it's here I'm a little resentful, but I appreciate it
>>
>>55311981
table of contents and folding, friend
>>
>>55311981
consider splitting it into several files. take the first 75 lines and put them in first\ code.cpp, the second 75 lines and put them in second\ code.cpp and so on, and then do

#include <"first\ code.cpp">
#include <"second\ code.cpp">

in a file called all_code.cpp
>>
>>55311997
I can just use the find function, my variable names and comments are clear enough
>>
File: pixel_pants.jpg (34 KB, 529x600) Image search: [Google]
pixel_pants.jpg
34 KB, 529x600
What is the best language to program a chatbot gf?
>>
>>55312039
kekalekadingdong
>>
https://m.youtube.com/watch?v=MticYPfFRp8

What do you think?
>>
>>55312182
befunge
>>
What's the format for the special code text box again?
>>
>>55312380
It goes like this
>>
>>55312396
Have it your way

import random

def main():
compCast()
userCast()
winner(compCast,userCast)

def compCast():
for count in range(3):
number = random.randint(1,4)
if number == 1:
number = "rock"
return "rock"
if number == 2:
number = "paper"
return "paper"
if number == 3:
number = "scissors"
return "scissors"

def userCast():
choice = str(input("Please cast rock, paper, or scissors: "))
if choice == "Rock" or "rock":
return "rock"
if choice == "Paper" or "paper":
return "paper"
if choice == "Scissors" or "scissors":
return "scissors"

def winner(compCast,userCast):
if compCast == "rock" and userCast == "rock":
print("Tie!")
if compCast == "rock" and userCast == "paper":
print("User wins!")
if compCast == "rock" and userCast == "scissors":
print("User loses!")
if compCast == "paper" and userCast == "paper":
print("Tie!")
if compCast == "paper" and userCast == "scissors":
print("User wins!")
if compCast == "paper" and userCast == "rock":
print("User loses!")
if compCast == "scissors" and userCast == "scissors":
print("Tie!")
if compCast == "scissors" and userCast == "rock":
print("User wins!")
if compCast == "scissors" and userCast == "paper":
print("User loses!")

main()

input()

Why isn't this printing anything?
>>
>>55305159
because we're living in the world where everything is called object and have value
>>
>>55312380
If only there were some kind of rules page that you could refer to for this information!


I want the illiterate and willfully ignorant to leave.
>>
>>55312405
>number = "rock"
they let just about anyone these days, don't they?
>>
>>55312322
It's impressive how he manages to misread almost every sentence.
It's like he knows how to pronounce most of the words (Mardor?) but doesn't know what they mean.
>>
>>55312437
I am literally just starting, do I need to put str( for all of those or am I going down the wrong path altogether
>>
>>55312441
....
What do you think about what he said?
>>
>>55312405
https://codeshare.io/XzSia
>>
>>55312405
Ignoring all the stupid shit, you're calling compCast and useCast functions in main and not doing anything with them then you're passing nonexisting variables into winner. Your winner function has does nothing if gibberish gets passed in so it's printing nothing.
>>
>>55312449
This is probably a troll but I'll bite. I can't program in python but I can already see a couple mistakes.
>Name your variables correctly, it's a good habit to get into.
>You don't need to set number = "rock" or anything like that in compCast()
>I bet you could use .toLower() or whatever the python way is, so you just do choice.toLower() == "rock"
>You can make a two dimensional array of integers to represent wins: 0 = tie, 1 = player 1 wins, 2 = player 2 wins
>Also, try to give real names to your functions. compCast doesn't mean anything.

also see
>>55312510
>>
File: 1457271423229.png (468 KB, 936x550) Image search: [Google]
1457271423229.png
468 KB, 936x550
Are there any statisticians on /dpt/?

For my research I'm writing a program that needs to be able to determine the magnitude of the effects of n input variables, which will either be classified as high or low (they're literally just bits, so 1's or 0's), with the output of some scoring function. The scoring function will assign a single scalar value to the sequence of 1's and 0's. Now the issue is, how do I determine the effects of the individual bits without taking into account all possible permutations of the input variables?

In other words instead of testing 000, 001, 010, 011, 100, 101, 110, 111, I might only have data for some subset of them, e.g. 001, 101, 111. So with incomplete data, how can I get an estimate of the effects of each bit on the output of the scoring function?

Unfortunately this is part of a much larger project and stats is not my strong suit. I was considering using a factorial DOE setup, but I don't think that would work because I can't possibly have enough replicates for every permutation.
>>
>>55312501
oh god
this is so great
>>
Check it out faggits, it works

import random

def main():
choice = str(input("Please cast rock, paper, or scissors: ").lower())

computerChoice = random.randint(1,3)
if computerChoice == 1:
computerChoice = "rock"
if computerChoice == 2:
computerChoice = "paper"
if computerChoice == 3:
computerChoice = "scissors"
print ("The computer has cast",computerChoice)

winner(computerChoice, choice)

def winner(computerChoice, choice):
if computerChoice == str("rock") and choice == str("rock"):
print("Tie!")
if computerChoice == str("rock") and choice == str("paper"):
print("User wins!")
if computerChoice == str("rock") and choice == str("scissors"):
print("User loses!")
if computerChoice == str("paper") and choice == str("paper"):
print("Tie!")
if computerChoice == str("paper") and choice == str("scissors"):
print("User wins!")
if computerChoice == str("paper") and choice == str("rock"):
print("User loses!")
if computerChoice == str("scissors") and choice == str("scissors"):
print("Tie!")
if computerChoice == str("scissors") and choice == str("rock"):
print("User wins!")
if computerChoice == str("scissors") and choice == str("paper"):
print("User loses!")

main()

input()
>>
>>55312872
>Still didn't use code tags, even when an anon told you where to find the answer
Retard.
>>
>>55312872
I hope we were of service.
>>
>>55312891
yeah, the "poop" copy paste made me realize that I was approaching the problem incorrectly and I cleaned up the main function
>>
>>55305125
Sauce plaese?
>>
>>55312872
import random

def rps(whatever):
print(["User wins!", "User loses!", "Tie!"][random.randint(0,2)])

wew
>>
>>55313028
except that isn't the answer
>>
>>55313050
except there wasn't a question
>>
>>55313050
>>55313028
it's possible that the user will get "Tie!" every single time they play
so, we may as well simplify this to
print 'Tie!'
>>
https://codeshare.io/XzSia
https://codeshare.io/XzSia
https://codeshare.io/XzSia

GET IN HERE YOU GUYS
>>
>>55313061
If you're playing rock paper scissors by your self, it may as well just be
print 'User loses!'
>>
>>55313026
Please respond.
>>
how the fuck are all these big youtubers getting hacked? it's like the hackers can get into any account. boogie said they stole his phone number and got into his account through that somehow. is there like some exploit that lets you receive other people's text messages or something and then some website does the password reset through that?
>>
>>55313543
try goto /sqt/
>>
>>55313590
it's not really a stupid question though, it's hardly common knowledge (if it is, then youtube/twitter/instagram or whichever site has been compromised really ought to fix it), we need to get to the bottom of this and maybe some people here are infosec guys that could come up with some ideas
>>
given two real valued functions of real variable, how would you check they're equal if you don't have the source code? i was just thinking people don't usually have to do this with computers. checking whether two functions are equal (value-wise) is common in mathematics, but not in programming

In [1]: f = lambda x: x

In [2]: g = lambda x: x

In [3]: f == g
Out[3]: False


how slow would it be to check all 2^64 values (i don't remember how many represent real numbers) for floating point numbers? makes u think huh
>>
    static unsigned sql_insert(const db::song &s)
{
char uri[s.uri().length() + 1];
char title[s.title().length() + 1];
char artist[s.artist().length() + 1];

// Not copying them into a char array causes ASAN to complain about use-after-free errors, not sure why though, as the array returned by std::string::c_str() is valid until the string object is modified.
strcpy(uri, s.uri().c_str());
strcpy(title, s.title().c_str());
strcpy(artist, s.artist().c_str());

sqlite3_bind_text(stmt_insert, 1, uri, -1, SQLITE_STATIC);
sqlite3_bind_text(stmt_insert, 2, title, -1, SQLITE_STATIC);
sqlite3_bind_text(stmt_insert, 3, artist, -1, SQLITE_STATIC);
sqlite3_bind_double(stmt_insert, 4, s.base_prec());
sqlite3_bind_int64(stmt_insert, 5, s.last_played());
sqlite3_bind_int64(stmt_insert, 6, s.times_played());
sqlite3_bind_int64(stmt_insert, 7, s.times_skipped());

sql_exec(stmt_insert);
return sqlite3_last_insert_rowid(sqldb);
}

Anyone know what might be the problem here?
>>
>>55313543
>>55313645
Why the fuck do you retards keep asking non-programming related questions in these threads?
>>
>>55313669
I'm pretty sure Meme++ doesn't have VLAs.
>>
>>55313694
>gay fag cartoon shit
>gee i wonder why
>>
>>55313724
GCC supports them regardless, and thanks for reminding me of that, I would've left them in if you hadn't.
>>
>>55313669
Also, what I say problem, I mean the comment. As in why do I need to copy it into a char array so ASAN doesn't complain?
Is it a problem with ASAN or is it a problem with me?
The code I posted compiles and works as expected, but I don't like it.
>>
I'm trying to write a simple cgi script to automate some form on my website.

How come the cgi script downloads every time I press submit?
I'm using lighttpd, btw.
>>
>>55313760
And for those who don't know what ASAN is, it's the builtin address sanitizer in GCC and Clang.
>>
>>55313694
you don't care if some random kid can just walk into your (anyone they choose) youtube/twitter/paypal/etc accounts just like that? you don't care HOW they do it? of course it's more or less programming related. it's a serious breach, fuck you.
>>
>>55313101
it's empty
>>
>>55313810
>It's a serious breach
>Therefore it's programming related.

No, if it's anything but SQT related, it's WDG related.
Go fucking ask in those threads not fucking here you stupid cunt.
>>
SOURCE ON THE OP IMAGE PELASE/
>>
I wanna learn more complex regex. Does Anyone got a link that provide a good regex references and tutorial?
>>
>>55313839
lol ok as if no one ever talks about infosec in /dpt/

and i don't see you complaining about posts like this: >>55313845
>>
How would I select 3 random items from a list and allow for duplicates?

Every time I try to use random.choice I either end up looping it three times choosing one at a time or choosing 3 random items from the list at the same time
>>
>>55313849 (Me)
also it's relevant for us programmers that have youtube and twitter accounts and run servers etc that need to be secure
>>
>>55313810
maybe if you made an effort to present it as a programming subject. there might be a bug somewhere because of some programming error, sure, but we can't say anything intelligent about it programming-wise
>>
>>55313849
Give me source on the OP webm and ill go away!
>>
>>55313849
>>55313845 is an objectively higher quality post than >>55313543, >>55313645, >>55313810, and >>55313849

Do the Human race a favor and select yourself out of the gene pool.
>>
>>55313900
kys literal faggot manchild weeb
>>
>>55313909
Where in my post did I imply I was a weeb?
>>
>>55313860
why don't you just take three items at random from the list? [a, b, c] = [list[rand()] for x in range(3)]
>>
>>55313918
>literally retarded
ok kid
>>
File: 84729482.png (13 KB, 398x375) Image search: [Google]
84729482.png
13 KB, 398x375
SOURCE SOURCE SOURCE.
Thread replies: 255
Thread images: 22

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

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.