/dpt/ - Daily Programming Thread

What are you working on, Sup Forums?


Previous Thread:

Other urls found in this thread:

01.org/linuxgraphics/gfx-docs/drm/process/coding-style.html
javatpoint.com/java-regex
github.com/x0rz/EQGRP
benchmarksgame.alioth.debian.org/u64q/python.html
twitter.com/AnonBabble

First for D

Second for C is technically an interpreted language.

Third for every language can be interpreted or compiled.

Try this.

#include
#include

using namespace std;

string play(string p1, string p2) {
string result = " ";

if (p1 == "rock") {
if (p2 == "rock") {
result = "Draw!";
}
if (p2 == "scissors") {
result = "Player 1 wins -- Rock breaks scissors";
}
if (p2 == "paper") {
result = "Player 2 wins -- Paper covers rock";
}
}

if (p1 == "scissors") {
if (p2 == "scissors") {
result = "Draw!";
}
if (p2=="paper") {
result = "Player 1 wins! -- Scissors cuts paper";
}
if (p2 == "rock") {
result = "Player 2 wins -- Rock breaks scissors";
}
}

if (p1 == "paper") {
if (p2 == "paper") {
result = "Draw!";
}
if (p2 == "rock") {
result = "Player 1 wins -- Paper covers rock";
}
if (p2 == "scissors") {
result = "Player 2 wins -- Scissors cuts paper";
}
}

return result;
}

