/dpt/ - Daily Programming Thread

old thread: What are you working on, Sup Forums?

Other urls found in this thread:

stackoverflow.com/a/236803
visualstudio.com/en-us/products/visual-studio-express-vs.aspx
tutorialspoint.com/csharp/
github.com/jesserayadkins/lily
blog.ethereum.org/2016/06/19/thinking-smart-contract-security/
stackoverflow.com/questions/27068362/static-const-vs-define-for-efficiency-in-c
en.cppreference.com/w/cpp/locale/ctype_char
twitter.com/SFWRedditGifs

First for D

Kill yourself

Bare bruk Haskell, Elm og Idris, når skriver dere nye ting.

cute girls

>når skriver dere nye ting.
Når dere skriver nye ting (programmer hores mer naturlig ut).

Takk!

C++ question

How do I parse string "9,3,12"

then push each individual value into a list?

I am learning about networks, so that I can be proficient while hosting a website. I am stuck at the following.
Ok. So I found that the subnet physically can just be a switch.
Furthermore, subnettting further divides the host part of an IP address into a subnet and host address, and a subnet.

But physically, what is the Subnet Mask? When i type in ipconfig, i get 255.255.255.0. What is this?? Why is this 255.255.255.0, and not 255.255.0.0?

I've tried to program for ages, however I can never get it. I saw pic related in the last thread and for the past few hours tried to apply some algorithms, but I can never get it. I suppose I see projects online like coin flippers, tic tack toe, etc and I try them but can never get them to work, or I feel like they're too boring and I'm not learning shit.

So can anyone give me some guidance to basic projects that will teach me application of fundamental programming concepts, as well as a book or something to study from.

If it helps, I've tried C C++ and Python.

