[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
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: 16
File: timetocode.webm (2 MB, 1152x648) Image search: [Google]
timetocode.webm
2 MB, 1152x648
This is /dpt/, the best subreddit of /g/

Umaru-chan edition

In this thread:
r/programming
r/compsci
r/ReverseEngineering
r/softwaredevelopment

Filesharing and chat: https://volafile.io/r/kUFzLJ

code of conduct:
no racism
no insult
no sexual harassment
no gender discrimination

wat r u working on, anon-chan ?
>>
My programming language with dependent types, linear types, manual memory management, and FFI.
>>
first for C
first for tfw no trap programmer bf
>>
second for Go, the language of the memes
>>
3rd for Go.

>>51474126
how come you fags don't understand the most basic intrinsic rule of the internet? do NOT feed the trolls.
you fall too easy for their b8s. seriously, who, ever, uses Integer in Java? and yet you kept trying to convince the troll... this is, like, the definition of autism.
>>
I finally got my TCP server working in Go. I was struggling with broadcasting, but I got it working. What do you think? https://github.com/TeaGuy/euphonium/tree/dev (I'm rethinking my username).
>>
Cast your vote if you haven't done that yet.
https://strawpoll.me/6069029 (embed)

Make sure to read the question carefully.
>>
>>51474181
D is better
>>
>>51474126
dumb hamsterposter
>>
>>51474225
D is tryhard.
>>
>>51474282
>not trying hard D
>>
I am working on a type of static type checker in Scheme for my first compsci class, almost done, just need to do all the error messages. Comp sci is pretty fun senpai desu
t. Major in math, thinking of switching over
>>
int oddPos = 0;                

while (oddPos < evens.length)
{
if (evens [oddPos]%2 == 0)
{
oddPos++;
}
else
{
for (int i = oddPos + 1; i < evenMaxSize;i++)
{
evens[i - 1] = evens[i]; //only works when array ends with an even number
} //if i add oddPos++ to the for loop, the array will work and complete, but not to the intended function
evenMaxSize--;
}
}

Working on an assignment in java where you have to sort randomized numbers into odd/even arrays, i've managed to get the loops working but with one hitch, if the original generated array (values, which code snippet related is copied to evens with arrays.copyOf) ends with an uneven number, the program won't be able to complete the loop, is an end-specific condition on the else statement the way to go here?
>>
>>51474198
reminder, any language trying to replace C++ and Java is a meme language
>>
>>51474410
It better be bidirectional.
>>
>>51474212
>All those Javascript/Python - Employed
Spotted the students
>>
>>51474126

i'm programming an atmega328p and I can't figure out how to use the ADC to calculate a PWM signal with the max resistance from a potentiometer being 100% duty cylce, and minimum resistance 0% or off.

the trouble is the minimum and maximum resistance of my potentiometer is not read as exactly Vcc and 0 volts respectively by the ADC

how do I figure out the minimum and maximum resistance without having to calibrate it or something?
>>
>>51474210
>using clientLock instead of chan []*Client with bufsize = 1
you can lock things with channels too
in fact, the type enforces the user to safely acquire []*Client, it just doesn't force the user to release []*Client again.
with locks you enforce none of those - i can just grab your []*Client and fuck with it if i forget that there's a lock

also, your encapsulation is fucked. why are you encapsulating conn but not Out? in fact, why isn't the entire client type package private?
>>
>>51474474
>bidirectional
? ? ?
First compsci class so dunno what you are talking about, it works like this (check '(+ int (* real int))) -> real, should work for arbitrary depth and all operations are binary
>>
>>51474487
>http://benchmarksgame.alioth.debian.org/u64q/java.html
You knows those benchmarks are 100% arbitrary right? Some languages have very optimised versions of some tests, other languages don't.

Data processing is not faster in Java than it is in C. You've lost your marbles if you think that could possibly be true.

>you are the one who just said that java allocates everything on the heap
It allocates a lot of stuff on the heap that shouldn't need to be there yes. What has that got to do with arrays primitives fragmenting?

>https://en.wikipedia.org/wiki/Bounds-checking_elimination
What about it? That optimisation can't always be made genuis. Especially if the array length is in any way arbitrary.
>>
>>51474524
Spotted the unemployed
>>
File: 1342664478674.png (3 KB, 210x230) Image search: [Google]
1342664478674.png
3 KB, 210x230
>All projects at work being blocked by other team members
>Side projects at home being blocked by other project contributors
>Can't find anything to busy myself with
I don't care for this
Not one bit
>>
>>51474126
Thank you for using anime pic
>>
File: 126146619089.jpg (155 KB, 550x700) Image search: [Google]
126146619089.jpg
155 KB, 550x700
>>51474573
I work full time in a .NET factory
>>
>>51474419
I have no idea what you're doing here. You have an array called "evens", but are accessing the index with "oddPos". That seems contradictory to me.

>sort randomized numbers into odd/even arrays
I'd probably write something that looks more like...

int[] randomNumbers = new int[100] { ... };
int[] evenNumbers = new int[100];
int[] oddNumbers = new int[100];
int evenIndex = 0;
int oddIndex = 0;

for (int number : randomNumbers) {
if (number % 2 == 0) {
evenNumbers[evenIndex++] = number;
} else {
oddNumbers[oddIndex++] = number;
}
}
>>
I need to write a program in Java to generate a summary report on a store inventory using an input text file and outputting a text file.

The summary text file needs to determine the
1. Total value of the inventory
2. The cheapest item
3. The most expensive item

The first line of the input text file designates the number of records while each line represents a record in the format [ItemName, Quantity, Price]

Example:
2
Stove, 52, 540.90
Table, 78, 99.46

Any help is appreciated.
>>
>>51474526
do you have a way to read values from the mc via serial interface or a display or something?
>>
>>51474608
I work full time in a Java FactoryFactory
>>
In Prolog, what does this syntax mean?

f(g(X), g(Y)) :- something.


Does it just mean that f(X, Y) holds if g(X) holds, g(Y) holds, and something holds?
>>
>>51474652
First you need to invent the universe.
>>
>>51474676

Nah, I only have two shitty perfboards I built for running and flashing the data
>>
>>51474709
can you write to eeprom and read eeprom with your programmer?
>>
C# question.

I'm writing a command line application that's being used in a pipeline to feed file data to another application.

The problem is, if the other application is closed my program continues to run in the background.

I've seen other command line applications that quit once the same program is closed when used in similar fashion.

How can I do what other applications are doing?
>>
I have an idea for a small application, not something I think is marketable but just something I genuinely want on my phone for personal use.

It would be within my ability to code this if it were a WPF program on VS. I've never touched the Android SDK but I think it's going to be ez.

My question is, can I just straight copy this app onto my phone over a USB cable? Do I have to root my phone? Have any of you guys ever developed for Android and do you have any tips?
>>
>>51474557
this. use buffered channels and selects to lock things. channels are obviously THE solution for this kind of things...
>>
>>51474652
Read first number
Open file, read into string[] by line
iterate over the first number of times the array
Record each one into whatever, array, list, tuple, doesn't fuckin matter
iterate over that and check and each value against the other to see if it's less (or more, for the expense)
While doing that, also add each number into an int.

Ta-da, you have done everything in two loops.
You can probably get this into one.
>>
>>51474745
>It would be within my ability to code this if it were a WPF program on VS. I've never touched the Android SDK but I think it's going to be ez.

Oh boy, are you in for a rude awakening.
>>
>>51474737
Here's my simple code btw
static void Main()
{
string file = @"file.ts";
FileStream fs = new FileStream(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
byte[] buffer = new byte[65536];
Stream consoleStream = Console.OpenStandardOutput();
int fileLength = (int)fs.Length;
int writeLength;

while (fs.Position < fileLength)
{
writeLength = fs.Read(buffer, 0, 65536);
consoleStream.Write(buffer, 0, writeLength);
}

fs.Close();
consoleStream.Close();
}
>>
>>51474737
In order for this type of control to take place, one program has to launch the other. Then it can make intelligent decisions about when to close the launched program, or how to act upon the launched program's closing.
>>
>>51474769
Can it just continue running, and block until it receives more data from file.ts? Or does it need to close?
>>
>>51474652
What specifically are you having trouble with? Also, I could tell you a lot of ways to do it, but I know a lot of professors have restrictions on not allowing students to submit homework using things they haven't covered in class yet.

You will probably want to read the file using a buffered reader. Something like this:

BufferedReader inventoryReader = new BufferedReader(new FileReader("path/to/input.txt"));


You will want to read that first line with the number of expected items. After that you can use a loop to go through each line.

String line;
while ((line = inventoryReader.readLine()) != null) {
// do stuff
}
>>
>>51474765
I believe you... I'm super interested to hear why though
>>
>>51474745
To unlock dev mode on your phone, go to settings and tap your phone model number a bunch of times

After that you can do whatever
>>
Is there a quick and dirty guide to using -options in c, such as program --version.

I'm really not a programmer but I want to make a small program so I dont get tired.
>>
>>51474776
>>51474799

Well then what are other applications doing to close themselves when the pipeline breaks?

For example, the first application closes when the second is closed in this command line
cat file.ts file2.ts | ffplay -


I'm guessing 'cat' is written in C.

On the other hand my program (code here: >>51474769 ) continues to run. Considering it's a general case, the former one must be doing something.
>>
File: csharpcucks.jpg (129 KB, 1024x997) Image search: [Google]
csharpcucks.jpg
129 KB, 1024x997
>yfw C#keks will defend this
>>
>>51474557
I agree, the lock is a far from an ideal situation. I don't really follow you on using a channel instead of a mutex. I don't want to sound like a lazy nigger, but could you post an example? I found something in the Go docs, but I don't know if that's what you mean.
func handle(r *Request) {
sem <- 1 // Wait for active queue to drain.
process(r) // May take a long time.
<-sem // Done; enable next request to run.
}


I want to parse the read bytes from the client in a different package. The result is pushed into the clients Out channel. I don't want other packages to dick around with the conn field. That's why Out is exported and client not.
>>
>>51474879
I'm not that advanced to be able to defend this :^)
>>
>>51474840
int main(int argc, char** argv)

argc is the argument count, argv is an array of strings given as arguments, and argv[0] is the name of the program
for example program --version will result in argc=2 and argv = {"program","--version"}
>>
>>51474859
When the input's end has been reached, the EOF character is being sent. All you need to do is have your while loop run until it finds the EOF character.
>>
>>51474212
If my work involved programming in my favorite language I would hate my favorite language, because I am not in management. I'm not old and experienced enough to be in management, like an autist has to be if they want to get into any position like that.

Why does everyone act like that's the holy grail of programming? The holy grail isn't being employed as just any fucking code monkey so you can show up on a forum and say "I ACTUALLY HAVE A JOB PROGRAMMING PROFESSIONALLY YOUR OPINIONS ARE INVALID" whenever you're not writing generic proprietary bloatware for a corporation's internal uses.

It's independence combined with a salary, so not only are you a professional, but you can write whatever you want within the confines of "improving profits for the employer" (possibly yourself) and tell other people what to write. In your favorite langauge. Theirs can go suck it.

Heaven.
>>
>>51474763
>>51474815
Thank you so much. I think he just wants us to use normal arrays but I don't think he'll mind if I use a buffered reader.
>>
>>51474826
Visual Studio is an enterprise-directed software suite intended to provide a easy-to-use interface to make .NET applications.
WPF is an abstraction layer of the Windows API intended to be much more user friendly and powerful compared to WF.
Visual Studio includes a What-You-See-Is-What-You-Get editor for WPF in order to streamline the app development process even more.

The Android SDK, on the other hand, is a pile of steaming garbage loosely tied together by another steaming pile of garbage - only that second pile of garbage is being phased out in favor of a can of Fix-A-Flat, which solves absolutely none of the problems that the first garbage pile had.
Also, there's pretty much no useful IDE for Android, and you'll be fighting whatever GUI tool you end up using to do every little thing.

Not to mention that Android apps are Java while WPF is (usually) C#. Keep in mind that C# exists today specifically because Microsoft felt that Java was too garbage-quality to be saved (and believe me, they tried to save it).
>>
>>51474725

Yes

I use avrdude
>>
>>51474935
If he just wants you to use normal arrays then do the same thing, open the file and read it by line
Then for each line, split the values by comma and store them into an array.
>>
>>51474859
What happens is that cat runs, puts the output in a buffer, and terminates.
Then ffplay is launched and receives the buffer as input.
Ffplay runs and acts upon the data until it has run out of data to receive, and then terminates.

This guy >>51474815 has the solution I think. If you need to just use an array, you could cheat by making the first the first and last elements be "empty" and "full" signifiers, assuming you have flags that are outside the expected dataset.
>>
Which does \g/ prefer?

C
#define MAX(A, B)         (((A) > (B)) ? (A) : (B))
#define MAX3(A, B, C) (MAX(A, MAX(B, C)))
int main(void)
{
double z = MAX(200, 300);
double y = MAX3(z, 600, 1000);
return 0;
}


C++
template <typename T>
const T &max(const T &a, const T &b)
{
return a > b ? a : b;
}

template <typename T>
const T &max3(const T &a, const T &b, const T &c)
{
return max(a, max(b, c));
}

int main()
{
auto z = max(200, 300);
auto y = max3(z, 600, 1000);
return 0;
}
>>
>>51474951
Wow. Is there a counterargument? A school of thought that disagrees with you?

>Not to mention that Android apps are Java while WPF is (usually) C#. Keep in mind that C# exists today specifically because Microsoft felt that Java was too garbage-quality to be saved (and believe me, they tried to save it).

Right, but they are similar enough that coding a rudimentary app should be fairly easy right?
>>
>>51475013
No. ffplay isn't started only after cat terminates.
>>
>>51475020
Both languages are outdated.
>>
Could you guys help me figure out what's wrong with this function? It's supposed to check if a word is either less than 3 characters or if it matches a predefined blacklist.
int blacklist(char *word)
{
static const char *blist[] = {
"all",
"and",
/* ... */
"who",
"why"
};
if (strlen(word) < 3)
return 1;
else if (bsearch(word, blist, sizeof(blist)/sizeof(char *),
sizeof(char *), strcmp) != NULL)
return 1;
else
return 0;
}


The length test works, but the bsearch appears to return NULL every time and lets the word pass through. I'm guessing that I passed the arguments incorrectly?

       void *bsearch(const void *key, const void *base,
size_t nmemb, size_t size,
int (*compar)(const void *, const void *));
>>
>>51474929
>tell other people what to write. In your favorite langauge. Theirs can go suck it.

This is precisely why you should never be a manager or in charge of any important project. You'd blow some project all to hell because you get a woody playing with software like it's a sex doll. Although the internet likes to circlejerk their favorite languages, most businesses have figured out that tooling and available libraries are far more important than what some autist thinks about Haskell or Lisp.

I'm writing an application for work using Spring Batch, a Java library. Java gets a lot of shit on /g/. But you know what? Because of things like Spring Batch and other tools, I'm getting this job done 100x faster than I ever could in a /g/ approved language.
>>
>>51474879
Why would you be serializing a reference?
>>
>>51475054
In many ways, yes.
In many other ways, no.

The two are syntaxically similar and share a lot of the same core design concepts, but Java is basically just a really shitty C#. You won't have any trouble reading or writing it, but the way a lot of functions behave and default for types will throw you off.

That and, really, the android sdk is trash.
>>
>>51475013
I strongly believe cat continues to feed data to ffplay as video files tend to be too large to pass with one read. It also remains in the process list as long as the file plays.
>>
>>51475020
C because you can understand what it's doing even if you don't know C

Ideally, the same syntax would be applied to a language with a more user-friendly type system

The C++ solution is a fucking kludge

User friendliness is what all language wars boil down to. "Elegance", "power", "sensibility" - these are all different ways programmers say "easy" while preserving their egos based on doing things other people consider hard.
>>
>>51475065
u fuckin wot
>>
>>51474894
that is exactly what I mean.
the point is that you CANNOT acquire the client slice without effectively locking it.
>>
>>51474212
How the fuck are more people not using Python at their job? Even if you are flipping burgers you should be able to figure out an occasional need to whip up a quick scrypt.
>>
>>51475123
>unironically using the snake language
>>
>>51475103
It does, run something like "cat - foo | grep bar" that let's cat run until you hit ctrl-d.
Both cat and grep will keep running.
>>
>>51474989
the simplest solution I could come up with is making a calibration that goes something like this:
>start with the pot somewhere in the middle
>have the mc keep track of the minimum and maximum value coming from the ADC
>turn pot all the way down and then all the way up
>have some trigger like a button or just after x minutes to make the mc write the min and max values to eeprom
>read eeprom with the programmer
Now you know the minimum and maximum value you get from your potmeter
you might have to adjust those down or up a bit
>>
>>51474935
>I think he just wants us to use normal arrays but I don't think he'll mind if I use a buffered reader.
Those two things are not in any way related. You can't use arrays to read from a file. I'm thinking you really should be talking to a TA instead of /g/.
>>
>>51475123
Because python is absolute shit.
In what situation are you using python scripts in place of powershell, bash, or javascript?
>>
Why the fuck is there still no superior alternative to ncurses in 2015, this shit is cancer.
>>
>strings are immutable
>`byte` datatype is 2 bytes
>implicit function calls

I love C# but damn is it stupid sometimes.
>>
>>51475092
Why do you think you're using java?

It's your manager's favorite language and he's forcing you to use it even though there is no scientific evidence proving that it makes employees more efficient. It's all his opinions.

Somewhere in brazil, someone doing programming for that one bank is using clojure and saying the same things about spring batch
Why is he using clojure? Because it's what his manager thinks is the shit, even though there's no real evidence for it.
>>
>>51475186
>`byte` datatype is 2 bytes
Go on
>>
can't find the libjcsl libraries for java. Anyone got a link?
>>
File: Capture.jpg (11 KB, 146x112) Image search: [Google]
Capture.jpg
11 KB, 146x112
>>51475186
>`byte` datatype is 2 bytes
What the actual fuck are you on about?
>>
>>51475221
char isn't byte right?
>>
>>51475165
anytime i want to process text, like if i get a list of personnel changes and i want to compare it to another list of personnel changes in various ways.

because i can write it much much faster in python, because i find it syntactically pleasurable

why am i wrong? my question was directed at people who say that python is their favorite language, but they are unemployed (which includes people who are employed, but don't use it (their favorite language))
>>
>>51475185
there is

it's called drawing an actual fucking GUI. if you want it to run in a terminal then those terminal faggots can get it via sixels.

>but muh remote apps!
terminals are not the only way to access a remote system. your display server probably provides similar features, or if you use wayland, weston has RDP.

since you don't give a flying fuck about aesthetics you can just write in pure xlib and tell people to tunnel X11 over ssh.
>>
>>51475221
"The System.Byte keyword denotes an unsigned 16-bit integral that stores values in range 0-65535."
-MSDN
>>
>>51474643

it was an internal logic thing, the main goal of the variable was to find the odd numbers to remove them from the array, I could easily change it around later.

On that note, I should also have mentioned that the length of the arrays are supposed to be the same as the amount of odd/even numbers in them. the total number of randomly generated integers are also bound to the users input.

Here's the general thought process while making it since I'd had some trouble wrapping my head around the array/ even/odd sorting thing:

>Create the initial array, values
>If I fuck around with values too much while sorting the even numbers, i might fuck up for when I'm supposed to count the odd ones, I'll make a copy of the array to be sure that I don't fuck something up.
>however, copy is too big, and you can't change the length after it's initialized, with how I've currently made the program, I'll have to make another
>cue the while-statement, leaving even numbers as is and removing the odd ones, aswell as using evenMaxSize to set up the length for the next one.
>>
>>51475286
https://msdn.microsoft.com/en-us/library/5bdb6693.aspx
>Size
>Unsigned 8-bit integer
?
>>
>>51475191
>It's your manager's favorite language
No it's not. My manager doesn't even make the decisions about what language to use.
>even though there is no scientific evidence proving that it makes employees more efficient
Programming efficiency is really fucking hard to measure. Go look up some of the academic literature published about it. About half the papers aren't worth the disk space used to store them and the other half restate shit known since the 70s.
>>
>>51475254
You're not wrong, but at a job there would be no realistic reason to use python over anything else.
It has very limited feature sets, it's unbelievably slow, and any business wouldn't want you writing that stuff in python instead of what everything else is being written in.
>>
I still dont fully understand the concept of OOP....
>>
>>51475367
...what don't you understand about it?
>>
>>51475380
The concept of objects. Is this why libraries exist? Do procedural languages use libraries?
>>
>>51475404
Libraries have nothing to do with OOP.
>>
>>51475165
>powershell
doesn't powershell use python? also, lol @ comparing powershell to bash, or even python...

>>51475185
patches are welcome
>>
>>51475404
Libraries have absolutely nothing to do with OOP.
>>
>>51475367
It's OK, you're better off not knowing. Unlearning years of OOP bullshit was one of the hardest parts of becoming a genuinely better programmer.
>>
>>51475428
>doesn't powershell use python?
No, retard, Powershell itself is a scripting language front-end for the .NET Framework, with some backwards compability to cmd.exe added in.

In terms of what it can do as a programming language it's far above Bash.
>>
>>51475367
The most important thing to understand about OOP is that it is a tool to be applied where necessary, not a religion to devote your code to.
>>
>>51475365
I'm using it for personal scripting, not for actual development.

Also I know people who work in forensics who use it when a bunch of datalogs get dumped on their laps and they have to parse them real quick. Lots of people in industry love python for this sort of stuff because it's arguably the fastest language to /write/.

It seems to me like you are considering a very limited sphere of the sorts of applications computer programming has.
>>
>>51475428
>patches are welcome
You can't patch something that's inherently broken without making a further mess.
>>
>>51475365
are you autistic? if you need speed and more features (what features is python missing??), then code a real program or pay someone else to do it
there is a reason python is a SCRIPTING language, just like other SCRIPTING languages

>>51475446
>In terms of what it can do as a programming language it's far above Bash.
HAHAHAHAHAHAHAHAHAHAHAHA
HAHAHAHAHAHAHAHAHAHAHAHA
HAHAHAHAHAHAHAHAHAHAHAHA
HAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHA
I hope you are being ironic... do you even use bash? do you understand what bash is supposed to do?

what's with the retarded MS shills in /dpt/?
>>
>>51474212
>no common lisp
>no scheme
>no racket
>no dylan
>no F#
>no ocaml
I won't even bother responding. This is beyond retarded. It's pretty clear whoever made that poll is in middleschool.
>>
>>51475367
The goal of OOP is code reuse through class inheritance.
>>
>>51475485
>linkeks continue to be BTFO on a daily basis
>>
>>51475113
Monkey doesn't understand. The application gets stuck when addClient is called.
var clients = make(chan []*Client, 1)
func addClient(client *Client) {
//clientsLock.Lock()
//defer clientsLock.Unlock()
//clients = append(clients, client)
c := <-clients
c = append(c, client)
clients <- c
}
>>
>>51475485
>I hope you are being ironic... do you even use bash? do you understand what bash is supposed to do?
I use Zsh as my shell of choice. I dual boot W7 (which doesn't even have a functional package manager built in...W10's impl. does, though) and Arch Linux so yes I have quite a bit of hands on experience with both.

Because Powershell is yet another front end for .NET, you can theoretically write any program in PS that you could in C# or VB.NET or C++/CLI.

You can't really design GUI programs in Bash. You could actually design Microsoft Word in Powershell if you really wanted to, and you wouldn't need any external tools.
>>
>>51475516
I don't understand why just calling a function from another function isn't sufficient. Inheritance brings way more problems to the table than it solves.
>>
>>51475365
>unbelievably slow
I can't fathom a situation in which the speed differences between bash, PS and Py make any fucking difference. I'm not sure you understand what people are using scripting languages for senpai
>>
>>51475550
>GUI is all that matters
MS shills please just leave.
>>
>>51475560
Because eventually you have too many fucking functions just thrown into code to deal with them all.
>>
>>51475485
Write a linked list in bash. I'm waiting.
>>
>>51475527
What kind of autistic tongue is that?
>>
>>51475516
Ok so its mostly design?
>>
File: 48865091.jpg (12 KB, 243x250) Image search: [Google]
48865091.jpg
12 KB, 243x250
>>51474126
I'll wait for the next thread without the reddit nonsense
>>
>>51475568
Please remove the shit from your mouth and hands, and then re-read my post for comprehension.
>>
>>51475527
I'm fucking stupid. I forgot to add an empty array to the channel.
>>
>>51475568
Faqu'ils ont imposé leur logiciel privateur sur tout'la terre asti'!
>>
>>51475630
du bist ein dickes ei
>>
>>51475644
I'VE GOT A BIKE YOU CAN RIDE IT IF YOU LIKE
>>
>>51475550
ah, you are the edgy arch guy
tell me, kid, for how long have you been using windows, linux, computers in general? have you ever read the bash manpage? you'd be suprised at how much bash can do in its domain.

bash != python != powershell
powershell is the retarded copy of the other two scripting languages, and a massive abortion

>>51475575
>Write a linked list in an scripting language. I'm waiting.
are you reading your own stupid comments? I will assume you are autistic m8.
>>
>>51475550
>you can theoretically write any program in PS

If it's GUI, there is some likehood you may need additional libraries loaded.
With CLI yeah, PS can act as a C# replacement if you're not deeply concerned about performance impact.
>>
>>51475662
>are you reading your own stupid comments?
The fact that you had to change the wording of the comment you quoted is very telling.
>>
>>51475090
Anybody?
>>
>>51475739
see, I was right, you are retarded.
>>
>>51475186
>strings are immutable
isn't this the case for, let's see.... just about every commonly used language out there?

>'byte' datatype is 2 bytes
see replies above, not even going to bother quoting them

>implicit function calls
See, this isn't stupid - it's pretty cool. Instead of having a huge mass of boilerplate functions
public void SetMinutes(double value)
{
m_seconds = value * 60;
}
public double GetMinutes()
{
return m_seconds / 60;
}

you just have properties, which act as variables but are actually functions, making the code referencing these private members much more intuitive
public double Minutes
{
get { return m_seconds / 60; }
set { m_seconds = value * 60; }
}


What's really cool is being able to use these implicit functions to access immutable data types with anonymous functions
public double SomeMemberVariableImmutableValueOnlyReferencedByAFunction => memberVariable.thatFunction();


you can even do this with functions, as I have found out

public double SetSomeMemberVariableImmutableValue(double value) => memberVariable.setSomeValue(value);
>>
>>51475684
> libs for gui

This is Windows. Look at the name closely. The WM is in the kernel mind you
>>
>>51475786
>isn't this the case for, let's see.... just about every commonly used language out there?
No.
Not at all.
>>
>>51475786
>isn't this the case for, let's see.... just about every commonly used language out there?

No? Are strings immutable in C, the most commonly used language?
>>
>>51475835
> C, the most commonly used language

That's not how you spell Javascript.
>>
>>51475782
>laughs at someone for suggesting Python is more powerful than bash
>someone calls him out on it by posing a simple challenge to prove his point
>HURR DURR, UR RETARDED

I should mention that I'm not the poster who wrote about Python. I do however get paid to write Korn Shell for a living. Seeing your post with the million HAs, got me laughing because I knew how easy it would be to call you out on it.
>>
>>51475186
C# has mutable "strings". They are correctly called char arrays instead of strings.
>>
>>51475835
Based
const char*
>>
>>51475786
Properties are great. I was referring to constructors.
>>
File: 1447540131824.gif (439 KB, 250x188) Image search: [Google]
1447540131824.gif
439 KB, 250x188
Alright my C# skills are top class, EF skills are high, and LINQ to X is pretty great, albeit not very hard thing to do for any of these.

Webforms experience is great, but trying to actually come into the 21st century but am having trouble finding a good starting place for MVC.

The tutorials I find use MVC 4, however I'm told it's pointless and to find a tutorial that uses MVC 5 and Razor and to learn REST services. But for the life of me can't find full tutorials anywhere.

Any help from fellow she sharp devs on getting a good starting point down would be appreciated
>>
>>51475786
>>51475835
>>51475884
const char* SHALL NOT BE INFRINGED
>>
>>51475911
Bingo, sir.
>>
>>51475020
I like how you purposefully chose the most crufty examples of C and C++.
Nobody does shitty #define macros in C.
>>
>>51475846
>That's not how you spell Javascript.
That's not how you spell Chinese.
>>
File: 234234.jpg (87 KB, 409x285) Image search: [Google]
234234.jpg
87 KB, 409x285
>>51475846
>>
>tfw you mention that you wrote something in C
>everyone asks why you still use that shitty language
>you mention "m-muh performance"
>they sarcastically suggest you write in assembly instead
Why do all you faggots think the difference between writing C and writing ASM is basically nil? C, C++, Java, Python -- it's all still abstract, high-level programming, and I'd expect a programmer in any of these languages to be able to rewrite any program into any other language with some effort.

Assembly is not the same and it requires an entirely different skillset. Writing something in C is trivial. Writing the same thing in ASM will take much longer, period.

Writing the same thing in Python might be faster, it might not be, but it certainly won't execute faster.
>>
>>51475946
What? How do you do it in C, then? I use #define macros all the time.
>>
>>51475846
that's not how you spell node the only real dev language.
>>
>>51475974
>translating C++ to Java to C is easy
>translating C++ to C to assembly is hard
>>
File: 1446581256145.jpg (30 KB, 461x373) Image search: [Google]
1446581256145.jpg
30 KB, 461x373
This shit is driving me nuts

After reading an M * N array of ints, how can I print the maximum value for each row?

Like this: The maximum value on row 1 is :
The maximum value on row 2 is:
.....
and so on

C or Java.
>>
>>51475991
Why wouldn't you write MAX and MAX3 as their own functions?
Hell, you can even reuse them.

>>51475974
People have been brainwashed into thinking python/js/etc is the future and C is this ancient trainwreck on the same level as COBOL even though their fucking memory safe and sandboxed scripting languages are all implemented in C or C++.
>>
>>51476017
easy you calculate the maximum and then print for each row
>>
>>51476011
Yes, translating C++ to Java to C is pretty fucking simple. Translating C code to *optimized* assembly is a pain in the ass comparatively.
>>
>>51476017
Holy shit you're hopeless.
>>
>>51476017
so it's a 2d array or just a big 1d representing a 2d structure?
>>
>>51476027
>Why wouldn't you write MAX and MAX3 as their own functions?
They wouldn't be generic.
>>
>>51476017
Is the data sorted?
Do you want to sort the data?
Why the fuck isn't your data sorted?
>>
>>51476031
>this is what C programmers actually believe
>>
>>51476040

yeah?
it's not as easy as it seems
>>
>>51476027
Why would you write functions when you could use macros? You can reuse macros too. I have a .h full of helpful helper macros like this.

Macros have the advantage of being type-agnostic, and since C doesn't have function overloading, it's quite useful.
>>
>>51475864
I think it can be done. It's going to be an anti-idiomatic mess that leaks memory, isn't useful in real situation, in brief pointless and awfully stupid, but it JUST WERKS
>>
>>51476051

a 2d array of ints
>>
>>51476061
You can write them as generics.
Either way, you don't want to use #define for anything but magic numbers.
>>
>>51476096
>You can write them as generics.
Show me how you'd do this in C. I'll be waiting.
>>
>>51476031
translating Java to *optimized* C, you mean?
>>
>>51474126
>no racism
>no insult
>no sexual harassment
>no gender discrimination
Fuck you, you fucking nigger pussy cunt kike faggot
>>
>>51476110
The compiler can handle that.
>>
What language should I start learning? I have a talent for programming, but little experience. I have experience with Scratch, Java, Visual Basic, and Jeroo, so mostly just building blocks. I've also got a real nack for HTML. What's the best language to learn for general IT work?
>>
>>51476122
b&v&n&os
>>
>>51476027
If you wrote them as functions then you'd have to make a different function for int/real/signed etc.
Also macros are just guaranteed inline.
>>
>>51476106
>>51476154
>what is void types
I'm not going to spoonfeed you, good day.
>>
>>51476096
You know C doesn't have templates/true generics.
They introduced that weird _Generic thing in C11 but that's basically a type-based switch statement.
>>
>>51476173
Anything but C89 is heresy.
>>
>>51476164
>by-passing typing by passing void pointers
you fucking mongoloid cunt
>>
>>51476164
Alright, you've gotten the values into the function. Now compare them.

void *genericMax(void *x, void *y) {
// what goes here?
}


>I'm not going to spoonfeed you
Oh, right, because you can't.
>>
>>51476089
for(array a : array){
int max = 0;
for(int i : sub_array){
if(i > max) max = i;
}
System.out.println(max);
}

somethin like that idk i'm an amateur babeey
>>
>>51476188
Just cast them to doubles, anon. It's easy! And so fast! :^)
>>
>>51476188
return x > y ? x : y;
returns the largest pointer
>>
>>51476209
Kek, I should borrow that
>>
>>51476204
int main()
{
struct test { int value; };

struct test a { .value = 2 };
struct test b { .value = 3 };

void* max = genericMax(&a, &b);
}
>>
>>51476188
genericMax should have a 3rd argument that is a function pointer to a custom compar function that you specify.

The compar function would cast them to the type you want and then returns less than zero if less than, 0 if equal, and 1 if greater than.
>>
>>51476209
>>51476188
>ugg how does pointers work
are you fucking serious
return *x > *y ? *x : *y;
>>
>>51476245
>missing the joke
>dereferencing void pointers
>being retarded
>>
>>51476244
>going through all that trouble instead of just writing a fucking macro
Christ. It'll also be slower, because last I checked function pointers don't get inlined.
>>
>>51476244
All of this to avoid a harmless #define
People are literally so retardedly dogmatic sometimes, it's utter nonsense
>>
>>51474686
Been a while but it means f is a predicate defined as something. It is an equivalence between the two sides relating the parameters to something. The parameters are not themselves predicates (though predicates might appear on the right hand side)
>>
>>51476245
>dereferencing void pointers
>>
>>51476017
import numpy
numpy.maximum(data, axis=0)
>>
>>51475835
>Are strings immutable in C, the most commonly used language?
String literals are.
>>
>>51476188
>>51476187
>>51476164

What's more, passing void* is detrimental to the compiler's ability to optimise - since it's harder for it to work out wtf you're doing.

And in the worst case scenario - you're now having to go to the RAM just to do fucking min/max.
>>
>>51476283
>String literals are strings
OK... but string literals are "literally" useless in most programs.

User input can't be a string literal. Data read from the hard drive can't be a string literal. They're a tool to make your programming easier, but they're not really "strings".
>>
>>51476286
>>51476257
>>51476262
Why is this even an issue?
It's 2015.
>>
This seems like a good time to remind everyone that C strings aren't text.
>>
File: 1440102087068.png (74 KB, 870x867) Image search: [Google]
1440102087068.png
74 KB, 870x867
>>51476308
>>
>>51476308
#define current_year 2015
>>
>>51476286
But anon, macros are EEEEEEEEEEEVIL! :^) :^) :^) :^)
>>
>>51475454
>it's arguably the fastest language to /write/.
Except it's not. It many ways, it's much slower because of the lack of features and frameworks.

