[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
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: 39
File: timetocode.webm (2 MB, 1152x648) Image search: [Google]
timetocode.webm
2 MB, 1152x648
This is /dpt/, the best subreddit of /g/

Umaru-chan edition

In this thread:
r/programming
r/compsci
r/ReverseEngineering
r/softwaredevelopment

Filesharing and chat: https://volafile.io/r/kUFzLJ

code of conduct:
no racism
no insult
no sexual harassment
no gender discrimination

wat r u working on, anon-chan ?
>>
File: fams for life.jpg (95 KB, 732x710) Image search: [Google]
fams for life.jpg
95 KB, 732x710
>>51269776
>>51269781
i thought you were all retarded but now that i looked up the answer these posts make a lot of sense and it was correct
thanks senpaitachi

it didnt want me to print what the site was inputting into it
it just wanted me to input something as the variables and then run the program for those
>>
>>51270067
2nd for Go
>>
>>51270067
fuck you nigger faggot i'll rape you while i slap your tits you fucking cock sucking whore
>>
>>51270067
wait, the other thread didn't even have 310 posts...

sage this shit
>>
>>51270152

The other thread has 330 posts.
>>
>>51270152
previous dpt has 330 posts
>>
>>51270093
Yeah. I thought that was clear in you, that's why I omitted being explicit about it in my answer. Still, it's better that you realized it on your own.
>>
>>51270067
Umaru sucks.
>>
>>51270152
>>51270182
>>51270183
yeah, nevermind, I'm retarded
>>
File: 1353024259184.png (217 KB, 480x480) Image search: [Google]
1353024259184.png
217 KB, 480x480
>mfw python has multiple libraries for using threads, both bundled and third-party, cumulatively tens of thousands of lines of code long

>mfw python doesn't even have threads
>>
File: bingo.png (319 KB, 740x926) Image search: [Google]
bingo.png
319 KB, 740x926
One of these
>>
File: ji.webm (3 MB, 750x422) Image search: [Google]
ji.webm
3 MB, 750x422
Ask your favorite and beloved programming literate anything.

>>51270067
>wat r u working on, anon-chan ?
A general utility C library for dpt
>>
File: kek.png (380 KB, 740x926) Image search: [Google]
kek.png
380 KB, 740x926
>>51270241
I did Hard Mode: only things that I've been paid for.
>>
>>51270241
10111
11111
11111
11111
10101
>>
>>51270270
>C library for dpt
For doing fizzbuzzes?
>>
File: Untitled.png (240 KB, 740x926) Image search: [Google]
Untitled.png
240 KB, 740x926
>>51270241

with jews, you lose.
>>
>>51270292
Teach me your ways. How did you get those jobs? Did you go to college? How old are you?
>>
D
>>
>>51270335
I started my own companies and built them, I'm 19
>>
I'm writing a printf implementation using cout because my teacher said I can use c libraries

I'm also writing it in bash and I'm going to use clever preprocessor tricks to convert it to c++.

Fuck intro to c++ desu
>>
>>51270346
>I'm writing a printf implementation using cout because my teacher said I can use c libraries
Uhhh
>>
>>51270346
can't use c libraries*
>>
>>51270346
>a printf implementation using cout
Is this some independent study project?
>>
>>51270346
>Fuck intro to c++
I'm in the same boat. Worst part, my course is still on pseudocode for some inane fucking reason while I've already moved on to writing code on my own to avoid getting bored of it otherwise.
>>
File: 42315.jpg (39 KB, 300x309) Image search: [Google]
42315.jpg
39 KB, 300x309
>GUIs with java
>>
>>51270323
juice i lose
>>
>>51270407
I know that feel
>>
>>51270374
Nope. I just prefer to use printf because of how exactly I get to format everything. But she said I can't use C libraries. Because there are certain aspects of C++ that I'll need to know.

Since I can't use C, I'll just implement printf myself using cout.
>>
>>51270407
Literally the most verbose way possible to write a GUI.
>>
>>51270345
did you really? I'm having a hard time believing you
>>
>>51270407
this left me some trauma about GUIs in general
>>
31st for shilling projucer - live C++11 programming
>>
>>51270466
She's right, but that doesn't mean you should be listening to a woman
>>
Reminder that cute boys that dress like cute girls make the best programmers!
>>
Please never write anything longer than 128 lines in Perl.

Perl is good because it deprecates awk+cut+paste for basic text processing/filesystem shite. Perl is bad because it's an inconsistent, poorly designed clusterfuck that quickly turns into unmaintainable garbage for general programming.
>>
>>51270335
There's actually not that much variety. For example, I was contracted to make a mobile app that checked all of GUI, actively used, oo, DSL, non-x86 and database.

I currently do big data on Linux which checks off most of the others.

I'm 31 with a MS in CS, and I've been working for 7 years, 3 of which were as a consultant on a bunch of varied projects.
>>
>>51270599
>128

How did you come up with this magical number.
>>
>>51270407
>learn GUIs with Java
>hate every moment of it, holy fuck just aligning things to the way you want takes so many fucking containers (assuming it's even possible)
>so many times I'd finish something only for the labels to fuck up when rendering
>learn C#
>it just werks
I now refuse to make any programs that need a GUI with Java.
>>
>>51270617
2^(2^(2+2) - 1)
>>
>>51270623
I have to make a GUI in Java soon too

wish me luck
>>
>>51270652
Android or Swing?
>>
File: ss (2013-05-24 at 01.49.37).jpg (23 KB, 308x282) Image search: [Google]
ss (2013-05-24 at 01.49.37).jpg
23 KB, 308x282
>want to be hardcore neet coder
>start to read K&R because everyone said C was objectively the best language and everything else is babby shit
>get 1/4th through the book
>realized I didn't actually learn anything

What's the casual way to learn, is Python really that bad
>>
>>51270652
import finishedproduct.java;
>>
File: dpt-bingo.png (339 KB, 740x926) Image search: [Google]
dpt-bingo.png
339 KB, 740x926
>>51270241
kind of too easy, I'd guess anyone over 25 should get at least one row
>>
>>51270705
Learn Python the Hard Way
>>
>>51270705
Learn by doing.
Now go write a function that reverses a string.
>>
>>51270466
>Since I can't use C, I'll just implement printf myself using cout.
I would love to see this implementation, good god it will be a fucking mess. Please share with us when you're done.
>>
>>51270703
I'm probably going with JavaFX
Depends on what the other devs feel like too
>>
>>51270777
I'm going to create an IOActionQueue class, printf will scan over the format string and push IOActions onto the queue depending on the format directives found within the string, returning an IOActionIterator which is evaluated at the end of the call.
>>
>>51270705
>is Python really that bad
no, python is an extremely useful language
>>
>>51270920
Oh, so you're just going to rewrite printf. I thought you were going to make a C++ version that was ``typesafe'' (as far as C++ goes for this). This is less challenging but still interesting. Good luck!
>>
File: yuki.jpg (104 KB, 984x927) Image search: [Google]
yuki.jpg
104 KB, 984x927
>>
>>51270705
>is Python really that bad
It is a better Perl. For non-English speakers, the bromide here is "damning with faint praise."
>>
>>51270981
Who is this semen demon?
>>
File: konata.png (215 KB, 1024x768) Image search: [Google]
konata.png
215 KB, 1024x768
>>
>>51270981
>>51270992
I'm gonna save these for when I have to make new threads. thanks
>>
File: zen.png (3 MB, 4961x3508) Image search: [Google]
zen.png
3 MB, 4961x3508
[- Python -]
> http://www.python.org/

Friendly reminder that python is the top notch programming language
and has been heavily adopted by the industry and the academics.

Python has events and conferences all around the world:
> http://www.pycon.org/

Python even has a video repository!!
> http://pyvideo.org/

Find your local pythonistas group
> http://wiki.python.org/moin/LocalUserGroups

Join python and become a true computer scientist.
>>
>unity makes bloated as fuck apk (17MB)
>check the application installed
>it's a few kb

wtf man.
can someone explain this?
>>
>>51270777
I wrote the beginnings already. I just have to research a bit more things. I also plan on doing width/identifiers as well as exceptions. It doesn't seem that difficult desu. I just have to research how to set up an arbitrary amount of parameters. Once I find that out, it should be a cakewalk. It is going to be exceptionally slower than just using cout. But this is a matter of principle god damn it.

#include <iostream>
using namespace std; //she's forcing me to use this too
void printf(char *s)
{
for(;*s != '\0';s++)
{
if(*s == '%')
{
*s++;
switch(*s)
{
case 'd':
break;
}
}
else
cout << *s;
}
}

int main()
{
char *p = "fuck my shit up\n";
printf(p,0);
return 0;
}
>>
File: asciiart.png (31 KB, 582x871) Image search: [Google]
asciiart.png
31 KB, 582x871
>>51270067
Finished the ASCII art script. Suggestions welcome! Here's the source:
from PIL import Image

#Opens the image, converts it to greyscale and saves it.
img = Image.open('batman.jpg')
img = img.convert('LA')
img.save('greybatman.png')

'''The lower the value, the darker the average.
We use 'weightier' characters like @ for the dark colours,
and more soft characters like "*" for the lighter colours.'''
characters = {
0: '@',
10: '#',
20: 'N',
30: '$',
40: '8',
50: '&',
60: '9',
70: '£',
80: '^',
90: '*',
100: '.',
110: ' '
}

IMAGE_WIDTH, IMAGE_HEIGHT = img.size

STEP_WIDTH = 40
STEP_HEIGHT = 35

def getAverage(x, y):
count = 0
for i in range(x - STEP_WIDTH, x):
for n in range(y - STEP_HEIGHT, y):
#Get the value of the pixel at every place within the step.
pixl = img.getpixel((i, n))
#getpixel returns a tuple, but we're only interested in the first element.
count += pixl[0]
#to find the average, add up all elements and divide by the number of elements.
#Count contains all of the values added up, now we divide them by the number of pixels in each step.
return count / (STEP_WIDTH * STEP_HEIGHT)

#Iterate over the whole image, taking steps defined earlier.
for x in range(STEP_WIDTH, IMAGE_WIDTH, STEP_WIDTH):
for y in range(STEP_HEIGHT, IMAGE_HEIGHT, STEP_HEIGHT):
#Get the average of all pixels within the last step.
average = getAverage(x, y)
'''This line is dense. Essentially, it searches the characters dictionary
for the value that's closest to the average we got previous, and prints the
corresponding character. We use end="" to avoids newlines.'''
print(characters[min(characters, key=lambda x:abs(x - average))], end="")
print("\n", end="")

>>
Can't tell if I've broken visual studio, or if it's just building
>>
>>51270722
I downloaded the book and it barely goes into explanation for topics, it's annoying
>>
>>51271083
why the fuck does this matter?
>>
>>51271107
If I was your teacher, I'd be pissed. So, if thats what you're going for, then good.

You know about iostream formatting and iomanip right? Also, don't listen to the /g/ trolls who parrot shit about 'using namespace std'. Its perfectly fine if you don't use it in a header file. Chances are, your programming teachers know more than /g/. ffs, my cat is a better programmer that most of /g/.
>>
>>51271309
Nah. My teacher's cool. She won't be upset. If anything she'll just laugh it off

And yeah, I know about that. I'm not planning on rewriting the entire standard myself. Just most of it.
>>
>>51271248
This might be more what you're looking for.
https://it-ebooks.info/book/2262/
>>
>>51271248
>>51271409
also http://it-ebooks.info/book/2265/
>>
>>51271409
>>51271427
Thanks man
>>
Decided to learn C++, currently working on the calculator from chapter 6 (I think) of Stroustroup's Programming: Principles and Practice.

After I finish, I'll try to do a polish notation calculator
>>
>>51271258
dunno, just curious.
where all the information of the apk went to?
>>
>>51271484
This is just a guess, but all the "bloat" was libraries(?) supporting the application you wrote. In other words, it's code the application needs to run that Unity provided, and what you refer to as the "application" is just what you wrote.
>>
I made a website to learn and to see if there was any interest in it, and no one cares
should I kill myself, or I should kill myself?
>>
Are the majority of people on /g/ just people who like "tech stuff"?

Seems like rest are uni students doing comp sci or w/e and the smallest group is people who have some sort of engineering or software related job
>>
>>51271621
>majority of people on /g/
people tech savvy enough to change the wallpaper without calling tech support
>>
how is TaPL? would it be a hard read if I didn't ever do CS at uni?
>>
>>51271621
The majority of /g/ is /v/ and reddit faggots.
>>
>>51270407
The sad part is it's easier to just use xlib in C.
>>
File: easy-st.jpg (57 KB, 455x264) Image search: [Google]
easy-st.jpg
57 KB, 455x264
>>51270407
>GUIs with Java for Android
>>
>>51271620
Option C, kill your family, then kill yourself.

Or, you know, just move on. You aren't the first person who's made an unsuccessful website. Just look at yahoo.
>>
How close am I here?
>Lisp
Latin
>C
German
>C++
English
>Java
French
>C#
Spanish
>Python
Russian
>Japanese/Chinese
4Lang
>>
>>51272050
>>Python
>Russian
what
>>
>>51272056
No articles.
>>
>>51271232
I templated C++ so hard that I created an unresolved symbol error in visual studio.
>>
>>51272050
> Kill
Yourself
>>
File: lrg_MSDN[1].gif (4 KB, 300x300) Image search: [Google]
lrg_MSDN[1].gif
4 KB, 300x300
Do you guys know any good introductions to the Windows command line and programming environment? It all seems a bit esoteric
>>
>>51272138
EXIT
>>
holy shit
>>
Anyone want to de-obfuscate this hello world?
All I can tell so far that the person did different was swapping the names of read and write. Is there more
 int i;main(){for(;i["]<i;++i){--i;}"];read('-'-'-',i+++"hell\o, world!\n",'/'/'/'));}read(j,i,p){write(j/p+p,i---j,i/i);} 
>>
>>51272138
Have you ever seen a bitter alcoholic abuse a dog? That's how Microsoft treats programmers. I can't figure out why everything they do is poisonous garbage.

But it is.
>>
>>51272138
please stop using windows for programming
>>
>>51272138
Yeah, download Powershell
>>
>>51272050
>Java
>French
>not whatever the fuck Indians speak
>>
>>51272138
Windows command line a shit.
>>
>>51272602
Err... figure out how to use Powershell rather, should already be on your system
>>
>>51272496
Sure.
main()
{
write("hello, world!\n");
}
>>
>>51272627
Not PowerShell though. PowerShell is better than anything linux has to offer (ignoring all the stupid privilege escalation bugs)
>>
>>51270308
inter alia
>>
>>51272050
>lisp
usa jew

>C
usa irish

>c++
danish

>java
usa

>c#
danish

>python
holland

>ocaml
french
>>
>>51272678
>PowerShell is better than anything linux has to offer
this seems unlikely; rather, they are just different, and you have opinions you're fond of
>>
>>51272678
How can you even say both of those things in the same sentence
>>
>>51272805
Ah right. I forgot bash doesn't have vulnerabilities.

>>51272782
It's better if only because you can freely use .net
>>
>>51272857
>It's better if only because you can freely use .net
we must have different dictionaries
>>
>>51272654
Not sure if bait but I meant explain it. I know it prints hello world. I want to know the intricacies beyond the swapping of read and write.
>>
my general utility, state of art, C library is advancing well. maybe a release date near the end of 2016.
>>
>>51272678
PowerShell is better than every single language with a command line interpreter that has been made to compile and work with linux? Lol.
>>
>>51272584
it doesn't seem that bad
>>51272596
I don't want to pigeonhole myself and most of my school stuff is probs gonna be Windows-based (EE)
>>51272643
yeah I guess a comprehensive intro to PS is partially what I am looking for
>>
>>51272917
I sincerely hope "array" isn't a vector.
>>
>>51272935
ofc. It's written by Microsoft after all.
Best IDE - fact.
Best OS - fact.
Best command line - now too.
>>
>>51272964
You don't beat the dog on the first day.
>>
>>51272982
true as fuck
>>
>>51272964
http://www.powershellpro.com/powershell-tutorial-introduction/
I used this to learn it at my internship, got me going on it pretty quickly. The tutorials are all in order on the very right side of the page.
>>
>>51272964
http://ss64.com/ps/
>Get-Help *
>>
>>51272910
You said de-obfuscate.
As for how it's done, dunno, it was made to be difficult to understand and there's no point in trying to figure it out when it clearly just prints "hello, world!\n".
>>
>>51272138

You may as well just find a job that has no benefits.
>>
>>51270617
He wrote a program that was 129 lines long.
>>
>>51270643
2^15 ?
>>
Whats a good programming language to learn for scripting?
>>
>>51272975
This might be bait, but it is also true
>>
>>51270617
#include <stdio.h>

int main(void){
int a=3, b;
b = a-- + a-- + ++a + a++ +
a++ + a++ + ++a + a++ +
a++ + a++ + ++a + a++ +
a++ + a++ + ++a + a++ +
a++;
printf("%d\n", --b);
return 0;
}
>>
Challenge sheet pls
>>
>>51273199
Python, Lua, Tcl, AHK (Winblows only)... mmmm yep, that's it.
>>
>>51273199
racket, scheme, awk, nodejs, clojure
>>
File: 1415572119601.jpg (43 KB, 450x450) Image search: [Google]
1415572119601.jpg
43 KB, 450x450
>>51273223
>>
>>51273199
Haskell
>>
>>51272138
install busybox.exe in your system and use that:
http://frippery.org/busybox/
>>
File: Untitled.png (119 KB, 1924x1080) Image search: [Google]
Untitled.png
119 KB, 1924x1080
Not real programming, more like scripting, but I did a shitty clock that sets the backgound to a hex value based on the time.

What math operation can I do so that 04:22:35 is a pretty color?
I keep getting black, green and blue over an over again in slightly different tones
>>
>>51272917
Where's code?
>>
>>51273478
>blue, black
>not pretty colours
r u gay
>>
>>51273478
>No se por que no funciona
BUILD WALL
>>
>>51273521
Build wall?
>>
>>51273531
B  U  I  L  D     W  A  L  L
U
I
L
D

W
A
L
L
>>
>>51273478
Convert to seconds
A day has 60*60*24 seconds = 86400
Color range is 0 to 0xffffff
Color now = 0xffffff/86400 * seconds
>>
I don't really want to, but I think learning node.js may be necessary.
What does /dpt/ recommend?
>>
>>51273517
Yeah ok, that combination looks quite baller, but I've seen enough of that, I fastforwareded a whole day and say that color all the time
>>
>>51273576
for what, servers?
>>
>>51273604
no, just learning resources, eg: websites/books
>>
>>51273491
code will remain closed, sorry.
I plan to provide a web interface where the user inputs his code then download a compiled executable so my code stay closed.
>>
>>51273558
I'm getting extremely high values
seconds = (h * 3600)+(m * 60)+s;
var color = 0xffffff/86400 * seconds;
console.log(color);

Time= 4:40:14
Color = 3264954.7802083334
>>
>>51273662
Values should be high, 0xFFFFFF is a very large number.
>>
>>51273642
B O T N E T
O
T
N
E
T
>>
Is busy waiting in a main loop the only way to not get fucked by inconsistent OS scheduling for high framerate games?
>>
>>51273585
what about navy
>>
>>51273662
I am on android so I can't test but maybe you need parentheses (0xffffff÷84600)*seconds
>>
>>51273701
Set up a timer and update based on that.
>>
>>51273737
Isn't that only available in multiples at least of 1ms on Windows? At least that's why Quake 3 did it.
>>
>>51273718
It should be
0xffffff÷(84600*seconds)
Doing it your way doesn't change anything because it already evaluates left to right.
>>
>>51273701
Events my mang. Let the OS schedule shit as it pleases and give you your shit when you need it. Anyway busy-wait monopolizes the CPU and forces the OS to task switch your shit. If you don't give up some CPU time the OS will take it from you.
>>
>>51273765
There are plenty of high-res timer libraries out there.
>>
File: Untitled.png (124 KB, 1924x1080) Image search: [Google]
Untitled.png
124 KB, 1924x1080
>>51273718
>>51273662
I think I got something going
seconds = (h * 3600)+(m * 60)+s;
var color = 0xffffff/86400 * seconds;
color = color.toString(16);
var color = color.substring(0, 6);
console.log(color);
document.getElementById("time").innerHTML ="#"+ auxh+":"+auxm+":"+auxs;
objeto_body.style.backgroundColor = color;


It updates the color every second but colors increment faster than I expected, still, I guess it does it's function pretty good, I'll experiement with different colors further on!

Thanks
>>
>>51273788
Yes, but not ones where you can yield the thread and wait upon.
>>
>>51273803

After some quick Google searches, it would seem that no third party library will allow you to sleep a thread for less than 1 millisecond, as Windows does not actually have sleep function that accepts units less than 1 millisecond. Most hardware does not provide timers for this small of a time quantum. Linux, on the other hand, has a usleep and nanosleep system call, because users may have more specialized hardware for real time systems.
>>
>>51274006
It's not sleeping less than 1ms that's necessary, but sleeping with high precision. You can busy wait with high precision, but you can't sleep so.

And I'm pretty sure the actual implementations of usleep and nanosleep are much coarser than their names imply.
>>
>>51273803
Is it not a good idea to have a loop with an admixture of syscall sleeps and busy-wait? SO you aren't starving the CPU and you aren't sacrificing high-frame rates. What do you even mean by high frame rates? If you have an excellent engine that can do state updates in a couple ms, give an ms here or there to the system, your engine is still running >100fps.
>>
File: what_the_fuck_shatner.gif (1 MB, 170x180) Image search: [Google]
what_the_fuck_shatner.gif
1 MB, 170x180
>>51273642
>>
>>51273701
Sleep if you have more than ~5ms of left over time (after setting timer min res to 1 ms), busy wait the rest is what I do for really precise frame sync when not using vsync.
But ideally you use vsync at 60/120/144Hz.
>>
>>51274047

Well, do you need perfect precision, out just decent enough to approximate 60 fps?
>>
>>51270407
>netbeans

problem solved
>>
>>51274106
No, problem created.
>>
>>51274092
The render thread can use vsync for blocking, but in my design it's asynchronous from the main thread.

>>51274100
240Hz is my target.

I've come to the conclusion that I'll just yield the thread when the window is not in focus, and busy wait otherwise. The render thread can use a blocking op on the graphics API.
>>
>want to learn three new languages
>want to start learning GPU programming
>want to at least finish one of the fifteen pet projects started but left hanging

>lurk /dpt/
another night down
>>
implemented iterators and remaining tests.
>>
>>51271620
>shut down the website
>work on other shit for several years
>find out years later that someone did your idea but executed it better and sold their company to Microsoft for 1 billion
>cry every night
>>
import std.stdio;

void main()
{
writeln("Good night /dpt/!");
}
>>
>>51274714
>>51274759
>>51274780
/dpt/ is not your personal blog
>>
>>51274784
Prove it.
>>
File: iamcat.png (292 KB, 500x497) Image search: [Google]
iamcat.png
292 KB, 500x497
>>51274714
stay up all night tonight and finish one anon
I believe in you
>>
Im fucking lost now, at the course we are seeing none computable programs, but can't really grasp the idea.

Somebody got a more easier way of explaining it and a simple example of a none computable program?
>>
>>51274897
printf("%d\n", 1 / 0 );
>>
File: i_dont_have_a_job.jpg.png (317 KB, 724x926) Image search: [Google]
i_dont_have_a_job.jpg.png
317 KB, 724x926
>>
>>51274905
but couldn't that be partially computable?
>>
The fact that Powershell is meant to be an entire scripting language goes to show the differences between unix and M$ philosophies
Does microsoft even have philosophies and principles?
>>
>>51274714
prioritize. just do one or, at most, two things in a day.

>>51274759
thank you for reminding me my worst fear.
I have lots of idea of what to do with the website and the idea behind it... and no clue on how it could be helpful or, even less, profitable.

>>51274784
fuck you
>>
>>51274714
What are some of the projects?
If you list the steps you need to complete the process becomes a lot easier
>>
i know you guys hate java, haven't been around programming for a very long time, wondering if everyone is still using eclipse or if people are using intelliJ now?
>>
>>51271209
This is cool.
>>
>>51272917
Why Japanese text?
>>
>>51275391
has been replaced (>>51274758). nothing to see here.
>>
>>51274714
I think "learning" a language is impossible. No matter how much I study the specifications for a language and go through tutorials, I basically know as much as any programmer who has never used it until I have implemented a program of sufficient breadth to allow me to see how a language uniquely handles certain situations.
>>
>>51274780
Nice.

>>51274897
It's prob
>>
Should I read The Little Schemer series/SICP or teach my self web development?

On one hand, opening the world of Lisp will probably make me a better programmer. On the other hand, web development will make me more marketable.

I'm leaning towards Lisp since most web development stuff isn't actually coding, just importing someone else's code.
>>
>>51275421
What is that kanji?
Sorede ( ) matta
>>
>>51275455
Just do both. If you are tight on money then rush web development until you get a job. Both are interesting and worthwhile desu senpai.
>>
# Prints the classic right-angle meme text with random white space.
# Copyright (C) 2015 Anonymous

import random

# Ask for the meme text.
meme_text = input("Meme text <- ")
meme_text = meme_text.upper()

# Save length of the meme text.
meme_length = len(meme_text)

# Print the string in all caps with spaces between individual characters.
index = 0
meme_string = ""
while index < meme_length:
meme_string += meme_text[index] + " "
index += 1
print(meme_string)

# While the full meme is unprinted:
index = 1
while index < meme_length:

# Add random white space after the next letter in the string.
letter = meme_text[index]
modified_letter = letter + (str(random.randrange(meme_length * 2) * " "))
modified_letter = modified_letter[:-1]

# Print the modified character.
print(modified_letter)
index += 1

What's a fun program I could write in less than an hour? I can't sleep.
>>
does anyone actually know how to code in fortran holy shit


pls help
>>
>>51275513
I've actually got a job right now. The majority of the company is e-commerce based and I'm on one of the only teams that writes C++ software rather than Javascript and JSP's. It's sort of alarming because I'm afraid that if I ever got moved to another team I'd be clueless.

You're right though, only thing stopping me from learning both is my own motivation.
>>
>>51275455
how about doing webdev while learning Lisp? :)

>>51275531
codeeval.com

>>51275553
I guess there is a #fortran or ##fortran channel in freenode: webchat.freenode.net
>>
>>51275564
>my own motivation
and time
feels weird being able to motivate yourself, I guess i feel unique in that
>>
This thread seems to be more lively, so I'll just link >>54712991

Summary: Problem with terminal color codes. I'm a windows pleb.
>>
>>51275309

I'm fairly sure I've seen people using both, though intelliJ is what Android Studio is based off of, so it should have a lot more users now. That said, both are bloated as hell.

>>51272917

Are these linked lists of a specific data type, or are you using macros to simulate templates?
>>
>>51275580
>codeeval.com
checking out, will report
>>
>>51275584
It's hard when you can just space out and browse /dpt/ instead.
>>
>>51275501
それで決まった
Sore de kimatta
done!
>>
File: prog.jpg (155 KB, 850x1003) Image search: [Google]
prog.jpg
155 KB, 850x1003
>>51275591
>Are these linked lists of a specific data type, or are you using macros to simulate templates?
can't tell because schroedinger.
>>
>>51275614
thanks senpai
>>
>>51275599
i only go on 4chan once i've spend enough time doing more elevated things
>>
File: 1441318390160.jpg (41 KB, 477x456) Image search: [Google]
1441318390160.jpg
41 KB, 477x456
>>51275643
>>
>>51275625

Schroedinger's C macros...

I now feel like writing generic types using macros.
>>
>>51270067
Hey /g/

Maybe I'll make a thread about this later but for now this will do.

I'm living out of VPNs due to lol-China. Lately I'm having problems getting or staying connected. Stunnel isn't working for me, no real idea why.

I own the server I connect to so I'm thinking of maybe trying to rip off PPTP[1] and wrapping it in some random light encryption and moving it to a new port.

Sound reasonable? I'm a reasonably experienced dev, just after a critique.

I assume I could just grab the source from repos and fuck with it a bit and recompile.

[1] I know PPTP is not secure but it takes analysis of collected traffic to break and anyway, I'm not doing anything that will get me sent away or my accounts/servers hacked. Most of it is to enable https connections to gmail and/or ensure my ssh all come from a whitelisted IP. It's for bypassing the firewall or controlling my endpoint rather than hiding from interception.
>>
>>51275802
Also, both PPTP and OpenVPN end up being detected by traffic somehow, so I suppose I also want to hear any advice on whether encryption is adequate to mangle the packets such that it won't be identifiable as those protocols by packet frequency or anything.
>>
File: 122.jpg (2 MB, 2400x1500) Image search: [Google]
122.jpg
2 MB, 2400x1500
>>51275769
last time i shared code (a definitive programming language benchmark) with /dpt/, you guys ostracized me
>>
how do i into C++ unit testing on windows?
>>
>>51276005
Install Gentoo
>>
>>51275999
Kill yourself, benchmark fag.
>>
File: 1441106046194.gif (204 KB, 600x538) Image search: [Google]
1441106046194.gif
204 KB, 600x538
>>51275999
>2.47 MB lossy jpg
>>
File: hIIM6TS.jpg (42 KB, 720x960) Image search: [Google]
hIIM6TS.jpg
42 KB, 720x960
>>51276055
>>51276112
please don't bully.
>>
>>51270067
Reminder that people with seasonal waifus are the worst because they've zero loyalty.
>>
>>51275999

DPT is not a place for pleasant comments. It is a place for criticism, which may often be constructive (amidst less constructive criticism). Your benchmark, if you were the closure bench guy, seemed fake from the initial posts of its results until you did post the source, and afterwards, we all realized why your results were that way -- because you used an almost inane way of benchmarking languages. I will give you that it gave me a decent laugh, however, and that it encouraged me to never again use std::function for any reason at all.

That said, just because people don't like your code doesn't mean you shouldn't continue to post it. I'll keep posting my code here (except for school assignments, so that if anyone here is one of my classmates lurking, they cannot use it to cheat), even if people yell at me for it. In fact, I look forward to negative responses because it tells me where I can improve. I would suggest you do the same.
>>
>>51274758
Why do you write .proc and .caption instead of just proc and caption?
>>
File: 1406026539260.png (191 KB, 550x550) Image search: [Google]
1406026539260.png
191 KB, 550x550
Fuck off reddit, you nigger whores
>>
>>51275093
lucky for you, anyone in a CS major get bingo almost all of those within their first three, if not two years.
>>
>>51276236
what do you mean ? why the dot ? because it's an array of structures.
>>
>>51276005
VS
>>
>>51276231
not that guy but it's good advice
You can always tell who is a shit programmer by the ones who get butthurt by people who shit all over their code. Even if you post the best solution, and some guy replies with a one liner >using x language for example:
You can still learn from that post, by analyzing, ok what interesting problems would I run into if I used a different language. Guys who refuse to learn are doomed. I'm not really sure why I'm replying to you though since tripfags inherently disgust me
>>
>>51276306
i'll try it out

lets say i have two projects in my solution, one for the actual application and one for testing
if i include the headers created by the main project in the test project, will that cause the the code in those headers to be compiled all over again for the executable generated by the test project?
>>
point *candidate(const point *prev, double &prevSlope, point *begin, point *end) {
bool foundPositive = false;
point *positiveCandidate = nullptr;
point *negativeCandidate = nullptr;

for (point *i = begin; i < end; i++) {
if (i != prev) {
/* Next Point: Smallest slope difference where slope(current, candidate) > prevSlope)
OR if all slopes < prevSlope, select Min(slopes) */
if (slope(prev, i) > prevSlope && (positiveCandidate == nullptr || slope(prev, i) - prevSlope < slope(prev, positiveCandidate) - prevSlope)) {
foundPositive = true;
positiveCandidate = i;
}
else if (!foundPositive && (negativeCandidate == nullptr || slope(prev, i) < slope(prev, negativeCandidate))) {
negativeCandidate = i;
}
}
}

prevSlope = foundPositive ? slope(prev, positiveCandidate) : slope(prev, negativeCandidate);
return foundPositive ? positiveCandidate : negativeCandidate;
}


I'm trying to run an algorithm that returns the convex bounds of a shape, this is the specific function for selecting the next point.
The problem I'm having is this currently can not detect a point if the previous point has the same slope as the previous slope (slope(prev, i) == prevSlope).
Anyone here smart enough to help me out?
>>
>>51276283
>because it's an array of structures.

You need the dot to initialize a structure?
>>
File: 1446411809786.png (77 KB, 694x801) Image search: [Google]
1446411809786.png
77 KB, 694x801
Anyone here uses physics in their programming? If yes then how?
>>
File: d.jpg (864 KB, 1280x1707) Image search: [Google]
d.jpg
864 KB, 1280x1707
>>51276471
when initializing specific fields, yes. it's like doing

array[10] = { 
[4] = 1,
[7] = 3
};

which is same as

array[10] = {0,0,0,0,4,0,0,3,0,0}


>>51276307
i never learned anything here.
>>
>>51276651
>i never learned anything here.
Obviously. But you can still use this as a means to learn things by yourself. /dpt/ does things that you should know in high school, whereas the so called programming gods of /dpt/ are little more than people who passed Introduction to Computer Science and Programming 101
>>
Can someone explain in layman's terms how to build a pushdown automata?

I've been banging my head against a wall for a few days now to no avail
>>
>>51270323
You invented a sorting algorithm? Sounds like bullshit.
>>
File: 1446195063311.gif (995 KB, 500x541) Image search: [Google]
1446195063311.gif
995 KB, 500x541
>>51276651
that looks comf as fuck
>>
>>51276651
I apologise to /g/ if I'm falling for localised bait, I'm not a regular.

Anon, isn't your first array initialising empty elements to null and your second array to integer zero?
>>
File: 1440274596563.png (357 KB, 740x926) Image search: [Google]
1440274596563.png
357 KB, 740x926
>>
>>51273680
>botnet
You read my mind.

>with your botnet
>>
>>51276583
It takes force to press keys to program, that's physics right?
>>
>>51274077
See >>51273680
>>
I want into MIT Media Lab
how
>>
>>51276759
"null" refers to pointers, not integers. However, NULL is defined to be (void *)0, so in some ways, you can consider them to both be equivalent.
With that array declaration syntax, every 'missed' element is initialised to zero.
>>
>>51276993
>NULL is defined to be (void *)0
what?
NULL is defined to be 0. Not a void pointer to 0.
>>
>>51276839
>this guy never wrote a red-black tree
>this guy never wrote a maze solver
>this guy never wrote fucking bubblesort
>this guy never wrote binary search
>this guy never used a Xilinx FPGA
>>
>>51277173
standard says
"The macros are NULL which expands to an implementation-defined null pointer constant;"
0 is an integer constant, not a pointer constant
(TYPE *)0 is a null pointer constant
void * and char * don't require being casted when used with other pointer types so the best for NULL is either (void*)0 or (char*)0
>>
>>51277173
it is in C
dont know what the C++ standard says but i know that NULL is defined as 0 in MVC++
>>
>>51277173
http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1548.pdf
6.3.2.3 Pointers
page 55
Paragraph 3

>An integer constant expression with the value 0, or such an expression cast to type void *, is called a null pointer constant 66). If a null pointer constant is converted to a pointer type, the resulting pointer, called a null pointer, is guaranteed to compare unequal to a pointer to any object or function.
>66) The macro NULL is defined in <stddef.h> (and other headers) as a null pointer constant; see 7.19.

