/dpt/ - Daily Programming Thread

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

Other urls found in this thread:

learnpython.org/
codecademy.com/en/tracks/python
cprogramming.com/tutorial/c-tutorial.html
learn-c.org/
learncpp.com/
cplusplus.com/doc/tutorial/
cprogramming.com/tutorial/c -tutorial.html
en.cppreference.com/
isocpp.org/faq
wiki.installgentoo.com/index.php/Programming_resources
stackoverflow.com/questions/7861886/how-to-get-file-properties
blog.asciinema.org/post/and-now-for-something-completely-different/
twitter.com/NSFWRedditGif

Thank you for using an anime image.

What is the best programming language?

(1/3)

So you want to learn programming?

Pick a starting language. For beginners, there are generally two recommended "programming families" that you can choose to start learning:
-Dynamically typed/interpreted programming languages, such as: Python, Perl, Ruby
-Statically typed/compiled programming languages, such as: C, C++, C#

These are amongst the most popular languages in use worldwide, including 4 from the top 5. Both approaches are perfectly fine, and well-documented.
-Dynamically typed programming may be a bit more flexible, convenient, and forgiving. It is more popular in academia.
-Statically typed programming is a bit more suited for making general applications. It is more popular in industries.

Cannot decide? Flip a coin.

If you choose dynamically typed/interpreted programming, you may want to start with Python. It is very easy to pick up. Here are some good sources:
learnpython.org/
codecademy.com/en/tracks/python

If you choose statically typed/compiled programming, you may want to start with C, then pick up C++. C is very well documented, and teaches many universal programming concepts. C++ is based on C, and adds new concepts. Sources:
For C:
The C Programming Language (K&R)
C Primer Plus (Prata)
cprogramming.com/tutorial/c-tutorial.html
learn-c.org/

For C++:
learncpp.com/
cplusplus.com/doc/tutorial/
cprogramming.com/tutorial/c -tutorial.html
en.cppreference.com/
isocpp.org/faq

>BUT I WANT MORE SOURCES!
Read: wiki.installgentoo.com/index.php/Programming_resources

>BUT I WANNA START WITH [language x] INSTEAD!
Sure, if you like. But the languages above are considered good for beginners.

>BUT I WANNA MAKE A COOL WEBSITE!
Learn HTML, CSS, and Javascript.

>BUT I WANNA MAKE iPHONE GAMES!
Learn Objective C and/or Swift.

>BUT I WANNA MAKE ANDROID GAMES!
Learn Java.

>BUT I WANNA MAKE PC GAMES!
Learn patience.

Also, friendly reminder that /dpt/ has always avoided becoming a "general" by adding links to the OP.
DO NOT ADD LINKS TO THE OP.

(2/3)

So you want a starting/junior programming job?

You must master the basics of programming, and be able to implement your programming knowledge using any language. That means solving problems without relying on any particular syntax. If you cannot separate programming syntax from programming concepts/algorithms, then you will need to go back and focus on the basics.

After mastering the basics, you want a starting job. Let us look at languages that will help you launch your programming career. And no, you will not be earning $300k/year when you are just starting, but you may do so if you persevere.

1- Java. Enormously popular, Java is everywhere, and everyone wants a Java developer. A must for Android applications.

2- Javascript. It runs most of the internet! A must for website developers, along with CSS and HTML.

3- Objective C/Swift. The languages that power Apple gadgets. A must for iOS applications.

There are more languages in high demand, but they require more experience. Learn the following to expand your horizons:

-SQL. Because data must get stored.
-C. For real programmers.
-C++. For classy, objective programmers.
-Python. For high-paying software engineering jobs.

>WHAT OTHER LANGUAGES ARE IN HIGH DEMAND?
Other than what was mentioned above: C#, Ruby, and PHP.

>I WANT TO WORK WITH HARDWARE DIRECTLY. WHAT LANGUAGE IS CLOSEST TO THE METAL?
Machine code. Good luck, friend.

>WHAT HUMANLY-READABLE LANGUAGE IS CLOSEST TO THE METAL?
Assembly. When it comes to programming, Assembly is the apex predator.

>I WANT TO KNOW ABOUT THE LATEST NEW MODERN not-a-fad LANGUAGES!
Take a look at Rust, Go, Hack, Scala, Julia, Dart, and Erlang.

>THOSE LATEST not-a-fad LANGUAGES WILL GUARANTEE A JOB, RIGHT?
No.

