[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: 33
File: 1467570941060.jpg (517 KB, 1521x1076) Image search: [Google]
1467570941060.jpg
517 KB, 1521x1076
Previous Thread: >>55572999
Next Thread: >>55584087

What are you working on, /g/?
>>
What is /g/ thoughts about Mechatronics Engineering
>>
>>55578771
>write a program that when run outputs its source code

here is my solution

post yours!
#include <stdio.h>

int main()
{
FILE *fptr = fopen(__FILE__, "r");

char c = fgetc(fptr);
while (c != EOF) {
printf ("%c", c);
c = fgetc(fptr);
}
puts("");

fclose(fptr);
return 0;
}
>>
>>55578771
I'm working on a tool that will create, edit, and audit wargame armies.
>>
>>55578802
Opening the .c file for reading is cheating and not a real quine.
>>
>>55578771
Kill yourself
>>
>>55578836
himegoto
kuragehime
shounen maid
henneko
gochiusa
yuyushiki
>>
File: crystal-h[1].png (15 KB, 1368x552) Image search: [Google]
crystal-h[1].png
15 KB, 1368x552
Is this the future of programming?

Syntax of Ruby and performance of C

https://github.com/kostya/benchmarks
>>
>>55578869
I'm not gay tho
>>
>>55578874
>GC
>performance of C
nope.
>>
>>55578836
Sekaiichi Hatsukoi
Kono Danshi, Ningyo Hiroimashita
Fuyu no Semi
Uraboku
Ai no Kusabi
Yami no Matsuei
Honoo no Mirage
Monochrome Factor
Kirepapa
Haru wo Daite Ita
Sukisho
Gakuen Heaven
Okane ga Nai
>>
I've written some small applications in Winforms C# that uses XML to store configuration settings. I know it's wrong but I also use the XML as a small database at times.
What's the best way to replace the XML without relying on something overkill like SQL DB?
>>
>>55578919
>>55578898
>>
>>55578927
You could write it yourself
>>
>>55578919
shit list
>>
>>55578898
sure, bisexual :^)
>>
>>55578927
ini-style config file, write the parser yourself.
>>
>>55578940
i just googled gay anime don't tell me you actually watch that shit like an ANIME FAN ON PROM NIGHT
>>
>>55578937
>>55578972
This database will never exceed 10k 'primary keys', but the XML is getting all fuck'd up with some special characters for some reason.
Anyway, I wanted something pre-made at least, but I will look into writing it myself, thanks.
>>
>>55578874
>Syntax of Ruby
That is not a good thing.
>>
>>55578979
Repostan
>>
>>55579117
look up soft body physics if you want to simulate tits
>>
>>55578771
what is that bar code?
>>
Posted a question in /sqt/, but I'll link it here as well since it's programming-related:
>>55579323
>>
>>55579358
something like
int e[3][] = { { 1, 1, 0}, { -1, 1, 0}, { 1, -1, 0}, { -1, -1, 0}, { 1, 0, 1}, { -1, 0, 1}, { 1, 0, -1}, { -1, 0, -1}, { 0, 1, 1}, { 0, -1, 1}, { 0, 1, -1}, { 0, -1, -1}};
>>
>>55579358
just a stupid array declaration, google that shit
>>
>>55578771
Who is this cum chum?
Also thinking of reverse engineering ARM firmware and embedded OS's in the SoC's
>>
I'm stuck at something.

here's the idea in C++
template< class T>
void function(params)
{
T.getSomething();
T.doSomethingElse();
}


the class is supposed to have 2 static functions, getSomething(), doSomethingElse()
in C++ i'd call it with function<someclass>(params)
haven't tried if it works.

how do i make somehting like that in java.
>>
>>55579388
>>55579415
Alright, I was thinking I'd have to do like a pointer or some shit. Pretty stupid looking back on it.
>>
File: 26375861581.png (75 KB, 430x546) Image search: [Google]
26375861581.png
75 KB, 430x546
>>55579431
inheritance
>>
>>55579492
but i want to keep that particular function seperate from the data structure.
Is there no way to do this without inheritance?
>>
I need to get the stat values from player and pass them to Input_check but I have no clue how to do this in Python can anyone help?

class Input_check(object):
stats

def input_checker(self, x):
if x == "s" or x == "S":
print("Health:%d\nAttack:%d\nDeffense:%d\n" % self.stats)

class Player(object):
player_name = "Edwin"
player_attack = 10
player_deffense = 10
player_health = 10
>>
>>55579514
pretty sure you can't in Java
>>
>>55579529
well thanks for answering me. i guess i'll pick up some design pattern for this
>>
well, this isnt about programming but to start messing with my programming projects, i need to find some good free proxys( dont say : pay some proxy or vpn with bitcoins or someshit like that cuz its the first thing that comes to every1s mind) ,so if you have some with the format: protocol ip port, it would be really nice ;)
>>
>>55579431
public abstract class Faggot {
public Faggot() { }

private static void getSomething() { }

private static void doSomethingElse() { }
}


If getSomething or doSomethingElse are going to return something, replace the "void"s with the return type (ex: "int")
>>
what is the point of putting a retarded amount of parentheses in macros?