In C, it's defined to be a void pointer. I think it's different for Meme++.
>>
>>51277229
>In C, it's defined to be a void pointer.
are you blind
>An integer constant expression with the value 0 ... is called a null pointer constant
NULL is 0 (and, well (void*)0)
>>
>>51276993
>"null" refers to pointers, not integers
Oh, it's an array of pointers, right.
>>
>>51277244
>or such an expression cast to type void *

Anyway, here is an extract from the GCC stddef header, typically found in /usr/lib/gcc/*/*/include/stddef.h:
/* A null pointer constant.  */

#if defined (_STDDEF_H) || defined (__need_NULL)
#undef NULL /* in case <stdio.h> has defined it. */
#ifdef __GNUG__
#define NULL __null
#else /* G++ */
#ifndef __cplusplus
#define NULL ((void *)0)
#else /* C++ */
#define NULL 0
#endif /* C++ */
#endif /* G++ */
#endif /* NULL not defined and <stddef.h> or need NULL. */
#undef __need_NULL
>>
>>51277244
http://c-faq.com/null/null2.html
>>
>>51276668
> Can someone explain in layman's terms how to build a pushdown automata?
Well, usually you use yacc/bison to build it for you. But anyhow ...

With a finite automaton, the next state is a function of the current state and the current input symbol (the transition function is typically implemented as a lookup table).