>I STARTED LEARNING [language x] BUT YESTERDAY MY [friend/colleague/lecturer/uncle] SAID TO SWITCH TO [language y]. WHAT DO?
You have already started, so stick. That other language will still be there when you are done with your current task.

autistically refreshing boards and listening to music staring into emptiness

GNU Bash

>recommending python
>any information about web dev whatsoever

>recommending java or javascript

What the fuck did I fucking tell you?

(3/3)
Please give your suggestions, comments, and criticism on the two posts. It does not matter if you are reading several hours later: All feedback that can help improve the copy/pasta is welcome, and I will check the archives to read your response if the thread is gone.

Thank you.

No such thing.

It depends on how high level your problem is.
For example, I could probably cobble together a shell script in 10 seconds that would take hours to write in C.

This is to help new people, not for sticking in the OP.

your subject is shell and your time starts now

q. how does one average an arbitrary number of integers in shell?

That's a low level problem, you'd be better off writing it in C because I don't want to look up how to do arrays in bash.
Likewise, I don't want to look up how to traverse directories full of files in C when I can just for (i in dir_name);

>interpreted programming languages
>compiled programming languages
They do not exist.

>Read: wiki.installgentoo.com/index.php/Programming_resources
It's shit

>Learn Java.
You don't *need* java

Also >not suggesting Scheme
It's literally the best language to start with.

Anyone else learning erlang? Ive got oreillys book, but so far its going slow, though its genuinely interesting language

Recommending python to someone is not helping them

>Machine code. Good luck, friend.
Assembly you shit

This

>that's a low level problem
>you'd be better off writing it in C
C is a high level language
Is a "low level problem" one that contradicts your claim?

>i don't want to look up how to do arrays in bash
then I guess you couldn't "cobble together a shell script", you don't even know shell

>C is a high level language
it's not 1978 anymore.

What language should we recommend to someone who is new, and wants to learn programming?

Noted.

>What language should we recommend to someone who is new, and wants to learn programming?

C isn't bad as the first language.

C++ or C

I was actually wondering. I was going to start C++ but I was thinking that maybe it will start getting ditched for Rust(mainly because of an article I read about the new FF update)
Does this bear any truth?
Also, practically, isn't VHDL "closer to the metal"(unless you want to stick to programming and not designing)?

I'd suggest c++ simply because c is outdated, and you'll learn oop while at it so all the similar languages will be extremely easy

I think its meant to be for programming computers rather than writing circuits.

Why can't Linux IDEs autocomplete standard C++?

the good thing about C++ is you don't have to do OOP (and you shouldn't)

oop is dope tho

you do oop in c with your retarded struct pointer bullshit, yet crap over proper class support
fucking cancer

Why not? OOP makes life easier.

So the copy/pasta is fine? I recommend and provide sources for both.

I've started learning C# a few months ago just for fun, and I'm in love with the language.

Right now I'm developing an image viewer in C#, so I can read my my mango. I has some features that I always wanted in an image viewer like an easy crop function, advanced zoom, last acessed file,etc.

