[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
/DPT/ - Daily Programming Thread
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 255
Thread images: 32
File: mpv-shot0056.jpg (74 KB, 1280x720) Image search: [Google]
mpv-shot0056.jpg
74 KB, 1280x720
What are you working on /g/?
Last thread >>53705124
>>
Haskell rules

Snek uses Haskell
>>
>>53705809
He is correct you fucking nigger.
>>
No screenshot, but University assignment. Fairly easy like the rest of University, just time consuming.
>>
C is the only language that matters.
>>
Learning Perl at the moment.
>>
What's your favourite programming language?
What should its slogan be?

What's your most hated programming language?
What should its slogan be?
>>
File: 1459091555909.png (521 KB, 1920x1080) Image search: [Google]
1459091555909.png
521 KB, 1920x1080
>>53714324

I don't know, but it works.
>>
>>53714378
C
Simple and cute!

Lua
Nigger and gay!
>>
>>53714378
Go.
Concurrency is not parallelism.

Greek.
Give our money back.
>>
>>53714383
What DE/WM are you using? And the bar aswell, looks super slick.
>>
>>53714397
Go treats its users with contempt.
>>
>>53714397
>Concurrency is not parallelism.
Learn English, idiot.
>>
i wanna take user input and put it in a *string in a struct. everything i try seems to fuck up. what i do pls?
>>
>>53714430
That sentence is correct, baka senpai nigger faggot.
>>
Guys I wanna automate creating webms with python but google doesn't bring up much, can you recommend me something to get me started?
>>
>>53714419
Just a tiling WM, herbstluftwm. Bar is tint2. Not much customization went into it besides a good wallpaper and a matching bar theme. Everything else is stock.

>>53714450
Post what you've tried so people can tell you what you're doing wrong.
>>
File: Screenshot_20160327-091929.png (235 KB, 1920x1080) Image search: [Google]
Screenshot_20160327-091929.png
235 KB, 1920x1080
>>53714378
Python: Computing for humans

Swift: I cannot ever stop shoveling shit into my mouth
>>
>>53714450
https://ideone.com/JKPFAo
>>
>>53714324
>mfw nobody is a combat butler here
>>
>>53714324
A little F# script that looks through the entire IPv4 address space in search for idiots that make their Raspberry Pi accessible via SSH without changing the default credentials.
>>
>>53714482
k well im extremely fucked up and i haven't slept in over 48 hours but i will try to remember
i've done like..
getline(&response, &sz, stdin);

to which i tried to strcpy, assign directly (newnode->blah = response;)
i got one kinda working but every time i printed out asll my struct elements they were all the last one i typed
so if i had like

first name
last name
age
website

and i put www.gewgz.com, first, last, age and website would be gewgz.
i dunno id on't rememr.
>>
File: mpv-shot0082.jpg (86 KB, 1280x720) Image search: [Google]
mpv-shot0082.jpg
86 KB, 1280x720
>>53714503
>no Hayate to marry
>>
>>53714488
sorry, C not cpp
>>
>>53714523
How about taking a nap and trying again next time?

If you're using the same pointer it will always point to the same line and your next getline call will overwrite its contents. Make sure you set **response to NULL again and assign whatever that points to into your struct.
>>
>>53714542
https://ideone.com/e71fc0
>>
>>53714602
No nap. This was just aquestion I remembered i waned to ask and notice d i had dpt open up in my list thing. i'll sleep tomorrow.
even when i used different pointer-- nevermind i think i see my fuckup.
>>
I have this code
 
while(cur != NULL) {
if(strcmp(word, cur->word) == 0) {
int i;
for(i = 0; i < MAXFILES; i++) {
if(cur->freq[i] > 0) {
FreqRecord *record;
if((record = malloc(sizeof(FreqRecord))) == NULL) {
perror("record");
exit(1);
}
record->freq = cur->freq[i];
strcpy(record->filename, filenames[i]);
records[reqCounter] = *record;
reqCounter++;
}
}
FreqRecord *emptyRecord ;
if((emptyRecord = malloc(sizeof(FreqRecord))) == NULL) {
perror("record");
exit(1);
}
emptyRecord->freq = 0;
strcpy(emptyRecord->filename, "");
records[reqCounter] = *emptyRecord;
break;
}
cur = cur->next;
}


for starters strcmp is returning 0 when the comparison is "write" and "a'cock'bil", which are not equal...
second it seems like when it gets to the empty record it jumps back and does more for loop iterations, i'm not sure if ddd is just fucking up or my code is wrong. my braces are closed right, so I don't know.
>>
>>53714640
nope i forget what iw as gonna do.
we'll resume this tuesday.
>>
Why would anybody write anything in rust ever when all the cool libraries are in c++?
>>
Wordpress and PHP is making me want to kill myself

It is shit on so many levels
>>
>>53714645
>strcmp is returning 0 when the comparison is "write" and "a'cock'bil", which are not equal...

It shouldn't?
>>
>>53714680
Not programming.
>>
>>53714680
>2016
>still using Wordpress and PHP
You really should kill yourself.
>>
>>53714689
What the fuck are you talking about?
>>
>>53714482
Thanks for the info anon, here have some luv <3
>>
>>53714716

It was meant as a statement, but I put a question mark there. Not sure why I did that.
>>
>>53714695
How so?

He could be working on Wordpress using PHP. This is what the post implies, in fact.
>>
I asked about this in the last thread, but does anyone have any resources on neural networks? I've written a few super simple ones but I'm not sure how to add intermediary neurons.
>>
>>53714737
And?
>>
I want to make an imageboard, but I'm bored of Python.

Should I use PHP, Perl (with cgi.pm) or something else?
>>
Cutting my teeth on a sudoku solver implemented in C
>>
>>53714754
Use rails, the transition from python will be ez
>>
>>53714750
Well, you said that it's not programming when in fact using a programming language necessarily means that you are programming. The programming language in question is PHP, and the thing that is being programmed is part of Wordpress or at least tangentially related to it.
>>
Is it true that dressing up as a grill makes you a better programmer?
>>
Just became part of one of my favourite open source program's organization on github.
Thanks /g/
>>
>>53714765
Web development is not programming though no matter how much you'd like it to be.
>>
>>53714779
Why isn't it? Please back up your claim in which you imply that using a programming language to tell the computer to do certain tasks or computations is not programming.

Or are you just being an elitist in order to feel better about yourself?
>>
File: vlcsnap-00002_zpst1qvnl9n.png (695 KB, 1024x576) Image search: [Google]
vlcsnap-00002_zpst1qvnl9n.png
695 KB, 1024x576
>>53714754
That fucking Ritsu double.
>>
>>53714789
>browsing 4chan is programming because you press buttons to execute some javascript in the background to tell the computer what to do

I'm not even gonna bother.
In any case, fuck off to >>>/g/wdg/
>>
File: 50874899_p0.png (422 KB, 800x800) Image search: [Google]
50874899_p0.png
422 KB, 800x800
>>53714754
Perl6
>>
>>53714789
PHP code cannot be reasoned about.

Also remember to use the correct function to escape strings for MySQL
>>
>>53714789
You're technically right, but it's not programming in the sense that it involves conputer science theory or skill.

You futz around in PHP and Javascript until it somehow works, and inefficiency doesn't matter because brute force
>>
>>53714378
Go.
Simple and concurrent.

PHP.
Non-programming language for non-programmers.
>>
>>53714821
Nowadays PDOs are used but I still think even the PDO functions are disgusting to use. I created a simple wrapper (fetchSQL($pdo, $query, $namedparameters) to make it at least somewhat useable. Best would be to have something like db.from("tablename").where(<some_condition>).select("column1", "column2") to cover 90% of my queries but I am too lazy.
>>
>>53714811
>browsing 4chan is programming because you press buttons to execute some javascript in the background to tell the computer what to do

You are misinterpreting, perhaps on purpose.

Writing programs which tell a computer what to do is programming. If you told the computer to press certain buttons on 4chan by writing a program, that would be programming.

If you're writing a program, essentially a set of instructions, then you are programming. There is nothing more to it than that.

You're not going to bother because you don't have an argument?

>>53714821
>PHP code cannot be reasoned about.
Sorry, I don't understand. Please explain.

>>53714854
>but it's not programming in the sense that it involves conputer science theory or skill.
The level of skill required depends on what's being written, and web development, being so diverse with many applications, can be said to require high or low levels of skill.

The idea that programming must also involve theory from computer science hasn't been proven.

>You futz around in C and assembly until it somehow works, and inefficiency doesn't matter because brute force

Look, I can say stupid things too!

>>53714875
>Non-programming language for non-programmers.

>it's not programming because I say so!
>>
>>53714910
>You're not going to bother because you don't have an argument?
No, I'm not going to bother because we're in /dpt/ and not /wdg/ which is a general dedicated to web development yet you bring web development into /dpt/ so you're simply shitposting at the best. You don't visit random generals like desktop threads, or battle station general and post about web development, do you?
>>
>>53714910
I can look at a Haskell function definition and tell you what it does. The same is not true of a PHP function definition.
>>
>>53714910
>>it's not programming because I say so!
I was quoting Rasmus. :^)
>>
>>53714875
Go: don't worry about abstraction, because it can't do it.
>>
>>53714921
>No, I'm not going to bother because we're in /dpt/ and not /wdg/
Nice argument.

>yet you bring web development into /dpt/
It's programming, so I bring it here. You may not like this sort of programming, but that's not my problem.

Simply because there is a more specific thread, that doesn't mean I can't post here. It also doesn't mean I can't post in both. Your reasoning is flawed.
>>
Hey functionalfags, what are some FP-esque functions like map, filter etc? Just need a couple of names because I'd like to implement those in Lua for fun.
>>
>>53714951
foldl
foldr
collect
>>
>>53714371
5 or 6?
>>
>>53714942
Oh, but it can. You're just retarded.
>>
>>53714922
>I can look at a Haskell function definition and tell you what it does. The same is not true of a PHP function definition.
Why not? Because you personally don't know PHP? I don't understand what you're saying.
>>
>>53714754
>imageboard
>python
https://github.com/Floens/uchan
>>
>>53715000
Side effects.
>>
>>53714910
>The level of skill required depends on what's being written, and web development, being so diverse with many applications, can be said to require high or low levels of skill.
It practically stops being webdev at that point.
>The idea that programming must also involve theory from computer science hasn't been proven.
wut
>>You futz around in C and assembly until it somehow works, and inefficiency doesn't matter because brute force
Yes, that also happens when nubs try to sysprog. Your point?
>>
>>53715000
I'd have to see the PHP environment configuration to figure out what the function does. And hope it gets called with something sensible.
>>
>>53714875
Go is the wheel reinvented for people too autistic for syntactic conventions that the rest of us are used to already.

Its concurrency is also overrated.
>>
>>53715030

I'm tired of this FP historical revisionism. If an effect is intended, it should be an effect. I will not stand for 'side effect'.
>>
>>53715031
>It practically stops being webdev at that point.
So, your point is, it becomes network-dev?
>>
>>53715076
>side effects are unintended
>>
>>53715091

They should be.
>>
>>53715076
You're free to come up with your own nomenclature :^).
>>
Happy Easter everyone.

Finished my non-sliding piece move generator, going to start on sliding piece move generation soon.
>>
>>53715074
These syntactic conventions often differ from project to project, so a language-level standard is useful to have. More so, because Go is intentionally a very simple language.

Yes, because mutex forest is a much better paradigm.
>>
>>53715017
>https://github.com/Floens/uchan
I already made one in Python, but thanks for the link.

>>53715030
So then you could say the same about any language with side effects, right?

>>53715031
>It practically stops being webdev at that point.
It stops being web development when you need to apply skill or an uncommon project?

>wut
My point was that nobody has shown that programming must necessarily "involve" theory from computer science.

>Yes, that also happens when nubs try to sysprog. Your point?
My point is that the idea of certain programming languages allowing one to "brute force" code is silly and fallacious. Only people who literally don't know how to program copy and paste code from other sources without knowing at least what it does.

What you describe as the "brute force" in web development in general also really just applies to noobs in web development.

>>53715052
>I'd have to see the PHP environment configuration to figure out what the function does.
The same could be said about other languages such as C which leave certain things implementation defined. In fact, it's worse in C because you can have UB.
>>
>>53715112

Prefer 'effect'. Side effects should be reserved for fuck-ups.
>>
>>53715127
>that color scheme
>C++
>>
>>53715173
The colour scheme is delicious and you know it.
>>
>>53715161
So then pure functions have no effect(s). Sounds even more dumb.

>>53715143
>So then you could say the same about any language with side effects, right?
Yes, but I don't know if it was what >>53714922 had been hinting at.
>>
>>53715235

No, they do have an effect, because it was intended.
>>
>>53715251
I guess I don't get it. What would then become the definition of a pure function?
>>
>>53715268
He's talking out of his ass. Just ignore the tripfags.
>>
>>53715268

The new system is based on intent rather than results. It's based on liberal progressivism.
>>
File: 1454010908047.jpg (86 KB, 537x947) Image search: [Google]
1454010908047.jpg
86 KB, 537x947
I am confuse
int64_t mp3_duration(const char * url) {
AVFormatContext *ctx = NULL;
int err = avformat_open_input(&ctx,url,NULL,NULL);
if (err < 0) {
return -1;
}
err = avformat_find_stream_info(ctx,NULL);
if (err < 0) {
return -1;
}
return ctx->duration;
}


This works just fine. But when I try to use an array as input.


AVFormatContext * create_context(unsigned char *opaque,size_t len)
{
unsigned char *buffer = (unsigned char*)av_malloc(BUFFER_SIZE+FF_INPUT_BUFFER_PADDING_SIZE);
struct buffer_data bd = {0};
bd.ptr = opaque;
bd.size = len;
AVIOContext *ioCtx = avio_alloc_context(buffer,BUFFER_SIZE,0,&bd,&read_packet,NULL,NULL);
AVFormatContext * ctx = avformat_alloc_context();
//Set up context to read from memory
ctx->pb = ioCtx;
//open takes a fake filename when the context pb field is set up
int err = avformat_open_input(&ctx, "dummyFileName", NULL, NULL);
if (err < 0) {
return NULL;
}
err = avformat_find_stream_info(ctx,NULL);
if (err < 0) {
return NULL;
}
return ctx;
}

AVFormatContext doesn't have duration set, well set to the error value that is. The rest of the fields seem just fine and I can work on it.
>>
>>53714324
>Hayate
My boy right here.
>>
>>53715714
fuck off fag
>>
Anybody have that image with the 100 different programming projects?
>>
File: tumblr_mh43cw9Q2j1rwqq0uo1_500.jpg (52 KB, 500x269) Image search: [Google]
tumblr_mh43cw9Q2j1rwqq0uo1_500.jpg
52 KB, 500x269
>>53715714
>worse than Kircheis
Worse than Yang too?

Do you know if the manga/anime ending of the show is some harem trash or do these two end up being together?
>>
>>53715822
This has nothing to do with programming. Please kindly fuck right off to >>>/a/
>>
>>53715783
better-dpt-roll.github.io
>>
>>53714378
Julia
Finally good JIT

Java
We can't afford pointers!
>>
>>53714324
Why the fuck is Hayate in the OP? It's not even a picture of him crossdressing.
>>
>>53714378
SQL
"It just works"

Perl
"Why"
>>
>>53716013
Just for you >>53714540
>>
>>53715714
Athena is best girl. I don't understand the fans' obsession with Hinagiku.
>>
Trying to get better at OOP patterns and stuff and I need help with some case studies.

If I had input for a game that is similar to Unity or Unreal in that certain inputs and axis have names that can be grabbed from pretty much anywhere.

Should I have a global Input singleton? How would I "register" different methods of input such as a controller thumbstick + mouse for a "Look Axis" input and would it be organized like a Input::Instance()->GetAxis("Look") kind of thing. Would the Input be updating variables every frame or would it be retrieving the state of the named buttons on the spot.

Something like "Jump" could be either "A" on a controller or "Spacebar" on a keyboard but How would I register both of these events and have it function properly for something like that.

C++ by the way
>>
>>53716048
literally nothing bad about perl
>>
>>53715000
For example, consider the function signature
id :: a -> a

Which means that id is a function that takes in a value of any type and returns a value of that same type. What could this function do? Excluding broken functions that loop forever and never produce a result, there is exactly one implementation that fits this type signature:
id anyValue = anyValue

Which simply returns the original argument. This is really cool if you think about it. In PHP, a function with that signature (I use the term signature loosely because php is dynamically typed) could do anything. It might read data from /dev/random/ and coerce the result into the type and then return it. It might increment a pointer and return null. It could launch missiles at Cuba before returning null. The only way to exclude possibility is to read the function definition. This is what makes Haskell so great - you can tell a lot about a function just by glancing at a type signature.
>>
File: Untitled34.png (21 KB, 640x400) Image search: [Google]
Untitled34.png
21 KB, 640x400
what am i doing wrong? i'm using java
    
public void insertAdjacent(City aCity, City adjCity) {
LinkedList<City> updatedCity = map.get(map.indexOf(aCity));
updatedCity.add(adjCity);
map.set(map.indexOf(aCity), updatedCity);
}



it's telling me
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: -1
at java.util.ArrayList.elementData(Unknown Source)
at java.util.ArrayList.get(Unknown Source)
at assg6.FlightMap.insertAdjacent(FlightMap.java:54)
at assg6.FlightMap.loadFlightMap(FlightMap.java:47)
at assg6.DeterminePaths.main(DeterminePaths.java:14)


the program's supposed to have an arraylist of linked lists of cities like in this picture i drew
>>
File: 0replies.jpg (25 KB, 221x221) Image search: [Google]
0replies.jpg
25 KB, 221x221
>>53715822
>>
I am working on a symptome-based knowledge database for first level and end user self support. Which DBMS would you use? Cassandra or Hbase? Also Solr or Elasticsearch for the search engine?
>>
File: 2014-08-12_06-15-41-231.webm (3 MB, 800x808) Image search: [Google]
2014-08-12_06-15-41-231.webm
3 MB, 800x808
>>53716117
Agreed.
>>
>>53716144
Did you read the docs? map.indexOf returns -1 if the input value does not exist in the list. https://docs.oracle.com/javase/8/docs/api/java/util/List.html
>>
How do you determine the size of an input from scanf in C? I want to let the user enter a string, and then have heap space allocated for the size of the string.
>>
>>53715822
Athena doesn't have a shot.
>>
>>53716168
scanf is shit but if you insist use %ms
>>
>>53716178
>%m
non standard pig disgusting
>>
>>53716175
I thought the one in the picture was Nagi.
>>
>>53716130
Surely this would be solved by adding function return types to PHP.

Also, if you're too lazy to read what the function does, what business do you have programming in the first place?

What's the difference between:

int id(int);


and

id :: a -> a


other than the fact that they are written in different languages?

>use IO monad
>launch missiles
kek
>>
>>53716201
It's standard, POSIX standard.
>>
>>53716221
not standard enough
>>
>>53716219
>Surely this would be solved by adding function return types to PHP.
PHP 7 has that.
>>
The other day I had an interview and the guy was asking me lots of questions about the concept of Test Driven Development, Unit Tests and how to throw a nice unit test framework around webservice development.

Unfortunately I couldn't answer all his questions.
What's a good place to start learning general stuff, from http-mocks to unit testing webservices?
>>
>>53716219
No, it really wouldn't. Yes, it's to do with the IO type.
>>
>>53716167
and it shouldn't be, so i don't know what i'm doing wrong which is why i'm asking
>>
>>53716219
int id(int);

Only works for ints where
id :: a -> a

works for all types.

int id(int);

could do arbitrary IO
id :: a -> a

does no IO

> too lazy to read what the function does
have you ever worked on a large codebase? Just a few weeks ago an engineer at work modified a function that previously did no IO to make a call to an external service. Since that function is called probably 200 million times per day by our clients, we brought down the external service with a very effective DDOS. If we had written this in Haskell, the engineer would have said "huh, this function does no IO. maybe I shouldnt make an architectural change my making it do IO." In fact, his change wouldnt have even compiled. Making guarantees like that is very powerful.
>>
>>53716292
they were trap questions, the answer was 'unit tests are completely unnecessary and only makes people good about themselves."
>>
>>53716314
So, to be clear, the type signature of a function specifies whether the function will do any IO in Haskell?

Does
id :: a -> a
constitute a function by itself?

What is the difference between this and:
function id($x) { return $x; }
?
>>
>>53716374
>So, to be clear, the type signature of a function specifies whether the function will do any IO in Haskell?
yes
>Does id :: a -> a constitute a function by itself?
No. It is a type signature only.

function id($x) { return $x; }

has no guarantees about how much IO it will do. Yes, I can tell it currently does no IO by looking at it. But that could change in the future. A direct translation to haskell would look like:
id :: a -> IO a
id anyValue = return anyValue
>>
>haskell is so shit, doing IO is a hack and needs to be a function specifier for itself and has keywords for itself

gee, a function may do IO? stop the world!
>>
>>53716433
Okay, thanks.

Seeing as id accepts any type, what would happen in the case that we have:

id :: a -> IO a
id anyValue = return anyValue + 1
and I provide id with the argument "sometext"
>>
>>53716451
You dont need to stop the world to do IO in Haskell, you just need to add IO to the type of the return value. Its not a big deal or an epic meme. It just gives the programer and compiler more information to work with.
>>
>>53716462
That wouldn't compile.
>>
>>53716462
Would not compile. Error would say something to the effect of "cannot determine that a and 1 can be added because a can be any value and not all values can be added together."
>>
>>53716462
wouldn't compile
>>
>>53716503
Not the same person but this is retarded. This should instead restrict the types a can be to anything that can be passed to + like OCaml does.
>>
While the subject is meme languages, here is a sorting algorithm I wrote in brainfuck

>>>>>,[[->+>+<<]>+>[-
<<+>>]++++++++[-<----
-->]>>+<+[->>>>>+<<<<
<]>>,]>>>[<<<<[<<<[->
>+<<[->+>[-]<<]]>[-<+
>]>[-<<<.>>>>->>>>>[>
>>>>]<-<<<<[<<<<<]+<]
<<<<]>>>>>[>>>>>]<]


".," operators do IO, there is no hack involved! Isn't brainfuck great?
>>
>>53716533
It would if no type signature was specified.
>>
>>53716315
hello hobby programmer, written any fizzbuzzes today?
>>
File: 2016-03-27_19-56-59.png (5 KB, 529x144) Image search: [Google]
2016-03-27_19-56-59.png
5 KB, 529x144
>>53716533
:^)
>>
need halp on winderps

