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

/dpt/ - Daily Programming Thread

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 343
Thread images: 34

File: dpt hime.png (518KB, 974x974px) Image search: [Google]
dpt hime.png
518KB, 974x974px
old thread: >>58967869

What are you working on, /g/?
>>
FIRST FOR TRAPS!
>>
>>58973326
Dammit. These 14 year olds tick me off.
>>
>>58973311
knowing c# helps
>>
>>58973412
>.NET
>C#
>Java
>gamedev
Funny.
>>
File: debug2.png (58KB, 758x1008px) Image search: [Google]
debug2.png
58KB, 758x1008px
>>58973204
get(&b,1) does not do it, method will add a \0. So I did pic related. No change.
>>
>>58973412
>unity
>gamedev
>>
Hey /g/ I could use some help.
I wrote this for the programming challenge yesterday (pascal's triangle) but it had some issues. Thread is dead now but I still want to see if I can make this work.
Basically I tried to do things the hard way, not using the obvious solutions (addition or recursion) but instead using the factorial rule to calculate each number: (n choose k) = n! / (k! * (n-k)!)
Factorials are huge obviously so I used some large integers (~512000 bits max). To divide them I used a shift-and-subtract algorithm which I read about here: http://www.plantation-productions.com/Webster/www.artofasm.com/DOS/pdf/ch09.pdf (page 22) and adapted it to work with multi-word ints.
Now I'm getting the right answers MOST of the time but it fails for some values. At least in (n choose k) where n>17 k=8, and n>51 k=24, maybe others too. The quotient is missing a few bits and it's leaving a remainder somehow which shouldn't happen.

Code here >>> http://pastebin.com/PXRD3VgM see function binom_cc
>>
File: 2017-02-16-180122_905x253_scrot.png (25KB, 905x253px) Image search: [Google]
2017-02-16-180122_905x253_scrot.png
25KB, 905x253px
>>58973326
I need to make a matrix M = [[1,2,3][4,5,6]] from an empty Z = [] list but I'm struggling
>>
>>58973526
[[i*3+j+1 for j in range(3)] for i in range(2)]
>>
>>58973526
Fuck you use GNU Octave
>>
>>58973445
std::ios::binary
>>
>>58973578
ah, it works

I'll analyse what you did there, not sure I get it

thanks
>>
>>58973578
List comprehensions were a mistake
>>
>>58973589
Fuck me sideways. It works and it could just be my problem. Thank you anon.

Nobody should denigrate this place ever again.
>>
>>58973326
I WANT TO GIVE HIME A REACHAROUND WHILE I POUND XIR BUNGHOLE AND SHOVE MY TONGUE DOWN XIR THROAT
>>
>>58973666
>XIR
Learn proper English, faggot.
>>
>>58973326
Trying to strip street names with things like suites/building numbers into two parts, kind of a living hell with all these stupid variations.
>>
>>58973635
They're super convenient, easy to write, and very readable. What do you not like about them anon?
>>
File: varg.jpg (114KB, 762x464px) Image search: [Google]
varg.jpg
114KB, 762x464px
Stop posting animu pictures.
>>
>>58973326
what a qt :3
>>
File: burdened_by_genius.jpg (9KB, 242x250px) Image search: [Google]
burdened_by_genius.jpg
9KB, 242x250px
>>58973635
>tfw too smart to understand list comprehensions
>>
>>58973923
It's "to smart", not "too smart", you fucking retard.
>>
File: b49.gif (1MB, 680x680px) Image search: [Google]
b49.gif
1MB, 680x680px
I'm making a g.a.m.e!
>>
Is learning COBOL a good move regarding the amount of legacy code and the lack of COBOL programmers ?
>>
>>58973996
Sure.
>>
>>58973996
Nobody under the age of 40 is hired to touch COBOL code, don't fall for the meme.
>>
>>58973996
Honestly? Yes. You can make up to $300 000/year while a Java junior is around $80 000
>>
>>58973972
What does g.a.m.e. stand for?
>>
>>58973412
Asset flips that run like dog crap are ruining the game industry.
>>
>>58974136
Green is my pepe
>>
>>58974165
no they aren't
>>
This was the closest thread I could find, anyone reckon they can take a crack at explaining how creating a plugin for https://sourceforge.net/projects/fourchan-dl/ works?
>>
>>58974340
Made steam get rid of green light.
>>
>>58974357
that's great, now i can pay my way onto steam
>>
>>58974408
No one wants your trash, thanks.
>>
>>58974408
I thought it was a refundable fee?
You're supposed to get it back if your software deliverable actually runs correctly and isn't shovelware trash.
>>
Guys im trying to learn C and i'm having lots of difficulties. I really need something like a dictionary for C that features and explains all the things in it. All statements like "if" to minor things like the "++" thing, for example. Does that exist?
>>
File: text-based.png (31KB, 737x503px) Image search: [Google]
text-based.png
31KB, 737x503px
>>58973326
I'm working on a text-based adventure game.
>>
>>58975046
Those aren't even exclusive to C.
Go learn your programming fundamentals, they're nearly identical in every language.
>>
>>58975046
Read a book.
>>
>>58975046
You seem like a retard so I'm not going to help you
>>
>>58975090
I wish more programming teachers would say this.
>>
UI/Window.cpp:25:37: error: ISO C++ forbids taking the address of a bound member function to form a pointer to member function. Say ‘&UI::Button::testCallback’


why does gcc want me to say things?
like, out loud? how will that help my crumbling confidence in my programming abilities?
>>
>>58975046
You're looking for C's i__ s___n_a__
>>
Does this regex met the specified requirements?

>write a regex that matches the following rules:
>number is a zero
>number must end in a digit
>the number can have underscores e.g 1_0, 2_3, etc

examples
>1_1_1 is the number 111
>1_0_0_0 is the number 1000
>2_3 is the number 23
>0_1 is the number 1
>1_______0 is the number 10
>[0-9]_ is invalid

my solution
[0]|([1-9]|["_"]|[1-9])*
>>
I am writing a recursive function in C as the following.

foo(struct Node *n){
if (n == NULL) n = // some shit to allocate memory and give values
}

But when it exits function it remains unmodified. I tried a bunch of stuff but all would either not work or give segmentation faults somewhere.

And how do i post as code segment like in >>58973578

?
>>
>>58975172
Tfw just took computer theory test, can understand the regex
>>
>>58975062
Check kneesocks
>>
>>58975172
You can't parse '1000' with that.
>>
Who are you quoting?
>>
>>58975046
Read a book called "The C programming language" and don't come back until you finish it
>>
>>58975199
If 4chan detects code it automatically formats it as such. Yours is just really fucking shitty
>>
>>58975255
right, thanks
the last part must have the zero digit
[0]|([1-9]|["_"]|[0-9])*
>>
File: text-based-2.png (36KB, 737x503px) Image search: [Google]
text-based-2.png
36KB, 737x503px
>>58975253
>>
>>58975199
PASS BY REFERENCE!!!!

you are welcome
>>
>>58973505
>bump for help
anyone..?
>>
>>58975275
please go back to /jp/ if you can not properly use "who are you quoting?"
>>
>>58975312
Check panties
>>
>>58975172
You don't need to put quote marks or brackets around single characters. Also, you can't handle zeroes following other digits. Finally, you've redundantly repeated the pattern '[1-9]'.

As a side note, your spec and examples contradict one another with regard to underscores:
In your spec, you state the you can't have underscores.
In your examples, you seem to remove underscores from the input. You cannot do this with a simple matching regex (as in your code); you need to use a replacement string also (in this case it would be epsilon: the empty string).
>>
Is autocompletion a meme? Or worst, a crutch?
>>
File: text-based-3.png (44KB, 737x503px) Image search: [Google]
text-based-3.png
44KB, 737x503px
>>58975335
>>
>>58975352
basically, this is a regex implementation to parse integers in java
in java, you can have
int a = 1_000_00;
but not
int a = 1_;
>>
>>58975365
It's a godsend in "library languages" where every function is 30 characters long and nobody bothers to memorize any of it because they have the intellisense to do the heavy lifting.
>>
>>58975390
Install gentoo
>>
>>58975365
> Doesn't want to use tool which makes programming significantly faster and easier because "muh superiority"

Grow the fuck up and use tools to get shit done!
>>
is there any language that allows this?

if value < num or > num2

instead of

if value < num or value > num2
>>
new challenge when?
>>
>>58975352
>>58975300
You now have a redundant pattern '[1-9]' in your regex.

Here is a regex that satisfies your spec: [0-9]+.
Here is a solution that satisfies your examples:
echo $input | grep '[0-9_]*[0-9]' | sed 's/_//g'
>>
>>58975420
python

you can have for example
a = 10
if 5 < a < 20:
print ('it works')
>>
>>58975420
if you do this a lot, just write a macro
#define is_between(n, a, b, op) ((n) > (a) op (n) < b))
>>
in c++, is there a first in first out container which only accepts unique elements and preserves entry order
>>
>>58975406
>>58975418
What if you're editing some code on default vim and are stuck because your reliance on such tools has crippled your ability to function independently?
>>
>>58975479
Default Vim has C-p
>>
>>58975479
yes, that happens
don't use autocomplete.
>>
>>58975405
At this point you are not parsing anything, you are just manipulating string representations of numbers.

The output string (e.g., '1000') will still need to be parsed into whatever data type you are using to represent numbers (e.g., int64) after you have manipulated the string representation.

If you are doing this for Java (which I'm not familiar with), I would point out that you will certainly need to handle negative integers, rationals (using decimal point notation), and it may support exponent shorthand or similar (e.g., 5e10).
>>
>>58975479
>>58975502

Use emacs tramp mode

next question
>>
>>58975454
if $input = "1_"
it yields 1 and it shouldn't

because 1_ is not a valid number
>>
File: 1246657863612.jpg (83KB, 550x825px) Image search: [Google]
1246657863612.jpg
83KB, 550x825px
>It's another episode of a C# toddler trying out Rust
https://www.youtube.com/watch?v=sv9fTlU7SCA
>>
Is it possible to only display certain integers in an Array?

Say my array is = {
{0 , 0 , 1 , 0},
{0 , 1 , 0 , 1};
is it possible for me to make an output of
1
1
?
>>
>>58975479
>What if you're trying to cut down a tree with a kitchen knife and are stuck because your reliance on a chainsaw has crippled your ability to function independently?
>>
>>58975542
is it a 2D array? you are missing a bracket
>>
>>58975560
yeah, my bad.
>>
>>58975518
>If you are doing this for Java (which I'm not familiar with), I would point out that you will certainly need to handle negative integers, rationals (using decimal point notation), and it may support exponent shorthand or similar (e.g., 5e10).

yes, i have to do for rationals and other types but the question i asked was for integers *only*.
>>
>>58975542
printf("1\n1\n");


Yes, it is.
>>
>>58975534
That's a good point, I forgot that grep checks for matches against substrings, not just whole strings.

You will need to add '^' and '$' anchors to the pattern.

>>58975573
If it is for integers only then you will have to handle negative integers.
>>
File: hqdefault.jpg (21KB, 480x360px) Image search: [Google]
hqdefault.jpg
21KB, 480x360px
>>58975540
Fizzbuzz
>>
>>58975542
No, unfortunately there is not. What you are describing is one of the great unsolved problems in computer science.
>>
>>58975567
if you are looking for a programmatic solution, use a nest of while loops and compare for 1 at the current index, print it, then break out of the loop.
>>
>>58975554
>y-yeah, of course I can program, but first let me just load these plugins, my dotfiles, and search stackexchange
>>
>>58975588
>If it is for integers only then you will have to handle negative integers.
no, right now i'm only worried about representing numbers i specified before

to handle negatives integers, i just have to add a "-" sign
>>
>>58975588
>>58975640
So you only want naturals, not integers?

To clarify, this is what we have so far, assuming that we are going with your examples but not your spec. It works for integers as well as naturals.
echo $input | egrep '^-?[0-9_]*[0-9]$' | sed 's/_//g'


I would reiterate that you are *not* parsing this into a numerical datatype, you are literally just manipulating string representations.
>>
>>58975636
>Entirely unaware of how real shit gets done in software development.
>Ideal editor is cat
>>
>>58975477
No, but it shouldn't be hard to create one yourself.

template<typename T>
class anons_queue {
private:
std::unordered_set<T> items;
std::queue<T> ordered_items;
public:
void push(T item) {
if (items.count(item) == 0) {
items.insert(item);
ordered_items.push(item);
}
}

void pop() {
items.erase(ordered_items.front());
ordered_items.pop();
}
}


Obviously need to add some more stuff, probably a peek function, constructor, etc. If you're storing big objects, you'll probably want to store by shared_ptr rather than by value in the two structures, but the above would be good enough for ints or anything else small like that.
>>
>>58975735
>cat
>not flipping the bits with a magnetised stick man comic
>>
>>58975663
>I would reiterate that you are *not* parsing this into a numerical datatype, you are literally just manipulating string representations.
yes

i'm only working with positive integers so the - signal is not necessary for now

so basically the regex would be
'[0-9_]*[0-9]'


again, this regex would have to successfully parse any positive integer in java
>>
>>58975773
That regex matches your example code, however it will succeed on '_1', which you may not want.

Remember that some systems default to matching against all substrings, not just the whole string.
>>
>>58975817
yeah you're right.

i was looking the specific implementation of this, i mean, how does java parses the numbers

but can't find anything
>>
>>58975817
The other thing I need to mention is that that regex will allow an unlimited number of leading zeroes, e.g., '00001' and '000'.

When you start adding these constraints, I would say that multiple-pass regexes are more readable than embedding the logic into a single regex.
>>
Reminder that AT&T syntax is hot garbage
>>
>>58975839
Java will use an actual context-free grammar *parser*. You are using regular expressions: not to parse the number, but to manipulate its string representation.
>>
I'm trying to get Macintosh Programmer's Workshop 3.5 to try out Retro68 but every copy I've found is corrupted in some way and no emulators, real Macs, or even the mighty Linux can mount it. Does anyone know where I can get a proven working copy of it? Or if possible, how to directly get the Universal Interfaces C headers? Apple has washed its hands and deleted its FTP server.
>>
import random
import time

words = ["Just........", "another.....", "Python......", "babby......."]

curwords = [0] * 80
curpos = [0] * 80

try:
for line in range(300):
line = ""
for col in range(80):
if curwords[col]:
curpos[col] += 1
if curpos[col] == 12:
curwords[col] = 0
curpos[col] = 0
line += " "
else:
line += words[curwords[col] - 1][curpos[col]]
else:
if random.random() < 0.01:
curwords[col] = random.randint(0, 3)
curpos[col] = 0
line += words[curwords[col] - 1][0]
else:
line += " "
time.sleep(0.1)
print line
except KeyboardInterrupt:
pass


Why is this working for all the words listed, except the last one in the list? Regardless of list length, content and string length, it only prints the first character of the last word, but the full word as it should for all others.
>>
>>58975877
but i'm building a mini-java compiler, anon

all this work is to parse integers when i compile my programs
>>
>>58975899
>using Python
I recommend you
import _JAPH_
.
>>
File: Untitled.png (360KB, 1016x638px) Image search: [Google]
Untitled.png
360KB, 1016x638px
im making a file browser for nintendo ds with build-in support for viewing and converting the most common file types
right now im working on the .nsbmd viewer
>>
>>58975877
Here is a version that disallows leading underscores and strips leading zeroes:

echo $input | egrep '^-?([0-9][0-9_]*)?[0-9]$' | sed -e 's/_//g' -e 's/^0*\([0-9]\+\)/\1/


Note that the replacement pattern now uses backreferences, which mean that the expression is no longer guaranteed to run in linear time.
>>
>>58975897
nvm, I found the CIncludes and RIncludes at a mirror under "Tool-Chest/Interfaces-Libraries/Interfaces".
>>
>>58975995
Very impressive!

>>58975899
What are you even trying to do?
>>
>>58976014
My bad: since the backreference was only in the replacement, rather than the pattern, the time guarantees are fine.
>>
>>58975865
It's a bit easier to understand, but for some reason I can't write in it.
>>
>>58975906
Then you need to write a parser! And you need to understand the difference between numbers and their decimal string representation! I've been saying this all along!

Also, this: >>58976014
>>
>>58976034
Run it and see for yourself.
>>
>>58973505
bump
>>
>>58976044
leal 8(%edx,%eax,2), %eax
>easier to understand
>>
File: ps3.jpg (11KB, 400x300px) Image search: [Google]
ps3.jpg
11KB, 400x300px
>have ps4
>have gf
>have photos of anus

how can i put my photos on the ps4 on the internet. can i try with SQL ad json?
>>
>>58973326
how can i submit a formula after i clicked on login? which bring me to another site with different url. this is what i got so far

#!/usr/bin/env python3
import libxml2
from selenium import webdriver

browser = webdriver.Firefox()
browser.get('https://example.com'')


button = browser.find_element_by_xpath("//img[contains(@src, 'get the fucking button')]/parent::a")
button.click()
>>
>>58975390
I fucking love the idea of this game already.
>>
Can someone help me convert this code into haskell? I'm having a hard time grocking error handling.

def errorTest() { 
print("Hello!")
try {
raise("you fucked it up!")
print("Wont happen")
} catch (Exception e) {
print(e)
}
print("We did it!")
}

What I've tried so far:
errorTest = do  
putStrLn "Hello!"
catchIOError
(do
(ioError . userError) "you fucked it up!"
putStrLn "Wont happen")
(\e -> do
print e)
putStrLn "We did it!"

errorTest2 = do
putStrLn "Hello!"
flip catchIOError (\e -> do
print e)
(do
(ioError . userError) "you fucked it up!"
putStrLn "Wont happen")
putStrLn "We did it!"

errorTest3 = do
putStrLn "Hello"
(do
(ioError . userError) "you fucked it up!"
putStrLn "Wont happen")
`catchIOError` (\e -> do
print e) >> do
putStrLn "We did it!"

but I hate all of them.
>>
File: java.png (217KB, 860x1571px) Image search: [Google]
java.png
217KB, 860x1571px
Professor wants us to make a 2d array maze and create a program that traverses it using the right-hand algorithm. The issue here is that my professor is basically giving us a skeleton of methods and doesn't really allow any freedom in producing the program. I practically have to think like my professor to make this project. Am I being an idiot?
>>
>>58976427
generally you shouldn't use exceptions, but here's one way

(<!!>) = catchIOError
userIOError = ioError . userError

errorTest = do
putStrLn "Hello!"
(userIOError "you fucked up!") <!!> print


points

>if you use something a lot (or if it's verbose) bind it elsewhere, e.g. ioError . userError

>\e -> do { print e }
(do { x }) = x
(\e -> f e) = f
>>
>>58976438
Not allowing freedom in how you implement a solution to a problem is pretty dumb. God forbid he think's there is one "proper" way, and that it is his... God have mercy on you at that point.
>>
>>58976427
>>58976572
another way would be this

use operator sections to flip functions, e.g.
(`mod` 3) = flip mod 3

>(`catchIOError` print) $ do
>>>ioError (userError "you fucked it up!")
>>
>>58973326
Is there any way I can make this more efficient or is it fine? Basic factorial calculator btw
#include <stdio.h>

int factorial(int num)
{
if (num <= 0) {return 0;}
if (num == 1) {return 1;}
return num * factorial(num - 1);
}

int main(int argc, char const *argv[]) {
int user_input = atoi(argv[1]);
printf("%d\n", factorial(user_input);
return 0;
}
>>
File: 1486648350212.png (475KB, 691x801px) Image search: [Google]
1486648350212.png
475KB, 691x801px
>>58975995
I love you anon
>>
>>58976687
>assert(factorial(0) == 1);
>>
>>58975995
What lang?
>>
File: Lauren5.jpg (108KB, 813x1200px) Image search: [Google]
Lauren5.jpg
108KB, 813x1200px
I just got an awesome idea for a private project.

An app called Guesstimate. Using different approaches, (Big Data, Data Mining, Web Crawling) it estimates various parameters for any geographical location in the World - what kind of person you would be, if you lived there.

I start with simple, linear parameters, like gross and net wage, life expectancy, for any geographic point in the world. These things these can be guesstimated easily be just opening Wikipedia, but then I will move on to non-linear estimates, like the most likely political views, religion, education, job, self-reported happiness, main worries and joys in life, sentiments on various topics, and the like ...


Have you ever seen something similar already?
>>
Is there any way to cross-compile from Linux or Windows to Mac OS 8? I'd found Retro68 but it's completely uncompilable on any modern Linux distro for some reason.
>>
>>58976034
>>58976716
thanks

>>58976734
C++, Qt for GUI, OpenGL for 3D.
>>
>>58976774
Does it take into account how we are right now? Otherwise that's no different from looking at country averages on Wikipedia.
>>
>>58976687
I think it's going to be faster if you do it iterative instead of recursive
also 0! == 1 so you can do with one test
>>
>>58975540
Why on earth is he making fizzbuzz this overly complicated?
>>
>>58976812

I wish to dig far deeper than just national averages for common parameters, albeit even that would have some (limited) use, if you can select and compare only the parameters that interest you.

I am talking averages for any point on the globe, for non-linear things.
>>
>>58976687
#include <stdio.h>
#include <stdlib.h>

int factorial(int sum, int num)
{
if(num == 0) return 0;
if(num == 1) return sum;
return factorial(num * sum, num - 1);
}

int main(int argc, char *argv[])
{
int user_input = atoi(argv[1]);
printf("%d\n", factorial(1, user_input));
return 0;
}

This does TCO with the gcc -O2 flag and avoids the potential stack overflow in your code
Or you can just do it iteratively
>>
>>58976901
>0!=0
nice programm
>>
File: fug.jpg (16KB, 600x450px) Image search: [Google]
fug.jpg
16KB, 600x450px
>>58976913
>>
>>58976824
>>58976901
is this kind of iteration decent?
#include <stdio.h>

int factorial (int num)
{
int i;
if (num <= 1) {return 1;}
for (i = num; i > 1; i--) {
num *= i - 1;
}
return num;
}

int main(int argc, char const *argv[]) {
int user_input = atoi(argv[1]);
printf("%d\n", factorial(user_input));
return 0;
}
>>
>>58973635
When the alternative is people littering their code with calls to map, filter and reduce, I think list comprehensions win from a readability perspective.
>>
File: typesgood.png (145KB, 876x569px) Image search: [Google]
typesgood.png
145KB, 876x569px
Is there a funnier man in programming talks than Gary Bernhardt? I've been listening to his stuff today and I'm actually laughing out loud:

https://www.destroyallsoftware.com/talks

(Except Wat is kind of cringey, but I attribute that to the time it was made in.)
>>
>>58976901
>This does TCO with the gcc -O2 flag
You're lucky you're using gcc on x86/amd64... the arm-eabi one seems to be completely random regarding TCO...
>>
>>58976963
yeah
you could also just do
int r=1;
do{
r*=num--;
}while(num);

instead of the for loop, but I don't think it'll make much of a difference in performance
>>
>>58977121
I think I'll use the do-while because it's shorter
>>
>>58976963
>assert(factorial(-1) == NAN);
>>
>>58977175
how do you use assert? I'm quite a beginner.
>>
>>58973326
I finally finished my project. It lets you multiply up to 16 integers together, and it would be easy to extend it to support more due to the flexible design that I invented.
It uses a cool recursive approach to minimize code duplication - a bit hard for newbies to grok, but elegant if you really understand it.
It might not look like much but it took a while to design and type it all in.

The main purpose wasn't for any practical reason - obviously this isn't going to be that useful for most projects with more modest integer multiplcation needs - but I am going to include it in a resume and hopefully catch the eye of a smart recruiter who can understand the simplicity and elegance.

int multiplyInts(int a, int b) {
return a*b;
}

int multiplyInts(int a, int b, int c) {
return a*multiplyInts(b, c);
}

int multiplyInts(int a, int b, int c, int d) {
return a*multiplyInts(b, c, d);
}

int multiplyInts(int a, int b, int c, int d, int e) {
return a*multiplyInts(b, c, d, e);
}

int multiplyInts(int a, int b, int c, int d, int e, int f) {
return a*multiplyInts(b, c, d, e, f);
}

int multiplyInts(int a, int b, int c, int d, int e, int f, int g) {
return a*multiplyInts(b, c, d, e, f, g);
}

int multiplyInts(int a, int b, int c, int d, int e, int f, int g, int h) {
return a*multiplyInts(b, c, e, d, f, g, h);
}

int multiplyInts(int a, int b, int c, int d, int e, int f, int g, int h, int i) {
return a*multiplyInts(b, c, d, e, f, g, h, i);
}

int multiplyInts(int a, int b, int c, int d, int e, int f, int g, int h, int i, int j) {
return a*multiplyInts(b, c, d, e, f, g, h, i, j);
}

int multiplyInts(int a, int b, int c, int d, int e, int f, int g, int h, int i, int j, int k) {
return a*multiplyInts(b, c, d, e, f, g, h, i, j, k);
}

int multiplyInts(int a, int b, int c, int d, int e, int f, int g, int h, int i, int j, int k, int l) {
return a * multiplyInts(b, c, d, e, f, g, h, i, j, k, l);
}

//Omitted similar cases for brevity

>>
>>58977137
Haha, you got trolled really nicely right there.

*puts arm around your shoulder*

Anon, my friend, just because something's shorter, doesn't mean it's better. What matters is readability. Take my words to heart, you will reflect on them once you are older and more advanced in your coding skills.

*pats you on the back*
>>
>>58977195
imo it's more readable too, I'm aware that shorter doesn't always equal better
>>
>>58974567
Really? I thought it was a one-off payment per game.
If it is like that, damn son, that is much better. I was beginning to worry my shitty murder mystery puzzler would never see the light of day.
Which will never happen anyway cause I am a lazy fuck. if anything, I am more likely to make that hentai game for /d/.
>>
>>58977189
I hope you didn't write that out by hand just for this shitpost
>>
File: bde.png (219KB, 827x1050px) Image search: [Google]
bde.png
219KB, 827x1050px
>>58977189
>>
>>58977250

that is some creature from Evangelion, but I forgot what it is
>>
>>58977185
It crashes your program when the comparison fails. That might sound stupid but it's very useful for debugging.
>>
>>58973505
re-re-bump
>>
>>58977189
I actually did make a function to do slightly similar things to this.

megaAND, at least 2 or more values.
Checks if any n+1 values are equal to n.
MegaDAND (dual AND), takes pairs of values and checks if they are equal to each other ,if any fail, it falses.
megaOR, compares every n+1 argument to n.
I cannot remember what I used them for again.
I think I used megaAND for collision detection that wasn't based on rectangles.
megaOR, I think I used that to check for empty variables quickly because I am a lazy cunt.

Also made a notMod, binary not modulus.
Not sure what I did with that. Probably some rotation shit, or some other value.
>>
I told terry davis that I was shizophrenic and wanted to learn programming, and he told me that "no, weak minds fail"

Wtf. What an asshole.
>>
>>58977469
He is true. If you weren't programming from the age of 9, you're shit.
>>
>>58977469
Because he actually thinks that he is indeed in a CIA prison and his internet isn't the real Internet. He doesn't know he has a disease! I mean he does, but it seems certain logical connections his brain can't make, he misses them.
>>
>>58977483
>starting at 9

You fucking dingus, you're supposed to be hacking the FBI mainframe in your first years
>>
>>58977508
I was too poor to get a computer at 11 months.
Had to wait several years before I got my Vtech laptop with BASIC.
>>
So I have a string formatted for xml. When I print it out in java it points it out to the console looking just fine. However in my jsp when I use c:out it prints it into one big blob. How did I get it to do the indentation properly for a pretty print?
>>
Finally figured out how to break out of OOP and use global variables everywhere:

public class Global {

public static Object param_1;
public static Object param_2;
public static Object params_3;

public static int add() {
return (Integer) param_1 + (Integer) param_2;
}

public static int subtract() {
return (Integer) param_1 - (Integer) param_2;
}

public static void main(String[] args) {
Global.param_1 = 2;
Global.param_2 = 5;
System.out.println(Global.add());
System.out.println(Global.subtract());
}

}
>>
>>58977457
Hopefully you used arrays or vararg and not hard-coding a bunch of different prototypes.
>>
>>58977618
I know jack shit java/jsp shit and a bit about webdev, but I guess your control characters are eaten by html.
Try to print it inside a <pre> block and check results. Overload the pretty formatter to spout html and/or html control characters; spam &nbsp;.
I think it will be something along these lines.
>>
I figured out how anyone can get better at programming I joined a sports team and play 3 times a week and it has given me more than enough energy to program. Before I couldn't even finish small projects now I ended writing my own C++ bootloader and kernel
>>
>>58977189
This was to replace the old version, which was a bit less elegant.

//Deprecated
/*
int multiplyInts(int a, int b) {
return a*b;
}

int multiplyInts(int a, int b, int c) {
return a*b*c;
}

int multiplyInts(int a, int b, int c, int d) {
return a*b*c*d;
}

int multiplyInts(int a, int b, int c, int d, int e) {
return a*b*c*d*e;
}

int multiplyInts(int a, int b, int c, int d, int e, int f) {
return a*b*c*d*e*f;
}

int multiplyInts(int a, int b, int c, int d, int e, int f, int g) {
return a*b*c*d*e*f*g;
}

int multiplyInts(int a, int b, int c, int d, int e, int f, int g, int h) {
return a*b*c*d*e*f*g*h;
}

int multiplyInts(int a, int b, int c, int d, int e, int f, int g, int h, int i) {
return a*b*c*d*e*f*g*h*i;
}

int multiplyInts(int a, int b, int c, int d, int e, int f, int g, int h, int i, int j) {
return a*b*c*d*e*f*g*h*i*j;
}

int multiplyInts(int a, int b, int c, int d, int e, int f, int g, int h, int i, int j, int k) {
return a*b*c*d*e*f*g*h*i*j*k;
}

int multiplyInts(int a, int b, int c, int d, int e, int f, int g, int h, int i, int j, int k, int l) {
return a*b*c*d*e*f*g*h*i*j*k*l;
}

int multiplyInts(int a, int b, int c, int d, int e, int f, int g, int h, int i, int j, int k, int l, int m) {
return a*b*c*d*e*f*g*h*i*j*k*l*m;
}

int multiplyInts(int a, int b, int c, int d, int e, int f, int g, int h, int i, int j, int k, int l, int m, int n) {
return a*b*c*d*e*f*g*h*i*j*k*l*m*n;
}

int multiplyInts(int a, int b, int c, int d, int e, int f, int g, int h, int i, int j, int k, int l, int m, int n, int o) {
return a*b*c*d*e*f*g*h*i*j*k*l*m*n*o;
}

int multiplyInts(int a, int b, int c, int d, int e, int f, int g, int h, int i, int j, int k, int l, int m, int n, int o, int p) {
return a*b*c*d*e*f*g*h*i*j*k*l*m*n*o*p;
}
*/
>>
>>58977871
Yes, improving your physical condition usually improves your mental as well. I should do more sports too.
>>
>>58977878
Fuck. Use an array dude.
>>
>>58977878
>not
return multiplyInts(a, multiplyInts(b, multiplyInts(c, d)));
>>
>>58977189
Another cool thing about this design is that it's very extensible and flexible - I also needed to make an addInts function for my math library, so I just copied and pasted the multiplyInts code, and did search and replace of '*' with '+', and 'multiply' with 'add'.

Pretty smart. That's the difference between a Software Engineer and a code monkey.
>>
>>58977900
This anon is trolling.

By responding seriously to this behavior, you have apparently been trolled.
>>
>>58977914
Fuuuck. You got me, I just can't take it how efficient and elegant is anon's solution.
>>
factorial -> int (int n)
#result = 1
#i.for (1,n+1)
result = result * i
-> result

print (factorial (5))

>2017
>not using rix-lang
>>
File: expression.png (991KB, 960x720px) Image search: [Google]
expression.png
991KB, 960x720px
Tabs or spaces?
>mfw code with both
>>
>>58978098
Spaces
Set editor to automatically convert all tabs to spaces
>>
>>58978098
Spaces.
>>
>>58978098
8-width tabs in C (and most everything else).
4-width spaces in Python.
>>
>>58976901
>
int sum

>factorial
>sum
wew
>>
>>58977902
This is actually a good point. I think that looks more elegant. I spent the last half hour or so refactoring my code to incorporate your suggestion, and I think the results speak for themselves.

//Here is some of the more impressive code.

int multiplyInts(int a, int b, int c, int d, int e, int f, int g, int h, int i, int j, int k, int l) {
multiplyInts(l, multiplyInts(k, multiplyInts(j, multiplyInts(i, multiplyInts(h, multiplyInts(g, multiplyInts(f, multiplyInts(e, multiplyInts(d, multiplyInts(c, multiplyInts(b, a)))))))))));
}

int multiplyInts(int a, int b, int c, int d, int e, int f, int g, int h, int i, int j, int k, int l, int m) {
multiplyInts(m, multiplyInts(l, multiplyInts(k, multiplyInts(j, multiplyInts(i, multiplyInts(h, multiplyInts(g, multiplyInts(f, multiplyInts(e, multiplyInts(d, multiplyInts(c, multiplyInts(b, a))))))))))));
}

int multiplyInts(int a, int b, int c, int d, int e, int f, int g, int h, int i, int j, int k, int l, int m, int n) {
multiplyInts(n, multiplyInts(m, multiplyInts(l, multiplyInts(k, multiplyInts(j, multiplyInts(i, multiplyInts(h, multiplyInts(g, multiplyInts(f, multiplyInts(e, multiplyInts(d, multiplyInts(c, multiplyInts(b, a)))))))))))));
}

int multiplyInts(int a, int b, int c, int d, int e, int f, int g, int h, int i, int j, int k, int l, int m, int n, int o) {
multiplyInts(o, multiplyInts(n, multiplyInts(m, multiplyInts(l, multiplyInts(k, multiplyInts(j, multiplyInts(i, multiplyInts(h, multiplyInts(g, multiplyInts(f, multiplyInts(e, multiplyInts(d, multiplyInts(c, multiplyInts(b, a))))))))))))));
}

int multiplyInts(int a, int b, int c, int d, int e, int f, int g, int h, int i, int j, int k, int l, int m, int n, int o, int p) {
multiplyInts(p, multiplyInts(o, multiplyInts(n, multiplyInts(m, multiplyInts(l, multiplyInts(k, multiplyInts(j, multiplyInts(i, multiplyInts(h, multiplyInts(g, multiplyInts(f, multiplyInts(e, multiplyInts(d, multiplyInts(c, multiplyInts(b, a)))))))))))))));
}
>>
>>58977691
>babbys first static objects
>>
>>58977189
>>58977878
>>58978269
The ultimate CS Grad/Pajeet code
>>
>>58978269
Dude you need to document your code
>>
>>58978269
template<typename T> T multiply(T... n) { return n * ...; }

this is the last time I'll feed any trolls
>>
>>58978541
>c++
>>
>>58978541
This is poor advice. Templates balloons the binary size and compilation time.
>>
>>58978269
why not something like this?
#include "stdlib.h"
#include "stdio.h"

int multiplyInts(int* values, size_t count) {
if(values == 0) return 0;
int total = values[0];
for (size_t i = 1; i < count; i++) {
total *= values[i];
}
return total;
}

int main(int argc, char* argv[]) {
int nums[] = {5,5,5};
printf("This is the product: %d\n", multiplyInts(nums, 3));
return 1;
}
>>
>>58978500
That's a very good point. I think the documentation makes it look a lot more professional, which is a big plus.

/*
****************
* multiplyInts
* Take a and multiply it by b and c and d and e and f and g and h and i and j and k and l
* then return the result
****************
*/

int multiplyInts(int a, int b, int c, int d, int e, int f, int g, int h, int i, int j, int k, int l) {
multiplyInts(l, multiplyInts(k, multiplyInts(j, multiplyInts(i, multiplyInts(h, multiplyInts(g, multiplyInts(f, multiplyInts(e, multiplyInts(d, multiplyInts(c, multiplyInts(b, a)))))))))));
}

/*
****************
* multiplyInts
* Take a and multiply it by b and c and d and e and f and g and h and i and j and k and l and m
* then return the result
****************
*/

int multiplyInts(int a, int b, int c, int d, int e, int f, int g, int h, int i, int j, int k, int l, int m) {
multiplyInts(m, multiplyInts(l, multiplyInts(k, multiplyInts(j, multiplyInts(i, multiplyInts(h, multiplyInts(g, multiplyInts(f, multiplyInts(e, multiplyInts(d, multiplyInts(c, multiplyInts(b, a))))))))))));
}

/*
****************
* multiplyInts
* Take a and multiply it by b and c and d and e and f and g and h and i and j and k and l and m and n
* then return the result
****************
*/

int multiplyInts(int a, int b, int c, int d, int e, int f, int g, int h, int i, int j, int k, int l, int m, int n) {
multiplyInts(n, multiplyInts(m, multiplyInts(l, multiplyInts(k, multiplyInts(j, multiplyInts(i, multiplyInts(h, multiplyInts(g, multiplyInts(f, multiplyInts(e, multiplyInts(d, multiplyInts(c, multiplyInts(b, a)))))))))))));
}

>>
>>58978671
Kek
>>
>>58978541
Absolutely disgusting.

#include <stdarg.h>

int multiply(int n, ...)
{
int res = 1;
va_list args;

va_start(args, n);

for (int i = 0; i < n; ++i)
res *= va_arg(args, int);

va_end(args);

return res;
}

#define array_len(arr) (sizeof(arr) / sizeof(arr[0]))
#define multiply(...) multiply(array_len(((int[]){ __VA_ARGS__ })), __VA_ARGS__)
>>
>>58978664
just use stdargs.h
>>
>>58978566
    mov ecx, [n]
@@: pop ebx
mul ebx
loop @b
>>
>>58973326
I am working on a compiler for a language I am working on..it will be an interpreted language similar to Python but without the whitespace nonsense and will feature somewhat verbose syntax. Think C# meets Python in a way.

Of course it won't be used for anything but it's a fun project to learn off of.
>>
>>58978722
I generally work with arrays
>>
>haskell game dev
https://www.youtube.com/watch?v=UhEXd0dGlmQ
>>
File: programming-languages.jpg (129KB, 640x369px) Image search: [Google]
programming-languages.jpg
129KB, 640x369px
Reminder
>>
>>58978981
>Go, Python, Ruby, Javascript
Get out of here, you filthy webdev.
>>
>>58979012
None of those languages are exclusively for webdev.
>>
>>58978981
Haskel and Lisp are below Python and Javascript? What kind of horrific hierarchy is this?
>>
[Reposted from /sqt/ because I'm kind of lost]
I'm following this tutorial to send an email through python:
https://docs.python.org/2/library/email-examples.html

I have the following code, but I'm not sure why I get an error:
import smtplib
# Import the email modules we'll need
from email.mime.text import MIMEText
import socket

#Open a plaintextfile to read (contains only ASCII chars)
test_text = "Test_email.txt"
fp = open(test_text, 'rb')

#Create a plaintext message
msg = MIMEText(fp.read())
fp.close()

me = "[email protected]"
you = "[email protected]"

msg['Subject'] = "The contents of the file %s" %test_text
msg['From'] = me
msg['To'] = you

print "Senging mail now!"
s = smtplib.SMTP('127.0.0.1', 8000)
s.sendmail(me, [you], msg.as_string())
print "Mail has been sent!"
s.quit()


The code raises the error:
socket.error: [Errno 61] Connection Refused


What should I do to send an email? I tried looking up what I should put for "localhost", but when I plug in my IP address, I get "Connection Timed Out"
>>
In c++, what exactly is the difference between nullptr and NULL?

I know NULL is just a macro for 0, but what is nullptr? I can't explain to myself why i should use nullptr instead of NULL.
>>
>>58979032
A non-memelang hierarchy

What do you say to an employed haskell programmer? "I want fries with that"
>>
>>58979057
It's just more bloat and duplicate functionality they decided to pile onto the language.
>>
>>58979057
My question is who uses NULL for anything BUT pointers?
>>
>>58978719
this is even worse. god C is such an ugly language
>>
>>58979146
I've never used va_args except as a wrapper for for sprintf family functions.

It only exists in the C spec to let printf function the way it does.
>>
>>58979057
NULL is an ugly old implementation-defined macro
nullptr is a nice type-safe keyword
>>
>>58979146
I still have no idea why the dude won't just loop over his data and be done with it
>>58978664
>>
>>58979146
The macro is a little messy, but that's just there so the user can use the function without needing to manually list how many arguments there are.
Other than that, I don't see what's wrong with it.

>>58979160
Sure, 99% of the time, va_list is just used to call v*printf functions, but it's a useful enough feature to possibly allow some interesting things.
>>
>>58978664
Compare that code to this enterprise-quality code: >>58978671

Which to you think is going to catch the interviewer's eye?
But even if the code weren't written for my portfolio, for loops are functionally equivalent to goto statements, which I consider harmful.
>>
File: ohwhatajoy.jpg (24KB, 400x400px) Image search: [Google]
ohwhatajoy.jpg
24KB, 400x400px
>syntax highlight
>autocomplete
>autolookup
>autoindent
>autocompile
>autofuck

When will you learn, that there is only one way?
>>
>>58978269
>not currying
Nice first try though.
#include <functional>
#include <iostream>

using ull = unsigned long long;
using oneArg = std::function<ull(ull)>;
using twoArg = std::function<oneArg(ull)>;
using threeArg = std::function<twoArg(ull)>;
using fourArg = std::function<threeArg(ull)>;
using fiveArg = std::function<fourArg(ull)>;
using sixArg = std::function<fiveArg(ull)>;
using sevenArg = std::function<sixArg(ull)>;
using eightArg = std::function<sevenArg(ull)>;
using nineArg = std::function<eightArg(ull)>;
using tenArg = std::function<nineArg(ull)>;
using elevenArg = std::function<tenArg(ull)>;
using twelveArg = std::function<elevenArg(ull)>;
using thirteenArg = std::function<twelveArg(ull)>;
using fourteenArg = std::function<thirteenArg(ull)>;
using fifteenArg =std::function<fourteenArg(ull)>;

oneArg mult2(ull a) { return [a](ull b) { return a * b; }; }
twoArg mult3(ull a) { return [a](ull b) { return mult2(a * b); }; }
threeArg mult4(ull a) { return [a](ull b) { return mult3(a * b); }; }
fourArg mult5(ull a) { return [a](ull b) { return mult4(a * b); }; }
fiveArg mult6(ull a) { return [a](ull b) { return mult5(a * b); }; }
sixArg mult7(ull a) { return [a](ull b) { return mult6(a * b); }; }
sevenArg mult8(ull a) { return [a](ull b) { return mult7(a * b); }; }
eightArg mult9(ull a) { return [a](ull b) { return mult8(a * b); }; }
nineArg mult10(ull a) { return [a](ull b) { return mult9(a * b); }; }
tenArg mult11(ull a) { return [a](ull b) { return mult10(a * b); }; }
elevenArg mult12(ull a) { return [a](ull b) { return mult11(a * b); }; }
twelveArg mult13(ull a) { return [a](ull b) { return mult12(a * b); }; }
thirteenArg mult14(ull a) { return [a](ull b) { return mult13(a * b); }; }
fourteenArg mult15(ull a) { return [a](ull b) { return mult14(a * b); }; }
fifteenArg mult16(ull a) { return [a](ull b) { return mult15(a * b); }; }

int main() {
std::cout << mult16(1)(2)(3)(4)(5)(6)(7)(8)(9)(10)(11)(12)(13)(14)(15)(16);
}
>>
>>58979250
>This is idiomatic C++
How do people defend this language?
>>
>>58979235
What is this code used for?

I just can't handle the fact that somebody would write such a repetitive series of functions.

Abstraction has been hammered down my throat over the years and your code hurts me.
>>
Is it better to use an array instead of a link list since all the data in an array is contiguous for faster access times?
>>
>>58978671
function overloading was a mistake
>>
>>58979280
Making you reconsider a career in software development
>>
How does /g/ feel about me declaring variables before all logic ala ANSI C?
>>
>>58979325
feels good
>>
I'm trying to modify the [s4s] dubs checker script to highlight both post numbers (in bold) and backlinks (subscript xx) to fit my userstyle. The desired result is what is in pic related.

The thing is, I'm trying to loop through all backlinks (while recording the last one, just like with postNums) and attributing a "BLdubsHighlight" class that's already defined and working on the code, but it never enters the backlink loop.

Is this a bug?

  // grabs all backlinks
var bLink = document.getElementsByClassName('backlink');
// iterate all of them
for (var i = window.lastBLNo; i < bLink.length; i++)
{
// get the post number
console.log(i);
var no = bLink[i].textContent;
// check for dubs
if (no.charAt(no.length - 1) = no.charAt(no.length - 2))
{

// highlight it
bLink[i].className += ' BLdubsHighlight';
}
}
window.lastBLNo = bLink.length; //last backlink we checked
>>
where can i find in my computer the class that implements
import java.util.regex.Pattern;


linux, btw

i just want to see how do they do those things
>>
>>58979325
It makes code harder to read, and was a terrible thing to enforce in ISO C90, so nobody ever enforced it.
>>
>>58979342
I forgot to mention that if I run line by line in the web-console it works just as desired.
>>
>>589793
hdd
>>
>>58979305
Yes. Unless you are adding/removing tons of elements to the front or middle of the list.
>>
File: 2017-02-16-215806_463x204_scrot.png (21KB, 463x204px) Image search: [Google]
2017-02-16-215806_463x204_scrot.png
21KB, 463x204px
>>58979342
>>58979357
[spoiler]Woops[/spoiler]
>>
>>58979235
#include "stdlib.h"
#include "stdio.h"

/*
* @author: Anon Anonovich
* @version: 0.1
* @inputs:
* values: the list of values to be multiplied together
* count: the number of values passed in
* @returns: integer product of values
* @created: 16/02/17
*/
int multiplyInts(int* values, size_t count) {
if(values == 0) return 0;
int total = values[0];
for (size_t i = 1; i < count; i++) {
total *= values[i];
}
return total;
}

int main(int argc, char* argv[]) {
int nums[] = {5,5,5};
printf("This is the product: %d\n", multiplyInts(nums, 3));
return 1;
}


Anyone can document their code...
>>
>>58979350
You should use better variable names if you genuinely believe this.
>>
Programming success is 99% effort 1% genius agree?
>>
File: Screenshot_2017-02-17_01-05-20.png (393KB, 1122x844px) Image search: [Google]
Screenshot_2017-02-17_01-05-20.png
393KB, 1122x844px
now I can play albums and tracks from bandcamp

WOO! WOOO!

even paid and unstreamable ones can be streamed with the power of scraping
>>
>>58979386
do you maintain a list of links or just download them?
>>
>>58979370
>not checking if values is null
>needing a count parameter
See me after class
>>
>>58977732
Oh yeah obviously used that. I'm not that stupid/trolling.

On a related note, I did a similar thing in Autohotkey to add pseudo-objects. Mainly because the newest version with objects is horrible as fuck and so hacky that it is pointless using it.
New function format was basically function(command, params, debug="") style.
problem here: these are single instance static objects. Or horrible levels of wrapper code, multi-instance.

Another better format that didn't create single-instance objects was just one parameter that combines these 3 in to one with a separator.
This allowed me to do stuff like:
bob:=class(bob)
class(data){
extract data (command, params and debug)
do command with params, handle any debug flags
recompress data, return it
}
This allowed for multi-instance objects in a hacky way, but it was tidy, it worked well without having to have loads of weird wrapper code to deal with it.
Still much better than the official shit Lexikos added. Holy FUCK AHK_L is awful.
Working with objects in AHK_L is clunky as fuck.
AHK2 is basically abandonware. All updates were from last November. RIP.
>>
You have no excuse not to write a one-line comment above your functions explaining what they do.

You have no excuse not to write tests for your code.
>>
File: 1470341172739.jpg (45KB, 333x333px) Image search: [Google]
1470341172739.jpg
45KB, 333x333px
>>58979325
>tfw writing c like Ada makes it a slightly less shit ordeal
>>
>>58979345
I don't think you can look at the source code of oracle java, but the openJDK source can be viewed online, I don't know if it is installed by default
>>
File: spain-fs8.png (582B, 402x402px) Image search: [Google]
spain-fs8.png
582B, 402x402px
>>58979430
why would i do that, bro?

do you even job security?
>>
>>58979430
>one line comments
should do that, but I try and make the function name verbose enough to make it self-explanatory anywhere in the code

>write tests for your code
I managed to break SDL2_net in some unit tests, and I wouldn't have figured this out had I just ran it normally
>>
>>58977189
>"recursive"
I'm triggered
>>
>>58979430
If nobody else has been doing it for 15 years or however long this web p.o.s. has been going why should I?
>>
>>58979430
Which is better:

>void fooer(int bar, int baz)

>//foos bar and baz
>void fooer(int bar, int baz)

Agreed on testing though.
>>
>>58979489
That doesnt explain what it does though

int copy_memory (int, void*, void*);[/ ode]
>"cmon guys its really obvious what this function does by its name, it copies memory!"
>>
Are you really suppose to test for things like nulls and shit in every one of your functions? Is there a trick or easy way to do it or do you just have your test conditions right at the start of the function
>>
>>58979522
Just dont use null without it being explicitly stated when a function will return/accept null, and if you use an external library then check the documentation carefully and check null if its a potential output
>>
>>58979522
Enjoy getting fired when your shit constantly crashes
>>
>>58979522
If you're writing embedded code, yes.
Otherwise, memory management is the OS's problem.
I shouldn't have to check if the OS ran out of memory because it's supposed to keep giving me more, even when there's no physical memory left.
>>
>>58978981
POO?
>>
>>58979522
If you are implementing a library function, or you are consuming a library you didn't write, then yes you do have to program defensively. Assume you are being fed garbage data full of NULLs and overflows. Check everything.

If you are writing an internal function, which is only called by your code and only calls your code, you can be a bit more lax but keep in mind that failing hard and fast is always better than letting things continue with subtle bugs.
>>
>>58979412
You can use the program to search bandcamp just like you do on their website. URLs to audio streams are downloaded as you add songs or albums to the queue. Apparently restrictions on streaming are only on the level of the interface on their website. If you can scrape the URL to the stream, you can listen to it.
>>
>>58979057
Don't you have to cast NULL iN c++? Why would you want that? Just always use nullptr in C++ code and never use NULL, anyone who tells you otherwise is talking about a different language (C) and you should ignore then.
Also I think you can create function overloads for nullptr literal arguments in C++, which would be neato, but I'll have to double check that
>>
>>58979345
http://hg.openjdk.java.net/jdk9/jdk9/jdk/file/bdf3d3a46863/src/java.base/share/classes/java/util/regex
>>
File: ferris tea.png (502KB, 486x481px) Image search: [Google]
ferris tea.png
502KB, 486x481px
>>58979522
I test for nulls in my own functions because I don't like writing if statements and sometimes I'll just pass in arguments that might be null and the function should just abort instead of segfaulting.

I've been trying to get out of this habit by testing for null in ternary statements within the function call. I still don't like if statements.
>>
can the GNU toolchain still target DOS?

i'm curious about very low level C programming, i thought targeting DOS could be a nice exercise
>>
>>58979700
You're looking for DJGPP.
>>
>>58979700
Yes.
Here's a build script: https://github.com/andrewwutw/build-djgpp
>>
>>58979745
will it cross-compile though?
>>
>>58979756
oh, i'll be a bit clearer

what i meant is for example the host system would be linux or even windows, and target DOS
>>
>>58979770
>>58979756
see
>>58979755
>>
>>58979756
>>58979770
No, it runs on DOS and produces DOS binaries. You would want to use a dosbox setup for dev, so that you can edit source files/run codegen scripts/etc on the host and run the compiler under DOS.
>>
>>58979595
there is a type called nullptr_t
nullptr is the only valid instance of nullptr_t
you cannot declare anything of nullptr_t
you can create functions that take nullptr_t but parameter must be anonymous
for example, when implementing a smart pointer you can implement the case when setting the smart pointer to nullptr
>>
>>58979755
>>58979782
oh i think this is precisely what i'm looking for, thank you
>>
>>58979784
You really don't want to -O3 -flto on DOS.
>>
>>58979587
in general you can open the memory of a process (be it flash, silverlight or whatever) and you can find stream urls that work :)
>>
>>58979817
Yep, but my program is also a music player and it can currently stream from youtube, soundcloud and bandcamp.

In the future I'll probably also add deezer and spotify, and maybe torrents.
>>
>>58979802
Why?
>>
>>58978757
>C# meets python
holy shit, I want to see that
>>
How do I pronounce Gnu?
>>
>>58979876
ganoo
>>
>>58979876
guhnoo
>>
>>58979700
A while back I was working on a C++14 library to do all the low-level stuff in DOS. I really should get back to that. I got to the point where I could assign lambdas with captures as interrupt handlers, fun stuff.

>>58979857
gcc takes a TON of memory and it's extremely slow without multi-threaded compiling (make -j 12)
>>
>>58979869
Check out Rix on github
>>
I have invented a new sorting algorithm.

Well, actually I've just figured out a heuristic which makes a merge sort on the kind of data we're dealing with much faster (basically exploiting some easily estimated properties inherent in the data to estimate run sizes).

I'll be putting it in a paper so my question is: should I be an arrogant twat and give it a name (or even a gigantic twat and name it (myname)sort)? Or should I just say I'm using a heuristic which works like so and so?
>>
>>58979916
you never decide the name of something yourself
>>
>>58979522
Use asserts
>>
>>58979916
If it is substantial an increase in speed?
Be an arrogant fuck. Be as arrogant as possible.
You just beat out well-established benchmarks.

if it is context-dependent improvements? Just write a paper describing it with a quirky name to it and no arrogance.
>>
>>58979916
Call it mootsort.
>>
File: 1482586276695.png (3MB, 2048x1714px) Image search: [Google]
1482586276695.png
3MB, 2048x1714px
>tfw to intellegent for C++
>tfw need to use Rust
>>
>>58979984
literallywho?sort
>>
File: trapezoid.png (89KB, 1331x398px) Image search: [Google]
trapezoid.png
89KB, 1331x398px
>>58979934
Not even Tai's Model?

>>58979957
Yeah the heuristic is just a by-product of the sort of data that's being studied, very specific to the area of application. It's not going to be its own paper, just something attached to a paper dealing with those data sets.
>>
>>58980027
What's your IQ big guy?
>>
>>58980080
87
>>
>>58979984
hiroshimasort
>>
>>58980092
Damn, nice. 74 here. Mostly do Python and Java.
>>
>>58980107
60 here. I code in C++
>>
>>58979342
>if (no.charAt(no.length - 1) = no.charAt(no.length - 2))
>=
>literally babby rookie's mistake
brb killing myself.
>>
300
D
>>
>>58980128
this will give a runtime exception anyway. no big deal
>>
>>58980147
300mm D?
Wouldn't that just be uncomfortably large?
How to you even wear pants?
>>
I'm currently trying to wrap my head around OOP, as a concept. I've been using it for years, and understand the benefits of code reuse, encapsulation, decoupling, etc. that has the compiler to enforce a paradigm of "you, the user, cannot interface with system structures except by this set of defined methods". Which is universally a good thing in my opinion.

But my concern is, I feel like these are side effects and/or consequences of the Object paradigm, rather than the goals. You don't have to have a 'class' to say "interact with this code in this way only". You don't need to group problems into discrete entities to be able to do that. (Not to mention that many problems CAN'T be grouped that way, or at least not efficiently).

What's the point of OOP? And can there exist access restrictions and encapsulation outside of the Object paradigm?
>>
>>58979844
Been seeing the progress for a while now, looking much cleaner! Keep up the good work anon
>>
>>58980128
>no -wall -werror
oh wait
>>
>>58980057
just call it the Heuristically Optimized Merging Order sort
>>
>>58980258
>javascript
>>
>>58980251
Thanks!
I've gotta work on finally cleaning up my code a little, it's slowly getting out of control. I find myself implementing new features before polishing old ones because it's much more fun.
>>
>>58980226
>You don't have to have a 'class' to say "interact with this code in this way only". You don't need to group problems into discrete entities to be able to do that
You're absolutely correct.

Here is an interesting video with some criticism of OOP: https://www.youtube.com/watch?v=QM1iUe6IofM
It's kind of long, though.
>>
>>58980226
>What's the point of OOP?
w-well i-it... y-you encapsulate your inherited methods under th-the... uh... m-manageable state flux...
>>
>>58980279
If you don't mind me asking, it's a web based application right? So pure js/jquery?
>>
>>58980057
>Tai's Model
What a hilarious episode.
"Tai's method is the trapezoidal rule. ... Although we do not have a first reference, it is our understanding that the trapezoidal rule was known to Isaac Newton in the 17th century."
>>
>>58980304
I'm using Electron, so it's mostly javascript/jsx (with React.js for frontend).
>>
>>58979792
You can also use it to overload functions to catch a null pointer dereference before it happens, right?
void f(int* a) { *a = 5; }
void f(std::nullptr_t) { throw an_exception { }; }

At least I think that should be possible.
>>
>>58980326
>I'm using meme, so it's mostly meme/meme (with meme.meme for frontend).
Please leave, webdev scum.
>>
File: enough.jpg (94KB, 440x521px) Image search: [Google]
enough.jpg
94KB, 440x521px
>>58980057
>223 citations
>>
>>58980340
Hey man, what have you written in C or whatever you use recently?
>>
>>58978719
Absolutely disgusting (Lisp ahead):
(* <your numbers>)
>>
>>58980360
I haven't written any programs recently.
I've been pondering the design of a C-like programming language lately, though.
>>
>>58980326
I'm always confused as to how to handle the audio... Just a library right?
>>
>>58980340
This is a desktop application. I've learned javascript and Node.js specifically for this project. Why would you arbitrarily restrict yourself from learning additional programming languages or techniques?

>>58980391
react-sound module handles it
>>
File: 1441684460338.jpg (92KB, 1280x720px) Image search: [Google]
1441684460338.jpg
92KB, 1280x720px
>>58980407
>This is a desktop application
>Javascipt for desktop/server
Jesus christ, that is even worse.
>>
>>58980381
I don't really understand the webdev meme, I enjoy coding in C and doing some js on the side is it just about the scripting?
>>
>>58980226
OOP is just a simpler way of modelling some interactions and optimizing time spent developing.
However, you CAN use too much OOP.
Those that try to force OOP everywhere is why OOP gets so much hate.

Same shit with Goto. A very useful command abused by retards lead to its hatred.
Some people so openly hate it, despite EVERYTHING relying on the foundation of it, JMP.
There's trillions of Gotos every second on a typical CPU.
But even if we don't go that far, switches, ifs, continue, next, break, all stealth gotos.
Hell, the very structure of functional enclosures are one.

Don't let retards stop you from using something very handy in the proper scenarios.
Use whatever you feel happy with for the job.
>>
>>58980226
Here you have a resource about criticism to OOP:
http://www.paulgraham.com/noop.html
>>
>>58980416
Care to elaborate why?

My program is making many concurrent requests and has to handle concurrent i/o, I found that Node.js has been written with this in mind so it was a great choice. HTML/CSS are also excellent for creating GUIs.
>>
>>58980423
Webdevs are some of the worst and stupidest posters on here.
They have their own containment general.

>>58980438
>OOP is just a simpler way of modelling some interactions
That is incredibly naive. Actual examples of OOP end up WAY more complicated than they need to be.
Don't pull any of your "no true scotsman" bullshit. OOP encourages you to program in a retarded way.
>>
>>58980475
>>58980475
Javascript is a braindead language, with many very retarded design decisions.
People just tolerate it on the web because they basically have no choice.
Why would you want to bring that cancer onto the desktop, when you can actually use a sane langauge?

Also, enjoy your callback hell.
>>
>>58980483
You don't need to program like a retard, though.
People that have to force OOP in to every scenario are the problem.
This was never its intention. Just some fucking faggots forming a cult around objects.

I've never sat up at night unable to sleep because the OOP code I wrote was horribly over-modelled and complicated.
Why? Because I don't write code that is 15 fucking inheritance layers deep.
Retards do that.
The most useful aspect of OOP is that you can create a DISCRETE entity that you can work with on its own. Strictly no inheritance involved there. No extends, no faggotry. Just a class and methods.
Inheritance-less OOP is best OOP.
>>
>>58980463
Paul Graham's a goofus. Have you ever read On Lisp? It's a chore. Whole book's dedicated to the "amazing" things you can do in Lisp, but never actually goes beyond the level of small example. No wonder Lisp is never used for anything.
>>
>>58980540
Watch the video I linked in >>58980291
>>
>>58980516
>Why would you want to bring that cancer onto the desktop, when you can actually use a sane langauge?

Not him but the situation with UI frameworks on the desktop is rather fucked. There's no sane library/framework that does GUI right. The best you can get is Qt which also has a fuck ton of its problems, unless you go with QML, but in that case you'll be using a web-based renderer as well. HTML and CSS are great tools for making the interfaces, and at this point, nothing even comes close so I can understand his choice.
>>
>>58980516
I wanted to use HTML and CSS to create a GUI, Electron was the easiest way I know of to accomplish that. I'm using javascript because I've never worked with it, and wanted to learn it. It's an awful, messy language but it's also useful to know it when searching for jobs. React.js is a great framework with a large library of reusable components.

I will enjoy my callbacks, thanks.

It took some learning but I'm using them pretty fluently now, it's a decent way of handling concurrency.
>>
>>58980570
desu, UI design can be a pretty unpleasant task, and just making one with HTML/CSS is probably one of the easier approaches - although you're introducing a ton of unnecessary complexity to your program by doing so.
>>
for (var i = 0; i<10; i++) {
document.getElementById("foo" + i).onclick = someFunc(i);
}


Will this result in the objects foo0, foo1, foo2, etc having their onclick value set to someFunc(0), someFunc(1), someFunc(2), etc or will they have someFunc(i)?

If the latter, what is the idiomatic/standard method to get the former behaviour in JS?
>>
>>58980570
what's the difference between atom and electron?
>>
>>58980560
2 minutes in and I already hate it. Sounds like one of those preachy fucks.
I'll still watch it.
>>
>>58980623
[insert shit physics joke here]
>>
>>58980623
An election is one of the components of an atom.
>>
>>58980623
Atom is a text editor, Electron is the shell that Atom is built on top of, Electron is also a framework that can be used freely without the Atom part.
>>
Ny trĂ¥d?
>>
>>58980666
>making a text editor that needs a fucking browser engine in order to run
way to go guys what an improvement over vim and emacs I mean fucking seriously what is wrong with you
>>
>>58980438
goto is essential for programming correctly in C
>>
New thread:
>>58980706
>>58980706
>>58980706

Webdevfags, please move over the your containment thread: >>>/g/wdg
>>
File: epic_lulz.jpg (61KB, 600x582px) Image search: [Google]
epic_lulz.jpg
61KB, 600x582px
>>58980559
>No wonder Lisp is never used for anything.
Maybe the most used CAD in the world?
https://en.wikipedia.org/wiki/AutoLISP

I'm reading On Lisp tho.
>>
>>58980559
Lisp already won. That's the difference between it and the meme languages today.
>>
>>58980687
you don't have to use it
>>
>>58980699
Exactly. Which is why I laughed at the retard dev that wrote Autoit3 for saying Goto was evil and removed it.
>>
>>58980605
This is a very good question, and I would also like to know the answer.
>>
>>58980732
It exists and diverts effort from worthwhile software and for that reason it should be deleted.
>>
>>58980624
>>58980560
Nope. Closed it. Guy's a fucking moron.

He is bashing OOP LANGUAGES, not OOP.
Java is not OOP.
Java is a fucking disaster and everything I said was wrong with people doing OOP.

He also doesn't know shit about anything from those minutes I lost.
Definite sub-100 IQ for being unable to think in a similar method to how brains work.

I think I need to sleep off this level of retard. See you next thread.
>>
File: 1374574508775.jpg (29KB, 499x500px) Image search: [Google]
1374574508775.jpg
29KB, 499x500px
>>58980763
>Java is not OOP
>No true scotsman
Seriously, kill yourself.
>>
>>58980786
>muh errythin needs to be oop
Fuck off.
OOP is not one single thing. It is a blanket term.

Come back when you have an argument instead of spouting stupid fucking fallacies.
Your pompous prick friends might think you are so enlightened, shit doesn't fly here kiddo.
>>
>>58980828
>OOP is not one single thing. It is a blanket term.
So, you're saying that the definition of POO is actually useless?
I sort of agree with that.
The video very clearly stated what he was arguing against, and not the shit that fucktards think is OOP (structs + functions that work on those structs, with fancy syntax).
>>
>>58980869
Yeah, he was arguing against stupid monolithic shit like Java OOP. (yet being a massive hypocrite for liking monolithic procedural)
Protip, most OOP instances are not like that. Not even that disaster C++.

OOP is a group term that referrers to a whole range of different styles, some totally opposed to each other.
Specifically, deep inheritance chains and large functions are the problem.

5/10 made me watch half a rant of a retard on levels similar to the AutoIt developer saying Goto was evil.
Sperglords that can't think properly are not indicative of proper programming.
See Toadycode and why Toady will die before Dwarf Fortress hits V1.
>>
>>58980937
OOP has always been about the segregation and encapsulation of state into small units (objects), and having those objects communicate with each other via messages.
If you're not doing this, you're not doing OOP: you're just using your terms incorrectly.
His argument is about why doing that is bad.
>>
(1x$a)!~/^1?$|^(11+?)\1+$/
>>
>>58981787
Needs some comments
Thread posts: 343
Thread images: 34


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

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.