[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: 23
File: 1468208604408.png (389 KB, 934x1000) Image search: [Google]
1468208604408.png
389 KB, 934x1000
Previous thread: >>55592646

What are you working on, /g/?
>>
I am currently working on my lisp. How easy would it be to make it use a jit library?
>>
>>55602501
Thank you for not using a political image

>>55602533
Have you already got a non-JIT bytecode compiler up and running?
>>
>>55602501

Thinking about messing with the rendering of a program to make it pulse the intensity of images ever 0.5 to 2.4 seconds in a predefined pattern.
>>
>>55602602
Not yet, I just browse the syntax tree and execute it. I could however make a VM + bytecode compiler relatively easily.
>>
>>55602619
asking from previous thread
>>
>>55602625
Yeah, before you work on JIT you should translate your code from a tree of instructions into a vector of instructions
>>
>>55602501
Why are you saying this anime character is Jewish and why is she/he/it holding a special ed textbook?
>>
>>55602664
Basically like the difference between

return x + 3y

and

move x to R1
move y to R2
mult y with 3
move Result to R2
add Result with x
return Result
>>
>>55602673
*mult R2 with 3
>>
what does this code do?
def all_permz(elementz):
if len(elementz) <=1:
yield elementz
else:
for perm in all_permz(elementz[1:]):
for i in range(len(elementz)):
yield perm[:i] + elementz[0:1] + perm[i:]

for i in all_permz([1,2,3]):
print i


i don't understand the recursion part
>>
Asked a bit late in the last thread...

What would be the best language to write a graph database in? I was thinking it would work well with any OO language, but I dunno if there would be a perk to using a functional language.
>>
>>55602697
Do you want performance or conciseness and composability?
>>
in C, is there any advantage in doing


void test(const char *string);


instead of

void test(char *string);

?

are you just giving an hint to the compiler, telling you will not modify the string
>>
>>55602716
Well likely composability and performance over conciseness. It's for a piece of software that multiple users will be using constantly and the database will be constantly changing as per the users' wishes.
>>
>>55602697

Probably a good use case for R.
>>
>>55602735
Unfortunately composability and performance isn't a choice
>>
>>55602720
If it is not going to be modified at all, and if modifying the string will cause unwanted side effects, just play it safe and make it const. No reason to give yourself a chance to mess things up. If you end up needing to be able to modify the string, go back and change things up.
>>
>>55602720
reduces likelihood that you will introduce unintended side effects.
>>
>>55602697
Sounds like a good use for R, if you're specifically trying to implement a graph database. That's about as far as I can recommend without more context.
>>
File: CeePlusPlus.jpg (105 KB, 603x324) Image search: [Google]
CeePlusPlus.jpg
105 KB, 603x324
C++ <thread>

Anyone can help me with some simple task, I can't get it to work..

1. Write a program that calculates prime numbers and numbers of Fibunacci on different threads.
a. The first thread starts searching for prime number from 1, until killing of the program and when a prime number is found the program must present the time for finding this number.
b. The second thread is calculating and printing numbers of Fibunacci from 1 until killing of the program. When a new number of Fibunacci is found the program prints this number and the time for calculating this number.
c. The time is shown in ms (milliseconds)
d. Think about strategies for not having overlapping messages from the console.
e. The program must work with large as possible numbers. When the number is too large to be held in type like unsigned long long the program stops the calculation of that kind of numbers and shows error message.

Example output:
Prime 1, 0.1 ms.
Fibunacci 1, 0.1 ms.
Prime 2, 0.1 ms.
Fibunacci 2, 0.1 ms.

>>
Hasklelfags will defend this:
>you lose the ability to define hylomorphisms because the result of an anamorphism can't be turned into an input for a catamorphism
>>
>>55602836
For more context, see: >>55602735
>>
>>55602847
the part I am not getting is the using <thread> lib to actually make it happen like the example output, otherwise the logic is ok
>>
>>55602654
Code Academy for python.
>>
>>55602856
I don't know if I'd write an entire app in R. But if there was any way for the database backend to be R and something more app-friendly (?) for the front end, I'd go with that. If you're really looking to write a good database system from scratch, definitely use R.
>>
>>55602654
LPTHW
AKA Learn Python The Hard Way. The author is kind of a prick, but the book will teach you. It's also available online for free iirc.
>>
>>55602847
Well you've given us the task, but none of the existing code you've written. We need more context if you need help solving something. If you're asking us to write from scratch...well I don't know if that'll happen.
>>
>>55602906
the author is a prick AND his books are not good learning material
>>
>>55602888

R has a C interface and there are a lot of gui front ends for it. I'd say it's completely possible to make the back end in R and use something more friendly for the front end.
>>
>>55602944
I didn't do LPTHW, just skimmed through it. His Learn C the Hard Way was a decent intro to C though so I just assumed. I actually learned python first through the python starter tutorial in the docs and then codeacademy python. Just kind of assumed LPTHW was decent too. Oops.
>>
>>55602963
That sounds pretty awesome. Going to double up my recommendation for R then for the guy originally asking the question.
>>
>>55602847
>Fibunacci
>>
>>55602989
>>55602963
>>55602888
I will look into it, thanks!
>>
I want to learn Scala and/or OCaml but have no project ideas. What do you do in situations like these?
>>
>>55603032
Learn Haskell instead
>>
>>55602858
this should be all you need

void FibThread(pointer to mutex){
for(){
lock mutex
print number;
unlock mutex
}
}

void PrimeThread(pointer to mutex){
for(){
lock mutex
print number;
unlock mutex
}
}

create FibThread
create PrimeThread
WaitForMultipleObjects(2, handle to both threads, true, INFINITE);
>>
Anyone knows how to check with Xcb if a window is already open?
>>
>>55603037
I already know haskell.
>>
>>55603065
Then why would you want to learn something as awful as Scala?
>>
File: f-fuck you.jpg (51 KB, 397x419) Image search: [Google]
f-fuck you.jpg
51 KB, 397x419
Friendly reminder to write code every day or you lose your powers!
>>
>>55603032
git gud
>>
>>55603096
>awful
I'd just like to say that is is probably not a good idea to rip on other programming languages. They all have their perks and disadvantages.
>>
>>55603115
That is in fact not true
>>
>>55603032
Try just doing some of Project Euler then. That's usually how I learn a programming language.
>>
>>55603115
that's like saying
>people with down syndrome aren't "disabled"; they're "differently abled"
>>
>>55603097
But go too hard on the code and you get burnt out. Seriously, don't get burnt out. It's really easy to do it with programming.
>>
>>55603129
No, Scala is a perfectly fine programming language. You are using a very bad analogy for this particular situation. What you want to compare is an esoteric language to something like C++--now that is like calling a disabled person differently abled.

Enjoy getting flustered everytime someone likes something you don't though! Tata!
>>
>>55603032

Just think of something random and then start making it. Anything that comes to mind and is a manageable medium or small project.

You could always go with making a simple interpreter / toy language or perhaps a chip8 emulator.
>>
>>55603123
+1 For project euler. HackerRank can be pretty fun too. Just choose a problem, solve it in the language you're learning. It's great for that. The only thing I don't like about either of these is that they tend to not show you how a lanuage works in the big picture of things, but for syntax and structuring algorithms they're amazing. Try a combo of small problems, then just pick a project at random and do it once you get an idea.
>>
>>55603169
>No, Scala is a perfectly
stopped reading here, because what you said was
>not a good idea to rip on other programming languages. They all have their perks and disadvantages.
>>
>>55603169
Imagine there's a language that's exactly like C++ except "bool" is replaced with

"HowMuchWoodCouldAWoodChuckChuckIfAWoodChuckCouldChuckWood"
>>
>>55603032
Antox is written in Scala if you want to contribute to open-source android project
>>
File: cyanogenmod1-752x490.jpg (39 KB, 752x490) Image search: [Google]
cyanogenmod1-752x490.jpg
39 KB, 752x490
>Cyanogenmod team forces exynos5420 device maintainers to use the exynos5422 hardware trees because they're newer
>They take the 5422 tree and rename everything to 5420
>The 5420 kernels are not compatible with 5422, this causes many bugs related to display, camera, memory allocation
>Maintainers request to merge back to official 5420 hardware trees which have worked fine for years
>Cyanogenmod team tells them to fuck off and decompile proprietary binaries so they can fix the bugs
>Device maintainers abandon official support for their devices
>Most 5420 devices are left abandoned and with bugs
Why is the CM team so autistic
>>
>>55603255
wrong thread?
>>
>>55603097
friendly reminder that you should spend 1% of your time writing code the other 99% thinking
>>
>>55603269
sorry I didn't realize it's only programming if you're working with less than 200 lines of code
>>
>>55603236
>>55603191
Imagine that there are people out there that get this militant about people using different programming languages than they do!
>>
>>55603236

#define bool HowMuchWoodCouldAWoodChuckChuckIfAWoodChuckCouldChuckWood


Problem fixed.
>>
File: jWWPolf.jpg (138 KB, 702x768) Image search: [Google]
jWWPolf.jpg
138 KB, 702x768
>>55602533
https://www.gnu.org/software/lightning/
>>
>>55603255
I don't get it, how can they force them?
>>
>>55603290
what are you talking about?
>>
>>55603301
> #include <bool>
What a shit language

>>55603296
>being this mad that not all languages are equal
>>
>>55603347
sorry I didn't realize it's only programming if you're working with less than 200 lines of code
>>
I have just finished learning Java up to the point of data structures and their implementations. Where do I go from here?
>>
>>55603315
official devices (devices that appear in the cyanogenmod website) can only use 3 non-official repos (device (android configuration for the specific device), kernel, vendor (proprietary binaries)), every other repo has to be from the cyanogenmod github.

exynos5420 needs to import repos to support the SoC.. Cyanogenmod supported this SoC with the repo https://github.com/CyanogenMod/android_hardware_samsung_slsi-cm_exynos5420

They decided that the 5422 hardware code would work with the 5420 chip... So they changed it without asking the device maintainers
>>
I was browsing the nethack source and I found the fact they were still usin archaic c function syntax interesting.

int
eat_brains(magr, mdef, visflag, dmg_p)
struct monst *magr, *mdef;
boolean visflag;
int *dmg_p;
{
...
}


Are there any other projects still in development that use this syntax? Are there any advantages to it?
>>
>>55603359

Oh you don't like using a define? How about this then..

enum class Bool : unsigned char {
False = 0,
True = 1
};
>>
>>55603423
enum {
False,
True
};
>>
>>55603423
>>55603453

>#include <bool>
>>
>>55603296
Sir, I think you might be differently abled.
>>
Im working on an emulator for the Ti430 in C for a computer architecture class.
>>
>>55602501
My ~/.emacs
>>
>>55603394
>still usin archaic c function syntax
you know, it's possible that piece of code was written when that syntax was all the rage.
>>
>>55603370
Time to learn a real programming language.
>>
>>55603423
>>55603453
>>55603458

#define False 0
#define True 1
>>
>>55603498
Yes I expected a shitty meme reply like this.
>>
>>55603507
Why would you need both?

Just

#define False 0
..
if (False)
if (! False)
>>
>>55603507
>#include <bool>
>>
File: 1464363624161.jpg (216 KB, 819x912) Image search: [Google]
1464363624161.jpg
216 KB, 819x912
>>55603507
#define False 1
#define True 0
>>
>>55603370
Well what sort of stuff are you looking to do?
>>
>>55603370
git gud
>>
>>55603453

Typed enum of char guarantees sizeof() == 1 by the c++ standard.
>>
>>55603513
It's not a meme though. Learn Design Patterns and then have fun at your soulsucking corporate job for the next 30 years.
>>
>>55603571
kill yourself
>>
>>55603236
>people still unorinically pretending this isn't a language fault
>>
>>55603567

A example of this:

enum class Bool_Typed : char {
False = 0,
True = 1
};

enum Bool_Untyped {
False,
True
};

int main()
{
Bool_Typed temp = Bool_Typed::True;
Bool_Untyped temp2 = Bool_Untyped::True;

std::cout << sizeof(temp) << ", " << sizeof(temp2) << std::endl;
return 0;
}


Will output "1, 4" on most c++ compilers.
>>
>>55603587
nice rebuttal
>>
>>55603635
desu your comment didn't have much of a rebuttal either.
>>
>>55603645
nice cum back
>>
>>55603645
this, it was just a continuation of his shitty meme
>>
#include <iostream>
using namespace std;

class fuck {
public:
void outputs;
int number;
cout << "enter your number: ";
cin >> number;
}
}