With a push-down automaton, the next state is a function of the current state, the current input symbol, and the symbol at the top of the stack. In addition to determining the next state, the transition function also determines whether to pop the top-most symbol from the stack or push some symbol onto it.

For parsing a context-free grammar, the transitions typically fall into two types: "shift" operations simply push the current input symbol onto the stack, while "reduce" operations pop some number of symbols from the stack and pop a new symbol onto it. The BNF terms describing the language correspond to reduce operations, where the LHS is the symbol pushed onto the stack and the RHS corresponds to the symbols popped off it. Shift operations are performed when there is no applicable reduce operation, i.e. when the parser needs to consume more input in order to match a complete term.
>>
>>51277304
> whether to pop the top-most symbol from the stack
Should have been "symbols" (plural).
>>
Any anons know how I could easily decode 4chan's api's md5s in C?
I have no idea how, I got base64 decoding going but how do I unpack it to 32 bytes?

From the api documentation:
text (24 character, packed base64 MD5 hash)

e.g. NOetrLVnES3jUn1x5ZPVAg==
>>
>>51277229
> In C, it's defined to be a void pointer.
Wrong. Read the text you quoted. It MAY be cast to a void*, but it doesn't have to be.
> #define NULL 0
and
> #define NULL ((void*)0)
are both conforming.

