[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: 26
File: 1449091772190.jpg (376 KB, 2500x1000) Image search: [Google]
1449091772190.jpg
376 KB, 2500x1000
Old thread - >>51738982
>>
first for anime
>>
Does anyone have that image macro of /g/'s programming 'challenges' ?
>>
>>51741451
>>51742000
It is in the old thread, dumbass.
>>
Anyone want to work on a project with me? I need someone to keep me motivated and on track. I love the project but have a really short attention span for projects.
I only have about 2k sloc in it so far.
>>
>>51742365
>>
File: 1426-061215.png (851 KB, 4000x2560) Image search: [Google]
1426-061215.png
851 KB, 4000x2560
Still working on this keygen...
>>
hi fags
>>
>>51742852
How's it going? What do you plan on using it for?
>>
>>51742071
fourth day

func solveFourthDay() -> Int {
let seed = "iwrupvqb"

for i in 1..<10_000_000 {
let input = seed + String(i)
var res = [UInt8](count: 16, repeatedValue: 0)

CC_MD5(input, UInt32(input.characters.count), &res)

if res[0...1] == [0, 0] && res[2] < 55 {
return i
}
}

return -1
}
>>
File: 1448700699447.jpg (121 KB, 900x866) Image search: [Google]
1448700699447.jpg
121 KB, 900x866
>I like to program in the hard way, losing time and productivity crawling for bugs and segmentation faults just to feel superior

Non-IDE coders will defend this
>>
>>51742921
>CC_MD5
slow clap
>>
Java
>>
>>51742473
anyone?
>>
>>51742473
what project is it
>>
>>51742473

What's the language and what's the project?
>>
>>51742959
more?
>>
File: 1449342381569.jpg (51 KB, 1280x720) Image search: [Google]
1449342381569.jpg
51 KB, 1280x720
>>51742968
What? Was I supposed to implement my own md5 function
>>
File: at least you tried.jpg (56 KB, 600x391) Image search: [Google]
at least you tried.jpg
56 KB, 600x391
How come the output is "song_"? The value of "val" is 1, so it should be "song_1". My code is:
ss.str("song_"); // ss is a stringstream i created earlier. i'm setting it equal to "song_"
ss << val; // val = 1, so it should append "1" to the stringstream
cout << ss.str() << endl; // this should write "song_1" but it writes "song_"
>>
stupid people itt
>>
>>51742959
>use Haskell without IDE
>no bugs anyways
>>
>>51742917
Just want to crack the algorithm desu.
>>
>>51742990
>>51742990
A hobby OS implemented in C and ASM. It uses bash and makefiles for the build system.

Here's a picture of it's current progress.
>>
>>51743019
No. But you are encouraged to post more loli.
>>
Why did t.b.h get replaed with desu

desu
desu?
DESU
>>
>>51743097
post source
>>
>>51743097
The name is nice, but before you continue you should really make a better logo.
>>
>>51743097
>>51742990
>>51742994

I plan on writing the keyboard handler next, then comes user space, a shell, and finally writing a fs
>>
>>51743111
>shinobu
>loli
pick one
>>
>>51743131
Not doing the logo shit.

Source is available at
http://neetco.de/zenoscave/bamfos

Caution: I ran cloc and there's like 50 lines of comments out of the ~2000 SLOC
>>
>>51743157
also the readme is out of date.
>>
http://ideone.com/voI9Bn
>>
>>51743157

I should probably start reading up on the osdev shit. Mite b phun.
>>
>>51743282
If you'd like to help I could always find documentation to be written. I have a few files that use the commenting style I prefer. I am open to suggestions as far as in-code docs go.
>>
File: 1430529951791.jpg (38 KB, 400x388) Image search: [Google]
1430529951791.jpg
38 KB, 400x388
I will never understand OpenGL transformations.
>>
>>51743328
they're in reverse

glTranslate
glRotate

rotate then translate
>>
>>51743328
What's wrong young one

I can try to help
>>
>>51743348
I'm trying to modify the graphics in a game I play, but i can't figure out how to do anything in the guy's setup aside from simple VBOs.
>>
>>51743311

I meant that I wanted to start on my own sort of project in that vein. Get a little shit OS hacked together and all that.

Any good sources besides the OSDEV wiki?
>>
>>51743097
Seems really cool. Unfortunately I know next to nothing about OS dev, would have loved to help.
>>
>>51741895
still working on http://www.nask.co
please report suggestions, bugs and features!
I noticed that people distrust random links, so I have to say: this website does NOT use flash, NOR it does require javascript to use it. it only uses JS for the advanced features. these features make it much easier to use, though.

some examples:
http://www.nask.co/see/aLL8VC9lSE
http://www.nask.co/see/8Is9gmuwnx
http://www.nask.co/hear/BO60IWpmZq
>>
>>51743439
sure there are! check out:
http://www.jamesmolloy.co.uk/tutorial_html/index.html (also read osdev's thing on molloy's tutorial and why it should be used with caution)

http://www.osdever.net/bkerndev/Docs/intro.htm

and just look at other's source on github. There's a few good ones.
>>
whats the best programming language and why is it c#
>>
they change answers for each player
>>51718172
>>
>>51743497

Thank you, based anon.
>>
>>51743550
Definitely give Klange/Toaruos and chenyukang/Panda a look on github.
>>
>procedural
Ha! That's so 1940!
>functional
What is this, the 60's?
>logic
>he fell fro the logic meme!
The future is here and now, with probabilistic programming languages!
If you're not using church or picture right now, get ready for that meteor to extinguish you, dinosaurs!
>>
>>51743574
panda is a huge part of my format for the loading info.
>>
>>51743586
transcendent programming when
>>
Have any of you looked at the chromium/webkit source code? Its like staring into a maddening abyss of darkness
>>
>>51743046
char* a = "world";
char* b = "hello";
std::stringstream ss;

ss << b << a;
std::cout << ss.str() << "\n";
return 0;
>>
>>51743824
Google code is usually like that.
>>
>>51742959
To me, IDEs are a waste of time. Compiling and linking is so much simpler and faster CLI
>>
>>51743824
google code is mostly shit. google developers are so fucking overrated
>>
>>51744065
Depends on language tbqh. Java/C# really can't be done without IDEs for instance.
>>
File: VendingMachine.png (31 KB, 589x248) Image search: [Google]
VendingMachine.png
31 KB, 589x248
/dpt/ I'm studying Object Oriented Java and I came across this exercise, the first part told me to write two classes that need to be integrated together, which I did here's the two of them:

http://pastebin.com/XKGQnwKE

http://pastebin.com/ey5Uc6xE

Then the second part of the exercise is the picture. I'm really having trouble writing the classes to actually implement the two current classes, anyone know how to approach and execute this? I'm not sure if I need classes with whole mutator and accessor classes or what, I tried it and it never worked.
>>
>>51743366
Learn trigonometry anon. I was where you are, believe me it helps.
>>
>>51743586
It's not just a meme either. Did you know that xbl matchmaking uses a TrueSkill implementation written in Infer.NET, which is a pretty good factor-graph-based probabilistic programming language? It's true! These languages are already used in industry. What are you waiting for?
>>
File: 1433698243654.png (29 KB, 613x556) Image search: [Google]
1433698243654.png
29 KB, 613x556
If I have a a cube positioned at (0, 0, 0) can I replicate this cube anywhere and multiple time in my virtual world just by drawing it with transformations added onto it in OpenGL?
>>
>>51744065
IDEs boost productivity in java like you wouldn't believe. real-time error checking, highlighting unused variables, renaming things. and that's just scratching the surface.
>>
>>51744169
yes
>>
Best language for getting shit done?
>>
>>51744209
C++
>>
>>51742959
>use vim + mingw(g++) to write code
>use codeblocks to compile/debug/disassemble

literally GOAT
>>
>>51744209
Java

>>51744242
kek
>>
wow wtf u guys are hackers
9gag was right about this place
>>
>>51744202
So with like 8 vertices I can make millions of cubes simply by applying a transform to it each time?

Is this how i get good performance?
>>
>>51743157
is there a way to contact you through your neetco.de account?
>>
what are some desktop software that dont exist but should? Gibe ideas so I can get rich goy.
>>
>>51743328
it's simple. like if you add 3 to 0 you get 3 which is 0 translated (moved) by 3. if you have the value 3 and multiply it by -1 you get -3 which is 3 rotated by 180 degrees. -1 is cos(180 deg) + sin(180 deg). you can rotate by any number of degrees like this. if you have -3 and multiply by 2 you get -6 which is -3 scaled by 2 (twice as "large").

https://www.youtube.com/watch?v=IrggOvOSZr4
>>
>>51744268
Sure. You can even fill up a buffer with a million matrices and draw a million different cubes in one draw call.
>>
>>51744257
>java
>getting Shit done
yes java will indeed create shit that you can call done
>>
>>51744277
nm, I found it
>>
>>51744299
>>51744316
Does this mean I should just render all my objects once at like the a base coordinator of (0,0,0) and then use transform/rotate to put them into the world where i need them?
>>
>>51744268
depending on which version you're using you could use glDrawArraysInstanced to draw many objects in one call. i don't think it's optimal for performance to upload a uniform each time before you draw each cube so you should use like a list or something with a set of transformations for each cube, not sure how that works.
>>
>>51744334
Can you please just follow a tutorial or read a book instead of spamming your questions here?

But sort of. Don't think of it as rendering it and then moving it, you're rendering the same mesh many times with different transformations.
>>
>>51744334
yes each model should be at (0,0,0) and then you transform it in your vertex shader
>>
File: 1437428054522.jpg (3 KB, 98x95) Image search: [Google]
1437428054522.jpg
3 KB, 98x95
>>51744358
>>
>>51744378
That's what they're for. You're not even talking about programming at this point, you're just asking extremely basic questions about computer graphics theory.
>>
>>51744299
>Trying to explain trig functions without mentioning trig functions
SohCahToa
Sin is the y axis of a right triangle divided by the longest side of a triangle (the opposite/hypotenuse)
Cos is the x axis of a right triangle dividied by the hypotenuse (adjacent/hypotenuse)
Tan is fucking irrelevant to this, just ignore it.

On an xy plain every single point forms a right triangle with the origin (0,0) and the xy plains.

All angles from 0 degrees start from the right of the plain and go around clock wise.

If you put any point on an xy plain that will be a direction. Do Pythagoras theorem to find the length of the hypotenuse then do sin and cos to it to find its direction. Then multiply this by whatever value you have to move it.

Open your calculator and type 45 cos and 45 sin. That is 45 degrees from 0,0 assuming you have it set to degrees, radians can fuck off. That is literally a direction. Do math with it.
>>
Anybody have a decent algorithm to remove all elements from a vector (or in this case string, but it's not like it will be any different in my case)

I am trying to do it using conditional statements and loops. I know most languages (in my case, MATLAB) have functionality that allows you to do it other ways, but for this particular little bit I can't use something like that. I just haven't been able to figure out the best way to do it.

How I was setting up the problem was this
function StringOut = remvow(StringIn)
StringIn= %some given string
vow = %An array containing the vowels/values to remove
num = %number of elements in the string

for i = 1:num - 1 %loop that attempts to work backwards from the given string
for j = 1:10 %check if the value is equal to one of the values needed to remove for each value
if strcmp(StringIn(num - i),vow{j}); %if the (num - i)th character is equal to the current vowel
StringIn(num - i +1) = []; %remove that value
end
end
end
StringOut = StringIn; %output the string



This handles everything EXCEPT if the end value needs to be removed (or in this case, where the loop begins)

However, since the dimensions of it are constantly changing, I haven't been able to figure out a way to remove the last component. Everything I try spits out an error because of the dimensions.

Any advice?
>>
>>51744107
post in online ide
>>
>>51744433
Counter clockwise, fuck.
>>
>>51744446
Go from back-to-front instead of front-to-back.
>>
>>51744433
anyone who finished high school should know this lmfao

i did mention
>-1 is cos(180 deg) + sin(180 deg). you can rotate by any number of degrees like this.
which is all he needs at this stage. one thing a ta time.

>set to degrees, radians can fuck off
no you fuck off
>>
>>51744488
also watch this if you don't know trigonometry

https://www.youtube.com/watch?v=ovLbCvq7FNA
>>
>>51744450
What do you mean? ideone?
>>
>>51744488
Anon, I don't know how to tell you this but the curriculum has changed a massive amount in a decade in basically every first world country. When I went to school we basically only covered Pythagoras theorem.
>>
>>51744107
1. i think switch statements support strings as of 1.7
It's a little cleaner than if else if if else if if else if...

2. Also create a function for each option so you don't have a 100 line method.

3. Use One-True-Brace style. It's better.
>>
>>51744507
>16 minutes
3 minutes on mathisfun.
>>
>>51744514
i finished high school last year and i even did matrix transformations in my last math course. that course was optional though. it depends on how shitty your country is and what options you have, like if you go for construction and maintenance you will not learn more than to like the pythagorean theorem
>>
>>51744584
I left high school literally 10 years ago.
>>
>>51744536
it explains it much better and you can speed it up on youtube. gtfo trying to learn opengl if you have ADD
>>
>>51744588
oh i thought you meant it had gone even more to shit recently
>>
File: eh.png (28 KB, 196x181) Image search: [Google]
eh.png
28 KB, 196x181
>>51744597
>Learning the same amount of material in less time is ADD
>>
>>51744614
No no, quite the opposite. I can't speak for the future as long as things like Nigger Core exist though.
>>
>>51744616
in school you spend months on this shit. there are many things you will not learn in 3 minutes on mathisfun
>>
>>51744456
Solved it!

That's the strategy I was using, but I think I just needed somebody to remind me that I was doing it right. I wrote it down on paper, and I figured out what I was doing.

I wasn't properly thinking about where it lied at the begging and end of the loop. I did some thinking through it, realized that my only problem was realizing where it started and ended gave me my errors, and fixed it.

Appreciate it!
>>
File: lambda-star-red-flag.png (23 KB, 1920x1080) Image search: [Google]
lambda-star-red-flag.png
23 KB, 1920x1080
>>51741895
A powerful algorithmic language called Valutron, based on the Scheme R[6]RS and ISO Lisp (for the iLOS, ISO Lisp Object System) reports. Implemented in Objective-C with the help of Lex and YaCC. Uses an advanced trace-and-sweep garbage collector.

Features V-expressions, which provide an option to write Valutron code in an algebraic, Algol-like style, rather than pure Sexpressions
>>
File: 1434839491480.gif (699 KB, 248x193) Image search: [Google]
1434839491480.gif
699 KB, 248x193
>>51744748
I'm getting pretty tired of your shit anon.
>>
>>51744748
But have you actually worked on it at all?
>>
tfw vim has a :Sex command
>>
>>51744642
in school they have to teach it slow enough that the dumbest 14 year old in the room can keep up. and you don't even need to know that much trig for anything in CS
>>
>>51744795
Yes. http://github.com/Valutron/Valutron
>>
Just read this: https://swtch.com/~rsc/regexp/regexp1.html

What the fuck? How can Python/Perl/etc have such slow fucking regular expressions? I thought they were supposed to be optimized for text?

Fuck scripting languages. As if I needed more evidence that they're only good for meme-tier programmers and web devs.
>>
>>51744983
This is beside the point but I don't know why any sane person would use a regex in the first place.
>>
>>51744830
yes school teaches at a snail pace but it's pretty ridiculous to think that you can get a good grasp on the subject in 3 minutes. you should at least be willing to spend more time than that on such an important topic. but basically to understand matrix transformations so that you can use opengl you pretty much just need to know
>it's simple. like if you add 3 to 0 you get 3 which is 0 translated (moved) by 3. if you have the value 3 and multiply it by -1 you get -3 which is 3 rotated by 180 degrees. -1 is cos(180 deg) + sin(180 deg). you can rotate by any number of degrees like this. if you have -3 and multiply by 2 you get -6 which is -3 scaled by 2 (twice as "large").
and what is shown in the video.
>>
>>51745038
Not him. Honestly you don't need to know anything about linear algebra to use matrices in simple rendering. You just need to understand that matrix multiplication isn't associative, and that row-major/column-major matters.
>>
>>51745030
>want to look for a regular substring within a fuckton of text
What tool would you suggest for this?
>>
i dont understand why insertion in data structures isnt always o(1)? you're just calling 1 single method, so why isn't it always the same....
>>
File: 1412888142440.jpg (90 KB, 930x1316) Image search: [Google]
1412888142440.jpg
90 KB, 930x1316
>>51744096
java can be done without an IDE quite trivially
>>
File: regex.png (18 KB, 400x112) Image search: [Google]
regex.png
18 KB, 400x112
>>51745163
A regular language parser that isn't programmed by writing a string of gobbledegook?
>>
>>51745163
vim
>>
File: VSdWFKg.jpg (281 KB, 1242x2208) Image search: [Google]
VSdWFKg.jpg
281 KB, 1242x2208
I want to be a programmer to work from the home, I've always really liked computers too.

I've been learning how to write HTML but I had to stop for a few months and I've forgot everything other than the very, very basics.

Now my meds have balanced out I want to learn again.

But now I'm wondering what to do, should I relearn HTML and them go onto learning programming or should I just jump into learning to write in a proper programming language?

Would HTML even help me in learning to programme, because that's why I was going it.

What's the best language to learn as a first too?

And would anyone even employ a housebound man to program for them?
>>
>>51745191
Let me guess, you've never learned a real language and think every language is like Python?
>>
>>51745191
>you're just calling 1 single method,
What happens inside the method matters. The path ahead is long for you.
>>
>>51745235
>that pic
lmao
>>
>>51745235
Black father left her with the kid ;-)
>>
>>51745228
Yes, grep is a good implementation of regular expressions.
>>
>>51745191
OK anon.
I give you a pencil, paper, and an eraser and tell you to write down the following list of numbers:
{3, 5, 8, 10, 15}

Now I say, OK please insert "4" in between the 3 and the 5. Chances are you didn't leave any room between the 3 and the 5, so you need to erase the 5 and write the 4 there instead. Except now you don't have room for the 5, so you need to erase the 8 and write the 5 there... and so on. So inserting a number into your handwritten array is an O(n) operation in the worst case.
>>
>>51745163
iterate through the text
>>
>>51745197
retard
>>
Just finished this challenge

r8 code

https://www.codeeval.com/open_challenges/

http://pastebin.com/kRQ0L33T
>>
>>51745399
>literally first day CS 101
just let him be, he's a pajeet
some people are just not cut out for this
>>
How long until "lowercase Java Internet Defense Force" is an official meme?
>>
>>51745426
Whoops, wrong link
https://www.codeeval.com/open_challenges/2/
>>
>>51745235
>pic
kek

but goddamn they aged a lot in 3 years
>>
>>51745407
Is this bait? What do you think regular expressions do?
>>
>>51745235
just learn java

https://docs.oracle.com/javase/tutorial/

knowing HTML won't help much if at all

there are programming jobs where you work from home. you could look at http://careers.stackoverflow.com/ once you've gotten more experienced.
>>
>implementing a monad transformer stack in haskell
>everything works perfectly once it type checks
how is this language so based?
>>
>>51745485
write a custom function. it's not remotely difficult and the performance increase will be worth it if it's
>a fuckton of text
>>
>>51745503
You haven't even scratched the surface of compile-time verification.
http://ncatlab.org/nlab/show/dependent+linear+type+theory
>>
>>51745516
Grep is highly optimized. If you aren't caching text, it's literally bottlenecked by your hard drive read speed (and it only reads as many bytes as it needs to). You couldn't write a better grep if you tried.
>>
I know I can do this in c++
char myChar = 65;
cout << myChar;

and that will output 'A' (right?)
but if I give it a number that's way too large
char myChar = 1000000;
cout << myChar;

will that work? Is there a limit to how high it can go?
Can I also use
int myNum = (int)myChar;

to essentially store an integer within a char?

I'd check myself, but I don't have any way to run this at the moment
>>
>>51745608
Are you retarded? Do you know what a char is? Hint: it's not a character. It's a data type, which means it has a specified length. It's always smaller than an int.
>>
>>51745608
you get @
>>
>>51745608
char is one byte. Get it together anon kun.
>>
>>51744983
>it is possible to write so-called “pathological” regular expressions that Perl matches very very slowly.
In practice it's never an issue or else the languages would have adopted a better approach. No one really cares to search for z.sin3ks((€sjJJJJnPnZZ0987sd so regex is still fast.
>>
H-hello guys

I'm new to programming, I'm using Python because I'm still trying to learn the basics of coding. What would be the best way to make a basic GUI-based dice roller? I want to learn how to design GUIs. I was reading about Tkinter but I can't seem to find any tutorial for the latest version of Python 3.

I know I'm probably coming to a place full of people that code really cool shit with a really basic question and probably a not-the-best language, but help would be appreciated.
>>
>>51745694
>H-hello guys
Hey there big boy *smooches you on the cheek*
>>
>>51743311
My C is shit, but if you need an agile PM I'm your man...
>>
>>51745694
>Python
Lel. Please learn a real languge or fuck off to >>>/wdg/
>>
File: Interviewer.jpg (17 KB, 350x244) Image search: [Google]
Interviewer.jpg
17 KB, 350x244
>i checked out your github and it seems you like to use xor bitwise hacks when a temporary variable would work just fine
>care to explain why?
>>
>>51745731
Define "A real language"
>>
>>51745737
Uh objection you're a shit, fuck off, fuck you. Go on keep on judging my code at the surface level, you'll never understand the art and engineering that forms the undercurrent to all code I create. Don't look me when I'm talking to you!
>>
>>51745694
You can use tkinter because it's simple enough, but remember Tkinter is complete shit. Use Qt if you can. Although maybe for a first project Tkinter is better.
Tkinter is compatible with python 3 so any python 2 tutorial for it will be fine.
>>
>>51744983
>Python/Perl/etc
>how can they be slow
>>
>>51745757
{C, C++, D, APL}
>>
>>51745757
If your language runs like shit and abstracts the hardware away entirely, then it's not a real language, sorry. Memory is an important concept to grasp and if you don't even have the option of manually allocating and managing your memory, then your language is just a toy.
>>
Would learning C++ and python be the way to go if I were looking for a programing job?
>>
>>51745786
>D
Fuck off.
>>
>>51745694
python is garbage kill yourself
>>
>>51745816
Fuck you! Good enough for Andrei, good enough for /dpt/!
>>
>>51745830
Enjoy you're botnet.
>>
>>51745796
no, we have too many pogrammers, fuck off
>>
>>51745796
C++ and java
>>
>>51745845
shut up
>>
>>51745796
Depends. Java is the way to go if you only care about money and want to get hired as quickly as possible. Javascript or ruby if you you're not a fan of corporate like software. C++ and python if you want to make something useful
>>
>>51745886
>python
>useful
>>
As part of a C++ assignment, I'm creating a kind of simple encryption for a text file with semicolons as delimiters. My problem is that when I encode the raw text, there's a chance some of the characters are changed into semicolons and saved to the file, throwing everything off when I go read the file and it isn't in the expected format. I can check to see if a character would become a semicolon so I can do something with it instead, but I don't know what because I need to be able to decode it to its original character too. Anyone have any suggestions?
>>
>>51744584
>matrices
>not covering them at age 14/15

You went to school in the U.S. didn't you
>>
>>51745927
Instead of using delimiters between "chunks", prefix each "chunk" with its size.

So you just keep reading like 4 bytes (int) for the size, then <size> bytes, then another size, then a chunk, until the end.
>>
>>51745927
In the encoding function, don't let characters be encoded as semicolons maybe? Why are you making this overly complicated?
>>
File: 1443317393088.jpg (601 KB, 2048x1363) Image search: [Google]
1443317393088.jpg
601 KB, 2048x1363
>>51745886
>Javascript or ruby if you you're not a fan of corporate like software.
>>
>>51745737

I don't have anything on github :-D
>>
>>51745993
Get out.
>>
>>51745964
Unfortunately the semicolon delimiters are part of the assignment so I'm stuck with them. I was thinking one option, if I had to, was to keep an array to keep track of the original characters and positions, but I'm hoping there's a more elegant way than that

>>51745981
If I just skip over them, they're still decoded normally and they'll end up being the wrong character
>>
>>51746026
Either change the encryption method so that semicolons are not in the range of output or do as you first suggested.
Better option is to change encryption
>>
>>51745795
Except that's completely irrelevant for the vast majority of programming going on today. Meanwhile, in the real world, people are embracing the new revolutionary technologies that continue to sweep over the market like SaaS/PaaS. Enjoy being a desktop pleb.
>>
>>51745886
>JavaScript
>not corporate

So like, literally anything web. IE everything corporate.
>>
>>51746078
>duh cloud doesn't have memory
>>
>>51746026
>If I just skip over them, they're still decoded normally and they'll end up being the wrong character
No, I mean, adjust the function so it can't encode something as a semicolon. When it tries to, it encodes to a special value. Then the decoder has a special case where it'll detect this special value and unencode it to the proper character.

I'm guessing your encryption scheme is retarded, so maybe fix that?
>>
>>51746026
Well, if you have to treat a semicolon as a special character, you'll need to make sure that your encoding will never produce a semicolon, won't you.
>>
>>51746025
there is no point in using sjwhub except if you're trying to advertise yourself for a code monkey job
>>
>>51746132
t. unemployed neet
>>
>>51746132
>programming interview
>"So I'm looking at your pull requests... it says here, you replaced every instance of "Master" with "Whitey" and "Slave" with "Nigger", is that right?
>>
>>51746101
I don't know how much experience you have with cloud development, but frankly no one is sitting around trying so save X physical performance here, when your performance bottleneck is obviously network speeds. You can have code that runs server side as fast as possible - doesn't making a fucking difference to the performer the client sees (ie the performance that actually matters).

Implying that even if you had the a perfectly efficient network connection between client and server, and perfectly efficient code, that you still wouldn't be bottlenecked by the client node.

L2cloud desktop shill, how are your hello world's coming along?
>>
>>51746146
there are better options available than github
>>
>>51746192
there's nothing wrong with github so long as you don't use the social media functions
>>
Ugh, I've been falling for the SICP meme. This text is really difficult for me, and I can't tell if I am just completely retarded or if it is really just that difficult.

I'm used to using stuff like C++, Python, and can do fairily well telling what most languages are doing, but when I look at lines of Scheme the format is so condensed that it makes it insanely hard for me to parse out what the algorithms are doing.

When everything is broken up in functional progamming languages it can be really difficult for me to step back and see the forest. Like I almost have to get out a sheet of paper and do an entire flowchart to untangle what some of these stupid examples are doing.

Also I am just now getting to lambdas around page 50ish, and having a horrible time understanding them at all!
>>
>>51746232
SICP is a dumb meme. Grab K&R if you want to write programs that are actually useful.
>>
>>51746232
Lisp is very powerful but readability is one of the reasons it never took off.
SICP is nothing special just pick up a newer book.
>>
File: 1430853197680.png (331 KB, 474x432) Image search: [Google]
1430853197680.png
331 KB, 474x432
>>51746232
>muh functions
>muh lambdas
>>
>>51745796

C# for Microsoft

Java, C++, Python for Google, Amazon

Javascript for web dev

C for microcontroller stuff
>>
>>51746454
yeah functions are dumb lmao
>>
>>51746710

You mean classes right?
>>
Is WPF the framework you want to use these days to develop Windows desktop GUIs?
>>
File: indians.jpg (35 KB, 460x276) Image search: [Google]
indians.jpg
35 KB, 460x276
hello friends who is java programmer here
>>
>>51746768
use SDL
>>
Closures are equivalent in expressive power to objects but they are superior in every way
>>
>>51746710
functional programming is pretty dumb. i mean you can have functions in your program but building your entire program around stateless functions... lolwut
>>
>>51746768
Yes

>>51746786
No
>>
>>51746796
>Purity => stateless
No
>>
>>51746768
What's your requirements? I've noticed WPF is more heavily used for internal-only tooling and data heavy programs.

Both WPF and Winforms are maintained and will be for effectively ever, so it doesn't really matter desu.
>>
File: 1425429412322.gif (141 KB, 287x344) Image search: [Google]
1425429412322.gif
141 KB, 287x344
>>51746817
>muh purity
>>
Alright lads I have a question about how to make deep copies of linkedlists or how I should go about this problem. I'm intermediate-ish and have struggled on this for about a day.

I have a linkedlist of 52 nodes, each node representing a card with the list representing a deck. The program draws a card at random and it is removed from the linkedlist to simulate a card actually being pulled out of the deck. The problem is that after a round is over, I want to restore the list back to 52 nodes, ie shuffling all the cards back into the deck. I can't do it by deleting all nodes and re-adding them because then I'd look like a twat, plus the list is made via file reading (as per assignment requirements).

Is there a way to make a deep copy "master list" of the full deck and then assigning the deck to this master deck at the end of each round? Or is there a smarter way of solving this problem which doesn't involve removing nodes from the deck? Any guidance would be appreciated, I've struggled on this for a long time.
>>
What is the god-tier order of learning programming languages? I want to focus on websites I don't care about software or operating systems.
>>
>>51746837
I'm saying that you can have purity without being stateless

There's a lot wrong with stateless, but nothing wrong with purity
>>
File: ffwindow02.png (38 KB, 672x509) Image search: [Google]
ffwindow02.png
38 KB, 672x509
>>51746768
I used WPF to make a window once. It was awful.
>>
>>51746580
Microsoft makes even heavier use of C++ than Google or Amazon senpai.
>>
>>51746247
>>51746277
>>51746454

I really am just trying to get out of my beginner/intermediary stage of skill level -I took two or three classes that taught me some basic algorithms, and I know some of the basic syntax of a couple popular languages. Above codeacademy/beginner tier but not yet ready for advanced stuff, having a hard time finding stuff that isn't so basic its a snorefest, but not so difficult that I have to take immense amounts of time to understand what is going on.

Goal: Get to a stage where I know some basic comp-sci topics and can use them competently, data structures, algorithm design, compliers, ect. Not just beginner soft-dev tier stuff.

SICP seems to have a bunch of the sorts of advanced topics I want to learn about, but the code examples and exercises are annoying the hell out of me.

K&R looks good, thanks, but if anyone else has any suggestions please let me know!
>>
File: 9k=.jpg (6 KB, 275x183) Image search: [Google]
9k=.jpg
6 KB, 275x183
Hello guys, I just finished coding a website in assembly, Lisp and Haskell in the back-end. Ask me anything
>>
>>51746865
z80 assembly or 6502?
>>
>>51746796
True, real programs require some state even functional programmers agree you cant have 100% pure programs.

but you tipped a fedora at the idea of functions themselves which means you probably spend your life in a garbage language that requires you to wrap every function in an object (functors). You're not gonna make it brah.

>Sometimes, the elegant implementation is just a function. Not a method. Not a class. Not a framework. Just a function.

>"i mean you can have functions"
oh great, thanks for allowing me to have functions mr god of programming
>>
>>51746848
PHP Java

I would've recommended Python in-between them, but it doesn't look to have a healthy future.
>>
>>51746848
>I want to focus on websites
>I don't care about software or operating systems
>learning programming languages
>>>/g/wdg
>>
>>51746890
>True, real programs require some state even functional programmers agree you cant have 100% pure programs.
See >>51746817, >>51746849
>>
>>51746848
pls respond :(
>>
>>51746846
you should use a linked list when all you are going to do is pop and push elements onto a stack. (rarely)
what you want is a more general array where you can do all that shit without worrying about nodes.
>>
>>51746865
Are you rich yet?
>>
>>51746907
Back end you knob
>>
>>51746891
it must be like one guy who's been shilling PHP lately. PHP is universally agreed to be one of the worst languages of all time. don't even consider learning PHP
>>
>>51746865
why did you use all 3 when all you needed was lisp?
>>
>>51746931
>I don't care about software
>>>/g/wdg is for back end too you dicktard
>>
>>51746931
>Single shot AT4
>"Don't ask for rockets, I'm all out"
kek probably a trainer.
>>
>>51746941
It's also used by every major CMS.
>>
>>51746972
gay
>>
>>51746986
There's nothing more gay than the mad dosh you can earn through Drupal and Wordpress development senpai.
>>
>>51746946

Because I'm a real programmer
>>
>>51746941
yeah, you should use hipster.js instead! the newest, most elegant and fresh and truly unique POC-friendly latinx library there is!
>>
>>51747013
kill yourself faggot
>>
>>51747023
FUCK OFF FAGGOT THIS IS THE PROGRAMMING THREAD NOT WEB FAG THREAD FUCK OFF TO >>>/G/WDG
>>
>>51747035
could it be? a real live idiot? in the wild?
>>
Rate my doubly-linked adjacency list graph data structure, /dpt/!
 #include <stdio.h>
#include <stdlib.h>
typedef struct node {
int dst;
struct node* prv;
struct node* nxt;
} node;
typedef struct graph {
int v;
node** ptr;
} graph;
graph* new_graph(int v) {
graph* g = malloc(sizeof(struct graph));
g->ptr = malloc(sizeof(int*) * v);
for(int i = 0; i < v; i ++) g->ptr[i] = NULL;
g->v = v;
return g;
}
node* new_node(int dst) {
node* n = malloc(sizeof(struct node));
n->dst = dst;
n->nxt = NULL;
n->prv = NULL;
return n;
}
void add_edge(graph* g, int src, int dst) {
node* n = new_node(dst);
if(g->ptr[src]) {
g->ptr[src]->prv = n;
n->nxt = g->ptr[src];
}
g->ptr[src] = n;
n = new_node(src);
if(g->ptr[dst]) {
g->ptr[dst]->prv = n;
n->nxt = g->ptr[dst];
}
g->ptr[dst] = n;
}
void remove_edge(graph* g, int src, int dst) {
node* p = g->ptr[src];
node* q;
while(p) {
if(p->dst == dst) {
if(p->prv) {
q = p->prv;
q->nxt = p->nxt;
free(p);
p = NULL;
break;
} else if(p->nxt) {
g->ptr[src] = p->nxt;
g->ptr[src]->prv = NULL;
free(p);
p = NULL;
break;
} else {
g->ptr[src] = NULL;
free(p);
p = NULL;
break;
}
}
p = p->nxt;
}
p = g->ptr[dst];

}
void print_graph(graph* g) {
putchar('\n');
for(int i = 0; i < g->v; i++) {
node* p = g->ptr[i];
if(p) printf("\nedges of %d:", i);
while(p) {
printf(" -> %d", p->dst);
p = p->nxt;
}
}
}
int main(void) {
graph* g = new_graph(3);
add_edge(g, 0, 1);
add_edge(g, 1, 2);
print_graph(g);
remove_edge(g, 1, 2);
print_graph(g);
}
>>
>>51747060
>using PHP or javascript for a BACK END
K I L L Y O U R S E L F
I I
L ᠎ ᠎ ᠎ ᠎ L
L ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ L
Y ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ Y
O ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ O
U ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ U
R ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ R
S ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ S
E ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ E
L ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ L
F ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ ᠎ F
>>
>>51747079
gross
>>
File: 1432870670196.jpg (59 KB, 461x421) Image search: [Google]
1432870670196.jpg
59 KB, 461x421
>>51747079
>
node** ptr;
>>
>>51746855

It seems like this is a problem that just keeps coming up again and again that everything always seems like it was written with extreme beginners in mind, or people who are already professionals. There is definitely a lack of good material written for people who are stuck inbetween.
>>
>>51747100
>he's not even a 2-star programmer
>>
>>51747086
re-read the conversation and try to understand where you went off the rails here

>>51747079
is it too late to get your money back?
>>
>>51746768
WPF is just awful
Either use WinForms (with .NET languages) or QT (with C++)
>>
>>51747123
What's wrong with the code? I'm in my 3rd year, just decided to post some homework on /g/ that I'm proud of.
>>
>>51747123
kill yourself
>>
What's the most amount of * you used for a pointer?
>>
>>51747181
your mom
>>
>>51747181
3 dimensional malloc'd array had me typing 3 layers of array indirection.

You shouldn't need more than 3, ever.
>>
>>51747181
For my real time rendering course, the professor's example used three and four levels of indirection. He's really not quite good when it comes to elegance.
>>
>>51747151
missing newlines (if its 4chan's fault nvm), lowercase class names, using underscores instead of camelcase for method names, unnecessarily brief var/member names (dst/prv/nxt/v, etc), "i ++" instead of i++, etc. its just fuckin ugly tbqhwyf.
>>
>>51747260
>he can't into 4d arrays
Kek, I knew /dpt/ was pleb.
>>
>>51747275
>lowercase class names
they're structs, it's C
>underscores instead of camelcase
it's C, snake case is the usual
>method names
functions, it's C
everything else is right though
>>
>>51742921
fifth day

func solveFifthDay() -> Int {
let input = getInput().componentsSeparatedByString("\n")

return input.filter {string in
if string["[aeiou]"].matches().count < 3 {
return false
}

if string["(.)\\1{1,}"].groups()?.count < 0 {
return false
}

if string["ab|cd|pq|xy"].matches().count > 0 {
return false
}

return true
}.count
}
>>
Hey guys, I'm trying to make C feel more like a modern programming language.
Can someone help me make this look nicer?
typedef struct PString {
char *chars;
int (*length)(struct PString *);
void (*grow)(struct PString *, int);
void (*destroy)(struct PString *);
} PString;


Right now, if I want to use any of the member function pointers, I have to feed it it's own pointer name like
str->destroy(str);

How can I make it refer to itself?
>>
Can anyone give me a direction to go for a project?

I have a automated bot that I want to strip of the automation and then just have a marker denote where to click.

> C++
> Bot for a java puzzle game
>>
>>51747337
Any reason why instead of using a higher-level language?
>>
>>51747337
this is C++.
>>
>>51747345
I don't need all the features of a higher level language, but member functions are comfy and i want those in C.
>>
>>51747337
Fuck off, idiot. We already told you not to do this.

If you want to write C++, use C++.
>>
>>51747364
>>51747337
do you have a good reason to be using function pointers instead of outside functions that operate on the struct?
Going for inheritance or something?
Just curious
>>
>>51747364
>I don't need all the features of a higher level language, but member functions are comfy and i want those in C.
Don't try to make C into something it's not. Just use a higher-level language where structs can have methods and the like.
>>
>>51747364
Fair, I was just curious
Good luck comrade
>>
>>51747395
>outside functions that operate on the struct
These are messy.
See, I have a PString constructor that returns an malloc'd struct with all the member function pointers filled in.
I could just use those functions directly, but then what's the point of having function pointers at all?
>>
>>51747337
PString s;
PStringInit(&s);
//...
int len = s.length(&s);

Sorry but it's retarded.

Try this: https://www.cs.rit.edu/~ats/books/ooc.pdf
>>
Is anyone doing the Advent of Code? If you are could you share with me your solution of the day 2 problem? I'd really like to see what some people did!
>>
>>51747448
PString *s = createPString(sizeof(char) * n);
>>
>>51747459
Here's mine:
#include <stdio.h>
#include <string.h>

#define MIN(a, b) ((a < b? a : b))

int getArea(int l, int w, int h)
{
int result = (2*l*w + 2*w*h + 2*h*l);
printf("Returning %d for area\n", result);
return result;
}

int getSlack(int l, int w, int h)
{
int result = 0;

int arr[3] = {l, w, h};

if(arr[0] > arr[1])
{
int temp = arr[0];
arr[0] = arr[1];
arr[1] = temp;
}

if(arr[1] > arr[2])
{
int temp = arr[1];
arr[1] = arr[2];
arr[2] = temp;
}

printf("\t%d\t%d\t%d\n", arr[0], arr[1], arr[2]);

result = (arr[0] * arr[1]);
printf("Returning %d for slack\n", result);
return result;
}

int getRibbonLength(int l, int w, int h)
{
int arr[3] = {l, w, h};

if(arr[0] > arr[1])
{
int temp = arr[0];
arr[0] = arr[1];
arr[1] = temp;
}

if(arr[1] > arr[2])
{
int temp = arr[1];
arr[1] = arr[2];
arr[2] = temp;
}

int result = 0;

result += (2 * (arr[0] + arr[1]));
result += (arr[0] * arr[1] * arr[2]);

return result;
}

int main(void)
{
int l, w, h;
int area = 0;
int ribbon = 0;

char buffer[256] = {0};

while(gets(buffer))
{
l = atoi(strtok(buffer, "x"));
w = atoi(strtok(NULL, "x"));
h = atoi(strtok(NULL, "x"));

area += getArea(l, w, h);
area += getSlack(l, w, h);
ribbon += getRibbonLength(l, w, h);
}


printf("Area:%d\nRibbon:%d\n", area, ribbon);
}
>>
>>51747337
>>51747364
If you really want to be an utter retard and do this, then you could use a variadic macro:
#define METHOD(obj, method, ...) (obj)->method(obj, __VA_ARGS__)

Protip: you're wasting efficiency by a) using virtual methods when you don't need them and b) not simply pointing to a vtable that gets shared between every instance of a "class".
Why are you using C if you aren't going to be hypersensitive about performance?
Thread replies: 255
Thread images: 26

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.