int main(){

myclass loldong;
loldong.fuck();
return 0;
}


why doesnt this work? can you not call cout's and cin's in a class before main and then call them in the main?
>>
>>55603394
That's real C. The other one was something ANSI copied from C++ when they wanted to pretend C wasn't a systems language.

C today is C++--.
>>
>>55603685
uhhhhhhhhhhh
c++ doesn't allow you to just have instructions floating in the middle of nowhere
put that shit inside a function
>>
>>55602501
So i'm just practicing c++ and came upon "class templates" which are fucking weird to me.
Note that I've just started learning about classes and templates.

template <class T>
class MyTemplate {
T element;
public:
MyTemplate (T arg) {element=arg;}
T divideBy2 () {return element/2;}
};


// class template specialization:
template <>
class MyTemplate <char> {
char element;
public:
MyTemplate (char arg) {element=arg;}
char printElement ()
{
return element;
}
};


Can someone explain what the fuck is going on here? Pretty please?
>>
>>55603685
pretty sure you have a bracket too much

also change myclasss to fuck
you're mixing class name with methods.
loldong.fuck() doesn't do anything and is actually invalid
>>
>>55603685

Main is where the code begins execution (Entry point). Any code outside of a function / class member will cause a compilation error, and will not be execute until called.

Something that would work looks like this

