/dpt/ - Daily Programming Thread

Old thread: What are you working on, Jow Forums?

Attached: 1568060800483.jpg (2000x2944, 553K)

Other urls found in this thread:

diffchecker.com/IyN3GrTE
github.com/andrei-markeev/ts2c
youtube.com/watch?v=7uLzaKlZSQQ
tutorialspoint.com/c_standard_library/c_function_sin.htm
twitter.com/SFWRedditImages

Imagine throwing them both off of a bridge

K on what?

M, LESS_THAN, SPACE, ALT_R

>calls xerself a programmer
>types in QWERTY layout

I am employed.

Lisp is the most powerful programming language.

I deployed.

Trying to learn C++ better by making a new brainfuck interpreter, and then an expansion to brainfuck to allow interfacing via tcp or udp.

I'd then like to try it again in assembly.

Once I have a better grasp on wiring assembly, in going to try to build a lexer and compiler.

Python scripts to batch download my danbooru, gelbooru, sankaku and yandere favorites

Attached: A.jpg (800x568, 351K)

there's a million of those on github

I'm trying to figure out the minimum required native features to make a compiled language usable. Operator overloading and inline asm means I can hand off arithmetic operators to the standard library. What about conditional branching, is it trivial to implement if, while, and for using just macros and gotos?

Attached: D03A380C-E280-4345-AD4C-DE4657211732.jpg (1280x720, 119K)

I've searched but didn't find any that lets me specifically download all my favorited pics

Friends. What's the best Dev Environment? Linux? Windows? Mac? Does it even depend on the language being used? In addition to that what's the best option on them Like Visual Studio or just using G++ or Clang

IYADA

Attached: scared mio.gif (428x420, 35K)

Mac if you can afford it because it lets you develop for Apple things and is a Unix based OS. Otherwise Linux. Mac > Linux >>>>>>>>>>>>>>>>>>>>>>>>>>> winblows

Why doesn't this take the input and multiply it by 0.5 until it gets below 0.1 while printing the results for every iteration?

t. Struggling PyTard

#include
#include
#include

using namespace std;

int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);

