[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Extra juicy! | Home]

/dpt/ - Daily Programming Thread

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 325
Thread images: 24

File: progcomfy.png (609KB, 700x714px) Image search: [iqdb] [SauceNao] [Google]
progcomfy.png
609KB, 700x714px
[Daily Programming] Thread

Pair Programming++ Edition

Wat are u workin on, anon-chan ?
>>
>>51595491
import faggot
print "op is a faggot"
>>
second for qt programmer traps!
>>
>>51595516
>using python 2
>>
File: 1435445674946.png (293KB, 443x406px) Image search: [iqdb] [SauceNao] [Google]
1435445674946.png
293KB, 443x406px
>>51595491
all those tissues from schlicking
>>
Nearly done with the login flow for my game server. I've decided to go with JSON as it is the easiest to maintain.
>>
>>51595491
That office looks awfully cramped
>>
>>51595491
> OUT KEEP
>>
How difficult would it be for a beginner in C to write a program that conjugates and declines Latin verbs and nouns/adjectives?
>>
File: 1443986196161.jpg (79KB, 600x586px) Image search: [iqdb] [SauceNao] [Google]
1443986196161.jpg
79KB, 600x586px
Reposting from previous thread.

Anyone got any good resources for C#? I'm looking to learn the basics with material thats easy to follow. I've tried the wiki and the links dead.
>>
>>51595491
>can afford a vaio and AC
>cant afford a bigger room
>>
>>51595562
really hard.
>>
>>51595562
I mean.. you could obviously.
But strings in C are pretty annoying when you're not used to it - and such a project sounds string heavy.
Go a tad more highlevel perhaps
>>
fn split_at(&mut self, mid: usize) -> &'a str {
let ret = &self.source[..mid];

self.source = &self.source[mid..];

ret
}


Reposting because I would like a better/more elegant way to write this function.
>>
>>51595572
>one-time purchases having any relation to how much rent she can continuously pay
>>
>>51595562
It's called C for a reason: it's a CTlanguage.
>>
>>51595527
>not using python 2
>having a reason to python 3
>ever
>>
>>51595566
You might find this interesting if you're familiar with java already: https://en.wikipedia.org/wiki/Comparison_of_C_Sharp_and_Java
>>
>>51595559
vertical writing in Japanese is right to left
>>
Why is Christianity still a thing? It's one of the main reasons sexism exists in programming.
>>
File: disgust.jpg (84KB, 653x463px) Image search: [iqdb] [SauceNao] [Google]
disgust.jpg
84KB, 653x463px
This might sound stupid but I can't get it to work. After reading how many rows and how many columns a matrix has, I'm trying to display the minimum element on each row, then the minimum element on each column.

My code looks like this, but sometimes it throws an IndexOutOfBoundsException, sometimes it just doesnt display the minimum for the columns, only for the rows.

The code for the rows, which works, is this

public static void minRand(int[][] n) {

int[] result = new int[n.length];
int min = 0;


for (int i = 0; i < n.length; i++) {
for (int j = 0; j < n[0].length; j++) {
if (n[i][j] < n[i][min]) {
min = j;
}
result[i] = n[i][min];
}
System.out.println("Minimum on line " + i + " is " + result[i]);
}

}


And the code for the columns, which does not work is

public static void minCol(int[][] n) {

int[] result = new int[n[0].length];
int min = 0;

for (int i = 0; i < n.length; ++i) {
min = Integer.MAX_VALUE;
for (int j = 1; j < n[i].length; ++j)
if (n[j][i] < min)
min = n[j][i];
System.out.println("Minimum on column no " + i + " is " + min);
}

}


If i give it 3 lines and 4 columns, the console displays this:

Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 3
at Principal.minCol(Principal.java:103)
at Principal.afisareMeniu(Principal.java:196)
at Principal.main(Principal.java:13)

Minimum on line 0 este 0
Minimum on line 1 este 0
Minimum on line 2 este 0


It's 0 because i didnt initialize the matrix, but the minimum on each line works.

Also. If i give it a square matrix, both the minimum for rows and columns work. What am i doing wrong?
>>
>>51595566
Learn Visual Basic through YouTube, then watch a few videos on C# and C Syntax. There the same thing senpai
>>
>>51595631
this is pretty low quality bait
>>
>>51595612
There are lots of reasons to use Python3 and virtually no reasons to use Python 2 except that you're scared of change and you're really entrenched in code that relies on python 2-exclusive libraries.

but you haven't shown that you're working on anything that justifies your obstinance.
>>
>>51595612
Python 2 has been end-of-lifed. 3 is the future.
>>
non-gay thread

>>51595634
>>51595634
>>51595634
>>
>>51595631
>sexism
>programming
Tumblr pls go
>>
>>51595626
It's in english though
>>
>>51595636
>being a faggot
>>
What's wrong with Python 3 again?
>>
>>51595626
But that english..
So if I write in Japanese, I should write left to right because I write english mainly?
>>
>>51595668
nothing, nothing is wrong with python 3.
>>
>>51595654
fuck off cumpai
>>
>>51595668
it broke compatibility with Python 2 and autistic people who can't handle change felt personally betrayed by that.
>>
Is the safe? For checking if i have internet conection and then restarting.
For ( 1>0){
if (!(Test-Connection www.google.com -quiet))
{
Restart-NetAdapter Ethernet
sleep 5
}}
>>
>>51595668
Nothing. Pyfags just have an issue with it for some probably trivial reason
>>
>>51595690
>>51595690
help me guys
>>
>>51595695
python 2 is end of life and almost all of the libraries have been ported to python 3
>>
>>51595654
>Report submitted! This window will close in 3 seconds...