class fuck {
public:
void outputs()
{
cout << "Number Entered: " << number;
}

void input()
{
cout << "enter your number: ";
cin >> number;
}

private:
int number;
};

int main()
{
fuck Give;
Give.input();
Give.outputs();

return 0;
}
>>
What are /dpt/ approved snacks?

What do you guys eat when you program?
>>
>>55603733
let's say you had a class that dealt with ints
but then you wanted the same functionality, but dealing with chars instead
you might duplicate functionality inside your class, or duplicate the class itself like so
class MyIntClass{
public:
int a;
void print(){ cout << a; }
};

class MyCharClass{
public:
char a;
void print(){ cout << a; }
};


or you could do this instead
template <class T>
class MyNewClass {
public:
T a;
void print(){ cout << a; }
};


and now you have one templated function that can handle any type, not just one
>>
File: alkaline_water_and_teeth.jpg (632 KB, 2800x1800) Image search: [Google]
alkaline_water_and_teeth.jpg
632 KB, 2800x1800
>>55603790
>>
>>55603803
lol you can't eat water silly
>>
>>55603733
>templates
you don't need to understand, it's overengineered shit and you could easily replace it with a simple preprocessor macro.
>>
File: ice-018.jpg (1 MB, 1680x1050) Image search: [Google]
ice-018.jpg
1 MB, 1680x1050
>>55603796
thanks senpai
what about the specialization? I get that it merely changes the implementation depending on the type you provided but how the hell does it work. the notation is just fucking weird