double min = 0.1;
double start = 0;
qDebug() > start;
if (start = min) {
cout

As the other user suggested, mac. But otherwise Linux or FreeBSD.

Since the ncmpcpp thing is looking for a new maintainer, I thought it'd be safe to write my own cli music player and use that instead. It's written in C and has the ususal features alongside an ncurses interface. Nothing special, but it was a nice project to take on.

hey Jow Forums, struggling student here.
Why is it that when I input option D, it just continues to prompt me to input another string over and over each time i input a new string instead of allowing me to run the rest of the program?

Autist prof is forcing us to use c-strings instead of normal C++ string objects, and we arent allowed to use break statements to exit loops or any c style syntax else its an auto fail.

Attached: badatC++.png (1167x730, 47K)

Windows 95 and Visual basic 5.0

Why is the thread so slow now? Did all the Java hating wagies go to bed so they can rest up for another day of Java programming? Hehehe

this is my output if i select option d and try to input a new string

Attached: badresult.png (391x362, 10K)

because you read reading 281 characters, cunt

What's your input? Also, cout doesn't automatically put line breaks.

i want to nakadashi ui

Only the getline call is inside the loop, there's no way for it to move back to the top of the program, so it'll just keep asking you for strings.

You need to take input again at the end of the loop.

Attached: justhangshere.png (794x510, 10K)

how do I find cool shit on github that isn't malicious linux scripts

Attached: 800px-Mazda_B2500_wagon_in_Ubon_Thailand.jpg (800x533, 110K)

I don't know... how about you search for something you can actually use?

Cute Hana.

Download, compile and run Petya. It's got lots of cool scripts

Works fine, just removed the Qt stuff.
$ cat iteration.cpp
#include

using namespace std;

int main(int argc, char *argv[])
{
double min = 0.100;
double start = 0;
cout start;
if (start

Why does Qt break it?

what would that have to do with my loops not working

oh i just realized that, any ideas on how to get the loop to go back to the top

Which loop are you referring to exactly? I tried putting another cin>> userInput at the end of both the D loop and at the bottom of the do loop, but neither worked.

I feel like theres something incredibly obvious Im missing

Can you post the results you're getting?

cin buffers everything that's not parsed when using the ">>" operator. You'd better use getline+sscanf to parse the first character and discard the rest of the line completely.

Yui and Ui are waifu material.

I’m writing software that mimics iRobot for a college class.

You should put all of the menu/if statement code inside a loop, and have options that exit the program use break/return to exit the loop, so that options that don't will jump to the top of the loop and repeat.

It just hangs after taking cin.

see

I would do that, but the professor has a restriction where if you use any break statements to exit a loop, you will automatically fail the assignment, and that would drop me like 2 full letter grades.

Funnily enough after making these changes it works:

#include
#include
#include

using namespace std;

int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);

double min = 0.1;
double start = 0;
qDebug() > start;
if (start = min) {
cout

So you can't even use a switch statement? What kind of shit is this?

Your professor is retarded.

So you can't exit the loop at all, or he just bans using the break keyword? If it's the former then I genuinely have no idea what the fuck he wants.

diffchecker.com/IyN3GrTE

I just don't get it.

I guess I need endl in the loop or it doesn't know when it can actually print the buffer?

Im not quite sure, its an online class and he refuses to answer emails outside of very specific hours. I would drop the class, but its my transfer year and Id like to not spend more time at CC.

Here is the exact verbage, I think he's only banning the break keyword but I cant be sure.

Attached: fuckprof.png (686x670, 49K)

The difference between the two codes you posted is the "double i = start;" declaration and the "cout

I think it's the lack of an endl after my couts. Is this interpretation correct? Or is it strictly a weird Qt thing?

I'm trying to make a function in C where I give it a number in degrees and it gives me back the tan, sin, or cos value back in degrees.

sin(), tan(), and cos() take a value in radians and gives back a value in radians.

I've come up with this:

#define sinDegrees(x) sin(x*(M_PI/180))

and it works but I don't know why it works. I thought I'd have to first convert from the degree value I'd want to radians and pass that to the sin() function and then convert the answer back to degrees. I don't understand why sin() is now giving me back my answer in degrees. Thoughts?

Attached: 1465300436436.jpg (414x508, 27K)

I see a loophole here, where you can just do: bool run_program = true;
while (run_program) {
// ...
run_program = false;
}

So instead of using a break/return, just set the variable to false and the loop will fall through at the end of the if statements.
Also your professor is retarded.

Stupid frogposter, you're not welcome here.
Return to reddit.

Attached: 1562750657679.png (557x625, 343K)

based. let's be free hackers together. fuck nutty professors.

Well... it should print everything in a single line, that should not be a problem, but who knows... Maybe that's the thing Qt does not handle well.

Thank you helpful free software user. Bless you.

From a technical or end user perspective, can you give me one concrete example where dynamic typing is preferable.

What is the best ternary syntax?

Im sorry, im a total brainlet, but where would I implement this?

Would the while statement be before the if statements? Or is the do, while loop nested inside the run_program while loop.

Really appreciate your help, Im just not good at understanding the stupid hoops I have to jump through for this class.

The one from Bash is BEST! (I really wished it would have one)
Tbh I like the usual `exp ? exp : exp` one.

It gives you some of the benefits of generics without crazy sepples templates. It also lets you emulate a nice feature of Java where you can have a list of objects that share the same superclass.

a && b ? x : y;

In Python you can use overload an operator to work on a scalar or a numpy array.

When am I supposed to use pointers?

It's a dumb requirement to have, since the very nature of the assignment means you would need to be able to run that "select a letter, write a string" loop an unlimited number of times, so unless he's looking for something like fucking recursion, you need a loop that can repeat as many times as needed. I don't know for sure if using a variable to kill a loop would also be banned but if it is then I'd either go straight to his office to ask what the fuck he's thinking or just give up trying and copy off the local chinks every assignment.

If I understand your program right, it'd be like "while run_program { print menu, read letter, if it's A or B or C or E then do those things and set run_program to false, else if it's D then read a new string and do nothing else }" which would replace the current "print menu, get letter, do { ... } while".
The options where the program should exit at the end will have the while loop condition invalidated and so will just drop out the end, while the ones where it should repeat will still have run_program set to true and will jump up to the top of the loop, so it'll print menu and read letter etc.
Sorry if this makes no sense, it's 3 am here.

how the fuck do interpreters exist??? i thought the whole point of coding and compiling was you had to compile it to machine code. youre saying you can just run it directly??????

Attached: 1406203295307s.jpg (250x241, 7K)

Point (5) seems impossibly vague to me.

What are the "required C++ syntactical rules of the language you are learning"?

What is "C style syntax"? Given that C++ evolved from C progressively...

Maybe the lecturer is training you to deal with autistic pedants, a numerous species in programming.

Interpreters are just JIT compilers

Interpreters are basically VMs.

Working on finding the inspiration to code

Work has been decent lately so my personal project hasn't gotten any attention

I am asking because I was looking at this JavaScript to C compiler github.com/andrei-markeev/ts2c
and I was wondering if I can rewrite almost everything from dynamic to static types, where are dynamic types actually really necessary...

Could you maybe name an application example from the user perspective, where it would be much easier to use a dynamic typed language?

This code is from the compiler example, JavaScript to C:

Another example:

var obj = { key: "hello" };
obj["newKey"] = "test";
console.log(obj);
transpiles to the following C code:

#include
#include
#include

struct obj_t {
const char * key;
const char * newKey;
};

static struct obj_t * obj;
int main(void) {

obj = malloc(sizeof(*obj));
assert(obj != NULL);
obj->key = "hello";
obj->newKey = "test";

printf("{ ");
printf("key: \"%s\"", obj->key);
printf(", ");
printf("newKey: \"%s\"", obj->newKey);
printf(" }\n");

free(obj);

return 0;
}

This is the true power of Lisp shitposting.

I am pricing an interest rate option. Sometimes I want to do it correctly and pass an entire vol surface. Sometimes I am lazy and want to just pass a scalar volatility. By taking the volatility argument as dynamically typed and using overloaded operators I can make the code compact and intuitive without having to have verbosity to handle the two cases.

>from the user perspective
A user doesn't give a shit how a program is implemented, it depends on how you want to balance efficiency and extensibility. If it makes it easier for you to reason about a program then go for it.
If you mean user as in you're making this an API, then dynamic typing of some kind will probably be necessary, in the form of an abstract class or an interface.

incredibly based

>No switch statements

Niggerlicious to the max.

Thanks user. Although I get the feeling that in the end it is just for the advantage of the programmer. I gotta look more into the overloaded operators stuff.

>You may not use C-style syntax
>You may not use variables of type string
So do you want me to take advantage of C++'s features or not? Fucking idiot.

my example is particularly from a Python context using scalar floats vs numpy arrays.

You too, amen.

I really appreciate you help user.
This is my current implementation, but Im fucking it up somehow, as now it simply exits
once i choose option d.

Ive placed the = false statement inside the d loop, outside the d loop, placed an = true statement in the d loop, and still nothing has worked.


Im truly at my wits end with this asshole.

Im truly

Attached: thxanon.png (1018x595, 27K)

>som, cos, tan return values in units of radians
Is this bait?

軽音楽
keiongaku
light music

>switch statements
garbage code

No, option D should keep run_program at true, not false. Also, I meant that the menu printing code and the letter reading code are also added to the loop, so that the process of making a choice and executing it can be repeated each time option D is selected.

youtube.com/watch?v=7uLzaKlZSQQ

You're a niggle calf. You question divine intellect.

>taking advice from a loonie toon schizo who streamed himself jerking off in a van before jumping infront of a train

glow in the dark detected.

He built his own derivative of C, a compiler for, and a kernel based on said language. Your arguments are empty, Satan.

No bully!

It even says the same thing here

tutorialspoint.com/c_standard_library/c_function_sin.htm

Attached: mad apu.jpg (600x439, 23K)

Can you believe the nerve of this imbecile? Talking trash about Terry.

Making a language and compiler is literally an undergrad project.
Plenty of people have made their own kernels for fun.
Temple didn't even have networking. Kill yourself.

>compilers and kernels are trivial

Present yours.

Put me in screenshot

Temple wasn't even a complex kernel. It did everything in ring 0. Likewise for compilers that never dip deep into optimizations which is where the bulk of the work is.

Radians are only relevant to the argument of the function. The return value of sin/cos is always in the (-1.0, 1.0) range.

who

That site is wrong.

Attached: file.png (484x255, 38K)

Present yours, glowie.