>>51595631
because republicans
>>
>>51595698
What kind of mongoloid language is that?
>>
File: 1444013904158.jpg (640KB, 944x1016px) Image search: [iqdb] [SauceNao] [Google]
1444013904158.jpg
640KB, 944x1016px
>>51595613
I familar with javascript and web development but not java

>>51595638
Funnily enough I've already completed a course on basic a long time ago, I'll get up to scratch with that and then move on to C#.
>>
>>51595527
>using x
>not using my_favorite_language
fuck you
>>
>>51595739
powershell
>>
>>51595636
Use multidimensional arrays brah
var i = new int[5, 2];

Or is that shit too difficult for jaba
>>
>>51595698
>google.com

Enjoy you're botnet. Can't you check your DNS provider instead?
>>
>>51595784
>>51595698
8.8.8.8
>>
>>51595698
you really can't tell what that does? it's pretty self explanatory. i've never used powershell either

>check if connected to google
>if not, restart ethernet
>wait 5 seconds and repeat
>>
>>51595822
i wrote it
>>
>>51595822
yeah but if we are connected to guggle, it'll just loop ad infinitum. Made me confused
>>
>>51595611
>>51595589
>>51595577
Well, it seems like a fun idea. Should I try?
>>
>>51595849
> Is the safe? For checking if i have internet
> conection and then restarting.
> For ( 1>0){
> if (!(Test-Connection www.google.com -quiet))
> {
> Restart-NetAdapter Ethernet
> sleep 5
> }}
I quote it
>>
>>51595676
In Japanese horizontal text is written left to right. You should only write from right to left if you are writing vertically. For example,
ABC
DEF
is horizontal text, but
D A
E B
F C
is the vertical version of that.
In vertical text, the right-most column represents the top line of the horizontal text.
>>
I'm learning the basics of C. does it matter if I'm using C89/C99/C11 right now?
>>
>>51595864
Not sure what level you're at, but just remember:
There are no 'strings' in C.
Only character pointers to the first character of your 'string'.
The string is then the next contiguous series of bytes until the null terminator (a byte/char with value 0 or '/0').
>>
>>51595932
Use C11 - makes things easier
>>
Help, /g/. My company is about to go full retard.

They want to go to app development from web development.
That's more than welcome from my point of view. Fuck PHP, fuck the frontend.
However, they're planning to use Unity3d for it. Yes, for apps. Not for games. A fucking game engine for apps, because "it's free".
They seem to think that Xamarin is too expensive.

But using Unity for apps is like... you don't even get native APIs or UIs, the battery is drained instantly and even a hello world application is 50MB large.
How the hell am I going to make it obvious to them that this is a terribly wrong decision and that no user is going to want to use an app like that?
>>
>>51595932
>>51595966
It doesn't massively matter though - C's never really changed, it's just been added to primarily.
>>
>>51595966
Yeah. Except, you know, finding jobs.
Because NO C job EVER uses C11.
Thanks to Microsoft, we'll be stuck on C89 forever and ever.
>>
>>51595978
Just use Phonegap.
>>
>>51595978
Why not just write apps in JavaScript? You can sell it as similar to web development.
>>
>>51595993
then what are the main differences between each version of C? if I compiled it under C89, will it compile without problems under C99 and C11?
>>
>>51596043
99% of the cases, yes
>>
>>51596072
ok cool. I'll do some tutorials and worry about what version of C I'm using later when I get better.
>>
>>51595932
get a book that teaches both, because you have to know both C89 and C99, ie C Programming: A Modern Approach, because you are going to have to deal with both kinds of code. the main difference is how integer types are handled, most the other features are optional. I really like being able to declare the counter variable inside a for loop, that one thing makes me want to use C99
>>
File: 1431087540696.gif (2MB, 316x166px) Image search: [iqdb] [SauceNao] [Google]
1431087540696.gif
2MB, 316x166px
>>51595612
>keeping back python development
no anon, you are the cancer.
>>
>>51596024
>>51596037
Bah. I mean, yeah, it clearly beats a fucking game engine, but app development in HTML5,CSS and Javascript is seriously shit.
C# and a proper interface designer with support for the common UI patterns and access to the actual APIs is, in my opinion, definitely the right way to do things.

Sure, if you want to make non-reusable, laggy and non-native looking crap, PhoneGap is probably amazing for you...
>>
>>51596110
Have you ever worked with Xamarin?
>>
>>51596129
Yeah.