int main() {
string p1, p2;

cout p1;

cout > p2;

cout

An Angular APP. JavaScript is the future.

Oh boy, I'd like to see you justify this

It's interpreted in the same sense as HTML is. The HTML interpreter takes a HTML file as input and generates a bunch of stuff to appear on your screen. The C interpreter takes a C source file as input and generates a bunch of stuff to write into an object file.

9th for 'monad' is another name for an object and funcfags are using OOP every day while being too dense to realize it

First for "compiled" is a subset of "interpreted"

Anything with dynamic dispatch is an object (including functions) and FP fags are perfectly fine with that especially considering its a much better framework than OOP.
Also monad isnt a thing, its a classification.

when I look at code it seems everyone has fancy notation for their variables. You see function variables with leading underscores and different acronyms defining different types.

Do all projects just have their own standards about variable naming or is there actually some community standard out there I should get familiar with?

Nice try, you clearly don't understand monads but are desperate to try to make OOP stay relevant.

PROTIP: if you have to water OOP down to the point that "everything is an object!!", then OOP doesn't mean anything at all.

Disgusting, define a type for rock/paper/scissors instead of using string everywhere.

New /dpt/ challenge: write a program that accepts arbitrary input, and reports whether the input is a monad.

Take that up with google or the user I'm responding to. I don't know all the restrictions or the template for the play function. As such I'm working with the limitations at hand.

Were you dropped on your head as an infant?

01.org/linuxgraphics/gfx-docs/drm/process/coding-style.html

thanks familam

>compile very poorly coded game on ICC
>fix boost, fix boost more, fix problems in const translation, fix templates
>finally compiling
>32gb of ram
>out of memory

i tried writing an operating system in haskell and it broke my computer

i press the power button and nothing happens, also there's a faint burning smell but now ive unplugged it at the wall

i knew this paradigm was janky ... i never should of given it a chance

It can be, but generally speaking, no.

The process of compiling is not called interpreting. A language is called "interpreted" if there is no intermediate step in the program's execution. That is to say, the source code is the program. A language is called "compiled" if the source code is used to create the program. So for instance, some object code or bytecode is generated, and that is what gets executed.

Is writing a lexer in C the ultimate beginner project? I just finished mine and I'm so proud of myself and I learned so much about pointers and file/stream handling.

First of all, you should be testing your program in a virtual machine before you test it on real hardware. Second of all, post your source. Maybe you shouldn't have your kernel be doing crazy things like turning off the fan and overclocking the CPU.

Pretty sure he's baiting, buddy.

String s = "/r text"
how do i turn someWord into its own string and remove it from s?

>haskeks think this constitutes an argument

Pretty sure he's baiting, buddy.

s2 = s[s.index("")]

Good start, write it in Assembler next time.

Why are games the only things that are fun to program?

Can learning algorithms revive a dead interest in programming?

learn FP

Learn Lisp.

I didn't say that games are fun to play, turbo nerd.

>fooling around with opengl
>glfw window + nothing else = 100mb ram usage In Java
>glfw window + nothing else = under 10mb in C++

how does this even happen?

If you use anything other than Java and Python you need to get a life or get used to being unemployed

That's what happens when people without running water script "programs".

Curry munchers that don't understand how to use malloc,calloc,realloc,new and delete/free
Pls garbage collect me bcuz I can't be trusted
So now there's a gigantic overhead for all your garbage collection
Rinse and repeat for anything else curry munchers are too stupid to do

Java is shit.
Python is shit.

If you think the same of C and Scheme then you need to suck on a fat one.

Another version of my intcat.

/**
* SUMMARY: intcat concatenates a series of integers and prints the result.
* NOTICE.: Any negative integers passed will be made unsigned.
* ........ All decimals points, if existent, will be cut off.
* ........ Cannot concatentate any zeroes at the moment.
* ........ Will add an option, -z, that will let the user concatenate zeroes
* ........ at the expense of not checking if the input is indeed an integer.
*/

#include
#include
#include
#include
#include

#ifndef DEBUG
#define DEBUG 0
#endif

// Checks for must-kill errors
#define ERR_CHECK_K(cond, msg) {if (cond) {logerr(msg); exit(EXIT_FAILURE);}}

// TODO: Add valist
void logerr(const char *msg) {
if (!msg) {
msg = "No messeage set";
}

if (DEBUG) {
fprintf(stderr, "%s:%d %s\n", __FILE__, __LINE__, msg);
}

else {
fprintf(stderr, "%s\n", msg);
}
}

// Returns the number of digits in a
int intlen(long a) {
return (int)(floor(log10(a))) + 1;
}

int main(int argc, char *argv[]) {
ERR_CHECK_K(argc < 3, "Too few arguments\nUsage: intcat "
"");

const unsigned Num_Ints = argc - 1;
long lints[Num_Ints];

// Converts the string args to longs
for (int i = 0; i < Num_Ints; i++) {
ERR_CHECK_K((lints[i] = strtol(argv[i + 1], NULL, 10)) == 0L || \
lints[i] == LONG_MIN || lints[i] == LONG_MAX, \
"An argument is out of range or not an integer.");
}

long catint = labs(lints[0]); // Stores the result of the concatentation

// Concatenate
for (int i = 1; i < Num_Ints; i++) {
long b = labs(lints[i]), s = (long)(pow(10, intlen(b)));
// Check if the resulting concatentation will be too big
ERR_CHECK_K(s > (LONG_MAX - b) / catint, "Concatentation is too large");
catint = catint * s + b; // $500,000 starting salary
}

printf("%ld\n", catint);

return EXIT_SUCCESS;
}

/* Cirno and Lain a cute! CUUUUUTE!*/

Are you trying to cover your bases before I say they're shit? Too bad, that won't help you.

What isn't shit?

Oh shut up. In a few years they'll kick us from our jobs because they'll be both cheaper and more qualified after they gain some experience.

I'm working on a script that identifies all the greentext-abusers in a thread, links all the post numbers and appends "Who are you quoting?" to the line-seperated list of post numbers.

I have a string with the format "/r text"
How would I separate "/r " from the string and put it into its own string?

>identifies all the greentext-abusers
why

Regex

>Kick "us" from jobs.
>More windows 10s pop up on market
>Pajeet interfaces, some windows have no less than 5 different context menu styles
>Everything runs slowly and is full of bugs because Pajeet cannot compile in debug and profile
>C++ development stops entirely
>PajeetSTD written 2052

I look forward to filtering your shit posts

Not him but a lot of people who abuse "greentexting" are shitposters or feelsposters.

People shouldn't use the quote feature without intending to quote someone, it's considered poor form!!!

Are you new?

Who are you quoting?

Stop responding to him

...

the irony of not knowing the "who are you quoting" meme and asking if someone else is new

how would i use that to get a word

Hello anons, I want to learn how to create my own android apps. From what I've read I should learn the basics to Java. What's a good book and/or online course I can take? Preferably one that teaches it with the assumption that you're running Linux. I'd prefer to learn hands on rather than listening to lengthy lectures... CS50 wasn't very fun with all the videos.

Clang has -O4, is this designed to absolutely break my program? I've heard of the dangers of -O3 from my GCC days.

What language are you using, user-kun?

Java

Character array. Take the indexes of the word, save it into a string.

Post code.

Thenewboston on youtube. Walks you through the basics.

>why am I using so many exclamation points?

Whom quoteth thou?

messageOriginal = ((CPacketChatMessage) event.getPacket()).getMessage();


if (messageOriginal.startsWith("/pm ")) {
String privateMessage = "";


input would be like "/pm user hello :3"

Who is the source of the quote contained in your post?

javatpoint.com/java-regex

>/dpt/ thinks they're superior to Indian software engineers who have studied 12 hours a day, 5 days a week for 4 years with state-of-the-art equipment at top universities
>/dpt/ doesn't realize (or is willfully ignorant of the fact that) an Indian computer science freshman will have to write a bootloader and a compiler IN THEIR FIRST SEMESTER or fail their degree
>/dpt/ considers themselves better than such engineers... and it's all because the engineers have brown skin
Inferiority-superiority complex much?

5,5
t. (you) bait for pepople calling you a pajeet

i mean the unwarranted anger at Indians is clearly from unemployable Sup Forumstards but i don't think your first or second statements are true at all

nice bait though, you'll catch some idiots

> studied 12 hours a day, 5 days a week for 4 years with state-of-the-art equipment at top universities
>compiling on same hardware
>scripting the same scripting languages

Here's a regex example with grep:
input: echo /pm user hello :3 | grep -oe "\s\w*\s"
output: user

what do you think lads
supposed NSA tools
github.com/x0rz/EQGRP

Don't care nor am I going to dig through thousands of shell scripts and other bullshit hoping to find one thing that's useful for me.

who here /code-let/
>take forever writing simple code
>can't wrap my head around monads

monads allow for linear ordering of dynamic effects
so you can think of them as an abstraction of procedures

explain more

e.g.

perform task a
THEN perform task b

the "THEN" bit is the linear ordering
or strict ordering, I may be using the wrong word

the dynamic part that makes an applicative into a monad, is bind or join
(join can be expressed in terms of bind)

join takes a (m (m a)) and gives back a (m a)
i.e., you have your abstract procedure that returns a new abstract procedure
the dynamic monadic part is that you can then jump into that new procedure, in the same context, while if it were just an applicative, you couldn't

the type parameter / generic bit is so you can return an arbitrary "result", e.g. (m Int) or (m ())

for something like the list monad, you can imagine each effect as being "fork". e.g.

do
x

Why do people hate Python?

Is it just special snowflakes who hate the language because it's noob-friendly and thus they can't feel special for writing FizzBuzz in C anymore?

it is absolute garbage and i cant believe you used a picture of karen to defend it

you will pay for this

ill understand this tomorrow

its purely a front-end language.

>claims it's absolute garbage
>no reasoning
Special snowflake detected

seems pretty ridiculous can you just do something like String recipient = msg.("\s\w*\s"); ?

a regex tester says that it gets the recipient name with white space attached which is fine

literal shit for brains detected

It's not a systems programming language, but that doesn't make it a "purely front end" language at all. Do you even know what 'front-end' means?

- slow
- no control
- made for intro to programming

>still no reasoning
I'm guessing I offended your special snowflake sensibilities, you're this triggered

Fuuuug I suck. Let's try this again:
Compiled and tested; it works.

import java.util.regex.Pattern;
import java.util.Scanner;
import java.util.regex.Matcher;

public class GetUserFromMsg {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);

System.out.print("Enter message: ");
String msg = sc.nextLine();

if (msg.startsWith("/pm")) {
Pattern pattern = Pattern.compile("\\s\\w*\\s"); // match words flanked by whitespace
Matcher matcher = pattern.matcher(msg);
// Get first result
if (matcher.find()) {
String recipient = msg.substring(matcher.start() /*the starting index of the username*/, matcher.end() /*the ending index of the username*/).trim();
// You now have the recipient's name.
System.out.println(recipient);
}

else {
/* ... */
}
}
}
}


It's been years since I wrote any Java.

>Slow
Wrong.
>no control
No control over what? Because it's GC? Idiot.

Its L I T E R A L L Y the language people use to front-end their projects.

You /can/ do non-front end work but you dont want to.

why exactly do people call dynamically resizing arrays a 'vector'? Rust has it as Vec, C++ as vector, and Java even has a Vector class but not commonly used.

Who did this? It confused the fuck out of me when doing graphics since that's not what vector means.

alt-c, lad
You can also highlight chunks and alt-c them.

> >Slow
>Wrong
right. Python is interpreted, and that will always be slower than a compiled (or even JIT compiled) language.

>wrong
benchmarksgame.alioth.debian.org/u64q/python.html

You are a retard for even trying to say Python is fast.

>No control over what? Because it's GC? Idiot.

This is exactly the attitude of a toddler who never used anything but Python.

>made for intro to programming
So you don't like it because lots of people use it because the syntax is clean?

This makes you a special snowflake.