>>55603819
>>
>>55603830
>but how the hell does it work. the notation is just fucking weird
yes. that's basically the issue with templates and why nobody uses them except sometimes when it's hidden far away inside a library
oh, and the horrible compiler errors they produce
>>
>>55603854
Java does classes much better. Superior Java master race
>>
>>55603881
Care to post a comparison?
>>
>>55603830

Specialization is just defining special code to run when supplied a specific type. Using the above example it'd look like this.

template <class T>
class MyNewClass {
public:
T a;
void print() { cout << a; }
};

template <>
class MyNewClass <char> {
public:
char a;
void print() { cout << "Char: " << a; }
};


Template meta-programming is a advanced topic in c++. It's basically a functional sub-language built into the language.
>>
>>55603897
https://docs.oracle.com/javase/tutorial/java/javaOO/classes.html

So elegant so easy to understand and such a neat format
>>
>>55603910
So every call to this template will be the first one unless a char is explicitely used(not possible in this example I think?)
Why the fuck is the type declaration in a different place then "class T". That's confusing as fuck
>>
>>55603931
you can have template declarations within template declarations
>>
>>55603931
>(not possible in this example I think?)
not sure what you meant by that. of course you could use char
>template will be the first one unless a char is explicitely used
is correct
>>
>>55603931

Yep when make a variable of the class you supply it's type.

template <class T>
class MyNewClass {
public:
T a;
void print() { cout << a; }
};

template <>
class MyNewClass <char> {
public:
char a;
void print() { cout << " Char: " << a; }
};

int main()
{
MyNewClass<int> A = { 1 };
MyNewClass<char> B = { 'D' };

A.print();
B.print();

return 0;
}


Will print out "1 Char: D"
>>
File: whywouldyoudothat.jpg (50 KB, 292x302) Image search: [Google]
whywouldyoudothat.jpg
50 KB, 292x302
>>55603943
Seriously that sounds awful
>>
>>55603973
Welcome to the glorious world of template meta programming
>>
>>55603854
D is a language that doesn't have god-awful template syntax. It's partly designed by the god of C++ templating
>>
>>55603973

It is a painful part of the language.. Sadly it's necessary for some generic types / techniques.

If you want to see some sexy template horror porn just look at the boost libraries.
>>
>>55604005
>Sadly it's necessary for some generic types / techniques.
when are they going to make it so I can use auto in class and function definitions?
>>
>>55603973
You can have templates that take templates as parameters

You can have templates that take a varying number of arguments

You can have templates that take constant values as parameters
>>
why program when you can engineer and build real things instead?
>>
>>55604022
What do you mean by that? It sounds like you want something like
class A {
auto var = 3;
}
>>
>>55604047
Am engineer, just learning to program to support said endeavors.

Reminder that CS is not engineering.
>>
>>55604047
A lot less building of 'real things' would be happening if there weren't any people to program the tools they use.
>>
>>55604022