Of course it's not ideal to have to make the frontend for each platform individually (unless you use XamarinForms), but it beats a "one frontend (does not) fit[s]) all" approach.
>>
>>51596043
C89 _should_ compile without modification under C11 (unless I've forgotten something).

C11 adds:
- In-language alignment options (_Alignas, _Alignof, stdalign.h)
- Very rudimentary generics (_Generic)
- Official multi-threading support (_Thread_local, threads.h)
- Improved unicode (char16_t, char32_t)
- Anonymous structs and unions.
- Static assertions (assert.h)
- Loads of utility macros for benign operations.
>>
>>51596110
Well it is your only other option that is free
>>
>>51595716
move out and get a job
>>
>>51596107
Guido is the one keeping back python development. He's the cancer.
>>
>>51596214
See more here: https://en.wikipedia.org/wiki/C11_(C_standard_revision)
>>
>>51596214
FILE in C11 can be a incomplete object, thus you can't do sizeof(FILE) or declare a FILE variable.

C99+ define a restrict keyword, so if you used it in your programs before that as a variable name, it will not compile.
>>
>>51596185
I did some Xamarin too. The idea of sharing business logic while keeping the native look&feel is pretty good. Like you said, money is usually an issue. The biggest problem I have with Xamarin is fucking MonoDevelop. It's even worse than Eclipse and IntelliJ combined.
>>
>>51596296
Yeah. They really desperately try to copy Visual Studio - and they are more successful at copying its flaws than the things that makes it great.

We're a Microsoft Partner though, so we should get VS at somewhat affordable prices. I know that one of us (3) already has it and the basic Xamarin corporate license includes that VS plugin.

I really wonder how money can be an issue. I mean, if our work is so worthless that 6000€ per year is a lot to us, then that is really quite sad.
>>
>>51596361
Most of my coworkers use macs and I run Linux so VS is useless to us. I don't know that freeware version is useful when using Xamarin though.
>>
>>51596384
I see.

I hate this. Just when I thought that I could finally escape the unholy trinity of web development... So I'm still going to make json APIs in PHP with shitfony and create user interfaces in HTML, CSS and JS?
Argh! No progress has been made... None. I was actually looking forward for this app development business.

I swear, when I'm done with my apprenticeship, I'm TOTALLY going to find a company that uses C# or C++ or Swift for... whatever.
Web development is a peasant's job and it will never improve because of IE and JS.
>>
>>51595636
in minCol()

if(n[j][i]... is wrong. The way you've written it, i is the column number and j is the row. So you want to walk down each column. i.e.

n[0][0] = column 0 row 0
n[0][1] = column 0 row 1 = n[i][j]
... as you work through the loops.

also, for(int j = 1...
why skip 0?
>>
I'm trying to just download a file in C++.
I was told to use URLDownloadToFile from urlmon.h

My compiler doesn't recognize it. I was told it's from urlmon.lib, which I don't have and can't find.

What now?
>>
>>51596460
le vendor lock in face
Seriously, mobile development is shit. Look at the desktop. There're some top notch frameworks available, like Qt.
>>
>>51595978
libgdx
>>
What UI pattern do you use let the user "sort" items on a website?

Of course, the obvious answer is drag & drop... But since none of the mobile browsers implement the API, I'm thinking that this doesn't work well on mobile, which is why they won't implement it?

But the alternative would be... what? <select>?
>>
>>51596460
>will never improve because of IE and JS.
JS is bad, but it's far far from the worst language out there. IE is not really a problem anymore.
>>
>>51596549
I let the users write their own regex.
>>
>>51596296
>MonoDevelop
you mean Xamarin Studio?

Xamarin works with VS you know.
>>
>>51596549
That's more of a website design problem, anon. Ask the other general.
>>
>>51596513
>what is a linker
>how do i make program
>>
>>51596384
>Most of my coworkers use macs and I run Linux so VS is useless to us.
>What are VM's
>>
>>51595631
go let your gf sleep around
>>
>>51596595
how do i link stuff in CMake?
>>
>>51596561
>JS is bad, but it's far far from the worst language out there

The main problem nowadays is the speed. There are some comfy frameworks out there and even Libraries like Polymer which actually make web development... yes, fun.
But then, your application needs like 3 seconds to display anything (more like 15 to render everything correctly on mobile, seriously, visit Polymer's official documentation on Windows Phone) and does nothing when JS is disabled or the user's browser is not compatible.

>IE is not really a problem anymore.
It is, when your company desperately wants to support even IE 8. Even IE 9 is still very bad.
IE 10 implements much more, but most of the implementations are buggy and slow.
IE 11 is going to be the next IE 8.
Yeah, it is a problem. It will always be a problem.
>>
>>51596582
Does not work on Linux.
>>
>>51596601
>not using Windows in the first place
>needing to let another operating system sleep with yours

C U C K
U o o C
C o o U
K C U C
>>
>>51596630
CMake is shit
>>
>>51596665
see
>>51596601
>>
which language compiles to the smallest binaries
>>
>>51596630
http://stackoverflow.com/questions/8774593/cmake-link-to-external-library
>>
>>51596695
assembly
>>
>>51596695
assembly
>>
>>51596695
Java
>>
>>51596695
Writing the machine code yourself / using an assembler is the only way.

However, usually, you don't have to care unless you program very primitive embedded systems or make demoscene programs.
Even for embedded systems, C++ is used nowadays.
>>
>>51596695
Python & JavaScript
>>
File: studentscum.png (34KB, 1008x733px) Image search: [iqdb] [SauceNao] [Google]
studentscum.png
34KB, 1008x733px
>2015
>Not building your own virtual computer and operating system from scratch
>>
>>51596765
>2015
>virtual
>>
thanks
>>
>>51596832
you're welcome
>>
>>51596832
fuck you
>>
hi
>>
>>51596916
hi :3
>>
xD
>>
>>51596696
how do i do that for a library that's in System32 without importing everything in System32?
>>
>>51596916
>>51596929
3==D

Open your mouths, ladies.
>>
>>51597026
Ebin
>>
>>51597114
are you into boys, anon
>>
>>51597145
O-Only cute ones, l-like you.
>>
Can someone help me with how to read a series of integers from a file that are simply formatted like this:
1
2
3
4
5

I have no idea and everything that I can find seems far more complicated than it needs to be.
>>
>>51597254
get(),
use ifstream
>>
>>51595491

1. Canvas app/ site for a freelance job
2. Set of pixel sorting scripts for Processing/ just for fun & sharing
3. Porting an old python program which streams live betting data and draws nice graphs
4. Another Canvas app/ interactive point-and-click adventure
5. OpenCL program for finding very large primes (over 10 million digits)
6. That game I'm never going to finish

Too much on my plate really :< Should quit my day job. I'd starve but at least I'd die leet.
>>
>>51597254
What language?
Usual procedure is to read it in line per line, then read the integer.
>>
>>51597272
Yeah, a simple loop that reads line by line while !eof (end of file) should be enough to get the numbers in, but I'm not sure if you'd need to static_cast all of them to use them like integers
>>
>>51597459
For a naïve C++ implementation, by the way
>>
>>51597459
yes, I think you'd have to cast it to (int)
>>
>>51596008

The reason why MSVC only supports C89 fully, is because the majority of MSVC users are C++ programmers, and will compile C as C++. People who program in C as C, for purposes such as embedded development or system programming, are likely to use another compiler, such as gcc or clang, both of which support C11.

>>51596274

>FILE in C11 can be a incomplete object, thus you can't do sizeof(FILE) or declare a FILE variable.

Are you sure that sizeof(FILE) isn't implementation defined?
>>
File: sizeoffile.png (54KB, 1366x768px) Image search: [iqdb] [SauceNao] [Google]
sizeoffile.png
54KB, 1366x768px
>>51597671

Was going to attach this, forgot to.

You can sizeof(FILE) in GCC.
>>
>>51597671
can you do sizeof (any incomplete type)? I thought it was undefined behaviour.
>>
>>51597708
This is because in glibc FILE is not a incomplete type, try in musl.
As I said
>can be a incomplete object
>can
not that it is
>>
>>51595743
>>not using my_favorite_language
Who the fuck uses snake case?
>>
>>51597840
real programmers
>>
you're all stupid
>>
>>51597904
but we're happy
>>
C# question here.

What's the more widely accepted way to do this. VARIANT 1 (using base) or VARIANT 2 (using this) when the class that inherits doesn't have a corresponding class variable itself?

class test1
{
public string text = "Hello World";

public void test(){
Console.WriteLine(text);
}
}

class test2 : test1
{
public test2()
{
base.text="Goodbye World"; // VARIANT 1
this.text="Goodbye World"; // VARIANT 2
}
}
>>
>>51591772
it's not possible to make a chatroom without PHP, right? using poorly Javascript
>>
>>51597989
non-c# here
i like base.text because it shows its a class base member

this is also good though because it's more explicit about referring to the current instance

can you do this->base->x or this.base,x in C#?
>>
>>51591772
do you have github
>>
>>51597840
You could say there's only one kind and that would be
.
..
.
.

.
python programmers
>>
>>51597989
Best way is probably to have a constructor in test1 and then call it using super in the derived constructor.
>>
>>51595636
>++i
>++j

There's your problem.
Also, like anon said, why start j from 1?
>>
>>51598067
>can you do this->base->x or this.base,x in C#?

base is a keyword, not a property so it's not doable.

>i like base.text because it shows its a class base member

Yeah, I myself feel that too, "this" is like "yeah this is here" while it's not factually true in this situation.

>>51598113
Well my example is meant to be more general.

What about inherited .net classes? You can't alter constructors there in such a way. The code that I'm working on is exactly that. My custom class inherits the System.IO.FileStream class.
>>
>>51598148
>What about inherited .net classes? You can't alter constructors there in such a way. The code that I'm working on is exactly that. My custom class inherits the System.IO.FileStream class.
Then just use super..?
>>
>>51598148
how's this
((test1) this).text
>>
>>51598164
super what? I'm talking C#, man. You probably mean base.
>>
>>51597733
>This is because in glibc FILE is not a incomplete type, try in musl.
struct _IO_FILE;
typedef struct _IO_FILE FILE;

>not a incomplete
lel, tard.
>>
>>51598265
Whatever. Either way, call the base constructor instead of setting the base's properties directly.
>>
>>51598313
Are you dense or just pretending?
>>
Anyone around with knowledge of boost:asio ?
I'm trying to learn it, but i'm not doing well atm
>>
>>51597733
>undefined behaviour
Why use C if you're going to depend on a specific version of a specific standard library implementation?
>>
>>51596222
Kivy is free.
>>
>>51598171
Casting? Well that works. Though I'm pretty sceptical as this approach is unintentionally confusing.

>>51598315
Ok, I'll repeat myself. I cannot change the constructor for .NET classes so support the variables that need to be defined. And I don't think the object initializer is usuable for the inheritaed base constructor.
>>
>>51598146
>There's your problem

No it's not
>>
File: 1448765436541.png (152KB, 359x414px) Image search: [iqdb] [SauceNao] [Google]
1448765436541.png
152KB, 359x414px
>>51598313
>#include <libio.h>
HAHAHAHHAHAA FUCKING FAGGOT GOT
BTFO
T
F
O
>>
>>51598411
Is there a legible way to get the base type that isn't overly verbose?

ideally you'd want:
(this as base type).text
but that's not C#
>>
>>51598549
Yeah, you just use the "base" keyword which is what he's starting with.
>>
>>51598591
his question is whether to use
this. or base.
both of which do the same thing
but for readability
(this as base) would be more readable
>>
>>51598615
No, it really wouldn't be.
>>
>>51598634
not only would it be more explicit and readable
it'd mean you could have a member called base, too
>>
>>51598615
Well they do the same thing in this example, but where both classes has a variable of same name, you would use "this" to refer the variable in this class while "base" to the inherited class' instance/object.
>>
>>51598373
Not like there's a choice, C is undefined behavior: the language. If you don't stop worrying about undefined behavior you end up writing inline ASM exclusively.
>>
>>51598688
oh? well he does want the base class's member

so i guess it's settled at base.member
>>
>Given a string not longer than 256 characters, write a program that prints "true" if any two adjacent characters are the same.
>Case is irrelevant, i.e., "Aa" prints true.

How long should it take you to write a solution to this? After how many minutes should I just fail the interviewee?

I want actual solutions, not just pseudocode bullshit. The algorithm is trivial, but how long should it take a programmer to implement a solution in their language of choice? I'm thinking if it takes you longer than a minute, you're not cut out for the job.

>tfw python solution takes 10 seconds to type out
>>
File: 161017757_44042348.jpg (67KB, 590x632px) Image search: [iqdb] [SauceNao] [Google]
161017757_44042348.jpg
67KB, 590x632px
>>51598471
except that libio.h is not standard, tard.
>>
>>51598716
well it's me replying, but I figure base is the appropriate choice.
>>
>Gayly programming thread
>>
>>51598700
Still, not depending on the implementation of a potentially incomplete type is low-hanging fruit.
>>
>>51598725
In C, about 10 minutes. In sane languages, 30s-1m.
>>
File: baka.png (165KB, 400x400px) Image search: [iqdb] [SauceNao] [Google]
baka.png
165KB, 400x400px
>>51598734
It is included from glibc's stdio.h, turd.
>>
This is coming in the mail tomorrow. I consider myself to be fairly computer savvy (have been running Linux as my daily for the last 5 years), but have very little programming experience.

How bad did I fuck up?
>>
>>51598789
glibc is not the standard.
>>
File: 1447830439576.jpg (453KB, 1600x1700px) Image search: [iqdb] [SauceNao] [Google]
1447830439576.jpg
453KB, 1600x1700px
>>51598805
Did I claimed it was?
>>
>>51598790
>"computer savvy"
>little programming experience
die
>>
>>51598814
Your logic is that since libio.h is included from the glibc implementation it's standard. Which implies that glibc is somehow the standard.
>>
>>51598817
whoah there buddy, you sure you're in the right board? Maybe >>>/v/ is a more appropriate place for you?
>>
File: 2314894.png (146KB, 364x364px) Image search: [iqdb] [SauceNao] [Google]
2314894.png
146KB, 364x364px
>>51598841
Where did I imply that libio.h is part of the standard?
>>
>>51598774
Kek, c-fags BTFO
>>
>>51598866
>libio.h is not standard
>b-but it's included from glibc's stdio.h
>>
File: laughing-5832.jpg (9KB, 200x200px) Image search: [iqdb] [SauceNao] [Google]
laughing-5832.jpg
9KB, 200x200px
>>51598790
>this is coming in the mail
>coming in the mail
>in the mail
Literally CUKED.
>>
File: 11.png (27KB, 362x300px) Image search: [iqdb] [SauceNao] [Google]
11.png
27KB, 362x300px
>>51598888
Again, where did I imply that libio.h is part of the standard?
I get the feeling that you did not follow the topic well.
>>
>>51598902
but muh paper
>>
File: sjw.jpg (231KB, 430x700px) Image search: [iqdb] [SauceNao] [Google]
sjw.jpg
231KB, 430x700px
>>51595604
Long live social justice

Make a macro which emulates Lisp's prog1. What you have with a rust block without a terminating semicolon is progn: evaluate the expressions in order and return the results of the last one. In contrast, prog1 evaluates the expressions in the same order, but saves the results of the first one in order to return them. Most of the time, progn is implicit. Rust has a more rigid syntax, but I challenge you to write your function as
fn split_at(&mut self, mid: usize) -> &'a str { prog1!{
&self.source[..mid];
self.source = &self.source[mid..]; } }

I've successfully written the macro, but I don't know what on which type this method is supposed to operate so I haven't tested this. Gud luk
>>
holy shit
understanding of regex just came to me
it's beautiful
>>
>>51598938
I mean that the macro doesn't exist AFAIK, sorry if my minority status triggered my speech impediment and prevented me from expressing my thoughts clearly
>>
File: 13664239921704.png (820KB, 764x950px) Image search: [iqdb] [SauceNao] [Google]
13664239921704.png
820KB, 764x950px
>>51598924
Never mind, you're right. I see that other anon was talking about glibc specifically.

Gomenasai...
>>
>>51598852
Not him, but the way you described yourself is pretty patronizing and off-putting, perhaps you should take your own advice and head back to /v/.
>>
>>51598888
checked
>>
>>51598988
That's not even me.
>>
>>51595562
Well I recommend you to build a parser for simple logic before moving on to human language.
>>
File: drink.jpg (175KB, 600x598px) Image search: [iqdb] [SauceNao] [Google]
drink.jpg
175KB, 600x598px
>>51598962
I will never forget you!
>>
>>51598946
How long have you been trying to learn it, anon? What flavor of regex did you learn also?
>>
>inb4 bunch of nerds
>>
>>51599003
Ironically this is also not me
>>
>>51599025
by understand I mean understand enough to not have to copy from the internet

basically i decided I wanted macros in D, e.g. for custom operators
in D you can import a file at runtime as a string literal and do lots of processing (including regex) on it

so I was looking at the regexr.com site and it just dawned on me all at once

why am i so retarded
>>
>>51599044
ok you're replying to me
>>
Threadly reminder that coding should never be used as a term to describe the act of writing code. The proper term is programming.
>>
>>51599035
i say that too
>>
>>51599061
not me though
>>
>>51599115
STOP replying to me!
>>
File: 1410301071491.png (24KB, 645x773px) Image search: [iqdb] [SauceNao] [Google]
1410301071491.png
24KB, 645x773px
>>51599081
>Hey anon, are you one of those cool coders?
>"Y-Yes..."
>>
>>51599149
>haha bro don't sweat
>>
check out my html compiler
http://blogging.neocities.org/site4/Tryit%20Editor%20v2.6.htm
>>
File: header.png (10KB, 800x144px) Image search: [iqdb] [SauceNao] [Google]
header.png
10KB, 800x144px
>>51599162
>nah imma coder
>>
>>51599149
>"awesome, hey do you think you could hack someone's facebook?"
Every fucking time.
>>
>>51598725
I did this in 3 minutes. Would you hire me?
def adcmp(s):
'''True if any adjacent characters are equal. Case-insensitive.'''
s = s.lower()
for i in range(len(s) - 1):
if s[i] == s[i + 1]:
return True
return False

def main():
testcases = ["jews", "bad", "news", "aa", "", "babB", "a"]
for test in testcases:
print(test, ": ", adcmp(test), sep="")

main()
>>
>>51599252
>3 minutes
How slow do you type, holy shit!
>>
There really should be a 'style' guide on how to phrase things

like

>You aren't a coder you are a programmer
>You don't write apps you develop applications
>You don't code html you write markup
>You don't write websites you design/develop website
>>
>>51598725
It took me 2 seconds to think about how I would implement it.
It would take me about 10 minutes to get you a working solution just because C strings a shit.
>>
>>51599274
sounds like petty elitism to me
>>
What are some relatively unknown languages that are still backed by actual modern industry usage? /dpt/ kinda skews the statistic on "unknown", but for instance, ocaml would qualify. What are some others? I want to be a leet hipster programmer but still work in a useful language.
>>
>>51598725
lowercase the string
regex (.)\1 -> true
>>
>>51599303
If you say so man, it gets pretty tiring to hear people sounding like retards.

Keep on coding u crazy coder kid
>>
>>51599285
>writing this takes 10 minutes

#include <stdio.h>
#include <string.h>

int isDupe(char* string, int len)
{
for(int i = 1; i < len; i++)
{
if(tolower(string[i-1]) == tolower(string[i]))
return 1;
}

return 0;
}

int main()
{
char string[256];
fgets(string, 256, stdin);

int len = strlen(string);

if(isDupe(string, len))
printf("true\n");
else
printf("false\n");

return 0;

}

>>
>>51599371
>uses string.h
0/10
>>
>>51599387
>what is strlen
>>
>>51599371
Stop being a fucking showoff.
I didn't feel like writing it because of his condescending tone.

I already had this figured out in 2 seconds.
while (sscanf(buf + traversedistance .... whatever)
{
if (toupper(prev) == toupper(current))
return true;
else
prev = current;
}
>>
>>51599252
doesn't that index out of bounds on
s[i + 1]
>>
>>51599392
literally a 5 line function kek
>>
>>51599344
Julia but shes growing fast
>>
>>51598774
>In C, about 10 minutes
What?
>>
>>51599455
Julia doesn't have industry users and is also broken as shit but that's not part of the question so whatever.
>>
>>51595864
Of course. If it's a hobby project why not.
I'm working on my own OS at the moment, so far I have my own boot loader.
>>
>>51599436
>-1
>>
>>51599371
>took 33 minutes and 20 seconds to respond by claiming it didn't take 10 minutes to write
>>
>>51595864
No. There's nothing fun about it. There's nothing challenging about it. It's pure tedium and hell because C is absoluSegmentation Fault
>>
>>51596296
How is intellij bad?
>>
> Gayly Pro-Gay'ing thread
>>
>>51599440
#include <stdio.h>

int isDupe(char* string)
{
while(*string++) //hope your string is nullterminated, fucker
{
if((string[-1] |32) == (*string |32))
return 1;
}
return 0;
}

int main()
{
char string[256];
fgets(string, 256, stdin);
if(isDupe(string))
printf("true\n");
else
printf("false\n");

return 0;
}

Does this appease you?

>>51599509
I only started writing it when I read his comment that it'd take 10 minutes in C. So about 6 minutes, assuming I started immediately after he posted (which I didn't.)
>>
>>51599519
C isn't really difficult to deal with once you got your vocabulary dispenser function down.
>>
Quick question if you'd help me out here /g/, I have experience in Android development and I put my projects up on Github. I'm programming stuff to get better. I got a somewhat decent project idea with Android, but I also really want to start Unity and start developing games.

Should I do this app and spend a few weeks working on it, or should I start doing games?
>>
>>51599565
>making use of undefined behavior
I'd kick you out and blacklist you from applying again.
>>
>>51599267
It is a misunderstanding of programming to think I was just typing. I was choosing variable and function names, choosing the correct algorithm, designing test cases, contemplating edge cases for failure, and only then did I type.

It can take a while to make sure you did something right, and even then I feel that this anon >>51599371 named his function better than mine and his algorithm might be a little faster in certain cases.
>>
>>51599565
>Only works for ASCII
Literal -1/10.
Please try again.
>>
>>51599583
>he's still showing off and gloating about writing a trivial char compare function

I know /g/ likes to joke that this place is full of worthless fizzbuzz babbies but holy shit.
>>
>>51598725
Timed myself, took 7 minutes to make sure everything was correct.
#include <stdio.h>
#include <stdbool.h>
#include <ctype.h>

bool
isdup(const char *s) {
for (size_t i = 0; s[i] && s[i + 1]; ++i)
if (tolower(s[i]) == tolower(s[i + 1]))
return true;
return false;
}

int
main(void) {
const char *testcases[] = {
"jews",
"bad",
"news",
"aa",
"",
"babB",
"a",
};

for (size_t i = 0; i < sizeof testcases / sizeof *testcases; ++i)
printf("%s: %s\n", testcases[i], isdup(testcases[i]) ? "true" : "false");
return 0;
}
>>
>>51599496
str = "test"
len(str) = 4

str[(len(str)-1) + 1] == str[4] == index out of bounds

am I right?
>>
>>51599621
I'm not showing off but if it makes you feel better about yourself anon.
>>
>>51595562
It might get annoying after awhile because of the irregular verbs, but go for it
>>
>>51599477
u r wrong
>>
>>51599647
Your C-like analysis is correct, but I used the Python range function, where the max of range(4) is 3.
>>
can you make a chat room using html5/javascript only?
>>
>>51598146

What's wrong with that? It's functional and more efficient
>>
>>51599697
got it
+1
>>
>>51599713
HTML5 is turing complete, so yes
>>
>>51599803
turing?
Like Alan Turing?
>>
>>51599803
Brainfuck is turing complete too but that doesn't mean you can implement a chatroom in brainfuck.
>>
>>51599827
google it
>>
>>51599837
>implying you can't
>>
>>51599839
I did my duckduck search, and he came-up
>>
>>51599847
>implying YOU can
>>
>>51599847
Can you access the internet? Just because it's Turing-complete doesn't mean it can make use of existing tech.
>>
>>51599839
I mean, it needs to communicate with the server
>>
>>51599572
You always need a reference handy if you plan to write code that doesn't rely on undefined behavior, and you need a billion libraries if you don't want to reinvent all the wheels. After that, you have to write project-specific boilerplate for hours before you can actually start doing things. And let's not even mention "debugging" in C, holy fuck.
>>
can html5 work back-end
>>
>>51599678
Prove it.
>>
>>51599930
Finally somebody says it. I've had it up to here with /dpt/'s lame adoration of C
>>
>>51598938
Thanks. This is the macro I wrote and it works for my code. How does it compare to yours? I'm still learning so feedback is appreciated.

macro_rules! prog1 {
( $first:expr; $( $rest:stmt; )* ) => {{
let ret = $first;
$( $rest; )*
ret
}};
}
>>
So I'm working on a small c++ project, using Qt Creator. I have two files, point.cpp and brute.cpp, brute.cpp have a main function and two other functions. I now want to replace brute.cpp with another file, so I comment out everything in brute.cpp, create file.cpp and write new functions, main and two functions with the same names as the functions in brute.cpp. When I try to compile the compiler tell me that there's multiple definitions of main and the other two functions. I've tried cleaning all, rebuilding the project and removeing brute.cpp. Searching the whole project tell me that there's only one instance of main.
>>
>>51599943
What. The. Fuck.
>>
Kek, I can't believe you fags think people care how fast programs run... Internet pings are 10000x slower than memory lookups so all your optimisation is meaningless in a post internet world.

Inb4 some buttmad C fag brings up "muh embedded"
>>
>>51600073
>request per second doesn't matter
>speed of processing request doesn't matter
>>
>m-muh turing complete!

https://en.wikipedia.org/wiki/Turing_tarpit
>>
>>51600073
Gamedev here, fuck you

Though I'm not using C
>>
>>51599899
use security flaws in your OS to call external functions
>>
>>51600140
C confirmed for turing tarpit!
>>
>>51600148
>>>/vg/agdg
>>
>>51600188
Already got the tab open
>>
>>51600073
>so all your optimisation is meaningless in a post internet world.
Battery life dawg.
>>
http://embed.plnkr.co/aTerAQbjteOiHtrNk8Ox/
>>
>>51600208
I ain't clicking that shit
>>
>>51600073
'Fast' programs use less power. Power draw is VERY fucking relevant in 2015.
>>
>>51600219
>'Fast' programs use less power
common mistake a idiot would make.
>>
>>51600216
if you knew plnkr you woudn't be afraid
>>
>>51600219
>developing for mobile devices
>>
File: 1445311716435.jpg (95KB, 724x720px) Image search: [iqdb] [SauceNao] [Google]
1445311716435.jpg
95KB, 724x720px
>>51600233
>a idiot
Also, do you think all of that garbage collection and runtime checks are free or something?
>>
>>51600233
Nope.
Best way to conserve power is to let the cpu shut down as much as possible.
How do you let the cpu go to sleep? Finish your computing task as fast as possible.
>>
>>51600256
Just as relevant for high-end servers.
>>
>>51600265
>>51600278
Expected mistake from people that just started programming. Don't worry, we are here to help you.
>>
Reminder that you're not doing anything of any significance if you can feasibly ignore efficiency concerns. If you know it's a problem and still choose to ignore it, you're a pleb, but at least you're doing something.
>>
>>51600292
Did you realise that you're a fucking idiot, and just kept going with it to save face?
>>
>>51600073
> Internet pings are 10000x slower than memory lookups
Which is relevant ... how exactly? Oh wait, it isn't.

Anyone running a web service which actually gets used is going to care how many servers they have to buy and maintain in order to handle a given load.

The back-end doesn't care so much about latency, as throughput, so ping is largely irrelevant.
>>
>>51600311
I think if I was keep going just to save face, I would know it.
>>
>>51600292
not a mistake, he's right, modern mobile operating systems (Android, iOS) are both unix based, the OS handles scheduling of the programs and puts all programs not in use to sleep. Its not like the old days of Palm4 where there was no multitasking, the program took over the entire device, and running a loop to long would gag the 20mhz CPU. Youre programming skills are no longer relevant, pls leave
>>
>>51600292
I suggest you read up on how cpu power saving states work.
>>
>>51600292

You know, I've heard from both corporate researchers and university professors that power draw is directly related to computer performance. But I'm curious what your credentials are in gauging energy consumption of processes.
>>
Alright lads, can somebody help me out. I want to start developing android apps but I can't use Android studio... It is literally aids for my pc, crashing and taking up GB of ram just being open. Is there something I can use for Eclipse that is good?
>>
Just a question from a sptastic noob,

Why can't we make a(example) C++ program with(example) Python scripts? So let's say the c++ would be responsible for the program to generate X and Y container content and print the mout but the algorithms/randomization of generation of the content of those containters would be written in python, this shit already possible? Am i retarded or is this a great idea?


Please explain.
>>
>>51600557
This is completely possible and there are various forms of Inter-Process Communication available, you should look it up.
>>
this recursive definition annoys me: PHP: Hypertext Preprocessor
>>
>>51600557
You can.
>>
>>51599995
Yep, that's pretty much what I did. I declared rest as stmt tho, but I'm probably wrong. Give that some thinking yourself, I havent looked at rust in details, I dont know what stmt vs expr would change, I just know the basics from an earlier attempt at it, and I sped through the macro part in order to write that. I know a lot of languages and I can tell you: macros are good.
>>
so it's possible to have one exec file to do one thing, and then ask the second exe file to do another. and them communicating
>>
>>51600612
Look into DLL
>>
File: neon paradise.png (4MB, 1543x965px) Image search: [iqdb] [SauceNao] [Google]
neon paradise.png
4MB, 1543x965px
I'm working on an image editor for glitch art.

We just released a new version, and I would be eternally grateful if you guys would check it out.
Feedback is greatly appreciated, especially regarding usability.
Something you didn't like, something that stood out, unexpected results, etc.

Link:
>glitchy.codemouse.dk

Pic is an image I made with the program.
>>
>>51600603
Also : should we have the macro accept a semicolon after rest, make it mandatory, or make it a syntax error? Your code has it mandatory if I'm not mistaken. What makes more sense from the user's point of view? I wonder
>>
>>51600397
>modern mobile operating systems (Android, iOS) are both unix based
Yes, and?

>the OS handles scheduling of the programs and puts all programs not in use to sleep
Yes, and?

You are a faggot.

>>51600443
I am well aware how it works.

>>51600458
>Ruby !!UOnz2YE1hdj
lol
>>
>>51600612
Yes, it's called interprocess communication (IPC).
The most simple example would be a pipe:
zcat file.txt.gz | wc -l

but that sort of communication is one way.
There are all sorts of shit such as sockets, shared memory and whatnot for processes to communicate, each with advantages and disadvantages.
>>
>>51600694
>I am well aware how it works.
You appear not to be.
>>
>>51600603
I meant to say that I did
 $rest:expr 
I dont have my macro anymore since I shut my computer down
>>
>>51600603
>expr: an expression. Examples: 2 + 2; if true then { 1 } else { 2 }; f(42).
>stmt: a single statement. Example: let x = 3.

This is what the Rust book says about it.

>>51600665
It makes more sense to me that it should be mandatory, since the macro encompasses what should be regular code. Normally when you leave out a semicolon at the end of a function it's an expr and not a stmt.
>>
>>51600757
Right. Thanks for sharing this time with me
>>
>>51600707
Nah
>>
why is this piece of shit chinese forum telling me that I mistyped the captcha?

>>51600208
>http://embed.plnkr.co/aTerAQbjteOiHtrNk8Ox/
lel, if you keep the button pressed, you never lose
>>
>>51600859
ouch, you pass all the obstacles. need to add the ceiling
>>
>>51600788
You're welcome. Thank you too.
>>
>>51600789
As evident by your statements, yes.
>>
Is a shitty job as a code monkey better than neetbux?
>>
>>51600882
think I'm going to vomit 2bh
>>
coding is fun
>>
>>51600884
Sure thing m8
>>
new thread when?

>>51600891
why not do both? you could be making money while collecting neetbux...
>>
>>51600148
If you aren't>>51600891
How do I get neetbux? I would be ok with living in a tiny room for the rest of my life as long as I get a computer and internet. Do I need a disability? If I go play in traffic (wear a helmet do I don't get a coma) would that qualify me?
>>
>>51600999
>new thread when?
bump limit is 310
>>
>>51600894
>2bh
Fucking fags. You should let the word filter get rid of your cancer desu
>>
>>51600999
You can't collect neetbux if you have any kind of job, part-time or fulltime, contract or regular.
>>
>>51599763
What's more efficient about it?
>>
>>51601087
I'm sure they would magically know if you got paid to do freelance work
right?
>>
New thread

>>51601187
>>
>>51601191
I'm sure your fraud won't get discovered, anon-kun. Go for it! Try to defraud your government, see how far that'll get you!
>>
love you guys
>>
>>51599945
Debugging? I won't acknowledge that as a problem because I'm literally perfect and I've never created a bug ever.

Also I've never created any real software.
>>
>>51600073
Ruby fag who writes trivially easy bullshit detected.
>>
>that fucking feeling when you finish a project with loads of tricky edge cases and it works

this is what I live for, this is my drug
>>
>>51600233
> Calling other people idiots for the truth
> Doesn't understand power throttling
>>
>>51600292
Are you going to try to back up your ridiculous claims or are you just going to take the level of humiliation you're currently at?
>>
>>51600694
Nice reasons and sources. Pls take your own life soon, thanks.
>>
>>51599081
"coding" is actually an older term than "programming"
>>
>>51595806
still google
Thread posts: 325
Thread images: 24


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]
Please support this website by donating Bitcoins to 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
If a post contains copyrighted or illegal content, please click on that post's [Report] button and fill out a post removal request
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.
This is a 4chan archive - all of the content originated from that site. This means that 4Archive shows an archive of their content. If you need information for a Poster - contact them.