What you want is called splitting a string (based on the character ','.
Take a look at this stackoverflow.com/a/236803

char *str = "9,3,12";
struct {
int num[1000];
int index;
} list;
char *tok = strtok(str, ",");
while (tok)
{
list.num[list.index++] = atoi(tok);
tok = strtok(NULL, ",");
}

Indicates which portion of the IPv4 address is the network portion and which is the host portion

192.168.120.0
11000000.10101000.01111000.00000000

255.255.255.0
111111111.111111111.111111111.00000000

Any bits in the address that match with a 1 bit in the subnet mask are part of the network portion, everything else is the host portion.

wait

char *str = "9,3,12";
struct {
int num[1000];
int index;
} list = { "", 0 };
char *tok = strtok(str, ",");
while (tok)
{
list.num[list.index++] = atoi(tok);
tok = strtok(NULL, ",");
}

what the fuck

Download this:
visualstudio.com/en-us/products/visual-studio-express-vs.aspx

Do these tutorials:
tutorialspoint.com/csharp/

Go through them one by one, and don't just copy/paste the code into your editor. Write them in by hand, play around with what you're typing in, modify the code in the tutorials so you understand how it all works together, what controls what etc.

As for basic projects, that's really up to you. Try to think about what you know how to do, then what you can build based on that. If you know how to take user input, do some basic math, and display numbers... then that's enough for a BMI calculator, so try to put one together. If you're missing a crucial step, say displaying the output, then you google and try to figure out how to do that. Rinse and repeat until you git gud.

How does RAM navigate to its address?

If I tell my computer to read the contents at the address 0xFFFFFFFFFFFFFFFF, does the memory controller start searching for that address beginning with 0x0000000000000000 to 0xFFFFFFFFFFFFFFFE?

Question: I already started learning Python, but due to my busy schedule as a student. I can vaguely remember half of what I learned.

So should I instead scrap python and begin on a new?

I'm thinking about learning C.

Thanks in advance.

>but due to my busy schedule as a student i forgot information
Why do you even go to college?

Scrapping python and learning C is never a bad choice. Unless you're dead set on making web servers and nothing else I suppose.

Please, make more of these!

>2ndbestimage.jpg
Whats the best image?

Er, I get where you're going with this but it seems a bit weird.

I like how the person explains it/does this, but I can't particularly do this as functions. More so, I just need to do it on the fly in the main.

Can I not just use a for loop and if (string[i] == ',') while iterating through the string? I mean I can't 100% get it to work as i's iteration isn't managed as easily but...

you don't even have time to learn like the simplest language there is and you want to learn C instead for no reason?

There's another sequence in this same scene where Unko shows hime a page from that book, but I don't know what to put in there.

C++ Primer Plus, soon or later theyll teach you basic alorithms and its implementation

first for rust

What ep and offset? Or could you post an image maybe? I could try helping.

Let's say I have this function:
int i(const int &j)
{
//poo in loo here
}

Is it possible to create an easy reference to this function in C++?

It's a hybrid, I'm not from the U.S so It's mandatory.
Hell, I want to develop software or even OS'.
Web can be a side thing, though.
For you.
In a year, I will attend an IT university and right now I have summer vacation.

So I thought, why not use the time productively?

The other one's better imo

ep4, 2:34

I don't know why you couldn't just look it up, the entire show is like 20 minutes.

You're asking for homework help aren't you?
Let me sudo code you an algorithm.

You want to accumulate every digit between commas into one number.
For every digit you should shift the current number left one place, then add the digit.
Let's say you are parsing the number 1234.
You read the 1, number = 1
read the 2, number *= 10 + 2. Number is now 12.
read the 3, number *= 10 + 3. Number is now 123.
Then when you get to a comma, store the number in your array.

So it would be something like this:
arr[]
index = 0
number = 0
while string is not empty
read char from string
if char is not ,
number *= 10
number += convertToInt(char)
else
arr[index] = number
index++
number = 0

Doesn't matter, because she is best girl.

Because I do not wish to waste 30+ minutes of my life trying to search just one little moment, and since you knew exactly where it was, why not just ask you instead?

>Er, I get where you're going with this but it seems a bit weird.

You didn't tell me for how long you would need the list of numbers.
I could have written up a linked list or a hashmap, but that's outside the scope of your question.

>JOB DESCRIPTION

>JUNIOR SMART CONTRACT DEVELOPER (SOLIDITY)
>REQUIREMENTS:
>EXPERIENCE WITH ETHERIUM, BITCOIN, SOLIDITY, SERPENT
>STRONG KNOWLEDGE OF EVM AND ERE ENVIRONMENTS
>FAMILIARITY WITH APPLIED CRYPTOGRAPHY AND OTHER BLOCKCHAIN TECHNOLOGIES DESIRABLE BUT NOT REQUIRED
>COMPENSATION: 150000$ WITH PERKS INCL FULL DENTAL INSURANCE

tfw haven't learned solidity can't get a job
tfw learned java instead
no java jobs only etherium/serpent/solidity

I'm a failure? I'm a failure. A fuckin failure.

You could always learn those languages

Wow, calm down there, frogger.

Try turning off caps lock before you write your posts, okay?

calm down user

have you thought of some dialog?

>Let me sudo code you an algorithm.
Pseudo code.

Working on this programming language that I made, as usual:

github.com/jesserayadkins/lily

150k a year for a junior to make meme buttcoin contracts that directly handle the company's cash flow?
What the actual fuck.

>brackets
pass

What's the difference between #define PI 3.14 and const pi = 3.14;? I would think using const would provide more information to the compiler for optimization.

That's a shame, but at least one person looked at it. :)

#define is just a search and replace through your program that changes all instances of PI to 3.14.

int x = PI;
becomes
int x = 3.14;

Before the compiler even gets to look at your code.

These are not meme contracts these are UNSTOPPABLE decentralized applications, user

>calm down user
I am not upset

>have you thought of some dialog?
You could use these frames (pic). I was thinking of saying something simple like "and this is how you do a binary search" while showing a page from chapter 6.5 (where it has trees and a binary search implementation).

Sorry for the jpeg, but I forgot to configure my mpv to save in png.

>github.com/jesserayadkins/lily
Looks cute.

Tell that to DAO. But "to the moon!" amirite?

So it seems like there's pretty much no reason to use #defines instead of consts if you care about the compiler optimizing as much as possible.

Well, this actually looks pretty fucking cool. How long have you been working on it?

It seems cute and cool, I will look more deeply into it tomorrow.

>cmake
you disappoint me

Doesn't look bad
I've wanted to build my own language, but making a compiler looks like a shit ton of work. Maybe I need to learn Flex and Bison to get myself started.

Thanks! It'll be 5 years as of next month.

They fucked up their programming, Vitalik will save us from this failure short-term and provide long-term incentives to build tools to develop safe smart contracts blog.ethereum.org/2016/06/19/thinking-smart-contract-security/

math.h uses
#define PI 3.14159265358979323846

I can't think of any optimizations the compiler would do on const int pi = 3.14 that it can't do on #define PI 3.14 desu.

stackoverflow.com/questions/27068362/static-const-vs-define-for-efficiency-in-c

This shows they both compile to the same thing.

>I would think using const would provide more information to the compiler for optimization.
Nope. With #define, the compiler gets the immediate value 3.14 which is obviously constant. With const, you're trusting the compiler to take the hint and do the right thing.
There is nothing wrong with using const, but it doesn't allow for more optimizations than #define. The main reason to use const is for better error reporting, or if you want to take the address of a constant for some reason.

Neat. You don't need to write your own compiler, since you can opt to hook into something existing like jvm/clr/llvm and work with that. Parsing and lexing aren't too bad if you do them yourself. The lexing might be tough at first with off by one's, but once you get a tokenization step that works, it pretty much never has to be touched again.

Hand-writing your own parser, recursive descent is a little harder, depending on the grammar you want to do. You might be able to find a 'build you a lisp' tutorial, since lisp is easy to parse and then once you get the feel for it branch from there.

>mfw I just got away with plagiarizing another assignment
>mfw I got 100%

I'm not actually using pi, it was just an example.
#define MY_CONSTANT 3
const int my_constant = 3;

Reported

typedef int (*iptr)(const int &j)

iptr var = i;

What's better, python or ruby?

if you're going to be a smug prick and say they're both shit don't bother responding. I'm so fucking sick of you cunts

Was it programming?

>mfw classmate copied my assignment
>mfw reported him

Consider suicide.

const static has the benefit of block scope while #define is global everywhere

>python
>ruby

Yes it was programming.

Both are shit. Learn C.

Both shit m8.

story pls

I hope you weren't expecting serious answers after that last part

What are you trying to get into?

>he can't get 100% without copying others
>>in programming
You must be a sad person.

It's secret

Why aren't you part of the C+JS master race?

i'm trying to make a compiler. why?
No

>they both compile to the same thing
Perhaps not with -O3. The fpu in 86/64 chips is 80 bits wide, while doubles are 64bits. Storing mPi locally can sometimes force a 64bit coputation as on lesser optimization levels.

You're just mad I got marks by cucking someone by using their code without their permission or license. 300k starting here I come.

Just fucking kill yourselves already. I'm so fucking done with this shitty ass board and the shitty people who inhabit it. I want this place to fucking burn and would DDoS it into oblivion if knew how. You people don't fucking deserve to have a place to act like an ass unrestrained

Lisp

It's well known around this place since the ancient times that python and ruby are both shit, oriented for hipsters, sjws and pajeets and ignore thousands of years of research.

Shiiiiit, that's a lot of work for a language.

Employers look for experience, not just degrees. So you're actually kind of fucked if you're not doing any work of your own in your spare time.

>oriented for hipsters, sjws and pajeets and ignore thousands of years of research.

that's not even a fucking sentence. How the fuck can you be expected to judge a programming language if you can't even speak a human one?

If you're trying to make a non-serious compiler, then either language will do. You may want to check for libraries that you think you'll need, as that will be the make/break for you.

It is you fucking retard.

No

Not him, but it is a valid English sentence. Maybe the lack of the Oxford comma is confusing you?

>So you're actually kind of fucked if you're not doing any work of your own in your spare time.

Why would I do work in my free time? Sounds pretty gay, bro. They should pay me.

how the fuck do they ignore research?

en.cppreference.com/w/cpp/locale/ctype_char
#include
#include
#include

struct csv : public std::ctype {
static const mask* make_table() {
static std::vector v(
classic_table(),
classic_table() + table_size);
v[','] |= space;
v[' '] &= ~space;
return v.data();
}
csv(std::size_t refs=0) : ctype(make_table(), false, refs) {};
};

int main() {
// whatever stream you read from
std::cin.imbue({std::cin.getloc(), new csv()});

int a,b,c;
std::cin >> a >> b >> c; // 1,2,3
}

>>So you're actually kind of fucked if you're not doing any work of your own in your spare time.

This is actually pretty fucked up.
Programming ability is treated like a artistic skill, yet you have none of social currency of being a skilled artist.

Next time please try to include any additional questions or requests in your original reply otherwise you may be accused of samefagging.

>Programming ability is treated like a artistic skill, yet you have none of social currency of being a skilled artist.
but i'm a code artisan though

Decided to finally look at Shen today.

Lots of really cool ideas, but ultimately it makes several big mistakes:
((/. -> fuzz)) doesn't behave as expected

I can't give provide any arbitrary predicate to datatype

"Polymorphism" exists essentially in name only -- there's no convenient way to match based on type. I can't extend the semantic system to destructure any type I define

Lazy evaluation is a second-class citizen

No predicates like pair? or list? builtin

It does do some cool stuff:
>type system optional
>strong, expressive typing based on good mathematical principles
>hosted on a bunch of platforms
>builtin DSL for Yacc
>better support than its competitors (read: Haskell) for meta-programming and language extensions
>backtracking is sweet
>hosted on various platforms in an intelligent way

Ultimately, it gave me a few things I want to implement in Scheme, so it wasn't a total loss of a couple hours. Shen is great, it just feels incomplete.

what the fuck are you talking about?

The Shen programming language

I am doing an internship. Stay homo gayboy.

you're literally pulling criticisms out of your ass and trying to deflect

Are you seriously expecting help from someone that you said and who after that tried to samefag?