> datalogs get dumped on their laps and they have to parse them real quick
Python sure isn't the way to go with that one if you want quick
>>
>>51476334
>it's much slower because of the lack of features and frameworks

Have you even used python?
>>
>>51476308
A cpu cache miss can cost 500 cycles.
It doesn't matter how fast each cycle is - that's still ~200 times slower than it could've been.
>>
>>51476352
import shitpostbot

shitpostbot.shitpost()
>>
>>51476283
#include <stdio.h>

int main()
{
char s[] = "immutable, you say?";
s[0] = 'n';
puts(s);
return 0;
}
>>
>>51476357
>premature optimization
you people make me laugh, as if your fizzbuzzes need to run 200 times faster.
>>
>>51476388
What language is this? Looks hard to write
>>
>>51476388
>copying the string literal into a local array

Please try again.
>>
Reminder that Python is literally the worst language ever invented.
>>
>>51476388
>[]
That's not a string literal, idiot.
That's a char array you initialised with a string literal.
>>
>>51476399
Fucking this.
Absolute garbage tier language.
>>
ITT: Autism
>>
>>51476427
>>51476399
HAHAHAHAHAHA
>>
>>51476427
nice
>>
File: 1445311716435.jpg (95 KB, 724x720) Image search: [Google]
1445311716435.jpg
95 KB, 724x720
>>51476399
>>51476427
>>
>>51476399
Finally one thing everyone in this thread can agree on. If you disagree, gtfo to /wdg/
>>
hello senpai ily
>>
void qsort(void *base, size_t nmemb, size_t size, 
int (*compar)(const void *, const void *));