I doubt if it'll make it into the language. The type deduction / inference method in C++ is very weak / stupid. The closest I've seen is something like this

template<typename T1, typename T2>
auto Func(T1 i, T2 b) {
return i + b;
}

int main()
{
cout << Func(1, 2.0);
return 0;
}
>>
>>55604058
it seems perfectly reasonable that we could use auto instead of templates in most cases
for example
void MyFunction(auto a) {
cout << a;
}

int main() {
MyFunction("Hello");
MyFunction(5);
return 0;
}


I see no reason why the compiler can't figure this out
it could just turn MyFunction into a template and "a" into the templated parameter
>>
>>55604071
programmers are glorified typewriters
>>
Do you have to be good at math to become a good programmer?
>>
>>55604160
no
>>
>>55604160
Yes, absolutely
>>
>>55604180
Okay well I suck horribly at math and I am okay at programming. How do I get good at programming?
>>
>>55604199
do it more
>>
>>55604199
>>55604160
There is a difference between math and logical thinking.
>>
>>55604047
Why engineer when you can program and build virtual things instead?
>>
>>55604160

In general yes. In certain problem domains / jobs no. It depends on what you're doing.

Someone writing statistical analysis tools / Rendering Code / Physics simulations is going to require completely different skills than your average "put up a webpage and interact with this database work".

A strong mathematical basis shows some baseline logic / problem solving skills.
>>
>>55604231
Yes I cannot do physics simulations math only thing I could do is basic physics math for game of collision detection and such but nothing advanced
>>
>>55604231
>A strong mathematical basis shows some baseline logic / problem solving skills.
This.
>>
>>55604102
That doesn't work well in cases where there's multiple template params. C++ has pretty bad syntax in general, anyways, so it's not like it'd be the first thing to add.
>>
>>55604255

If you're planning on entering a college then more than likely your degree will require at a minimum algebra 2 or Calc 2 in a bachelors program.
>>
>>55604102
>>55604273
This is an example of the program in D, which has better syntax for templates. It's just as short as the suggested cpp program:

void MyFunction(T)(T a) {
writeln(a);
}

int main() {
MyFunction("Hello");
MyFunction(5);
return 0;
}
>>
>>55604312
I already did Discrete math it was no fun
>>
>>55604273
>That doesn't work well in cases where there's multiple template params.
why ?

void MyFunction(auto a, auto b) {
cout << a << b;
}

int main() {
MyFunction("Hell", 'o');
MyFunction("3.", 1415);
return 0;
}


this can be done easily in templates
so why not auto?
>>
>>55604336
Discrete math is great.
>>
>>55604336
If you don't like math you should reconsider learning to program and just become a web dev or designer or something. I'm not joking here.
>>
>>55604336

Trigonometric, Mathematical Matrices, Vectors, Statistics, and rudimentary Calculus is used in a lot of problems solved by programmers.
>>
>>55604389
Discrete math is like the hipster of all maths

>>55604402
web dev involves math too you lie!
>>
>>55604404

Need caffeine.. Meant to type "Trigonometric functions"
>>
>>55604353
There is a TS for that, actually, but I don't think it made it in for C++17. http://en.cppreference.com/w/cpp/language/constraints#Abbreviated_templates
The main problem is that each use of auto creates a different templated parameter, which isn't super nice if the arguments are supposed to be the same type. The way templated classes are created is weird, it may cause problems there as well.
>>
>>55604160
in case it isn't obvious, yer being memed
most programmers use nothing more complicated than multiplication and division for their entire career
>>
>>55604417
>Discrete math is like the hipster of all maths
Nigga you have no idea what you're talking about.
>>
>>55604160
Math in programming is problem-oriented.

If your problem needs complicated math, your program will. If it doesn't, your program won't.
>>
>>55604160

To be a good "software architect" or "program designer," no

to be a "software engineer" you do
>>
>>55604578
these terms are all interchangeable and only have special meaning to you and perhaps your specific place of employment
>>
>>55602849
Why can't it?
>>
File: 1466845815772.jpg (16 KB, 480x360) Image search: [Google]
1466845815772.jpg
16 KB, 480x360
>>55604507
>july 2016
>still no concepts
>>
>>55604577

You're ignoring the case where the program shouldn't need complicated math but you have to use complicated math in order to do it in a acceptable manner (Processing time or Memory wise).

Brute force and simple non mathematical methods can only solve so many problems before it's just too slow to be practical.
>>
>>55604596

No they don't

https://en.wikipedia.org/wiki/Regulation_and_licensure_in_engineering

