[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: 24
File: daily programming thread2.webm (2 MB, 600x338) Image search: [Google]
daily programming thread2.webm
2 MB, 600x338
old thread: >>55535040

What are you working on, /g/?
>>
nothing

I want to do some programming but have no ideas
>>
>>55544625
Keep overflowing the stack Hime!
>>
File: poopybumchocolate.png (10 KB, 1166x504) Image search: [Google]
poopybumchocolate.png
10 KB, 1166x504
Making a 3D modelling interface for my game engine that will just outright display the VBO you assemble.

Currently working on the input forms. So far the input form changes colour when you mouse over.

That is it.
>>
>>55544625
Reading K&R C book. C is the master race of programming languages.
>>
>>55544704
C was shilled by (((MIT))) and other organizations to deliberately make software less secure and increase funding for (((Lisp))) and "functional programming" boondoggles.
>>
>>55544752
Butthurt
>>
>>55544704
>Reading K&R C book.
Same desu, sitting right next to me.
>>
>>55544752
https://www.youtube.com/watch?v=9a3eCHij4Vo
>>
>>55544789
>>55544803
>>55544814
MIT students detected. Go read your high school kids' book.

I bet you think null-terminated strings are safe and efficient. Does your school still teach that strings are linked lists?
>>
File: Untitled5.png (119 KB, 372x409) Image search: [Google]
Untitled5.png
119 KB, 372x409
>>55544828
>Implying I am anywhere near qualified to get into MIT
>>
>>55544639
make a rendering engine for HTML
>>
>>55544828
Not even an MIT student senpai.
>>
>>55544912
C is better than noob languages like Java or Python.

>>55544938
He probably is.
>>
>>55544961
>C is better
If you want to create the next big security vulnerability.
>>
>>55545051
>waaaaah waaaahh i did a buffer overflow all over the carpet waaahh i can't clean it up myself waahh

#include <gitgud.h>
>>
>>55545051
That's the programmers fault, not the language.
>>
>>55544639
Scheme implementation
>>
I have roughly 7 mb of html

what do you suppose would be a good method of searching it for strings?

I was thinking of taking the first word of input, returning all those results, take the second word and only search those first set of results and so on to make it as efficient as possible

Is that the best way to do it?
>>
>>55545627
$ grep PATTERN [FILE]
>>
Take 2, this time without that stupid newline.

>>55545627
Nokogiri should do it really nicely if you want to get rid of the HTML noise.

Example:
require 'nokogiri'
require 'open-uri'

puts Nokogiri::HTML(open("https://boards.4chan.org/g/thread/55544625")).text


This will put the text of the entire thread in your console. (Not very readably, but without any HTML elements)
You can grep the result, or use a Regex from Ruby's REPL.
>>
If I have a Juction Table with 2 Foreign Keys, do I need to add this IDs manually or they're automatically added when I insert something in the other tables?
>>
For this anon >>55544355

See
>>55545744
>>55545787
>>
>>55545762
oh no I know how to parse html with both regex and bs4, that's not a problem
this would be from a downloaded file anyways

I just was looking for a quick method of doing it owing to the large amount of text (like a hashtable, if someone knew how to generate that) preferably with little or no dependencies
>>
>>55545821
I suddenly don't understand what your want to do then.
What would you do with it..?
>>
File: hqdefault.jpg (13 KB, 480x360) Image search: [Google]
hqdefault.jpg
13 KB, 480x360
>just ass off to learn C++ in two days
>build up code
>debug it all night until it compiles
>code runs for 1 hour
> no data has been written
>found out Cygwin has aborted the execution itself (core dump)
>mfw
>>
>>55545839
first time building a bot
it would take inputs of quotes, for example:
"But my best memory of those days is now what I did but what I almost did", conduct a search of the text, and return From Living to Tell the Tale by Gabriel Garcia Marquez, Page 466, Chapter 30, Full Context: {Paragraph}

I have html I've extracted from various books for e-readers for this purpose
>>
>>55544828
>MIT students detected
I fucking wish, anon.
>>
>>55545078
>>55545079
kek you guys are so retarded.
>>
>>55545875
Neo Venezia will never be done at this rate, anon.
>>
>>55545900
If the HTML is in a consistent format, something like this could work:
#!/usr/bin/ruby
require 'nokogiri'

def search(search)
Dir.glob("**/*").each do |file|
doc = Nokogiri::parse(open(file)).css(".selector.for.text")

doc.find_all do |node|
node.text_content.include? search
end.map do |node|
node.parent.css(".title").text_content
end.each do |title|
puts "Found in #{file}, Heading: #{title}"
end
end
end


This is just untested almost-psuedocode, but it's how I'd do it.
>>
>>55545051
Wrong, the same chance to get fucked is for every popular language.
>>
>>55546153
If they have parts written in C.
>>
>>55546190
No
>>
>>55545875
Well, what's the issue anon?
>>
>>55546153
Yeah, no.
Programmer error leads to horrible memory vulnerabilities in C, whereas you'd be hard-pressed to do that in something else.
>>
>>55546216
>Programmer error leads to horrible memory vulnerabilities in C
Just as much as in other languages.
>>
>when he hasn't even written a line editor
why even call yourself a programmer
>>
>>55546225
You can't even ACCESS memory directly in most languages.
>>
File: mOBmO.jpg (67 KB, 1199x546) Image search: [Google]
mOBmO.jpg
67 KB, 1199x546
>>55545963
Lmao just fuck my shit up senpai.
>>55546210
I have literally no idea.
>>
>>55546240
You can do that in C as much as in other languages.
>>
>>55546216
If you were a more disciplined programmer and just didn't do everything haphazardly, maybe your shitty programs wouldn't have those memory vulnerabilities.
>>
>>55546248
gdb?
>>
File: Capture.png (15 KB, 474x126) Image search: [Google]
Capture.png
15 KB, 474x126
looks like 0 fun

how many hours did you spend on yours, if you don't mind me asking?
>>
Does codecademy actually teach you anything?
I feel like I'm just copy and pasting with no understanding of what i'm doing.
>>
>>55546268
this is wrong
>>
>>55546253
Right.
I am good enough to write mostly anything in C, but I would never trust that I didn't slip up with a double free somewhere or something stupid.

>>55546250
Not really. Try accidentally writing exploitable memory access in C#.
>>
>>55546287
>Not really. Try accidentally writing exploitable memory access in C#.
Probably just as easy as in C.
>>
>>55546301
This bait is delicious. But I'll keep biting.

>C exploitable memory requires you to miss a single detail somewhere
>C# exploitable requires pentesting the language
>>
>>55546287
So what you're saying is that you're too shit to use a language like C safely?
>>
>>55546340
Correct.

I am OK with writing things, but I would never offer to write something people would rely on for security purposes in it.
>>
>>55546335
>>C exploitable memory requires you to miss a single detail somewhere
Except not, what are you talking about?
>>
>>55546353
Just because you're incompetent, so is everybody else?
Stop projecting so hard.
>>
>>55546354
>Double free
>Unchecked buffers
>Raced mallocs

>>55546379
I'm not saying everyone is, I am saying that >>55546153 is untrue. C can easily fuck someone up in ways that is impossible in other languages.
>>
(((Smug C Weenies))) are (((Smug Lisp Weenies))) in disguise.
>>
>>55546399
>>Double free
Almost everything being nullable (java and C#).

>>Unchecked buffers
Just like in every language.

>>Raced mallocs
...what?


As I said, C is just as safe as the majority of the languages.
>>
>>55546440
Throwing an exception isn't the same as memory corruption.
>>
>>55546495
The C standard does not say anything about memory corruption. It is not the language's fault that you are using an unsafe implementation.
>>
>I-it's not the languages f-fault!

Sure, but apparently everybody is too fucking stupid to use it, because every sizable C project results in extreme & dangerous vulnerabilities.
>>
>>55546617
That is why c++ has the string class.
>>
>>55546617
>Hurr it's the languages f-fault that people are retarded!
>>
For a language to be safe it isn't enough to be possible to program in a safe way, it has to make it desirable other than the safety (ease, performance, etc.) and the community has to support idioms that reduce the chance of doing something unsafe.

>>55546649
An example of something C doesn't have
>>
how do you make two classes in separate header files include each other for mutual friendship.
>>
>>55546649
>>55546675
A string type would go against the spirit of C.
>>
>>55546660
Either only C programmers are retarded, or the language is more dangerous.
>>
>>55546715
Again, see >>55546511
Nothing to do with C programmers.
>>
>>55546649

Strings are truly underappreciated.
>>
>>55546511
If it's so easy to do something outside of the spec that almost every sizable program written in the language does it, then you have a problem.
>>
>>55546869
Doing something outside the spec has nothing to do with hat I said.

>that almost every sizable program written in the language
Not true, I hope at least.
>>
>>55546891
>Not true, I hope at least.
How many of these are not written in C or something that uses C's memory management?
https://www.google.ca/about/appsecurity/research/
>>
>>55546950
Most of them are not due to UB.
For the rest of them it could be solved if they followed my advice above.
>>
>>55546950
>or something that uses C's memory management?
careful, his might be too broad, since many compilers/interpreters are in C
>>
>>55546950
>written in C or something that uses C's memory management
That statement encompasses probably 95% of programs. Of course most most vulnerabilities occur in most programs.
>>
File: Rendering.png (18 KB, 806x629) Image search: [Google]
Rendering.png
18 KB, 806x629
-_- The rendering on my rust chip8 emulator bugs me.

Oh, well. It's working at least. Still deciding on the next project.
>>
>>55546253
This is why only the best should be allowed to use C
>>
>>55546991
You can only become the best by using C.
>>
>interning as a part of a university program
>team lead has to meet up with someone from my school and talk about my performance
>talking to my lead before they sit down
>"this meetup could go either way - good or bad. how do you want it to go?"
>"..preferably well"
>suggests that if an envelope were to be placed on his desk everything would go well
>start laughing because he's the type to tease people
>he continues to talk about it
>ask him if he's being serious (multiple times)
>he avoids answering the question
>mentions another student who "learned quick"
>"I've done my job"
>changes the subject of our conversation

Is he actually attempting to extort me? I still have no clue if he was yanking my chain or if he was actually serious. I don't know who would joke about something like this.
>>
>>55547166
I'm as socially clueless as you.
>>
>>55547166

Depends on the his personality. There is a very real chance of it happening.
>>
>>55547227

The person / his personality*

I really should drink some coffee before posting.
>>
>>55547238
>I really should drink some coffee
go to sleep
>>
>>55547256

It's a good idea anon. I've been up since forever on a death march.
>>
trying to learn C because I feel like a pleb web dev / java game developer....

how would you go about writing a game engine from scratch in C... particularly the graphics drawing part
>>
File: 1467133285993.jpg (261 KB, 900x900) Image search: [Google]
1467133285993.jpg
261 KB, 900x900
>tfw you can't find the bug that's making your code shit itself
Feels bad man. I swear to god everything looks right.
>>
>>55547306
Dumb frogposter.
>>
>>55547306
the bug that exists because of you
kill yourself
>>
>>55547350
Do I smell new fag? Or is that the aroma of a brogrammer?
>>
>>55547166
What uni and company?
>>
Oh God, I saw a lighting deal on a Raspberry Pi kit and bought it without a second thought
Damn you capitalism
>>
>>55547433
now why would I give that info
>>
>>55547555
So I could avoid them.
>>
>>55547565
which country do you live in
>>
>>55547577
UK
>>
>>55547589
Then you're fine.
>>
>tfw you'll never be an asset for The Machine
>>
>>55546990
yes but why are you writing it in rust
>>
>>55546990
>R8 project

8/8
>>
>>55547166
I would recommend getting other coworkers or team members to endorse you before this performance review, so that you have something to work with if he fucks you over.
>>
>>55547655

He could also shoot the guy in self defense. It's his right as an American citizen.
>>
>>55547930
The dude is in the UK.
>>
>>55547973
No he isn't.
>>
NOTAÞ HASKELL
>>
>>55548312
Shut up soÞlice
>>
>>55548366
It's soþlice, the thorn is lower case.
>>
>>55548381
Sorry soþlice
>>
>>55547278
SDL
>>
How can I compose functions in C?
>>
>>55548429
Stop posting the same shit over and over, you faggot.
>>
>>55548434
No, I won't.
>>
>>55548429
Write out a C program which contains the composed function
Compile and link it as a shared library
Dynamically load it
Call the function pointer
>>
>>55547973

Is he?
>>
Retard here, how would I be able to extract the data from this thing?
https://rsbuddy.com/exchange/summary.json
>>
>>55548519
argonaut
>>
>>55548085
Oh, I read the post chain wrong.
>>
>>55548503
Are you still SharpShill?
>>
>>55548429
int f(int x) { return x*x; }
int g(int x) { return x+1; }
int fg(int x) { return f(g(x)); }
>>
>>55548600
I'm after a generalized compose function.
>>
>>55548519
With some JSON implementation.
How else would you possibly expect to do it?
>>
>>55548628
You don't need it.
>>
>Gofmt formats Go programs. It uses tabs (width = 8) for indentation and blanks for alignment.
dropped
>>
When using a Scanner in Java with System.in stream, I don't have to worry about closing it right? Because it wasn't me that opened System.in...
>>
>>55548635
Says who?
>>
>>55548680
Many languages are smart enough where you don't need to close file streams, but it's always a good idea to close them yourself, just in case something wonky happens.
>>
>>55548680

no, you definitely need to close it

also make sure to leave comments on every line of code you write for clarity
>>
>>55548718
And comment the comments if necessary.
>>
>>55544639
There's always making your own kernel.

http://wiki.osdev.org/Main_Page

That should keep you busy for a few years and then you'll know everything there is to know about computers and can die fulfilled.
>>
>>55548714
>>55548718
Right, and I've always closed streams, but was never sure about System.in. And anyways, won't the garbage collector handle that shit?
>>
>>55548740
years? nigga I could do that shit in a few weeks cause that's how fucking hard I am. that's just how I roll. I got an A in my algorithms class so I know how to do this shit
>>
File: genesis.webm (3 MB, 1016x760) Image search: [Google]
genesis.webm
3 MB, 1016x760
Messing around with a point cloud. Written in pure JS, rendered to 2d canvas, no external libraries used, all 3d math done manually.

(Unfortunately it's really hard to webm compress a bunch of semi-randomly colored particles with decent quality and small size.)

https://jsfiddle.net/bm0e6217/1/
>>
>>55548769
haha
>>
>>55548769
Make sure to keep us updated on it.
>>
>>55548812
https://youtu.be/_MvAG70Injc?t=2m9s
Do this scene from Future Crew - Panic.
>>
Anyone have that /g/ projects image?
>>
>>55548696
I do.
>>
>>55548840
Seems pretty tricky to reproduce, but I'll probably try to create some similar effect.
>>
>>55548812
that's amazing

seems like not much practical use though
>>
>>55548846
it's called dpt roll

https://better-dpt-roll.github.io/
>>
which compiler to use for c++?

vb not possible
>>
>>55549116
gcc
>>
Learning my first programming language (Java). I'm retarded, why doesn't this code work. It's telling me I can't make a static reference to the non-static field "printArray".
>>
>>55549200
You have a static function and you are trying to modify a per-instance field. The per-instance field doesn't exist until you make a new object with 'new' and you are trying to reference it in a function that exist as soon as the program compiles. Tell me how that's supposed to work.

More likely than not you don't need to make the function static.
>>
>>55549226
>main
>More likely than not you don't need to make the function static.
why are u giving advice pajeet?
>>
>>55549200
>Learning my first programming language (Java)
Don't learn Java. Stop while you still can.
>>
>>55549200
You need to either make the variable static, or declare it inside the main function itself.
>>
>>55549239
shit, just realized that.

>>55549200
Make the variable printArray static. Or you can do this.

class Listing {
...
int printArray;

public Listing(String args[]) {
// put real main function here
}

public static void main(String args[]) {
new Main(args);
}
}
>>
>>55549261
Should be 'new Listing(args);'
>>
>>55549240
Not him, but for some fucked up reason that's the first language taught at my uni.

The lower 1000 courses are taught with Java, and then 1410 and up are in C++.
>>
>>55549200
Study OOP concepts
>>
Is there any reason in C to declare functions in header files if it isn't the source file with main()?
>>
How can I make this faster? Exercise 23 on project euler. My factor function could probably be better, but removing the nub check (obviously making the results wrong) only shaves of 20 seconds of the total 2m 7s time so there's probably a bigger optimization I can make here

import Math

main = print $ nonabunduntsums

nonabunduntsums = sum $ filter notsumtwo [1..28123]

notsumtwo num = null [x+y | x <- [1..num `div` 2], y <- [num-x], isabundunt y, isabundunt x]

isabundunt num = sum (factors num) > num

factors n = nub $ 1 : concat [[x,y] | x <- [2..isqrt n], y <- [n `div` x], n `mod` x == 0]
>>
>>55548571

For the rest of my life, probably.
>>
>>55549553
I did it on Python as well with no math functions. I have a C++ solution as well, but I think it's the same.
tl;dr:
>proper divisor sum sums all factors using a square root
>put them on a list
>another list for the sums of abundant numbers
>use Binary search on this list to increment the count

def proper_divisor_sum(n):

def Binary_Search(myList, element):

def abundant(n):
return proper_divisor_sum(n) > n

def deficient(n):
return proper_divisor_sum < n

def non_abundant_sums():
abu_nums = []
abu_sums = []
limit = 28123
total = 0

#loop for the abundant numbers
for number in range(1, limit + 1):
if(abundant(number)):
abu_nums.append(number)

#list for the abundant sums
for i in range(len(abu_nums)):
for j in range(i, len(abu_nums)):
abu_sums.append(abu_nums[i] + abu_nums[j])

abu_sums.sort()

for numbers in range(1, limit + 1):
if(not Binary_Search(abu_sums, numbers)):
total += numbers

print total
>>
How exactly does high level emulation work? Do they just look at some code and try to guess what it's gonna do?
>>
>>55549553
>>55549656
The code is not really optimized but here is the time it takes:
real    0m6.204s
user 0m5.996s
sys 0m0.200s

Actually, our code is very similar, except that I implemented some stuff by hand. Maybe there's too much overhead using all that Math library magic.
>>
>>55549688
yes
>>
>>55549739
Oh the math library is my own thing, only function I was using from there was factors and isqrt, I forgot to inline isqrt, I think yours is much faster because instead of checking every number you calculate all the numbers and then look at what's there, I'll try that
>>
>>55544625

after many years using spreadsheets and a typo yesterday - i discovered ms excel has an ampersand operation

I got excited for a second, thinking it may operate like the bash operator.

i googled and it looks like its just a infix version of the concatenate function

is there anything else excel's '&' can do? are there other operators that i may not be aware of?
>>
>>55549776
>inb4 +, -, /, *, isfaggot(you)
>>
I'm rewriting a WPF application I made a while back with very little knowledge of WPF, GUI design, or otherwise.

Thing is, universities don't really teach you the nitty gritty associated with modern GUI development, like two-way variable binding.

Is there a book or something of the sort I can read to get started on WPF?
Assume I only understand programming languages and fundamental concepts, like OOP, data structures, and algorithms.
>>
>>55547646

I'm interested in picking up the language for my hobby projects.

Nothing like a late reply after a nap!
>>
>>55549830
pick a different language
>>
Rate my C compose function:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/mman.h>
#include <unistd.h>

typedef void (*genfn_t)();

genfn_t compose(genfn_t a, genfn_t b)
{
static const unsigned char shellcode[] =
// movabs a, %rax
"\x48\xb8\x00\x00\x00\x00\x00\x00\x00\x00"
// callq *%rax
"\xff\xd0"
// movq %rax, %rdi
"\x48\x89\xc7"
// movabs b, %rax
"\x48\xb8\x00\x00\x00\x00\x00\x00\x00\x00"
// jmpq *%rax
"\xff\xe0";

long page_size = sysconf(_SC_PAGESIZE);

unsigned char *fn = aligned_alloc(page_size, page_size);
if (!fn)
return NULL;

memcpy(fn, shellcode, sizeof shellcode);
memcpy(fn + 2, &a, sizeof a);
memcpy(fn + 17, &b, sizeof b);

if (mprotect(fn, page_size, PROT_READ | PROT_EXEC) == -1) {
free(fn);
return NULL;
}

return (genfn_t)fn;
}

int add_1(int n)
{
return n + 1;
}

int main()
{
typedef int (*i2i)(int);

i2i add_2 = (i2i)compose((genfn_t)add_1, (genfn_t)add_1);
printf("1 + 2 = %d\n", add_2(1));
printf("10 + 2 = %d\n", add_2(10));

i2i add_3 = (i2i)compose((genfn_t)add_2, (genfn_t)add_1);
printf("5 + 3 = %d\n", add_3(5));

free(add_2);
free(add_3);
}

x86_64 Linux only.
>>
>>55549994

I'm sorry I've already picked up C, C++, Python, Lua, C#, Java, and Lisp to varying degrees of usability.

Oh, bias anon what would you suggest?
>>
>>55550275
What's this for?
>>
>>55550374
The dumb attempted forced meme that >>55548429 keeps posting.
>>
File: Program.png (29 KB, 1228x594) Image search: [Google]
Program.png
29 KB, 1228x594
New to C Programming. Having some issues with for loops within other for loops. I am just curious as to why this doesn't print out everything inside the for loop (x=0, x<s, x++) 4 times?
>>
>>55550404
You're using the 'x' variable in the inner loops.
It sets 'x' to equal 10, so it's going to exit the loop after the first iteration.

Use a different variable for the inner loops.
>>
>>55550427
Ahh shit yeah I see. Thanks a ton been struggling for the past hour trying to figure out why it wasn't printing out!
>>
>>55550393
What the fuck does it mean to "compose functions?"
>>
>>55550476
Calls function a, then function b with what a returns.
So basically b(a(x)), but it creates its own function to do that.
>>
How do I into Python?
>>
>>55550447

It's a very common beginner mistake. Dunno why but a lot of new commoners try to use the same variable for all loops.. With the route you're going it should look something like this

    int x = 0;
int y = 0;
int s = 4;
int num_of_spaces = (s - 2) * 5;

for (x = 0; x < s; x++) {
printf(" ___ ");

for (y = 0; y < num_of_spaces; ++y) {
printf(" ");
}

printf(" ___ \n | ? |");

for (y = 0; y < num_of_spaces; ++y) {
printf(" ");
}

printf("| ? | \n |___|");
for (y = 0; y < num_of_spaces; ++y) {
printf(" ");
}

printf("|___|\n");
}


This prints 2 rows of 4 cubes with 10 spaces between each cube.
>>
>>55550476
Did you visit a school?
>>
>>55550556
No. I'm pajeet.
>>
>>55544639
A short text based rpg
>>
>>55550538
>Not using printf to your advantage
#include <stdio.h>

int main()
{
int s = 4;
int num_of_spaces = (s - 2) * 5;

for (int i = 0; i < s; i++) {
printf(" ___ %*s ___\n", num_of_spaces, "");
printf(" | ? |%*s| ? |\n", num_of_spaces, "");
printf(" |___|%*s|___|\n", num_of_spaces, "");
}
}

or even using the even shorter (but more ugly) POSIX printf:
printf("  ___ %2$*1$s ___\n"
" | ? |%2$*1$s| ? |\n"
" |___|%2$*1$s|___|\n",
num_of_spaces, "");
>>
>>55550538

Repeated code was bugging me.. So I changed it to this.

void draw_cube(void) 
{
int x = 0;
int y = 0;
int s = 4;
int num_of_spaces = (s - 2) * 5;

char* msg[4] = { " ___ " , " ___ \n | ? |", "| ? | \n |___|", "|___|\n" };

for (x = 0; x < s; x++) {

printf(msg[x]);
if (x == (s - 1)) {
break;
}
for (y = 0; y < num_of_spaces; ++y) {
printf(" ");
}

}
}
int main(void)
{
int x = 0;
for (x = 0; x < 4; ++x) {
draw_cube();
}

return 0;
}


>>55550665
I was assuming this person was instructed to do it a specific way.. So I'm keeping the answer in line with it.
>>
>>55547930

Federal laws state you have a right to own a gun, not a right to shoot it. When and how you can shoot it depends on your state.

That said, if allowed to take a strictly literal word meaning interpretation of my state's justifiable homicide laws, that might include shooting someone who is trying to blackmail you. But you'd have a difficult time proving that happened at all in court anyways. Also, I'm not a lawyer, Anon doesn't live in Washington, and to my knowledge, nobody uses the literal word meanings of laws precisely because that same law I am quoting if taken in a strictly literal sense would allow a person to shoot someone for committing tax evasion if they were committing it in their presence.
>>
>>55550770

Ruby, it was a tongue-in-cheek "Haha, America!" kind of thing. No need to analyze it.
>>
We really need to get rid of the cockroach infestation in /dpt/.
>>
File: Untitled.png (82 KB, 2268x1071) Image search: [Google]
Untitled.png
82 KB, 2268x1071
I want to improve this pasta, to make it more accurate and more helpful. The goal is to help newbies started on picking a starting language to learn programming. It is not meant for people who already know programming, or people asking about "what language to get a job".

Please criticize. Thanks.
>>
>>55550830
?
>>
>>55550953

>>55550781
>>55550770
>>55547930
>>
im learning python right now, specifically web scraping with beautiful soup and im trying to get some data from html with really shit formatted tables

so I have a list with a structure of

[a1,b1,c1,d1],[a2,b2,c2,d2],[a3,b3,c3,d3]

etc, and what i'm trying to do is save the a and b values of each index of the list into a seperate variable

how would I go about extracting these values?

it's code for a runescape world data scraper, i scraped all the table rows first with

data_rows = soup.findAll('tr')[1:]

which skips the header row since i don't need it, then I find all the standard cell data with

server_data = [[td.getText() for td in data_rows[i].findAll('td')]
for i in range(len(data_rows))]
>>
Your comments, suggestions, and criticisms for >>55550915 are appreciated.
>>
>>55549553
nub is O(n^2) in the number of elements in the list, since it has to support things which are Eq but not Ord. It is possible to do nub in O(nlogn) for ordered types.

IIRC sum is not strict, so you may want to write a custom strict sum (using bang patterns or seq)
>>
>>55550915

Perhaps you might reference a few of the up and coming languages as options?

Like Rust, Go, Hack, Scala, and Julia.
>>
>>55551018
Good suggestion. I will add it to another copy/pasta, for higher level learners.
>>
File: 1452471092796.png (372 KB, 1280x720) Image search: [Google]
1452471092796.png
372 KB, 1280x720
>>55551018
>Hack, Scala, and Julia
>>
>>55551117
something something stick to it and don't switch because an autist told you to
>>
>>55550980
a = [1,2,3]
b = [4,5,6]
c = [7,8,9]
d = [a,b]
z = zip(*d)

#z is a generator with tuples
next(z)
# (1,4,7)


>>
>>55551134
Good advice. Thank you.
>>
>>55551133

Hack is backed by facebook there is a good chance it'll grow and get adopted.

Scala is starting to be used by companies like twitter, linkedin, and intel.

Julia is gaining traction in the scientific community.

I do not see how your reaction image is warranted?
>>
>>55551018

>Rust
>Go
Maybe

>Hack
I know of no one other than Facebook that uses this.

>Scala
Eh... just use regular Java. Or Clojure.

>Julia
I don't know of anyone who uses this.
>>
>>55551170
put a (deprecated) symbol next to Perl
>>
File: Untitled.png (81 KB, 1322x1064) Image search: [Google]
Untitled.png
81 KB, 1322x1064
This is the other pasta I am working on. Not polished, just starting. This is aimed at people who know basic programming concepts, but want a language that will get them a starting programming job.

Please let me know your comments, suggestions, and criticisms regarding this as well.
>>
>>55544625
Ugh. Two days have passed and I still cannot decide what should I use: React, React+Redux or Angular2.
I've lost track of JS ecosystem. What do cool kid use nowadays?
>>
>>55551238
all i know is the app i use that uses Angular is dog shit slow.
>>
>>55551190
>>55551195

I believe we may of accidentally synced up here..

Julia is starting to be used where people would previously use python + Numpy / Pandas or R.

I do agree though that Hack might have a very tough time seeing adoption. It's trying to replace php and is a big risk for companies that are used to running the old "stable" dinosaur that every web dev can grudgingly work with.
>>
>>55551299
Why would you use Julia and not Python?
>>
>>55551233
>no mention of FP
>Go, Scala, Erlang, Hack won't land you a job
b8
>>
>>55551320
first time of hearing hack.
Go? i've never seen it in any job postings.
Scala? i've seen it once or twice
Erlang? never
>>
>>55550915
dynamic programming ≠ dynamic typing
structured programming is not the opposite of dynamic typing (Ruby and Python have both)
neither are really "families" since the languages other than C are all the same paradigm (imperative+oop) and the languages are all based on the same core design
>>
>>55551320
b8
>>
>>55551358
Facebook is the main user of Hack, but I've heard of other companies moving to it from PHP
Go's huge with Google, Twitch.tv, etc.
Scala is the most popular (lots of JVM users with startups developing for Android or people moving away from Java)
Erlang is probably used at any major telecom company, ISP, phone carrier, etc.
>>
>>55551362
What is the best nomenclature that I can use to group the Python family and the C family?
>>
>>55551393
Imperative programming languages.
>>
>>55551313

Baseline Julia performs very close to C in terms of speed without the extra work you'd need in python.

Julia is built with parallelism in mind. The base functions / types reflect this.

Packages in Julia come directly from github and doesn't have the schism issue that python2 / python3 has.

Anyway, at this point in time your comparing a mature fully realized language and a infant language. There is plenty of time for any issues to be resolved and for the ecosystem to catch up.
>>
>>55551402
Separately, not together!
>>
>>55551420
Compiled vs Interpreted.
Statically typed vs dynamically typed.
>>
>>55550915
the use of dynamic languages in academia is more about flexibility and convenience than it is about their being suited for heavy computations (because in fact it's the opposite that's true; compiled static languages are better suited for heavy math because their compilers are capable of heavier optimization).
>>
If you can't figure out what this regex does, you need to leave /g/ forever.

/^[a-zA-Z0-9- ]*$/
>>
>>55551433
This means taking Java out. But thank you, I will use this.

>>55551442
Thank you. Will edit accordingly.
>>
>>55551442
and in this case "academia" is fairly limited to heavily computational tasks that are mainly composed of arithmetic. basically, other than AI or ML research and a number-crunching for experimental data Numpy/Scipy aren't useful
>>
>>55551299
Hack doesn't seem to be actively trying to replace php. Facebook mostly made it to assuage the horrors of having a shitton of PHP code (see also: javascript & flow). It's a major advantage of hhvm, so it was made public.
>>
What is everyone's favorite language for certain types of projects?
>>
>>55551478
Everyone's favorite language for certain types of projects is indisputably Java.
>>
Rate:

So you want to learn programming?

Pick a starting language. For beginners, there are generally two recommended "programming families" that you can choose to start learning:
-Dynamically typed/interpreted programming languages, such as: Python, Perl, Ruby
-Statically typed/compiled programming languages, such as: C, C++, C#

These are amongst the most popular languages in use worldwide, including 4 from the top 5. Both approaches are perfectly fine, and well-documented.
-Dynamically typed programming may be a bit more flexible, convenient, and forgiving, and thus it is more popular in academia.
-Statically typed programming is a bit more suited for making general applications, and thus it is more popular in industries.

Cannot decide? Flip a coin.

If you choose dynamically typed/interpreted programming, you may want to start with Python. It is very easy to pick up. Here are some good sources:
http://www.learnpython.org/
http://learnpythonthehardway.org/book/
http://www.codecademy.com/en/tracks/python

If you choose statically typed/compiled programming, you may want to start with C, then pick up C++. C is very well documented, and teaches many universal programming concepts. C++ is based on C, and adds new concepts. Sources:
For C:
http://www.cprogramming.com/tutorial/c-tutorial.html
http://c.learncodethehardway.org/book/
http://www.learn-c.org/

For C++:
http://www.learncpp.com/
http://www.cplusplus.com/doc/tutorial/
http://www.cprogramming.com/tutorial/c++-tutorial.html
http://en.cppreference.com/

>BUT I WANT MORE SOURCES!
Read: https://wiki.installgentoo.com/index.php/Programming_resources

>BUT I WANNA START WITH [language x] INSTEAD!
Sure, if you like. But the languages shown above are considered very good for beginners.

>BUT I WANNA MAKE iPHONE GAMES!
Learn Objective C and/or Swift.

>BUT I WANNA MAKE ANDROID GAMES!
Learn Java.

>BUT I WANNA MAKE A COOL WEBSITE!
Learn HTML, CSS, and Javascript.

>BUT I WANNA MAKE PC GAMES!
Learn patience.
>>
>>55551462
agreed. and i prefer to work with C++ even for AI/ML work for performance reasons, but i don't speak for the community, and i don't personally require the flexibility that some surely do.
>>
>>55551497
>http://learnpythonthehardway.org/book/
>http://c.learncodethehardway.org/book/
Don't do this to people.
>>
>>55551478

Quick and dirty small projects: Python
Performance dependent: C or C++
Brain Gui Apps / Tools: C#
Fun personal projects: Rust or C++
Scripting engine embedded in a project:: Lua or a small lisp dialect.
Bare Metal: Minimal amount of native assembly language necessary for the architecture mixed with C.

Web dev: Fuck this I do not enjoy it at all.
>>
>>55551569

When auto complete turns a misspelled "boring" into Brain. What the hell?
>>
>>55551523
This. Zed Shaw is a hack.
>>
I've been interested in generating colourschemes for a while now.

I know that the basic way of generating a colourscheme is to generate a rainbow circle and then superimpose a sample vector (see http://paletton.com/ or adobe kuler)

But does anyone have any idea how https://coolors.co/ works?
>>
>>55551523
>>55551625
Any specific objections, alternatives?
>>
>>55551696
k&r c or c primer plus
>>
>>55551696
"Learn C the hard way" is literally just "copy my poorly explained code".
He also got BTFO about his incorrect statements about K&R, and got all butthurt and put this thing up about it.
>>
>>55551625
Why is he a hack?
>>
>>55551696
Add https://isocpp.org/faq to C++, it has lots of good stuff.

But other than that, online tutorials will never teach anyone as much as real books.
>>
>>55551737
What wrong statements about K&R?

He was right about recommending stuff like bstr to people. C strings are the cause of security holes.
>>
>>55551756
I really can't be bothered going into an in depth critique when someone else has already done it much better than I could:
http://hentenaar.com/dont-learn-c-the-wrong-way
>>
>>55551706
>>55551737
>>55551746
>>55551779
Noted. Thank you.
>>
>>55551738
Go to bed, Zed, you faggot.
>>
>>55551818
K. N. King C Programming A Modern Approach is good too.
>>
please help

http://paste.debian.net/780814/

why is my globalvariable loading my predefined default in translate_projection?
>>
>>55551839
I have too many sources for C/C++ now. I think that is enough. Sorry.
>>
>>55551879
>http://paste.debian.net/780814/

Looked at your link. Saw that it was using llvm and instantly closed the tabbed. Good luck anon llvm is painful to deploy and use!
>>
>>55552017
yep llvm is a pain, thanks though!
>>
>>55551497
>Learn Objective C and/or Swift.

Why would you recommend to learn Objective-C? Apple is shifting clearly towards Swift. It is clearly the more advanced and more modern language.
>>
>>55551879
>expires: 2016-07-14 07:58:48
>trying to hide your shitty llvm code from the world

https://paste.debian.net/780820/

get fukt m8 haha
>>
>>55552143
wow anon, you showed him
>>
>>55552093
It is the older language, with more examples and tutorials. Once Swift becomes the sole language behind iOS applications, we can remove Objective C.
>>
>>55552158
I did showed him m8 rite
>>
A basic kernel with "multiprocessing" for my operating systems class.
>>
Is <threads.h> worth learning?

it looks promising
>>
>>55552175
you showed me
now show me why my globalvariable is not working as intended
>>
>>55550915
>>55551233
If anyone has more suggestions, comments, and criticisms for these two copy/pastas, please let me know. Thank you.
>>
>>55545875
Why the fuck would you learn C++. Learn Rust.
>>
>>55552222
nice digits
>>
>>55545875
What anime does this Qt come from
>>
>>55552222
dub quads speak the truth
>>
>>55552222

Why not both? C++ is mature and has decades of library support, Rust is sexy and immature.
>>
>>55552222
>>55552268
Quads speak truth.
>>
>>55552222
All the cool libraries are in c++.
>>
File: mad max.png (158 KB, 322x198) Image search: [Google]
mad max.png
158 KB, 322x198
>>55552222
WITNESSED
>>
>>55552278
Rust has a 0 overhead to C/C++
Thread replies: 255
Thread images: 24

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.