Friendly reminder that this is idiomatic C.
>>
Is Python really anything but a toy language?
>>
>>51476476
And?
>>
>>51476476
>tfw you wrote your own quicksort because you couldn't figure out how the C stdlib did it
>>
File: ahmeds-face-when.jpg (58 KB, 634x422) Image search: [Google]
ahmeds-face-when.jpg
58 KB, 634x422
>>51476427
>>51476399
>>
File: anime_gril_facepalm.jpg (53 KB, 372x363) Image search: [Google]
anime_gril_facepalm.jpg
53 KB, 372x363
>>51476427
>>
>>51476478
Nope.
This guys >>51476399 and >>51476427 have it right.
>>
>>51476476
Pretty concise looking.
I can see immediately that this thing takes a pointer, two sizes, and a function pointer (a function which itself takes two pointers).

What's the problem?
>>
im fresh graduated, c# and java based. And have a little knowledge about C. Accepted a c job which is embedded programming.

Do i gonna regret it ?
>>
>>51470662
not when it comes to the scope of a. and being forced to use a while loop instead of a normal for loop as you are in python is just cumbersome and pathetic
>>
>>51476524
>Do i gonna regret it ?
Maybe you should learn English first.
>>
>>51476524
Anon please give me your job. I am a professional NEET and I've been programming in C for the past 8 years.
>>
What's happening in Belgium?
>>
>>51476512
just stop
>>
>>51476548
That isn't me.
>>
>>51476394
W T F
T T
F T W
>>
>>51476565
use a different tripcode then
>>
>>51476394
RETARD