basically not every asshole can claim the title "engineer"
>>
does MIT require me to put a copyright notice in my BINARY distribution
>>
So, I have a Galaxy S5 which is working but the display is dead, the touch screen is fine though and I can use it with my computer working as the 'display'.

Do you have any idea of what I can do with it?
Anything useful or fun?

I'm also thinking about opening and trying do fix it but that would be the last thing that I would try
>>
>>55604639
that page as literally nothing to do with "software engineer"
>>
>>55604639
>>55604674
>>in some countries it is literally illegal to program without a permit
>>
>>55604737

In some countries you are literally considered a domestic terrorist if you believe in constitutional rights.. What is the point in this line of argument?
>>
>>55604774
Are you arguing without a logic engineer permit?
I'm calling the police
>>
>>55604646
>Having binary distributions
kek
>>
>>55604814

10 / 10 :D
>>
>>55604834
>using an interpreter
Enjoy your 5fps simulation
>>
>>55604894
>not compiling your code yourself
Enjoy you're backdoors.
>>
>>55604737

My point is that there is a distinction between "software engineer" and every other programming title
>>
>>55604990
>compiling your code yourself
Enjoy your unintended backdoors.
>>
>>55604990
He's backdoors?
>>
>>55604674

> control f
> "software engineer"

what it says is that many countries and some states regulate the title "software engineer"
>>
>>55604990
Sounds like someone's never heard of the Ken Thompson Hack
>>
>>55605003
not in practice in america and not on the internet
and not even according to wikipedia
>Many people prefer to call themselves software developer and programmer, because most widely agree what these terms mean, while software engineer is still being debated.
https://en.wikipedia.org/wiki/Software_engineer
>>
void operator<<(Box &b){
std::cout << b.l << " " << b.b << " " << b.h;
}


Isn't this how you would overload "<<" to allow printing of objects? In this case printing the variables l, b and h.
Compiler is just shitting out this every attempt I try to use cout
solution.cc:105:19: error: cannot bind 'std::ostream {aka std::basic_ostream<char>}' lvalue to 'std::basic_ostream<char>&&'
>>
>>55605025
*hissssss
>>
>>55605144
std::ostream& operator<<(std::ostream& o, Box& b) {
o << b.l << " " << b.b << " " << b.h;
return o;
}
>>
>>55605144
https://msdn.microsoft.com/en-us/library/1z2f6c2k.aspx

You should be returning a reference to a ostream
>>
>>55605144
You've just declared a unary operator<<
>>
>>55605193
std::ostream& Box::operator<<(std::ostream&, Box&)' must take exactly one argument


I don't even
>>
THis... might sound dumb, but does an to-do list exist for those, who want to code projects in incremental difficulty?

Like, from hello world to building your own OS?
>>
>>55605314
>a + b
>+ must take exactly one argument
>>
>>55605314
Never mind I just figured out it's supposed to be outside of the class(why?)
>>
>>55602501
Where's the image with different programming challenges?
>>
>>55605522
No need for that: http://better-dpt-roll.github.io/
>>
>>55605537
> >>>g/dpt/
>it doesn't even identify which /dpt/ is valid and navigate to it
>>
>>55605537
>pop-up when rolling
>>
>>55605336

You're overloading the operator in ostream that is why it's declared as friend. It doesn't necessarily have to be outside the function definition. You can do something like this

struct Num {
int a;

template<typename T>
Num& operator+=(const T& rval)
{
a += rval;
return *this;
}
friend Num operator+(Num lval, const int& rval)
{
lval += rval;
return lval;
}

friend std::ostream& operator<<(std::ostream& lval, const Num& rval)
{
lval << rval.a;
return lval;
}
};

int main()
{
Num a = { 2 };
auto b = a + 4;
cout << a << " , " << b;
cin.get();
return 0;
}
>>
Le noob here. How does a computer manage time? Let's say you want your program to call a function after 5 seconds. How does it know to stop for really 5 seconds and not 4 or 6? How is that measured?
>>
>>55605596
Your computer has a clock
It checks what value the clock has
>>
>>55605596
I think by the cpu clock, don't quote me on that tho.
>>
>>55605596
2 kinds of clocks:
1. Network time
2. CPU clock

1 is used to synchronize devices with each other since devices will drift away from the real time over time. The battery on your motherboard keeps this alive.

2 is used to calculate how much time has passed. It's accurate within a certain time-frame but as I said starts drifting from the real time if too much time has passed(really depends on device how long that is)
>>
>>55605590

You're giving the operator function access to private / protected members of your class and overloading it.
>>
>>55604894
Distribute source you stupid fuck.
>>
>>55605659