In most contexts, either will work. But if you're passing a parameter to a variadic function or to a function with no prototype in scope, you should add an explicit cast.

In C++ prior to C++11, it's required to be an integer constant expression equal to zero. Cast to void* isn't allowed. In C++11 and C++14, it is allowed to be defined as an integer constant or as nullptr, but not as void*. The reason is that operator overloading means that the type matters, a lot; you can't rely upon implicit conversions because those only happen after an overload has been selected ... based upon the parameter types.
>>
File: progbingo.png (319 KB, 740x926) Image search: [Google]
progbingo.png
319 KB, 740x926
>>51270241
Considering I only recently turned 18 and am completely self taught I guess I'm doing alright.
>>
>>51270067
op, sharing last threads link wont hurt, you know.
>>
>>51277455
>>>/g/archive
>>
File: animegirl.png (4 KB, 329x335) Image search: [Google]
animegirl.png
4 KB, 329x335
>>51270067
As someone who has never coded anything, what's the best way to get started learning? I was thinking about using treehouse.
>>
How can I impress a girl using SQL code?
>>
>>51277502
I think bash scripting isn't a bad beginning.

Starts off trivial but before long you have functions, variables, expressions, all the basics.

Once you can write advanced bash scripts, you have 30% of the compiled languages anyway.
>>
/g/, I'm away from my PC and I'm reviewing for a java exam

I know that if you have a linked list in java
LinkedList list = new LinkedList();
you can add some generic stuff
list.add(1)

and to remove you just do list.remove(index)
but what if I just write list.remove() with no parameters? Do I get an error, or does the link list remove the last item added to the list?
>>
>>51277569
go check the fucking java docs on linkedlist.remove, you dumbcunt
>>
>>51277569
Jesus christ, this is honestly the laziest question I can ever remember reading on /g/. How about you open up your IDE and find out? Or spend 2 seconds looking up the docs?
>>
>>51277584
I am man, but I don't see anything on using remove with no parameters

I guess it's just not used that way? Whatever then

>>51277600
I'm on my phone man, and I need a better one. This one can't even handle ideone
>>
>>51277604
>I don't see anything on using remove with no parameters
then it doesn't exist.
no fuck off and learn to google
>>
>>51277604
>I'm on my phone man
You can use 4chan but you can't google the Java docs? fuck off.
>>
the salt over a question in this thread is unreal at times
Thread replies: 255
Thread images: 39

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.