FUCK OFF TO STACKOVERFLOW/GITHUB/REDDIT FUCKING FAGGOT
>>
>>51476542
yeah have some problems with english, im not english origin mate. you dont need to be mad.

do i regret to accept the job?
>>
>>51476534
also, more subtly, for and while loops behave differently with regards to break and continue
>>
>>51476547
you tell me, i ain't following the news right now
>>
>>51476308
>>51476394
This is how you spot someone who's never worked on a VM or anything largely CPU bound before.
>>
>>51476396
it's erlang
>>
>>51476617
nah just roll with it, maybe try to learn some C before you start but really with java/C# you have the most basic parts down and learning the specifics of C shouldn't be that hard.
>>
Holy shit furry porn is the best.
>>
File: umaru2.jpg (1 MB, 1700x2400) Image search: [Google]
umaru2.jpg
1 MB, 1700x2400
>>51474126
>>
>>51476394
>>51476308
Can't tell if ignorant or just really really stupid
Either way you're a moron for having that kind of attitude

>>51476666
fucking best innit
>>
>>51476662
yea currently working on it mate, thanks for reply. its not so different from c#.

im currently reading "the c programming languages 2. edition"
>>
What's the best way to introduce someone to programming?
I'm adept at C now, but I don't actually remember how I got at this point because I just took bits and pieces from different tutorials over the course of 2 years.
>>
>>51476636
i dunno checking /pol/ you probably should too
>media blackout
>mximum terror threat level
>>
God I'm such a fucking faggot.
>>
>>51476636
Good news site I found:
http://www.reddit.com/
>>
>>51476476
Well, yeah, good luck implementing quicksort as a macro.
>>
>>51476725
c is hard to start with, try c# or java to introduce, high level languages better with start
>>
>>51476767
should be possible
>>
>>51476816
>c is hard to start with
No it's not. I learned C as my first language and I had no problems with it.
C is very intuitive, unlike the Java forced-OOP shit.
>>
>>51476816
If you've never malloc'd memory before, you have no business using the new operator in Java.
My first experience with programming was with java and I had no idea why things were written like String s = new String("string");