The clock on my phone and computer is cpu or network? If both lag then how is it always accurate then?
>>
File: ghost.jpg (33 KB, 600x600) Image search: [Google]
ghost.jpg
33 KB, 600x600
>>55605741
Sorry, I didn't think there were any GOD DAMN COMMIES in this thread

Fucking fruitbowl
>>
File: colourball.png (483 KB, 966x1000) Image search: [Google]
colourball.png
483 KB, 966x1000
Spent all day making a program to generate the HSV colour ball - it took longer than I expected because I was trying to do it in a more complex way than was necessary.
>>
>>55605794
Network time just checks once in a while(you can set this yourself)
CPU time tries to keep track of time with no external reference.

And no the time between your phone and computer is not the same. They differ in microseconds and this difference only gets larger over time. It gets corrected by the network time once in a while like I said.
>>
I am using Java to try to make like a chat program, but I want it in the console. Is it possible to use scanner or something to wait for output, meanwhile updating the console as per usual?
>>
>>55605839

So cpu time is a lot more reliable than network time since it's not busy trying to sync other devices?
>>
>>55605659
>>55605839
this, plus i've read there's interpolation so the cpu clock isn't constantly updated
>>
import java.util.Scanner;

public class StringPrint {
public static void main(String[] args) {
System.out.println("Enter some text:");
Scanner scan = new Scanner(System.in);
String line = scan.nextLine();
for(int i = 1; i < line.length(); i++)
System.out.println(line.charAt(i));

}

}

London.java
>>
Hi /g/, I want to get a software development career, and I would love any sort of opinions on how I can move into it from my current situation.

>My background:
>25 y/o
>CIS degree, light coding experience in college, some C#, js, and java. Nothing good enough to go into a portfolio
>Worked as walk-up desktop support for my uni, now working as semi-technical hardware support for a major silicon valley company (read: hardware troubleshooting, inventory management, event support)

Sorry for the micro-blog, I'm just unsure of the proper path to get from my current situation to actually landing a job in programming. Should I try to work on independent projects? Are bootcamps worthwhile?
>>
>>55605943
Use the threads luke
>>
>>55606008

A good path into programming for someone with minor experience is

qa -> qa test developer -> developer

qa jobs can be gotten fairly easily if you have a good work ethic.
>>
>>55605943

What you want is an events system.
>>
>>55606033
For looking into entry level QA, is it worth it to learn about systems like selenium, or is entry level QA usually entirely manual? Aside from good work ethic and interview skills, what's looked for in QA?
>>
>>55606025
What exactly would I put in a thread? My server receives text and sends it to all the clients, so how can I thread the clients so that they receive and are always waiting for input?
>>
>>55606102
You would have a thread that is monitoring and updating the console and a thread that is doing networking. git gud
>>
>>55606100


It depends on the company really, every company has their own way of testing.

Selenium/TestNG is *almost* essential along with a basic knowledge of webpages - enough to write xpaths

Knowledge of how to test eg, functional/unit/manual/regression is also essential along with a basic understanding of TDD and the agile workflow.

I've seen people hired with 0 knowledge of anything and do well simply because they were intelligent and hard working.
>>
>>55606160
The server has a thread for every client.
The client would have to have a thread for listening and sending messages.
>>
what does fizzbuzz look like in your favorite language?

 i=0

for i in range (0, 50, 1):
print i

if i%3 == 0:
print ('fizz')

if i%5 == 0:
print ('buzz')
>>
Can someone explain to me how Python's ord function works?

ord('a') returns 97, which is an integer representation of 'a', but where/how is that representation determined?
>>
>>55606578
That's the ascii value for the character.
>>
>>55605943
http://www.darkcoding.net/software/non-blocking-console-io-is-not-possible/
>>
>>55606594
How does that work? Why is 'a' 97?
>>
>>55606178
Thanks for the information!
>>
>>55606624
Because that's the character encoding, since computers only understand binary, all the characters needs to be mapped to an specific number (binary). I don't know where this is actually saved, prolly in an assembly.
>>
>>55602888
R is extremely limited for writing any kind of backend, you would want to use Julia, you can create entire web apps in Julia
>>
>>55606624
Don't think 'a' is '97'
Think '97' represents 'a' in ASCII, UTF-8, etc.
The mapping is stored in the character encoding.
>>
>>55606234
at least get it right anon
>>
>>55606675
>since computers only understand binary
binary is a representation, saying that the computers only understand binary
is extremely uninformed.
>>
>>55605988
Isn't it doing this:
In: L O N...
Out: L

O

N
...