basically i have a bunch of files named in a folder:

derp_1.png
derp_2.png
derp_3.png

how would i go about deleting the derp_ part only leaving the 1.png, 2.png, 3.png

? on win command, i think Win10 includes powershell as well
>>
>>53716577
Yes, what?
>>
>>53716533
Why? The explicit type signature puts no restrictions on the value of a, so a could have type Car or any type that coudnt be added. That's why I say
id :: a -> a

has only one implementation - there's not much you can do to arbitrary values and no IO. If you wanted to your function to work on addable values, add a Num restriction:
fun :: Num a => a - > a

which reads "for any type with + defined, take in a value and return a new value of the same type. Sample implementations could be:
fun a = a + 2
fun a = a + 3
fun a = a * 5
fun a = a

Statically typed languages wont let you perform addition on arbitrary values.
>>
>>53716616
install linux, then run
for name in *.png
do
newname="$(echo "$name" | cut -c6-)"
mv "$name" "$newname"
done
>>
>>53716577
>using the smiley with a carat nose
>>
>>53716647
>Statically typed languages wont let you perform addition on arbitrary values.
>what are templates and operator overloading
>>
>>53716655
>>53709145
>
>>
>>53716655
It's carrot, not carat.
>>
>>53716647
Haskell is retarded if it requires that.