linux kernel's version
#define list_entry(ptr, type, memb) \
(type *) ((char *) (ptr) - (unsigned long) &((type *) 0)->memb)


my version
#define list_entry(ptr, type, memb) \
((type *)((char*)(ptr)-(unsigned long)(&((type *)0)->memb)))



am I missing something?
was the linux dev just ignorant of operator precedence rules?
>>
>>55579586
wait shit,

my version is the top one
>>
>>55579524
Under Player:
ic = Input_check()
ic.stats = (player_name, player_attack, player_defense, player_health)
ic.input_checker("s")


That is the easiest way to do it based on the code you have now, but it isn't very proper.
>>
>>55579529
>>55579563
Am I missing something? Why isn't link related sufficient? https://en.wikipedia.org/wiki/Generics_in_Java#Generic_class_definitions
>>
>>55579614
Java can't assume the type being parametrised supports those operations
>>
>>55579567
Why are you writing like a retard?
>>
>>55579567
>cuz
You ain't my cuz, nigga.
>>
"waaah, setting the GOPATH env var is hard!"

https://github.com/golang/go/issues/12488
>>
>>55579613

The person asking about this is probably new to programming. The design and question should give that away.

Mvc or Mvvm would help here.. But it's kinda hard to find a beginner friendly resource to explain for this person.
>>
File: 2016-07-15_014445.png (2 MB, 1507x1684) Image search: [Google]
2016-07-15_014445.png
2 MB, 1507x1684
A simple image viewer because I was sick of bloated shit.

It just
1) show images in an absolutely clean GUI and is able to (decently) scale them
2) show a folder view with decent looking thumbnails of the current directory

I wasn't really in the mood of doing it so the result is a shitty ~160 lines python script where the 90% of the lines are actually a call for some PyQt function/class.. but well, for sure it's pretty light and does the work.
>>
>>55579602
>>55579586
because pre-processor macros perform text-replacement before the code is compiled

A macro is just a straight text substitution.
example
Consider the macro replacement using this macro:
#define SQR(x) (x*x)

Using b+5 as the argument, SQR(b+5) will become:
(b+5*b+5), or (3+5*3+5).

Now remember your operator precedence rules: * before +.
So this is evaluated as: (3+15+5), or 23.

The second version of the macro:
#define SQR(x) ((x) * (x))


Is correct, because you're using the parens to sheild your macro arguments from the effects of operator precedence.

The thing to remember here is that you should get in the habit of always shielding any arguments in your macros, using parens
>>
>>55579693
top kek

https://github.com/golang/proposal/blob/master/design/13073-code-of-conduct.md
>>
>>55579739
I knew about the argument shielding, but I now realize that if I am to use a macro like a function that returns something, I need to parenthesize the whole thing so I can use it in an expression.
>>
File: 1465853911575.jpg (54 KB, 412x627) Image search: [Google]
1465853911575.jpg
54 KB, 412x627
>falling for the cpp meme
Why does everyone code in C++ in these shit threads??
>>
>>55579802
templates > macro abuse
>>
Went through the python course in codeacademy, now I want to learn how to use curses to create a GUI in CLI.

This is happening. Help?
>>
>>55579830
http://stackoverflow.com/questions/16137108/python-error-importing-curses-not-sure-why