You should probably skip spaces for a true LONDON experience.
>>
>>55606624
https://en.wikipedia.org/wiki/ASCII#Printable_characters
>>
File: cfg_r5.png (126 KB, 995x646) Image search: [Google]
cfg_r5.png
126 KB, 995x646
I've been working on a UI for my disassembler. I'm still not quite happy with it.
>>
>>55606675
Also, 97 is not binary, 97 is decimal, duh.
>>
NOTAÞ HASKELL

SOÞLICE
>>
why is the state monad in Haskell called so, when really it embodies stateful computations?
>>
>>55607399
It's just a name bruh, you could call it the Java monad if you wanted
>>
>>55607342
Never said that:
>be mapped to an specific number (binary)
Btw, thanks for correting me in the first response, but couldn't find a better way to explain things without being extensive.
>>
>>55607342
not necessary, could be a binary number where the two symbols are 9 and 7.
>>
File: Capture.png (162 KB, 795x769) Image search: [Google]
Capture.png
162 KB, 795x769
>>55602501
>this is what CS/CE really looks like

JUST
>>
>>55607593
Does this really make you a better programmer?
>>
>>55607593
Ya blew it, just be a webdev.
>>
>>55607606
it makes you a better person
>>
>>55602720
Keep in mind that the first example declares the pointer "string" to be constant, not the string it points to. It won't make any attempt to stop you from modifying the string.
>>
>>55607593
The problem with academic mathematicians is that they aren't a fan of simple syntax
>>
>haskell
*tips*
>>
what are you guys programming f a m ?
>>
>>55607701
nothing I haven't written one character's worth of code in over 15 years kill me desu
>>
>>55607679
Maybe if you stopped tipping you might realise Haskell is a pretty nice language
>>
>>55607718
why are you here then
>>
>>55607593
High school math, senpai.
>>
>>55607593
I have never done mathematical proofs in high school or in university for computer science. I don't understand them
>>
>>55607639
I'm an idiot and mixed up
const char *string

with
char * const string

Disregard my post.
>>
>>55607593
>Chinese Remainder Theorem
If you can't gasp basic number theory you will have a bad time...
>>
>>55607778
Protip: nobody will ask you to recreate the proof.
>>
>>55607790
its my first year in college and I'm reading through their library

I'm not even in university yet
>>
>>55607593
Never studied CS, but that is super basic.
>>
Adaptive Levin search to use in my implementation of Solomonoff's Alpha strong AI architecture.
>>
I have 4 years experience in a useless programming language (Scala), and a 3 month noncompete period during which I can learn something new that will be useful for getting a job.

What should I learn? What sites/books should I use? I guess web stuff is popular these days. Is it worth learning some JS frameworks?
>>
>mfw I rewrote a shitty script of mine for work
>mfw it's now beautiful functional python instead of hacky shit with tons of comments

:3
>>
>>55608478
>beautiful functional python
Pick two.
>>
>>55608490
beautiful and functional is the only valid combination
>>
Why is SQL so retarded?
>oh we designed it so non-programmers could use it
>>
>>55602501
Anyone can help me understand the threads in C++ ?
How do I run two or more functions on separated thread ?

also why does one is faster than the other

// super fast calculates the frequency of prime numbers occurrence
int fastfrequencyOfPrimes(int n)
{
int freq;
freq = n - 1;
int sqr;

for (int i = 2; i <= n; ++i) {
sqr = sqrt(i);
for (int j = 2; j <= sqr; ++j) {
if (i % j == 0) {
--freq;
break;
}
}
}

return freq;
}
// slower
int slowfrequencyOfPrimes(int n)
{
int freq;
freq = n - 1;
int sqr;

for (int i = 2; i <= n; ++i) {
for (int j = sqrt(i); j > 1; --j) {
if (i % j == 0) {
--freq;
break;
}
}
}

return freq;
}
>>
File: photo_2016-07-17_01-45-02.jpg (104 KB, 720x1280) Image search: [Google]
photo_2016-07-17_01-45-02.jpg
104 KB, 720x1280
>>55602501
Still working on my fucking 4chan Android app, though I made a lot of progresses today
>>
File: photo_2016-07-17_01-45-10.jpg (113 KB, 720x1280) Image search: [Google]
photo_2016-07-17_01-45-10.jpg
113 KB, 720x1280
>>55608614
Dumping some screenshots
>>
File: photo_2016-07-17_01-45-06.jpg (53 KB, 720x1280) Image search: [Google]
photo_2016-07-17_01-45-06.jpg
53 KB, 720x1280
>>55608623
Thread replies: 255
Thread images: 23

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.