It's coming nicely, but I ran into a small problem with windows folders and I don't know if anyone can help me?
Basically what I want to know is the current sort mode any given folder (if it's sorted by name, date, size, etc). I tried using the DirectoryInfo class, but apparently the sort mode information is not in the folder itself, maybe it's saved in some sort of explorer cache.
For example, the Windows Photo Viewer somehow knows the sort mode a folder and organize all the images accordingly.

I don't think someone will come up with anything better.

ayy dpt I wanna code something neat
any ideas for useful simple programs for mobile? (wanted to test xamarin for android, so C#)

OOP was designed so that retards could learn to program

Structs are not OOP

Samefag

stackoverflow.com/questions/7861886/how-to-get-file-properties
in a loop over all files in a dir?

>Structs are not OOP
sure grandpa

That only happens if you're a shitty programmer.

I'm a noob, sorry.

I want to make sure that the user inputs a valid integer larger than 0. If he does, the loop terminates. That works.
However, when the user inputs something else (decimal number, negative number, 0, NaN), the program goes into an infinite loop printing its output but not querying for a new input: the scanf command seems to be completely skipped. What's going on?

#include
#include

int main() {
int input_number;
do {
printf("Integer larger than 0: > ");
if (scanf("%d", &input_number) != 0 && input_number > 0) {
break;
}
else {
printf("Error! Please enter an integer number larger than 0.\n");
}
} while (1);
return 0;
}

Output:
$ ./test
Integer larger than 0: > 34
$ ./test
Integer larger than 0: > c
Error! Please enter an integer number larger than 0.
Integer larger than 0: > Error! Please enter an integer number larger than 0.
Integer larger than 0: > Error! Please enter an integer number larger than 0.^C

Also why the fuck am I getting the difficult v1 captchas with the random letters and changing black / white background?

Structs are not OOP. OOP is more than just simple objects. Objects are self-contained and communication to one another by passing messages to one another. Structures don't work this way - they are simply a container of data.

You don't even understand OOP yet you're recommending it
No, it's the endgame of all OOP

You don't have to go full retard with inheritance when it doesn't make sense but classes with all their tools are useful as fuck.

Please stop posting this shit it's just all-around terrible and reeks of Sophomore.

No.

Transmitting a float via the digital pins of arduino.
Output pretty much done.


#include "TimerOne.h"
void setup()
{
Serial.begin(9600);
pinMode(5, OUTPUT);
pinMode(A2, INPUT);
Timer1.initialize(1000);
Timer1.attachInterrupt(comp);
analogReference(EXTERNAL);
}


byte b = B00000000;
int i = 0;
int t = 0;
int s = 0;

void comp()
{
noInterrupts();
switch (s)
{
case 0:
digitalWrite(5, HIGH);
s = 1;
break;

case 1:
//während i>9 byte mit maske abgleichen und verschieben,
//0 oder 1 analog und über serial monitor ausgeben
if (i > 1;
i++;
}
else
{
//wenn i>8, i=0, neues B einlesen
i = 0;
int v = analogRead(A2);
double spannung = v * (3.3 / 1023.0);
//int help = (double) spannung * 100;
int help = 150;
b = (int) help;
Serial.println(b);
s = 2;
}
break;

case 2:
if (t

>OOP was designed so that retards could learn to program

wat

It's a paradigm based entirely on the concept of nouns and verbs

scanf consumes only the input that matches the format string, returning the number of characters consumed. Any character that doesn't match the format string causes it to stop scanning and leaves the invalid character still in the buffer.

Use fflush().

>in a loop over all files in a dir?
Yes.
Right now I'm sorting all the files by the name. I could also sort by creation date or size too, but before that I need to know the sort mode that the folder is in, however this information is not neither in the folder or in files within it.
I could add an option so the user could choose the sort mode manually, but I want my app to get the sort mode automatically. I just can't find where this info is stored.

Do while loop executes at least once, always. You may way to try a simple if conditional instead to test for a number greater than or equal to 1

>Does not know about polymorphism

That pic only happens when you take a programmer that doesn't know how to OOP and they write it like they would a procedural language and uses classes like functions.

Fuck you dude. This copy pasta is great and contributes to the topic unlike your (and mine) shitposting

Instead of unicorns and third wave feminist deobjectifying.

... the diagram is fundamentally about inheritance

Sorry, meant for

>It's a paradigm based entirely on the concept of nouns and verbs

Wait are you serious? Let me laugh even harder AHAHAHAHAHAHAHAHAHAHAHAHAHAHA

Kek.

kys

Reminded me of this deliciousness

> In the scope of my research, a feminist programming language is to be built around a non-normative paradigm that represents alternative ways of abstracting. The intent is to encourage and allow new ways of thinking about problems such that we can code using a feminist ideology.

> The idea came about while discussing normative and feminist subject object theory. I realized that object oriented programmed reifies normative subject object theory. This led me to wonder what a feminist programming language would look like, one that might allow you to create entanglements (Karen Barad Posthumanist Performativity).

> I realized that to program in a feminist way, one would ideally want to use a feminist programming language. So what is a feminist programming language? Well I took a look at the major programming paradigms, the following are the four main groups a programming language can fall into: imperative, functional, object-oriented, and logic. I decided to explore feminist logic such that a feminist programming language could be derived.

> I am currently exploring feminist critiques of logic in hopes of outlining a working framework for the creation of a feminist programming language.

Jesus christ user.
In Haskell, what do you name your types? Verbs? Are your functions nouns?
Just because the communities of one language (Ruby) tried to make every single interface appear like the english language doesn't mean the entire paradigm is about it.

I'm not OP
pic

wrapped the old windows consol since its shit

currently working on implementing IOCP sockets and ICMP hole punching

You're already assuming there's a great deal of difference between the two

What would you call a function that returns a function?
What about a procedure that returns an integer, but only fetches io rather than "doing" anything?
What about a value that is a function?

fuck the autists I keked a lot

>Do while loop executes at least once, always.
I know, and that's precisely what I want.
>You may way to try a simple if conditional instead
That is possible but I wanted to try it this way to cut down on unnecessary checks. If I do this:

#include
#include

int main() {
int input_number;
int valid_output;
do {
printf("Integer larger than 0: > ");
valid_output = scanf("%d", &input_number);
if (input_number

I'm pretty sure you can't really access that information as it's a system/user setting.

>fflush() is for files.

No, it isn't, it flushes any stream.

fflush(stdin);

hurr, thanks.

We believe you :^)

Sure, there are some cases where it makes sense to do that.
That still doesn't change the fact that OOP isn't a paradigm based only on the concept of verbs and nouns (there's a good deal of people using adjectives for getters for instance!).

I don't care if you believe me

OOP IS based on nouns and verbs

You have objects (nouns) and messages (verbs)
That is the fundamental premise of OOP

That's what I was afraid of.
What bothers me the most is that Windows Photo Viewer has access to this information, I don't know the fact that WPV is being 'called' from the dllhost.exe grants it any special permissions.

Wait that didn't help either.

#include
#include

int main() {
int input_number;
do {
printf("Integer larger than 0: > ");
if (scanf("%d", &input_number) != 0 && input_number > 0) {
break;
}
else {
printf("Error! Please enter an integer number larger than 0.\n");
fflush(stdin);
}
} while (1);
return 0;
}

Still results in an infinite loop if I try to enter anything but integers. Integers

Sure you don't :')

That's the fundamental premise of smalltalk OOP.

Consider using getchar() instead of scanf.

That would mean looping getchar() until a terminating character is detected, right? Fuck, why does this have to be so inconvenient? Why doesn't scanf just consume the stdin queue? Why doesn't fflush(stdin) flush the queue? Grrrr!

You are better off reading one line into a buffer using fgets or a character with . Then parse that line/character using sscanf/atoi/strtol.

Just FYI, golang is finished.

blog.asciinema.org/post/and-now-for-something-completely-different/

Top kek. Does the unicorn imply it's amazing or impossible though?

My emacs can do that accurately.

who knows

Most of these reasons are completly valid.

>lack of central repo
I don't think that's an issue, I think that's an advantage. That being said, Go's dependency management is lacking for large scale stuff (which also sorta encourages less dependencies, which is good - if including dependencies gets too easy, you get left-pad).

>batteries included
Most of these are included in the Go standard library as well.
Go is fully batteries included for backend webdev and has more useful stuff than Python, but for the usecase of that application it's more lacking than Python.

>int32 to int64
I think that's good. Imagine if all that stuff was implicit - overflow errors waiting to happen!

>if err != nil
Explicit error handling at every level is nice if you're working with many people. For scripts and similar, exceptions are better.
That being said, exceptions suck for concurrency related stuff if you don't have supervisors.

Lisp because you can implement all other languages in Lisp using Lisp.

and you cant in other languages?

That goes for most languages, and Lisp isn't a programming language

Yeah, I was using a shitty one. Others work.

Is this show worth watching?

If you're a pathetic faggot, sure

For one thing, you need an interpreted language that can modify its reader/parser dynamically.

I don't mean write a program in a language that can run programs in a different language, I mean turn the language into a different language.

It's like 40 minutes, just watch it.
If you like it, you can always read the manga, which is much longer and the anime was basically just an ad for the manga anyway.

so you mean you can make a compiler in lisp that takes in some language A and spits it out in another? im pretty sure that is very doable in many languages, i dont see how mapping between languages, assuming one exists, would be too hard, if i understand you correctly

He means turn the language you are writing in into another language. E.g. you are writing in a lisp, then you do some stuff that extends the syntax of lisp so that it is another language, and then you can use your usual lisp interpreter/compiler to run that code, and you can use normal lisp things inline, or vice versa

I mean, it is possible to do in lisp:

(load "make-lisp-into-python.lisp")

def foo():
print("Hello world!")

foo()

load("make-lisp-into-java.lisp")

public static void foo() {
System.out.println("Hello world");
}
foo();

load("make-lisp-into-javascript.lisp");

process.stdout.write("Hello world");

and run this using Lisp.

oh, in that way, my bad.
well if we are going to be pedantic, you could do that with something like
char *src = "...";
exec(compile(src));

but changing the actual language itself, yea thats pretty cool.

undefined behavior

>flushes any stream
>any
For some definitions of "any".

:^)

#define any void*
:^)