rename your file
>>
>>55579907
thanks dude
>>
>>55579907
It worked, thanks.
>>
>>55579907
thanks, that did it
>>
>>55579907
wow thanks
>>
>>55579826
There's a difference?
>>
File: 1.png (68 KB, 681x612) Image search: [Google]
1.png
68 KB, 681x612
>>55579959
>>55579945
>>55579937
we did réddit!
>>
>>55578802
print open(__file__, 'r').read()
>>
>>55578802
((λ (x) `(,x ',x)) '(λ (x) `(,x ',x)))


This counts because using google is what programmers do.
>>
>>55580138
>This counts because using google is what programmers do.
?
>>
>>55578802
#!/bin/cat
>>
rate my quine:

(λx.xx)(λx.xx)
>>
File: 2016-07-15_023604.png (11 KB, 648x53) Image search: [Google]
2016-07-15_023604.png
11 KB, 648x53
>when a process eats all the memory linux will evoke a "reaper" to kill him and sacrifice his child to prevent freezing

Why so violent?
>>
why is this allowed?
why aren't multi-statement expressions described in K&R?
printf("max: %d\n", ({int x = 3; int y = 4; x > y ? x : y;}));
>>
>>55580237
Programmers like to have fun.
>>
>>55580244
It's a GNU addon.
>>
>>55580244
non-standard extension i believe
>>
>>55580279
oh

It should be in the language 2bh
it's like a lambda expression
>>
>>55580294
If you want usable lambdas, use C++.
>>
>>55580313
no, C++ is gross
>>
x: for (goto x; goto x; goto x);
>>
>>55580294
Never will be, it has some problems with C++.
https://gcc.gnu.org/onlinedocs/gcc/Statement-Exprs.html
>>
>>55580328
t. pleb
>>
>>55580332
a.c: In function 'main':
a.c:2:10: error: expected expression before 'goto'
x: for (goto x; goto x; goto x);
^~~~
a.c:2:18: error: expected expression before 'goto'
x: for (goto x; goto x; goto x);
^~~~
a.c:2:26: error: expected expression before 'goto'
x: for (goto x; goto x; goto x);
>>
I'm trying to write a function that does hexadecimal addition, but when I run the program, the for loop doesn't seem to be running... In other words: Where did I fuck up?

void addTwoVectors(std::vector<byte> vector1, std::vector<byte> vector2, std::vector<byte> result)
{

int max = vector1.size();
if(vector2.size() > vector1.size())
{
max = vector2.size();
vector1.push_back(0); //Makes both vectors the same size;
}
result.resize(max+1, 0); // Makes sure adition goes correctly by not caring about what result was previously

for(int i = 0; i < max; i++)
{
short a = vector1[i];
short b = vector2[i];

short temp = a+b;

result[i] += temp;

if(result[i] > 0xFF)
{ //If the result of the addition is > 255, then shift bits and
//Add num-255 to the ith term and num/255 to the (i+1)th term
result[i] = result[i] & 0xFF;
result[i+1]= ((result[i] >> 8) & 0xFF);
}
std::cout <<"f(i) = " << result[i];
}
}
>>
>>55580343
and this is why C++ is gross

C++ should adapt to C and not the other way around
>>
>>55580151
I just googled "rosetta code quine"
>>
>>55580363
Your compiler is broken
>>
>>55580375
Use a debugger.
>>
File: Selection_085.png (43 KB, 678x299) Image search: [Google]
Selection_085.png
43 KB, 678x299
about to add the in-app store for users to buy rare pepes
>>
>>55580396
Wow, clang is even worse.
a.c:2:10: error: expected expression
x: for (goto x; goto x; goto x);
^
a.c:2:18: error: expected expression
x: for (goto x; goto x; goto x);
^
a.c:2:26: error: expected expression
x: for (goto x; goto x; goto x);
^
a.c:2:26: error: expected ')'
a.c:2:9: note: to match this '('
x: for (goto x; goto x; goto x);
^
4 errors generated.
>>
>>55580407
I've tried using breakpoints in XCode, but it doesn't really help me get any more information... All I know from the breakpoints is that XCode realizes that there's a for-loop there, and just doesn't run it...
>>
>>55580455
Try reading the variables when in a breakpoint. Or why use breakpoints at all, just step into the function.
>>
File: pikachu.jpg (158 KB, 640x480) Image search: [Google]
pikachu.jpg
158 KB, 640x480
How do I interact with a database in C?
Do I have to manually compose SQL query strings and then pass them to some black box function, or is it much more intuitive than that?
>>
>>55580487
#include <database.h>
>>
>>55580237
fucking brutal, based linus
>>
File: Extra3.jpg (99 KB, 773x893) Image search: [Google]
Extra3.jpg
99 KB, 773x893
Best resource for learning ARM?
>>
>>55580464
Alright... Found the error, apparently I wasn't passing vectors by reference, which is why the for-loop wasn't running... Thank you, though! Looking at the variables was surprisingly helpful!
>>
>>55580535
Where did you get that byte type?
>>
Help me anons, I'm no c programmer, I'm trying to understand this code to port it to another lang. What is going in this line?
count = *((unsigned short *) (in+inptr));

in is a char * and inptr is an int
Go to the character at in[inptr] dereference it and cast as unsigned short? Looks just weird and the castings confuse me
>>
>>55580487
Depends on the library you use.
>>
>>55580559
pointers were a mistake
>>
>>55580559
Yeah, you pretty much nailed it
>>
>>55580559
some expression (in+inptr) getting casted to (unsigned short *) and assigning what that points to, to count.
>>
>>55580559
>inptr is an int
but it says "ptr"
>>
File: 1418685966596.jpg (2 MB, 2000x2610) Image search: [Google]
1418685966596.jpg
2 MB, 2000x2610
>>55580559
this is how computers actually work you better learn pointer arithmetic and fast, if you don't know already then I can't show you, C is the one true language all others are just immitators, OOP and webdev give me a headache how can anyone understand that garbage pointer arithmetic is easy and simple to understand go take an abstract algebra course fucking kids these days I miss my 486 when programming meant something C is so easy make programming great again
>>
>>55580617
What's a good book for learning abstract algebra?
>>
>>55580581
They're just a one-element array zipper
In that sense they're comonads
>>
>>55580558
Someone gave me the code for the byte type... It's literally just
using byte = unsigned int;


It's useful for hexadecimal operations
>>
>>55580584 >>55580586
Alright

>>55580597
I've seen lots of regular ints called ___ptr in the code I'm reading to denote offsets in actual pointers, such as: char *namelist; int nameptr;
>>
>>55580685
this is wrong
byte is 8 bits, not 32
>>
>>55580685
using byte = char;

I have no idea how C++ works, but that's how I gather you typedef
>>
>>55579613
So I did it the way you showed me but like you said it feels clunky. I can already see problems that might arise when I have to update any of the stats. so what is the proper way of doing this. its for a text based game im working on for learning.

class Input_check(object):

def input_checker(self, x):
if x == "s" or x == "S":
print("Attack: %i\nDeffense: %i\nHealth: %i" % (self.stats[0] ,self.stats[1], self.stats[2]))
elif x == "i" or x == "I":
count = 0
for item in self.inventory:
print ("%d: %s" % (count , item))
count = 1 + count

class Player(object):

player_name = ""
player_attack = 10
player_deffense = 10
player_health = 10
inventory = {"Wood Stick", "Health Poition"}

def print_welcome(self):
print("Hello and welcome to The Game.")

def print_name_welcome(self):
print("Ohh hello %s let me show you around." % self.player_name)

p = Player()
ic = Input_check()

ic.stats = (p.player_attack, p.player_deffense, p.player_health)
ic.inventory = (p.inventory)

p.print_welcome()
p.player_name = input("So what should I call you by?\n")
p.print_name_welcome()

print("First we will talk about stats.\nStats are a very important part of this game.\nThey will determin the outcome of rolls that you make while playing. To see your stats enter s")

check = input()

while check != "s" and check != "S":
print("im sorry you need to press s and hit enter to print stats.")
check = input()

ic.input_checker(check)
check = input("Good work now lets take a look at youe inventory. Enter i to open your inventory.\n")
ic.input_checker(check)
input()
>>
>>55580617
>C is the one true language all others are just immitators
C is a heavily gimped and bastardized PL/I subset.
>>
>>55580715
Oh shit, sorry... It used to be unsigned char, but I changed it briefly for debugging purposes...
>>
File: Extra5.jpg (56 KB, 600x955) Image search: [Google]
Extra5.jpg
56 KB, 600x955
>>55580521
Bump
>>
>>55580813
32 or 64 bit?
cute legs
>>
File: Extra4.jpg (45 KB, 650x698) Image search: [Google]
Extra4.jpg
45 KB, 650x698
>>55580826
>cute legs
T-thanks
64-bit
>>
Is ANDing a byte with 0xFF the exact same as casting it to unsigned in C?
How do I cast a value to unsigned in a language where "unsigned" doesn't exist
>>
>>55580862
>How do I cast a value to unsigned in a language where "unsigned" doesn't exist
lmao what a shit language
>>
>>55580862
ANDing a byte with 0xFF is exactly the same as doing nothing with the byte
>>
>>55580862
You're talking about reinterpreting the bit representation of an integer.

That doesn't have anything to do with programming languages.
>>
>>55580862
>Is ANDing a byte with 0xFF the exact same as casting it to unsigned in C?
Yes, but your compiler will still classify it as whatever you declared it as until you tell the compiler it is to be interpreted as a char. (by casting it)
>>
>>55580862
You don't cast it. In Java it's popular to just throw an exception when a value you expect to be positive is negative.

>>55580881
He probably meant
|=
>>
>>55580857
No tutorials for that, the way I do is get qemu for my distribution, and go with this
https://github.com/freedomtan/aarch64-bare-metal-qemu
(im building an OS myself rn)
that's a nice position, you got more?
>>
File: Extra2.jpg (35 KB, 687x498) Image search: [Google]
Extra2.jpg
35 KB, 687x498
>>55580921
I got a few left, they're from a short-lived manga called Daikousha Nagi. 8 or so chapters, but only two translated ;-;
Is there any major differences between 32-bit and 64-bit ARM? I don't imagine I couldn't just learn 32-bit and figure out any quirks of 64-bit on my own.
>>
>>55580881
>>55580901
Nope, I mean AND
int i = b & 0xFF; // unsigned b
Seems to work but c is weird. freading into a struct
fread(&somestruct, len, 1, file)

Gives different results on my linux 64 and windows 32 if the struct containts only chars, even though I'm pretty sure the C standard defines that char has the same size. Maybe something with endianess


>>55580901
https://ideone.com/RGuO9f
>>
>>55580971
Java and bytes act like unsigned bytes but with 0x80 subtracted from them. It shows when converting strings to bytes, they are always off.
>>
>>55580966
not really, apart from register sizes, amount of the registers, and changes in the flags system. I recommend you to read the first chapters of this:
http://115.28.165.193/down/arm/arch/ARMv8-A_Architecture_Reference_Manual_(Issue_A.a).pdf
it'll tell you alot about the differences and features, then jump to A64 instructions below to play around, making functions etc. Also gnu as and make and ld manuals that come with the linaro compiler are good too. Either way good looking legs and buttocks ;p
>>
File: Extra1.jpg (79 KB, 599x684) Image search: [Google]
Extra1.jpg
79 KB, 599x684
>>55581007
Cool, thanks m8. Good luck with your OS
>>
>>55581019
You're welcome, hope you'll have lots of fun. Thanks for the glimpses of the panties and stuff
>>
>>55581019
13. Do not use avatars or attach signatures to your posts.
>>
>>55581034
Is it still an avatar if it doesn't repeat?
>>
>>55581034
Calm yourself m8, he was interested.
>>
>>55581079
I don't think you can post repeated images
>>
>>55581135
You can if change a couple of pixels.
>>
>>55580628
Category Theory and Abstract Algebra for Haskell Memer Enthusiasts by Bida Lam
>>
>>55581019
omg hi!!! how big r u? pls don't eat me :((((
>>
>>
File: 1467990020630.png (1 MB, 1100x1315) Image search: [Google]
1467990020630.png
1 MB, 1100x1315
>>55581548
>>
File: 1467377690790.gif (265 KB, 160x120) Image search: [Google]
1467377690790.gif
265 KB, 160x120
What is the de-facto standard for describing types in academic papers?

Standard ML? Pseudocode?
>>
>>55581701
Just describe the exact number of bits your implementation uses.

32-bit unsigned integer.
>>
>>55581701
Depends what you're doing
>>
>>55581701
Mathematicians use sets. Types are "esoteric" meme math.
>>
>>55581737
>>55581732
Actually I just meant data structures.
>>
What's the most complete and up to date 4chan archive available for downloading & offline analysis?

archive.moe's 2015-06 torrent?
>>
>>55581548
>>55581562
>people on /g/ think C is elegant
>>
>>55581914
>people think that because you can misuse something that makes it inherently inelegant
>>
>>55581914
But it lets you do autistic shit, which caters to the average user base.
>>
How does an complete beginner who knows nothing about computers get into programming? Plz help are there any guides out there for morons like me?
>>
>>55582218
Code Academy
>>
>>55582218
google "Haskell Tutorials"
>>
>>55582218
Learn maths.
>>
coding newbie here, trying to understand factories. I'm sort of grasping the concept but not the application. Is the following visualization of mine a sound analogy to the workings of a factory?

>a car dealership offers several different feature packages for a car
>customers come in and choose what they want on the car using a terminal or just filling out a checklist of options and submitting it
>the dealership sends their request to the factory, where the correct car is made based on their specifications
>the car is then sent to the customer for their use
>the customer doesn't actually know how the internals of the car work, but they know how to interface with it via the vehicle controls in the driver's seat, so they can use the car

so in that analogy:

>customer - ?
>factory - factory
>car - product of factory
>vehicle controls - interface

Is that right? Or am I off still?
>>
Would rust be suitable for a complex, 3D rendering intensive desktop application? I haven't looked into it much yet but previously heard it should be a suitable replacement to C++, now I'm seeing people call it a meme language?
>>
>>55582403
Well, I think Rust is more intended for systems programming, C++ has well developed graphics libraries and APIs (OpenGL, DirectX).
>>
>>55582430
Idk I've seen a lot of graphics API wrappers for rust, people here talk shit about the language for some reason unknown to me though
>>
>>55582455
People talk shit about things here all the time.
Rust is a relatively new language, so the wrappers might not be as well tested or robust as the ones for C++, but you can give them a go if you want.
>>
>>55580725

In C++, typedef looks like this:

typedef unsigned char byte;
typedef signed char sbyte;


>>55580375

Pass your vectors by reference or the boogeyman will come into your house and byte your hands off with razor sharp teeth, leaving you incapable of programming.
>>
thinking of mapping the world of music to find new stuff

now that I know how to do this stuff I feel like it won't take that long
>>
>>55582455
They make fun of it because it serves no purpose
>>
>>55582430

Rust COULD very easily be used for graphics shit if it had the libraries though. It does compare decently for performance.
>>
>>55582642
Well, sure, I'm not saying anything regarding it's performance.
I've heard it's pretty good on that front (as a language intended for systems programming should be).
>>
If you were making a language, what would you call it /g/?
>>
>>55582666
The Best Programming Language
>>
Tried out the new phpstorm. Still don't like phpstorm. I'm set in my ways with netbeans.

>>55582666
Not telling you, satan.
>>
>>55582666
YAPL
>>
>>55582672
(All Rights Reserved)
(Copyright)
(TM)
>>
>>55582666
~java

it would be everything java isn't, and nothing that java is
>>
>>55582695
Why would you make an OOP language?
>>
>>55582666

Adamantium. Sort of a cross between C++, Rust, and Ada, with a strong focus on a clear and consistent syntax for compile time effects (i.e. constant expressions, modules, templates), and on producing deterministic code for systems applications. File extension might be something like .adm.
>>
>>55582760
Cool
>>
So /dpt/, about a month ago I started work on a research project at my university. There's a medium-sized codebase that I've essentially inherited, and it's almost entirely undocumented. I'm trying to come to a conclusion on how to document this code so that the next asshole that comes in after me won't need to spend two weeks just learning the codebase. I'm currently really fond of software contracts. Anyone got any ideas?
>>
>>55582666
GPig(guinea pig)
Coal
Delhi
RSI
>>
>>55582769

One of the things I'm not a fan of in C++ is how constant expressions, templates, and macros all use completely different syntax, and none of them really can do what static if does in D (well, maybe templates if you use enable_if, but that will look ugly). Conditional compilation and compile time evaluation are rather useful features, and it would be nice to be able to consolidate them into one common syntax. Another thing I'm not a fan of is that a number of useful features in C++ are available as non-standard extensions. I think every compiler should be able to tell as a standard language-defined compile-time constant what endianness the target platform is. It should also be able to specify a function as pure if it is pure, thus making optimizations easier. There is actually a GNU extension to say that a given C or C++ function will never mutate global state, and thus one can make the assumption that same input = same output every time. But it's not a part of the C++ standard, which is kind of annoying.

Basically, I want GNU C++ with clean syntax, static if, and a few more metaprogramming utilities. Maybe make a binary format for storing compile time information
>>
>>55580237
Damn Linux is satanic
>>
>>55582895
> he cannot document some shitty lines of code without help

Are you retarded?
>>
>>55582895
use doxygen
>>
>>55582941
No, I've already commented the whole codebase, I just want to impose some set of formalizations to at least deter that when I leave it won't return to anarchy.

>>55582954
We currently use doxygen (in theory), but as far as I'm aware it's not really for modelling interactions, more for pretty comments, right?
>>
>>55582979
>more for pretty comments,
pretty and searchable comments which allows you to write tutorials/news/blogs while referencing the code

http://www.alsa-project.org/alsa-doc/alsa-lib/pcm.html

alsalib is my favorite example of this
>>
Whats a good starting project for someone who dabbled with Python and has the skillset of a retarded monkey? I figure I could make a text game, but I'm not creative. Any simple but challenging ideas?
>>
Anyone recommend any good reading for programming AI?
>>
>>55583001
Does doxygen provide the ability to link certain files directly to functions/classes? I'm really only familiar with POD/manpage-style documentation as yet.
>>
File: 1463787570427.jpg (113 KB, 728x546) Image search: [Google]
1463787570427.jpg
113 KB, 728x546
I want to learn programming. Someone said I should learn Python.

Python 2 or 3? Where is the best place to learn? How about books?

Im more of a classroom learner,where you learn then do exercises. I have a hard time trying to give myself "homework" so to speak.
>>
>>55583018
berkeley has a machine learning/ai course avaiable for free online
my sisters taking it rn for real, hear it's pretty good

they do optimization for things like pac-man
>>
>>55583034
like this?
http://www.alsa-project.org/alsa-doc/alsa-lib/group___p_c_m.html#gace4920d5943820c395dab8d9cd4fed0a
>>
>>55583043
code academy
>>
>>55582666
D
>>
>>55583095
DUDE GARBAGE COLLECTION LMAO
>>
File: Capture.png (10 KB, 926x128) Image search: [Google]
Capture.png
10 KB, 926x128
ok python question

I've been working with a lot of utf-8 and it's extremely annoying to have to to clean the invalid chars all the time

is there a way I can install these symbols (outside the range of [^\x00-\x7F])?
>>
>>55583059
This is probably what I'm going to do. I'll probably still write in the contracts in the hopes that someone finds them useful and mimics me.
>>
>>55582572
How's that
>>
What do you think of my fizzbuzz implementation? It uses no loops when you run it.

import std.stdio;
import std.conv;

string fizzbuzz()
{
auto code = "auto fizzbuzz = \"";
foreach (i; 0..100)
{
auto fizz = i % 3 == 0;
auto buzz = i % 5 == 0;
if (fizz && buzz) code ~= "fizzbuzz";
else if (fizz) code ~= "fizz";
else if (buzz) code ~= "buzz";
else code ~= to!string(i);
code ~= "\n";
}
code ~= "\";";
return code;
}

void main()
{
mixin(fizzbuzz());
writeln(fizzbuzz);
}
>>
Im working on an account creater on various websites. Once I finish it up ill probably sell it on some forums.

> Put info in the program (name,email,password,whatever is needed to sign up on site)

>puts it all and does all the clicks

>notifcation comes up to tell you to do the captcha
>>
>>55583067

literally everyone says to stay away from code academy though.
>>
Quine in Rust. That was a fun problem. It came out kinda ugly, but there's definitely no "cheating" involved, like eval, i/o, etc.
fn escape(a: &str) -> String { a.replace("\\", "\\\\").replace("\"", "\\\"") }
fn quine(a: &str) { print!("{} quine(\"{}\") }}", a, escape(a)); }
fn main() { quine("fn escape(a: &str) -> String { a.replace(\"\\\\\", \"\\\\\\\\\").replace(\"\\\"\", \"\\\\\\\"\") }
fn quine(a: &str) { print!(\"{} quine(\\\"{}\\\") }}\", a, escape(a)); }
fn main() {") }
>>
File: doggo.png (770 KB, 638x638) Image search: [Google]
doggo.png
770 KB, 638x638
>loading secp256k1 in botan results in a segfault unless i load another key shortly before it
>>
>>55583179
how is that marketable?
can't everybody do that in seconds?
most of the time it doesn't even require a session key

google is the only one I've had a lot of trouble with, still run the logins actually
>>
>>55583188
I know right? I spent a week doing It and now I'm clueless. It's like they give you the absolute basics and nothing more. What do after codecademy?
>>
>>55583188
he wants to learn through busy work

dont know where else to send him
>>
>>55583203
i believe it would probably be used by criminals a lot.
>>
>>55583142
What's it's focus, goal, or niche?
>>
Guys, what do you think of learn C in 21 days? Should I always do the quizzes to get the most out of it?
>>
>>55583266
any book called
learn * in * days

is trash
>>
>>55583266
Read K&R.
>>
>>55583213
>>55583215

WHAT DO

HOW DO I PYTHON
>>
File: Capture.png (30 KB, 1137x604) Image search: [Google]
Capture.png
30 KB, 1137x604
>>55583305
you just do it I don't even understand what's so complicated
>>
>>55583272
ill check it out. Is it good for noobs?
>>
If I've got an array of values, a buffer so to speak to which I will be inserting stuff, and once everything is inserted, the buffer needs to be sorted... Should I sort everything at insertion (insert at end, then swap until a suitable spot is found) or sort at the end? Does the function passed to C++'s std::sort usually get inlined?
>>
>>55583323
dont be a cunt m8
>>
Days of erratic and poor sleep, heavy kava and caffeine consumption, and a building sense of stress has left me burnt at best.

Lack an innate means to shift into a better state. Trying to figure a pharmacological means to force myself into a "zone". It's the only way to get through the catch 22, too anxious to defuse anxiety.

Life is 3/10.
>>
>>55583474
damn dude sounds like it sucks to be you
>>
>>55583474
>too anxious to defuse anxiety.
try sertraline
>>
File: ak24.jpg (77 KB, 640x800) Image search: [Google]
ak24.jpg
77 KB, 640x800
reminder to maintain good posture
reminder to get up and stretch often
reminder to stay hydrated
>>
I'm retarded /g/, plz help.

num = input("Enter a number: ")
mod = num % 2
if mod > 0:
print("You picked an odd number.")
else:
print("You picked an even number.")


^^^^^^^^^^^^^^^^^^^^^^
Could someone break down why num > 0 = an odd number? Or better yet could you break the program down for a beginner?
>>
>>55579794
Because the linux dev's don't give a shit about 4 extra characters, they just want to write code that works.
>>
>>55583607
because num % 2 provides the remainder of division

0/2=0 w/ no remainder
1/2 provides a remainder of 1
2/2=1 w/ no remainder
3/2 provides a remainder of 1
>>
>>55583358
Well, apparently I should sort at insertion because having just tried std::sort for sorting a bunch of sprites, sorting at insertion provided about twice the FPS.
>>
will a multithreaded program run on a single core machine?
>>
>>55583756
yes
>>
>>55578800
I'm a controls engineer who works with a few mechatronics engineers. As an undergrad, I'd say you'd be better suited getting a more specialized engineering degree (e.g. electrical, computer, mechanical) and then moving into mechatronics as a job. Most of the mechatronics engineers I've met end up doing bitch work.
>>
>>55583778
thanks! I assume there could be some performance problems though?
>>
>>55583803
depends on the OS
the OS allocates time to threads like it would a process, sorta
of course a single core machine will run at least 4 times as slow as a 4 core machine (with the same processor architecture)
>>
File: PythonProgramming2nd.jpg (45 KB, 200x241) Image search: [Google]
PythonProgramming2nd.jpg
45 KB, 200x241
>>55583305
>>
File: AaYphmp.jpg (61 KB, 350x453) Image search: [Google]
AaYphmp.jpg
61 KB, 350x453
I'm trying to do some pointer stuff in C++ and im getting a mysterious segfault
Node* findGreatest(Node* list)
{
Node* greatest = new Node;
greatest->amt = MIN_INT;
while(list->right != NULL)
{
list = list->right;
if(list->amt > greatest->amt)
{
greatest = list;
}
}
return greatest;
}
Node* sortList(Node* head)
{
Node* newList = new Node();
newList->left = NULL;
newList->right = NULL;
while(head->right!=NULL)
{
newList->right = findGreatest(head);
newList->right->left = newList;
newList->right->right = NULL;
newList = newList->right;
}
while(newList->left != NULL)
{
newList = newList->left;
}
return newList;
}

I know its shitty and inefficient but I don't see why it shouldn't run. The error appears on the line
newList->right = findGreatest(head);
>>
Fug
How do I access the associative table in a cakephp belongstomany? I'm not just meant to also create a hasMany to the associative table, am I? Can I somehow pull the associative table out of the relationship?
>>
>>55583328
No. Expect to not be pampered with truth tables or any other bullshit. It's a book that expects you know not to be brain dead with CS and *nix. You will definitely learn C however, so pick your poison.
>>
>>55581548
So? The only stupid thing is that array declared after variable name instead being attached directly to type name like in java. I don't think pointers to functions can be made any better.
>>
>>55583905
>while(head->right!=NULL)
you never change head, this is an infinite loop
>>
>>55583905
I'm pretty new to pointers so maybe I don't understand but when I make greatest equal to the greatest valued node and then make greatest a part of the newList am I not removing the node form the head list? So eventually after enough calls of findGreatest(head) it should just be head->NULL right instead of head ->list->null
>>
>>55583247
Being a better C++ apparently
>>
>>55583905
>pointer stuff in C++

Use nullptr instead of NULL.
>>
>>55583905
there's too many problems with this, if I were to fix it, it wouldn't even be similar to what you've posted
>>
>>55584099
You don't have to fix it but you could you tell me what some of those problems may be?
>>
>>55584066
YAASSSSSS
OMG YASSS
>>
>>55584121
You're needlessly allocating new nodes to traverse through the list.
>>
>>55584121
1) findGreatest creates a new node every time, leaking memory
2) findGreatest skips the first node when checking for greatest
3) while (head->right != NULL) <- this is an infinite loop
4) newList, you never set the original node to anything meaningful, you immediately set newList->right instead
5) it does more things but there's no point in me even looking at it at this point
>>
We are committed to providing a friendly, safe and welcoming environment for all, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, religion, nationality, or other similar characteristic.
On IRC, please avoid using overtly sexual nicknames or other nicknames that might detract from a friendly, safe and welcoming environment for all.
Please be kind and courteous. There’s no need to be mean or rude.
Respect that people have differences of opinion and that every design or implementation choice carries a trade-off and numerous costs. There is seldom a right answer.
Please keep unstructured critique to a minimum. If you have solid ideas you want to experiment with, make a fork and see how it works.
We will exclude you from interaction if you insult, demean or harass anyone. That is not welcome behaviour. We interpret the term “harassment” as including the definition in the Citizen Code of Conduct; if you have any lack of clarity about what might be included in that concept, please read their definition. In particular, we don’t tolerate behavior that excludes people in socially marginalized groups.
Private harassment is also unacceptable. No matter who you are, if you feel you have been or are being harassed or made uncomfortable by a community member, please contact one of the channel ops or any of the Rust moderation team immediately. Whether you’re a regular contributor or a newcomer, we care about making this community a safe place for you and we’ve got your back.
Likewise any spamming, trolling, flaming, baiting or other attention-stealing behaviour is not welcome.

bunch of flaming sjw faggots

>web devs in charge of making a "good" programming language
>>
I'm looking for a pet language to pick up. Any suggestions?
>>
Exactly why Rust will never become relevant.
>>
>>55584142
Do you have autism? I'm not even saying that is what it actually is because I don't fucking know, that is supposedly the goal though
>>
>>55584187
Ops, meant to answer to this >>55584181.
>>
>>55583905
There's a lot wrong with this code. You should practice stepping through code on paper or in your head, along with the most basic form of debugging: putting print statements everywhere.

You should be able to predict exactly what state everything will be in at any point in the running of the program. If you can't, then it means there's a part of the language you aren't understanding correctly (or you've made a mistake in running the code in your head / on paper).

You can also step through program with a debugger. This will allow you to watch step-by-step as the program changes state, or let it run and stop and inspect it when certain things happen.
>>
Anyone know of a good inventory project I can read in Python?
>>
>>55584237
Inventory project?
>>
>>55584237
import inventory
>>
We need a Discord channel. WDG has one. Much easier to use than shit like IRC
>>
>>55583106
Learn how Unicode works fucko
>>
>>55584186
Same. I'm torn between Python and Javascript.

I love JS but Node has no real parallel support, you have to start an entire subprocess to achieve that

Python's useful and shit but ehh... If I could choose one single language to adopt it would be JS
>>
>>55584327
you'd rather pick a webdev language?
>>>/wdg/
>>
>>55584345
That's just the thing, Node.js sucks for general computation because of the whole event loop shit, any non-trivial function would bottleneck the event loop

I guess I should just use Python like everyone else
>>
>>55584364
Wouldn't this be solved by async/await in ES7?
>>
>>55584280
>encouraging the use of closed source software
kys
>>
>>55584364
I really want to like python, but I find it incredibly boring to work with. Ruby is more fun but has too many redundancies. My dream language would be something like hack but without the baggage of php.
>>
>>55584392
I love Ruby as a language but the entire Rubygems thing is crap and unfixable because it's already set in stone.

Python has a godlike module system but the language itself is boring.
>>
Which book on design patterns for modern C++?
>>
>>55584448
I'm reading "Modern C++ Design" by Andrei Alexandrescu, and it's amazing.
>>
>>55584476
>Alexandrescu
I remember reading his template magic when I just started learning C++. Shit was surreal as fuck.
>>
>>55584476
Andrei Alexandrescu is a god. Have you checked out his book on D?
>>
How shit is functional programming in C++14
>>
>>55584509
Nope, might do, though. D looked pretty cool, too bad it never really took off.
>>
>>55584476
A book from 2001? Did you know that new language features eliminated the need for a bunch of them?
>>
>>55584510
C++ has gotten so shit recently in general. They went 10+ years without any major changes and now are trying to cram in every feature known to man
>>
>>55584523
Andrei recently quit his job at FB to work on the language full time. He's really honest about the shortcomings of the language and what can be done to fix them. I have hope it will succeed. If only the name wasn't as shit.
Thread replies: 255
Thread images: 33

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.