It wasn't until I looked at C++ that java started to make sense.
>>
>>51476869
>malloc
>C++
wut
>>
>>51476733
damn we're getting keked hard

at least if you look at it on the bright side, something is happening so that hopefully we'll be getting less mudslimes coming into europe
>>
>>51476879
sorry, meant C
>>
>>51476882
>another country will declare war on ISIS
>>
>>51476816
Fuck off. This meme needs to die. C isn't hard to start with. A "Hello World" in C is easier to understand than a "Hello World" in Java, for instance.

The difference is, in C, you have to build your own tools from scratch, and that's where a lot of the learning comes in. In Java you just call one of the thousands of standard library and never learn a goddamned thing.
>>
>>51476869
You don't need to understand malloc to understand Java's new.
You create a NEW object, instead of calling some static function, makes perfect sense.
>>
http://strawpoll.me/6075877
>>
>>51476879
I use malloc exclusively and I write in C++ every day. Is there a problem?
>>
>>51474726
> "unicode string" is meaningless
It usually has a very clear meaning, i.e. a sequence of wide characters whose values are unicode code points, e.g. wchar_t* in C or std::wstring() in C++ when __STDC_ISO_10646__ is defined, or Python's "unicode" type.

Note that this isn't the same thing as a UCS-2 or UTF-16 or UTF-32 string, even when it happens to have the same representation. UCS-2, UTF-16 and UTF-32 are encodings, which describe a sequence of *bytes*. A wide string is a sequence of wide characters, "wide" meaning that they're larger than a byte. The fact that a wide character is (like anything else) stored as some number of bytes isn't relevant here.

Files store bytes, hence they don't store "unicode strings", they store UTF-8, UTF-16, UTF-16-LE (or whatever) strings (also note: byte order matters here; "UTF-16" without qualification is big-endian; that's inconvenient for Microsoft, who a) historically developed for little-endian architectures and b) like to read/write chunks of memory directly from/to files without explicit serialisation, so they invented the UTF-16-LE encoding, which is little-endian).
>>
>>51476946
That's the thing I hate most about C++fags: they like to pretend that they're writing C and not writing C at the same time, and switch between them to better fit their shitty arguments.
If you're going to write C, write fucking C.
>>
>>51476974
I refuse. C++ is largely shit, but has features that I don't think should exist in C, but are also genuinely useful and make programming faster and easier. I'm not talking about templates (which are shit compared to real metaprogramming), I'm talking about stuff like default arguments, function overloading, and (limited) operator overloading. Besides those things, I write C... it's just compiled as C++.
>>
How would i go about doing somehting like this?
int main(int argc, char** argv){
if(/*argv contains hello world*/){
printf("Hello World!");
}}
[/code[
>>
>>51476869
CS101 Java tard here
why are things written like that?
Thread replies: 255
Thread images: 16

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.