>Statically typed languages wont let you perform addition on arbitrary values.
This is not what I asked.

>which reads "for any type with + defined
Doesn't seem like it.
>>
>>53716667
"arbitrary values" != "a type with + overloaded on it"
>>
>>53716691
You're retarded if you dont see how that's exactly the same as C, C++, C#, Java, Ocaml, and every other compiled language out there.
>>
>>53716712
It isn't.

>compiled language
There are no compiled languages.
>>
>>53716728
mom this wont compile :(
public Object fun(Object a) { 
return a + 2;
}
>>
>>53716744
Needs more beans, my boy.
>>
>>53716744
>C#
It's shit.
And actually has nothing to do with the topic.
>>
>>53716755
>C#
>>
>>53716702
What do you mean?

template<typename T>
T f(T a){
return a + 1;
}

This will work as long as + 1 works for a, be it integer, double, pointer or a class with + overloaded on it.
>>
>>53716755
>>C#
>It's shit.

You take that back you.. you.. double nigger.
>>
>>53716805
>double nigger.
Are you sexually attracted to me? You nigger-loving cuckold.
>>
>>53716787
>this will work as long as a is...
then a is not arbitrary
>>
>>53716817
Nobody claimed that you fucking faggot. Stop talking to yourself.
>>
>>53716815
>You nigger-loving cuckold.

Stop trying to make cuckoldry happen.
>>
>>53716676
*caret
>>
>>53716879
No, it's pointy like a carrot. A carat is a unit of measure.
>>
I'm writing my own shell in C. How do I see when the user presses tab so I can autocomplete.
>>
>>53716964
fgetc
>>
>>53716964
if(key_pressed==TAB_ASCII_VALUE) {
autocomplete();
}
>>
>>53716964
What system and what library? In pure C you can't do that except if you just check for \t in stdin.

>>53717001
Just no
>>
>>53716948
A carat is a unit of measurement, but I said a caret, not a carat
https://en.wikipedia.org/wiki/Caret
>>
>>53717008
Pure C ;_;. How does bash do it?
>>
>>53717055
you can't
>>
>>53716547
Is there a language that builds upon brainfuck and uses code snippets like yours as functions?
it'd seem a lot like writing shell scripts since you're streaming IO across programs
also it'd allow parallel execution of brainfuck code
>>
>>53717061
Okey. Then how does BASH/Zsh do it?
>>
>>53717055
Bash uses the readline library. Other shells use libedit I think? You can make your own with (n)curses or POSIX.

>>53717061
He can, if he checks for \t from stdin.
>>
>>53717074
Your terminal uses a system specific library to get key inputs.
>>53717081
stdin is usually buffered on OSes. No key will be sent until user press enter
>>
>>53717081
Thanks!
>>
>>53717049
Claret is a wine, doofus
>>
>>53717111
>stdin is usually buffered on OSes
This is why set(v)buf exists.
>>
>>53717073
implementing a brainfuck interpreter is not that hard, you can easily make a library to support brainfuck in your code
>>
>>53717142
here's the (You) you want for attention
>>
>>53717073
>also it'd allow parallel execution of brainfuck code
I posted a brainfuck implementation that supported pthreads a few years ago.
>>
>>53717148
are you sure this disables terminal's buffer? I am not on linux right now
>>
>>53717205
No, it's not portable. You need to use POSIX functions there.
>>
>>53716834
you did, here >>53716667 are you autistic?
>>
>>53717351
Actually, I am. Pretty low to use that as an insult.
>>
>>53717351
Not me. You claimed something about "arbitrary values" before that at >>53716647
>>
>>53717363
woah man I had no idea sorry dude I didnt mean it as an insult. its endearing, you know?
>>
I'm working in c++. I have a vector that stores structs which have a char as a member field and I have a class that has a set as a member and it stores pointers to the stuff inside the vector I mentioned.

I did a fucking double check. Inside the class constructor, I print out the addresses I stored in its member set and then after the whole construction is complete I iterate through the instance of the class and it prints back the addresses I constructed it with. When I dereference them inside the constructor they give the correct chars, but when I dereference those addresses again somewhere else, even though they are correct, the chars are fucking gone.

I'm losing my mind here. What can cause crap like that?
>>
>>53717543
maybe pointers get invalidated when vector reallocs?

generally, you don't want references/pointers to items in vector
>>
>>53717543
Sounds like the vector went out of scope. If that happened your pointers would be pointing to garbage.
>>
File: 1455299342780.jpg (36 KB, 246x274) Image search: [Google]
1455299342780.jpg
36 KB, 246x274
Please suggest some good short intro to Linux GUI theory. I used to develop GUI apps for Windows for a while but I don't want to develop for a shitty proprietary botnet OS anymore.
>>
>>53717543
use a deque
>>
>>53717578
>>53717622
That's the first thing that occurred to me, but that's strange. the first thing I do is fill the vector in, and I don't touch it after that.

the code is more or less
readIntoVector(vector);

readIntoClass(Class, vector);

PrintOutWhatEverIsIntheClass();
>>
File: 1435180155102.jpg (268 KB, 758x663) Image search: [Google]
1435180155102.jpg
268 KB, 758x663
>>53717709
As someone who did this, there are no good docs, Glade is your friend, you are going to have to deal with GTK at some point.
I just pretend everything is GNOME and rig something together with as little actual interactiion with GTK as possible.
>>
>>53717736
It's just what I don't want since I'd have no way to procure the address of the element I need.
>>
>>53716048
SQL isnt a programming languages, its a query language.

Its even in the name you numnut
>>
>>53717860
You can program with SQL.
>>
>>53717709
>GUI theory
Wat
>>
>>53714483
what's so bad about Swift? i messed around with it a while back, and while the syntax wasn't optimal, the language itself had a pretty decent set of features
>>53715161
this is the term generally used with algebraic effects
>>
>>53717744
You are using a copy of the vector instead of the actual vector. The copied vector goes out of scope as soon as the function call ends. Try passing by reference instead.
>>
>>53717947
*using a copy of the vector instead of the actual vector when you pass it to a function.
>>
>>53717918

That reminds me, I've been meaning to try out Silver, which is Swift for .NET.
>>
>>53717947
>>53717964
I figured it out on my own, but thank you nonetheless.
>>
>>53717981
>try out Silver
wat
>>
>>53718020

It's Swift, but for .NET, so I don't need to be a MacFag to use it.
>>
File: fsharp256.png (3 KB, 256x256) Image search: [Google]
fsharp256.png
3 KB, 256x256
>>53718085
I hate to be such a shill, but can't help myself, so here it goes. Why not give F# a shot instead?
>>
>>53718085
Just a normal fag.
Filtered.
>>
There is no reason to use go when nim exists.
>>
>>53718166
>nim
Trash
>>
>>53718156

I'm a fag. Frankly I have nothing against F#, and no reasons not to use it, I just haven't gotten around to it yet.
>>
I hate asking and you will all tell me to fuck off but I'm new to programming and I want to learn C or C++ to program my arduino for projects, Is it a bad start to learn a hard programming language? Am I digging into something that will be too hard for me and in the end will make me hate coding? if it's a yes which language should I go to in the first place? I just wanna do robotics
>>
>>53718323
>Is it a bad start to learn a hard programming language?
No, this is a meme.
>>
>>53718323
all programming languages are basically the same. C or C++ aren't inherently hard to learn, theyre just harder to learn
>>
Would making a multiplayer websockets game be considered programming or should I fuck off to /wdg/?
>>
>>53718188
>passing judgment on a language he's never used
typical behavior you'd expect from a Go """programmer"""
>>
>>53718404
I don't use Go :^)
>>
>>53718341
>>53718350
So which one is more benific? C++ or C? I know that C++ is object oriented and C don't.
>>
>>53718444
C++ is a clusterfuck. Just learn C if you want to program your ardwooynoh
>>
>>53718444
C++ is not really Object Oriented. C++ is clusterfuck oriented.
>>
>>53718462
>>53718477

kek ok, I started to read this yesterday it<s quite easy to understand in the beginning yet my friend who program told me I<m in something that might turn me off
>>
>>53718536
It was the reverse for me. C is what turned me into programming. I tried C++ and some shitty languages before but they didn't taught me anything.
>>
>>53718536
Start with nasm, then progress to fasm and tasm. Learn some ARM too
>>
>>53718580
>not starting with GAS and staying in GAS.
>>
>>53718444
c++ is way more benefic.
you can't really use C for anything other than writing drivers, kernels, and embedded
>>
>>53718599
Spotted the bullshitter.
>>
Hi, can anyone solve this problem?

filepath = '/path/to/directory/myfilepaths'
location = raw_input('Where is the file? ')

with open(filepath, 'r') as mf:
for line in mf:
nline = line.replace("\n", "")
# cline = glob.glob(nline + '*') #PROBLEM LINE
path_obj = os.path.join(location + str(nline))
obj_stats = os.stat(path_obj)


Inside /path/to/directory/myfilepaths(file)

/current/0.e_head/10000000d.000000002__head
/current/0.13_head/10000008.000000001__head
..


The true filenames on the file system is

/current/0.e_head/10000000d.000000002__head_918293
/current/0.13_head/10000008.000000001__head_9891283


So what I have in myfilepaths is a list of file paths, I know this may sound weird but what I need to do is iterate through a list of files in myfilepaths and then perform actions on these files. So what I am looking for is to use glob as * in linux, where I can match any files which start 100... whatever and then put * to match all files with unpredictable characters at the end.

When I delete the comment in the problen line and change to cline in path_obj. It says my input from
location
with [] at the end.

Can anyone help me please?
>>
File: what.png (118 KB, 1387x855) Image search: [Google]
what.png
118 KB, 1387x855
I'm trying to 'link against a library' in C++. ITS NOT FUCKING WORKING

I've watched over a billion fucking tutorials on youtube, I swear to god im gonna strangle a fucking puppy someone explain me how I do this fucking shit

http://www.oblita.com/interception.html. I'm trying to get the first example working

Running MinGW and CLion. Pretty much a beginner in C++.

I've downloaded the interception library (which included two folders x86 and x64, and the files interception.h, utils.c and utils.h).

Next I've done this in my CMakeLists.txt:
>set(SOURCE_FILES main.cpp utils.h utils.c interception.h)

Next I've copypasted the first example on the interception page, BUT instead of doing
>#include <interception.h>
I've done:
>#include "interception.h"
Because <> wasn't working at all

I've put all files and folders in the root directory of my project. I have also run the .exe command line thing that the website told me to do.

Someone please fucking kill me
>>
>>53718674
I'm having literally the same problem for the last 12 hours now.

FUCK YOU ECLIPSE FUCK YOU
>>
>>53718674
how how easy this would be without cmake

g++ -linterception main.cpp utils.c
>>
>>53718674
lol, windows.
>>
>>53718749
>>53718674
well to answer your question

set_target_link_libraries(interceptionTest interception)
>>
>>53718674
>CMake
>CLion
>>
>>53718580
>>53718593

wait what?
>>
>>53718804
Nothing
>>
>>53718768
he also needs FindInterception.cmake module in CMakeModules, because clion + windows lol
>>
>>53718832
>windows
lol
>>
>>53714324
thanks for using an anime image, OP
>>
>>53718768
>Error:Unknown CMake command "set_target_link_libraries".

>>53718776
>>53718749
>>53718738
>>53718832
This shit is giving me fucking cancer, should I just use G++ and like Notepad++? I really like CLion because I'm a jetbrains cuck, but CMake is the worst fucking thing I've ever experienced
>>
>>53718869
yes.
fun fact: shit autocomplete will make you a better programmer because you will have to read the documentation

btw you could also use visual studio it's very easy to link libraries there
>>
>>53718869
oh, my mistake

it's
target_link_libraries
>>
>>53718674
>>53718738
yet another example of why not to use an ide
>>
File: 73467856.jpg (85 KB, 623x626) Image search: [Google]
73467856.jpg
85 KB, 623x626
>>53714324
A small toy project on JS and react that went out of hand and became a year project.
>>
>>53718869
Use GCC and Kate/Nano/Emacs/Whatever on GNU/Linux.
>>
>>53718738
This is wrong btw
the -linterception needs to go behind the source.
g++ main.cpp utils.c -linterception

When the compiler scans the source it keeps unresolved links for later. a
-lLibrary
scans the library for any symbols that have not yet been resolved in the source files scanned so far.
>>
>>53718914

Isn't that how it goes? From "I just want to test this out" to several K LOC.
>>
>>53718890
>btw you could also use visual studio it's very easy to link libraries there
Other anon with the library problems here. Fuck this, you're right. Nobody should have to go through 12 hours of this bullshit. So long eclipse, hello VS
>>
>>53718567
yup, initially tried C++ and i basically learned nothing of substance when i tried
>>
>>53718967
but the god tier choice is emacs.
other than being infinitely customizable, the navigation keybinds are irreplaceable.
i can't use any other editor without rebinding everything to emacs keybinds
>>
File: 1424876697266.png (75 KB, 198x198) Image search: [Google]
1424876697266.png
75 KB, 198x198
Tfw you btfo everybody who tried to bully you for programming in Notepad.
>>
What's the point of programming when everything already exists as an API?
>>
>>53719041
>Can't even handle UNIX Line endingsEnjoy your one line, faggot
>>
>>53719054
I use programming to supplement my math studies.
>>
>>53718323
well for adruino you have to use C or ASM anyway... so your question flawed.
>>
>>53718644
Anyone.. Please?
>>
>>53719176
use a better language faggot
>>
What is /g/ recommended text editor for a beginner programmer?

I am using notepad++ and sublime text 3, sublime text 3 is cool.
>>
How do I make something good? Should I java?
>>
>>53719257
Java will make anything good
>>
>Learn C
>Write some sorting algorithms
>Get bored
What now?
>>
>>53719327
Sort your sorting algorithm with a different sorting algorithm.
>>
>>53719242
Sublime text on windows, Emacs on Linux
>>
>>53719242
Notepad++ or sublime.
Thread replies: 255
Thread images: 32

banner
banner
[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y] [Home]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.