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

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

Thread replies: 255
Thread images: 30
File: himegoto.webm (3 MB, 720x405) Image search: [Google]
himegoto.webm
3 MB, 720x405
old thread: >>55559257

What are you working on, /g/?
>>
File: Programming Shelves.png (952 KB, 2100x1400) Image search: [Google]
Programming Shelves.png
952 KB, 2100x1400
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:
http://www.learnpython.org/
http://www.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)
http://www.cprogramming.com/tutorial/c-tutorial.html
http://www.learn-c.org/

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

>BUT I WANT MORE SOURCES!
Read: https://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.
>>
File: hiro.png (106 KB, 622x564) Image search: [Google]
hiro.png
106 KB, 622x564
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
>>
>>55568584
GNU Bash
>>
>>55568586
>recommending python
>any information about web dev whatsoever

>>55568598
>recommending java or javascript

What the fuck did I fucking tell you? >>55568571
>>
>>55568586
>>55568598
(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.
>>
>>55568584
No such thing.
>>
>>55568584
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.
>>
>>55568614
This is to help new people, not for sticking in the OP.
>>
>>55568623
your subject is shell and your time starts now

q. how does one average an arbitrary number of integers in shell?
>>
>>55568639
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);
>>
>>55568586
>interpreted programming languages
>compiled programming languages
They do not exist.

>Read: https://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
>>
>>55568632
Recommending python to someone is not helping them
>>
>>55568598
>Machine code. Good luck, friend.
Assembly you shit
>>
>>55568675
This
>>
>>55568656
>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
>>
>>55568691
>C is a high level language
it's not 1978 anymore.
>>
>>55568675
>>55568688
What language should we recommend to someone who is new, and wants to learn programming?

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

C isn't bad as the first language.
>>
>>55568705
C++ or C
>>
>>55568598
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)?
>>
>>55568723
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
>>
>>55568736
I think its meant to be for programming computers rather than writing circuits.
>>
File: cpp.jpg (45 KB, 340x255) Image search: [Google]
cpp.jpg
45 KB, 340x255
Why can't Linux IDEs autocomplete standard C++?
>>
>>55568745
the good thing about C++ is you don't have to do OOP (and you shouldn't)
>>
>>55568763
oop is dope tho

you do oop in c with your retarded struct pointer bullshit, yet crap over proper class support
fucking cancer
>>
>>55568763
Why not? OOP makes life easier.
>>
>>55568716
>>55568723
So the copy/pasta is fine? I recommend and provide sources for both.
>>
>>55568572
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.
>>
>>55568782
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#)
>>
File: 1464632537832.png (152 KB, 1948x858) Image search: [Google]
1464632537832.png
152 KB, 1948x858
>>55568772
>>55568779
OOP was designed so that retards could learn to program

Structs are not OOP
>>
>>55568584
>>55568572
Samefag
>>
>>55568787
http://stackoverflow.com/questions/7861886/how-to-get-file-properties
in a loop over all files in a dir?

>>55568797
>Structs are not OOP
sure grandpa
>>
>>55568797
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 <stdio.h>
#include <stdlib.h>

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?
>>
>>55568805
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.
>>
>>55568805
You don't even understand OOP yet you're recommending it
>>55568809
No, it's the endgame of all OOP
>>
>>55568797
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.
>>
>>55568586
Please stop posting this shit it's just all-around terrible and reeks of Sophomore.
>>
>>55568823
No.
>>
>>55568572
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 <= 7)
{
if (b & B00000001)
{
digitalWrite(5, HIGH);
}
else
{
digitalWrite(5, LOW);
}
b = b >> 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 <=9)
{
digitalWrite(5,LOW);
t++;
}
else
{
t = 0;
s = 0;
}
break;
}
interrupts();
}

void loop()
{}
>>
>>55568797

>OOP was designed so that retards could learn to program

wat
>>
>>55568845
It's a paradigm based entirely on the concept of nouns and verbs
>>
>>55568818
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().
>>
>>55568805
>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.
>>
>>55568818
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
>>
>>55568823

>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.
>>
>>55568831
Fuck you dude. This copy pasta is great and contributes to the topic unlike your (and mine) shitposting
>>
>>55568856
Instead of unicorns and third wave feminist deobjectifying.
>>
>>55568872
... the diagram is fundamentally about inheritance
>>
>>55568883
Sorry, meant for >>55568854
>>
>>55568854

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

Wait are you serious? Let me laugh even harder AHAHAHAHAHAHAHAHAHAHAHAHAHAHA
>>
>>55568799
Kek.

>>55568572
>>55568584
kys
>>
>>55568854

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.
>>
>>55568854
Jesus christ anon.
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.
>>
File: OOP.png (69 KB, 1210x467) Image search: [Google]
OOP.png
69 KB, 1210x467
>>55568911
I'm not OP
>>55568929
pic
>>
wrapped the old windows consol since its shit

currently working on implementing IOCP sockets and ICMP hole punching
>>
>>55568939
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?
>>
>>55568584
fuck the autists I keked a lot
>>
>>55568869
>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 <stdio.h>
#include <stdlib.h>

int main() {
int input_number;
int valid_output;
do {
printf("Integer larger than 0: > ");
valid_output = scanf("%d", &input_number);
if (input_number <= 0) {
valid_output = 0;
}
else {
valid_output = 1;
}
if (valid_output == 0) {
printf("Error!\n");
}
} while (valid_output == 0);
return 0;
}


... it still goes into an infinite loop.

>>55568856
So because the input isn't an integer number, it stays in the stdio queue so on every iteration, scanf tries to read the very same again? Fuck.
fflush() is for files.
>>
>>55568858
I'm pretty sure you can't really access that information as it's a system/user setting.
>>
>>55568960
>fflush() is for files.

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

fflush(stdin);
>>
>>55568971
hurr, thanks.
>>
>>55568941
We believe you :^)
>>
>>55568950
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!).
>>
>>55568986
I don't care if you believe me
>>
>>55568996
OOP IS based on nouns and verbs

You have objects (nouns) and messages (verbs)
That is the fundamental premise of OOP
>>
>>55568964
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.
>>
>>55568971
>>55568983
Wait that didn't help either.

#include <stdio.h>
#include <stdlib.h>

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 <= 0 are okay.
>>
>>55568997
Sure you don't :')
>>
>>55569006
That's the fundamental premise of smalltalk OOP.
>>
>>55568960
Consider using getchar() instead of scanf.
>>
>>55569029
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!
>>
>>55569012
You are better off reading one line into a buffer using fgets or a character with >>55569029. Then parse that line/character using sscanf/atoi/strtol.
>>
Just FYI, golang is finished.

http://blog.asciinema.org/post/and-now-for-something-completely-different/
>>
>>55568584
Top kek. Does the unicorn imply it's amazing or impossible though?
>>
>>55568760
My emacs can do that accurately.
>>
>>55569243
who knows
>>
>>55569204
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.
>>
>>55568584
Lisp because you can implement all other languages in Lisp using Lisp.
>>
File: 1334548135174.gif (2 MB, 300x225) Image search: [Google]
1334548135174.gif
2 MB, 300x225
>>55569309
and you cant in other languages?
>>
>>55569309
That goes for most languages, and Lisp isn't a programming language
>>
>>55569280
Yeah, I was using a shitty one. Others work.
>>
>>55568572
Is this show worth watching?
>>
>>55569335
If you're a pathetic faggot, sure
>>
>>55569322
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.
>>
>>55569335
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.
>>
>>55569376
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
>>
>>55569428
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
>>
>>55569428
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.
>>
>>55569468
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.
>>
>>55568971
undefined behavior
>>
>>55568971
>flushes any stream
>any
For some definitions of "any".
>>
>>55569551
:^)
>>
>>55569551
#define any void*
:^)
>>
>paste unicode into python IDLE
>everything sucked into a black hole
rip hours of work
>>
>>55569679
That describes anything unicode well, really.
>>
File: 14674085525911.jpg (52 KB, 600x534) Image search: [Google]
14674085525911.jpg
52 KB, 600x534
>>55568598
>Rust, Go, Hack, Scala, Julia, Dart, and Erlang.
>not a fad
>>
>>55569679
>save file? do we even have the technology already?
>>
>>55569679
What the fuck did you paste?
>>
>>55569707
i bet it had some nasty whitespaces or linebreaks in there
>>
>>55569707
http://pastebin.com/raw/7wt6jDZg
Tried it again, I don't even..
>>
>>55569694
>Erlang
>fad
Is C++ a fad as well?
>>
>>55568705
>What language should we recommend to someone who is new, and wants to learn programming?
Scheme, I said it before.
There is a reason SICP uses it.
>>
>>55568745
C++ is outdated by design.

>OOP
>good
>>
>>55568971
You can't use fflush in stdin, this is undefined behaviour.

>>55569551
This
>>
>>55569753
C++ isn't an OOP language
only OOP fags call it an OOP language
>>
>>55569771
I know, real OOP languages are smalltalk and erlang.
>>
>>55569753
C++ is bloated by backwards compatibility, if they could just move on from their "but muh ANSI C from '93 wont work if you remove 'register'"

>C++ being OOP exclusively
you dont know C++ very well do you?
>>
>>55569784
>C++ is bloated by backwards compatibility
Not only, there are many other things that bloat or mark C++ as outdated.

>>C++ being OOP exclusively
I didn't say that. You are retard, aren't you?
>>
>>55569784
Also, C++ is not backwards compatible with C nor it tries to be (for example in C++ you have to cast from/to void *)
>>
>>55569791
many of the things that make it a bit outdated is because the committee are too concerned with not breaking existing code. hell, there are things i love about other languages, like explicit owership of pointers, const-by-default, nested functions, multiphase parsing, the removal of header files and more.

>You are retard, aren't you?
perhaps, but im not blindly hating on OOP
>>
>>55569805
You're retarded.
>>
>>55569846
Nice argument.
>>
I'm fooling around with 16-bit x86 assembly. It appears that my line drawing method corrupts stack in some way, because I have trouble reusing arguments.
void drawLine(short x0, short y0, short x1, short y1)

It takes four arguments, coordinates of points (x0, y0) and (x1, y1) and draws a line between them. I wanted to connect many points, so I call it like that:
push word 40
push word 320
push word 240
push word 320
call drawLine ; drawLine(320, 240, 320, 40)
push word 43
push word 354
call drawLine ; drawLine(354, 43, 320, 240)
push word 40
push word 320
call drawLine ; drawLine(320, 40, 354, 43)

But third draw call draws wrong, as if there was something else on the stack. The worst thing is that I have no 16-bit debugger available, so I can't take a look what's in there.
drawLine saves base pointer on entry and restores it on exit, so it should be okay, old parameters should still be on stack
Any ideas?
>>
>>55569852
display an example where C cannot be compiled as C++ and no K&R C doesnt count, nor does minor things like inline and its modern underscored relatives
>>
>>55569413
I don't understand the manga.

It's just 3-box comics, like Garfield.

>>55568584
>What is the best tool in my garage?
Sure, you can have a preference, but only a mouthbreather would say a particular language is objectively the best.
>>
>>55569886
See >>55569805
>>
>>55569898
he said no minor things included
>>
>>55569873
theres a lot that could go wrong, we have no idea what drawLine does to the stack or registers
>>
>>55569904
1: I don't care, if he wants to find out more it's extremely easy
2: It is not minor as most programs would suffer from that
>>
File: 3.webm (412 KB, 1920x1080) Image search: [Google]
3.webm
412 KB, 1920x1080
>>55569726
What. Why does it just die? No errors or anything..
Python doesn't have good unicode support?
>>
>>55569909
>we have no idea what drawLine does to the stack or registers

drawLine:
push bp
mov bp, sp ; save stack pointer on entry
; ... do stuff
mov sp, bp
pop bp ; restore base pointer on leave
ret ;return

It has local variables on stack, but they are initialized to zero. Function arguments aren't modified, they are tread as read-only in that function. I consider registers caller saved.
drawLine repeatedly calls drawPixel, that is in charge of putting pixel info to video memory segment, but that function saves base pointer too. I could really use a debugger here and go step by step.
>>
>>55569917
>i cant find any good examples
>my type system cant understand the concept of a memory address
>>
>>55569895
>calling languages ""tools""
>unironically pretending a language can't be better than another
>>
>>55569895
It's 4-box comics. The term is yonkoma.
Also, they all lead into each other so it's not like garfield at all.
Also, not all of the manga is in 4-panel format.
>>
>>55569943
what the hell are you rambling?
>>
>>55569297
>>55569243
You aren't bright

It's meant to mean it is a fairy tale, so nonexistent
>>
>>55569959
what do you mean?
>>
File: this article is real and true.png (329 KB, 711x610) Image search: [Google]
this article is real and true.png
329 KB, 711x610
>>55569966
Why, because that's what you want it to mean?
>>
>>55569975
what do you mean?
>>
>>55569939
looks about right to me, my initial guess wold be that some offset on the stack pointer is wrong.

at the top of my head i cant think of any asm debuggers other than the one that handles inline asm in visual studio, perhaps you can use that?
>>
>>55569950
There are certain groups of languages that are similar enough to pick one that is better. However, among all languages in existence, that's just silly.

I can say that C# is better than Java, but I can't say that C# is better than x86 Assembly, even though I would kill myself if I had to do assembly on a daily basis. They're not comparable in any meaningful way.
>>
>>55569928
It might be a problem with IDLE. IDLE is a shit IDE that is known to crash for capricious reasons. I remember when `import random` would cause it to crash.
>>
>>55569928
Follow-up to >>55570031

You are better off copying the contents into a file and running that, rather than running those commands directly in an interpreter.
>>
File: 1459926416792.jpg (25 KB, 263x263) Image search: [Google]
1459926416792.jpg
25 KB, 263x263
>>55570026
>They're not comparable in any meaningful way.
>>
>>55569994
I can't. It's a 16-bit real mode code, no chance to run it directly, I can only use dosbox.
Maybe I could use turbo debugger under dosbox.
>>
>>55570079
actually do you know where it currupts the stack? after 1, 2 or more calls, or perhaps on return?
my thought is that you might need to add (2 * the number of calls + 2) * word_size from the stack pointer when returning from the callee of drawLine
>>
>>55569886
#include <stdlib.h>

int repeated_global;
int repeated_global = 1;

void any_args();

int main(void)
{
const int const_with_no_value;
struct class {
int public;
struct nested_but_not_scoped {
int private;
} protected;
int flexible[];
} class = { .public = 1 }, * restrict y = malloc(sizeof *y);
struct nested_but_not_scoped c = { .private = class.public };
*y = (struct class) { .protected = c };
goto skip_init;
int no_init = 1;
skip_init:
any_args(y, &const_with_no_value, &no_init);
}

I bet you didn't know about 99% of this.
>>
>>55569976
Because I made the image
>>
Why do people still code in C when there's modern C++ available ?

Is it because retards can't handle the power and complexity of a real language ?
>>
File: 562.jpg (36 KB, 600x600) Image search: [Google]
562.jpg
36 KB, 600x600
>>55568572
>posting the homosexual anime webm
>>
>>55569873
>>55570114
Even second call produces incorrect results when I try to reuse arguments. As if it increased stack pointer, getting rid of two arguments.
push val0
push val1
push val2
push val3
call drawLine ; drawLine(val3, val2, val1, val0)
push val4
push val5
call drawLine ; should be drawLine(val5, val4, val3, val2) but actually is drawLine(val5, val4, val1, val0)

val3 and val2 just go missing
>>
>>55570168
Weak bait, Anon.
>>
>>55570116
actually the only thing i didnt know was the *y = (struct class) { .protected = c } part, but then again im sure 99% of c++ programmers dont know of the function-try-catch syntax either.
either way good example of very purpose specific code, now run it.
ill have to say though, intentionally using c++ keywords as identifiers made me laugh a bit
>>
>>55570121
but you weren't the one who edited it into the good version
>>
>>55570195
>intentionally
This might come as a shock: C was invented before C++.
>>
>>55570186
hime isn't gay
>>
>>55570194
> ooga booga

What's that? You just don't want to work 10 times faster with the help of C++ STL while producing equally fast code? Yeah, sure.
>>
>>55570193
try adding 4 to the stack pointer after the call?
>>
>>55570209
oh my, well remind me that if anyone ever revises any language they have to make sure that no existing code used intended keywords. variable names is just a low blow that is a "because i can"
>>
>>55570193
forgot to add, perhaps also push them in a different order: 2, 3, 0, 1 etc
>>
>>55570220
>>55570266
Hold the phone, I got it.
I tought I don't modify arguments in that method, but after looking once again, I actually modify first and second. I modify them as I loop though pixels, so after the exit stack pointer is good, but values on stack are modified. Look at code from >>55570193
After first call val3 is equal to val1, val2 is equal to val0.
I'll change that. Two more local variables in that method, but calling will be easier.
>>
>>55570195
>the only thing i didnt know was
There's no need to lie on the internet, anon. There's a lot you didn't know; protip: almost every line has something C specific that is forbidden in C++.
>im sure 99% of c++ programmers dont know
If they're "programmers" such as yourself, I bet.
>example
>now run it
Is this some kind of backpedaling for getting told? Don't get mad, I didn't expect you to be on my level anyway.
>using c++ keywords as identifiers
It's C. C++ keywords don't matter any more than Java and Python keywords. Here's real C from the linux kernel:
struct drm_nouveau_grobj_alloc {
int channel;
uint32_t handle;
int class;
};

>>55570242
>they have to make sure that no existing code used intended keywords
I didn't claim such a thing. Try not to be retarded.
>variable names is just a low blow that is a "because i can"
I bet anon would also be "made to laugh" if he sees a variable named "go", because it's a keyword in golang. Is that also a low blow? You're not very smart, are you?
>>
>>55570307
ha, gotta love it when things like that sneak up on ya.
ofc you could also try passing them in the registers, but then again idk how intensive your subroutine is on register usage
>>
>>55570336
>There's a lot you didn't know
assumptions

>If they're "programmers" such as yourself, I bet
nice uninformed insult, i await your argumentation

>Don't get mad
nope, but writing legal code and writing functional code is different things

>keywords don't matter
>Try not to be retarded
given we were discussing C and C++ compatibility i believe they do so, why else would you have chosen them?

why are you so upset anon?
>>
>>55569026
That's the fundamental premise of OOP. Smalltalk is the first language to implement the OO paradigm.
>>
File: dosbox_000.webm (97 KB, 640x480) Image search: [Google]
dosbox_000.webm
97 KB, 640x480
>>55570356
Sounds reasonable.
>>
>>55570387
The fundamental premise doesn't mean shit when the paradigm has been implemented differently in loads of different languages for the last 40 years..
The term "OOP" is mostly meaningless and associated with many different concepts.
Functions attached to structs + some form of encapsulation is enough for a language to be called OOP.
Nobody has called "methods" "messages" since smalltalk, smalltalks definition of OOP isn't relevant to determining whether something is OOP today.
>>
>>55570384
>assumptions
Literally proven. Go ahead, make it compile as C++. Let me know how many changes you had to make. C++ is "backwards compatible", it shouldn't be hard, right? Yeah, I know you won't, because you can't: you don't know enough C++ either.
>why else would you have chosen them
Why did the kernel developers choose them? Maybe because "class" made sense? Just like "private" makes sense for something private? How fucking retarded can you be to yell "b-but you can't use that, it's a C++ keyword, you're doing it on purpose" when 1) C doesn't have any obligation/intention to compile as C++ 2) C++ adds keywords all the time disregarding that they were valid identifiers previously? decltype? noexcept? nullptr? thread_local?
>>
>>55570539
>Literally proven
i dont see the proof

>you don't know enough C++ either
and you base this on what?
i have not posted a single line, all ive said about C++ is about a function try-catch block

>Maybe because "class" made sense?
and where did you names make sense in your example?

>adds keywords all the time
>Try not to be retarded.

you are upset arent you? now if you could give me an argument for why i "don't know enough C++"
>>
>>55570598
>i dont see the proof
>display an example where C cannot be compiled as C++
>I don't know any but I know C and C++ tho
>maximum damage control
Ok.
>>
>>55570660
you are retarded beyond reason.
congratulations you posted an example that doesnt compile as c++ code, so because i didnt immediately think of an example of C code give you an example i dont know shit about C++?

still awaiting a proper argument
>>
File: 1467713415072.png (18 KB, 604x618) Image search: [Google]
1467713415072.png
18 KB, 604x618
>>55570660
>not using the appropriate russian troll meme
>>
>>55570741
>you posted an example
>didnt immediately think of an example
No mate, the code I posted contains about 10 examples of C constructs that can't be compiled as C++. Again, you don't know enough about these languages to even realize that; all you did is get hung up on "muh keywords". You can go ahead and ask me to point them out to you so you at least can get some education besides getting told.
>>
Can someone explain this to me? I understand the array declarations and assigning values to each index of the array, but I don't get what's going on with:

int rand1 = (int)(Math.random() * length1);
int returnvalue = array[rand1].

So I randomize the entirety of the array (with length1) and then place it into rand1? Then wtf is array[rand1] supposed to mean?
>>
>>55570195
>i didnt know was the *y = (struct class) { .protected = c } part
You didn't know C then.
This contains 3 things that make it not compile in C++.
>>
>>55570947
The array isn't being randomized.

You're creating a random number no larger than the count of elements in the array, and then you're using that random number to select an element of the array and print it to console.

This would print one single value ten times.

randomizing
is never actually used.
>>
>>55570947
>So I randomize the entirety of the array (with length1) and then place it into rand1? Then wtf is array[rand1] supposed to mean?
?

You pick a random number in [0, 1). When you multiply by the length, that interval becomes [0, length). When you cast to int, it becomes {0, 1, 2, ..., length - 1}. So you end up with one of these numbers (chosen randomly) and you store it in rand1. The rest should be easy to understand.
>>
>>55570945
i pointed the keywords out because its such an obvious one. but no im not going to ask you because i do understand them, but keep waving your dick around thinking i dont know shit.

>>55570975
i never claimed to be an expert at C, but the thing i should have pointed out more explicitly was the .member assignment part
>>
File: lVRpkef.png (18 KB, 672x353) Image search: [Google]
lVRpkef.png
18 KB, 672x353
>>55570947
Also,
valuesOfArray
and
printArray
are not being used for anything.

That whole code block is just silly. I don't think it does what you think it should do.

What exactly are you trying to do?
>>
>>55570999
>its such an obvious one
They're all obvious if you do indeed know C++. As we've established, you don't tho.
>no im not going to ask you
Don't let embarrassment get in the way of learning. It's an anonymous board after all.
>>
>>55568572
>You'll never dress up like this in the public
;_;
>>
>>55571064
im done, keep thinking i dont know the language. go back to your mom and ask her to pad your head because you kept insisting on unbased claims
>>
>>55571070
Good you flying faggot
>>
>>55571070
more like

>you'll never be molested by a cute gay boy in the locker room
>>
File: rooms.png (4 KB, 187x225) Image search: [Google]
rooms.png
4 KB, 187x225
Shitty game dev here. Is this where I can go for some programming help?

Let's say I have a variable x that decides what "room" a sprite appears in. If the x = 1, the sprite's in the living room, x = 4 and they're in the hallway, etc. Pic related is how the rooms are "connected". If I want a sprite to move from room 7 to room 3, for example, the variable would be set to 7, then 6, then 4, then 3, with the proper pauses in between. Throughout the game, I will be ordering sprites to move from any room to any other, so I'm making a function that accepts the destination and then sets the variable accordingly in order as described before.

The problem is, the only way I can think of doing this is by manually defining every possible route between the eight rooms, meaning I'd have to have like 56 different manually-written routes. This seems tedious and I feel like it's not really the right way to approach this. Is there a better way of doing it?
>>
>>55571092
>keep thinking i dont know
Keep thinking you do and stay retarded, I don't mind.
>insisting on unbased claims
Proved it already, but you might be mentally ill.
Bye. :^)
>>
>>55571107
>>/vg/agdg
>>
>>55571122
okay never mind then, wave you dick and explain so you can feel good about yourself.

>might be mentally ill
i dont see how that is related

>:^)
kys kid
>>
>>55571107
You only need to model the graph.
Store the number of each room and which other rooms it's connected to (e.g. 4: 1, 3, 6).
>>
>>55571107
>>>/vg/148429610
>>
>>55571135
Sorry, I thought you guys would know more. I figured /agdg/ was more of an ideas/showcase thread as opposed to a programming/mathematics one.
>>
>>55568671
Die in a fire, scheme is a shit
>>
>>55571149
>Sorry, I thought you guys would know more
oh, you
>>
>>55570947
> java

>>>/x/
>>
>>55571107
>>55571149
There are multiple pathfinding algorithms.

https://en.wikipedia.org/wiki/Pathfinding
>>
>>55571107
If I understand you correctly, you just want an algorithm for pathfinding?
In that case, you can just an existing one.
https://en.wikipedia.org/wiki/Pathfinding
>>
>>55571107
I don't know if I quite understand exactly what you're saying but it sounds like your current implementation will give you problems.

What you have drawn is essentially a graph. If you stored the data of the rooms similarly then for a simple system like this you'd just use Dijkstra's path finding algorithm.

That said since you're giving rooms corresponding numbers rather than using enums is already a bad start.
>>
>>55571167
>NEET

>>>/out/
>>
>>55571107
https://en.wikipedia.org/wiki/Breadth-first_search
>>
>>55571232
https://en.wikipedia.org/wiki/Depth-first_search
>>
>>55571170
>>55571180
This is very interesting, but a bit out of my scope. I'll have to do some learning. Thank you very much for giving me a starting point.

>>55571184
>That said since you're giving rooms corresponding numbers rather than using enums is already a bad start.
I'm not exactly sure what that means. Why would the way I label the rooms in my variables matter?
>>
>>55571248
>>55571232
https://en.wikipedia.org/wiki/Dijkstra%27s_algorithm
>>
>>55571263
>a bit out of my scope
Anon, if Dijkstra's is out of scope, you don't need to be making a game.

There are plenty of examples in whatever language you're using.
>>
>>55571266
https://en.wikipedia.org/wiki/A*_search_algorithm
>>
>>55571263
it's actually exactly what you're looking for
this is stuff you solve in second semester of computer science
>>
>>55571276
I'm trying to do something fancy in a visual novel is all. I've only ever worked on turn-based games without any real need for this sort of mathematics, mainly because they're on a small enough scale to justify manually mapping out anything complex.

Thank you everyone for the help, by the way.
>>
>>55570992
I'm trying to create a program where I enter some list of words to the program, it'll shuffle all of the words and return them back to me with a random order.

>>55571047
I still don't understand "array[rand1]". I thought inside the brackets of an array would have something to do with elements (like specifying the amount, or which index you'd like to call). What does that variable mean?

Ty for the help btw, This isn't homework, I'm trying to learn Java. :S
>>
>>55571263

Well a path finding algorithm is your only choice here.

If you brute force it then your program will be slow as hell (Traveling salesman type of problem)

>>55571314
Visual novels generally use a flag system and predefined maps.
>>
>>55571324
>or which index you'd like
yes, that one is what it means
>>
>>55571324
Using your array, if you print the result of
array[2];
, you'd print the number 3.

Index #2 is the 3rd element in the array.

rand1 in this case is a random number from 0-9. If that random number lands on 9, let's say, then the number 17 will be printed 10 times, because 17 is at index 9, the tenth position.
>>
>>55571288
>>55571266
OP just wants to know a path from room A to B, retards. There are no weights.
>>
>>55571372
>OP just wants to know a path from room A to B,
no, I'm pretty sure what he actually wants is the shortest path from A to B.
>>
>>55568572
My Raspberry Pi comes in today
>thank you based Amazon Prime deal
>>
>>55571397
> implying you ever played a game in your life

Breadth-first search will give a short enough path. No need to complicate things.
>>
>>55571331

Brute force in this case means determine it on the fly by testing all possible routes dumbly.. In theory if you have small maps you could calculate and save all shortest routes from A -> B in the map data and just load it into a table.
>>
>>55571421
>Breadth-first search will give a short enough path. No need to complicate things.
maximal keks
>>
File: pp0758.jpg (55 KB, 597x519) Image search: [Google]
pp0758.jpg
55 KB, 597x519
I've spent the past three hours trying to get boost c++ libraries working on windows
>>
>>55571491

Normally I'd take a jab at windows here. But, in this case it sounds like user error.

Perhaps you should make the switch to a linux distro?
>>
>>55571491
> on windows
Google around, you're not the only one trying to do that.

Or maybe stop using windows.
>>
>>55571122
no? you dont feel like waving it around anymore?
well well now im disappointed
>>
>>55571263
>out of my scope

A game is out of your scope, then.

(I fucking hate indie devs)
>>
>>55571567
>all games require pathfinding algorithms
???
>>
>>55571590
Almost all games will require some basic algorithms for various tasks, not to mention a basic understanding of trigonometry for things like lighting and vision, if applicable.
>>
>>55571590
>want to make a game
>doesn't know about basic graph theory

If you knew even the slightest shit about that, you could easily come up with a naive algorithm that fits the problem.
>>
>>55571622
>all games require algorithms for lighting and vision
Now you're just baiting.
>>
>>55571635
>like
>if applicable

I'm pretty sure games at least require a certain understanding of English.
>>
>>55571590
All games will most likely require algorithms on that level.
It's not fucking rocket science, you can deduce Djikstra's one on your own since it's very natural.
>>
>>55571646
The point is, there are plenty of games you can make without the need for trig or any sort of algorithm, basic or not.
>>
>>55571661
>game without algorithm

Get a load of this dumb fuck.

Stick with unity, retard.

You should get banned.
>>
>>55571661
>game without algorithm
Any fucking game with user interaction already has algorithms on it.
Do you even know what an algorithm is?
>>
>>55571635
>>55571661
And my point is that even if you don't need trig, there are many other useful algorithms used in the most basic of games.

I find it ironic that you accused me of baiting after being completely incapable of understanding my last post. You're on some special stuff, I suppose.
>>
>>55571686
>you accused me of baiting
>Anonymous

and top kek at the baits
>>
>>55568572
im tasked with finding and fixing memory leaks in our companys DAL
i also have to do it by remote
never done this before
>>
>>55571590
Just learn what a graph is, how to represent and store one in a computer program and run algorithms on it. And learn a few basic algorithms. You can quickly find a tutorial or introductory lecture notes on this. These are simple things that will help you out in your career.

There are many clueless but pretentious retards ITT.
>>
>>55571263
>I'm not exactly sure what that means. Why would the way I label the rooms in my variables matter?

They don't matter exactly but they help with clarity.

Currently you might say room 5 is the kitchen. So in your code when you want the kitchen you use the number five. However this makes code less readable.

Enums can be thought of as a replacement. You'd be able to write Kitchen in your code but internally it's treated as number 5. Makes things more clear with no real downside.
>>
File: 1465158171193.jpg (132 KB, 997x1005) Image search: [Google]
1465158171193.jpg
132 KB, 997x1005
>>55571661
>without the need for trig or any sort of algorithm
>>
>>55571736
you're fucked lmao
>>
>>55571107 here. Just reporting that I managed to put something together and it seems to be functioning perfectly. I ended up using a breadth-first search if only because I wasn't entirely sure how to approach the problem of my paths all having equal weight when using Dijkstra's. Only after I was done did I realize the weights wouldn't make a difference. Oh well.

Thank you for teaching me something, /dpt/.
>>
File: jWWPolf.jpg (138 KB, 702x768) Image search: [Google]
jWWPolf.jpg
138 KB, 702x768
What do you need to become a great programmer ?
>>
>>55571844
Stop going to reddit.
>>
>>55571844
There's no two ways about it, you need severe autism.

Others can only become good but not great.
>>
>>55571844
You can't become a great programmer.
You just get it, or not, and it's decided by birth.
If you're one of the chosen ones, experience and study.
>>
>>55571887
This.
The best programmers I've met were some kind of weirdo.
>>
>>55571844
Honor. Honor and a penis.
>>
>>55571590
>Let's say I have a variable x that decides what "room" a sprite appears in. If the x = 1, the sprite's in the living room, x = 4 and they're in the hallway, etc. Pic related is how the rooms are "connected". If I want a sprite to move from room 7 to room 3, for example, the variable would be set to 7, then 6, then 4, then 3, with the proper pauses in between. Throughout the game, I will be ordering sprites to move from any room to any other, so I'm making a function that accepts the destination and then sets the variable accordingly in order as described before.
sounds like your/his game does, at least if you/him expand it to more rooms

>>55571107
56 short routes is not a lot for a computer
>>
>>55571661
>trig
yeah some really baby tier shit game, even a 2d platformer has trig

>any sort of algorithm
lol sure is summer
>>
>>55571137
>explain
>I already know but teach me tho
anon...
>>
>>55571887
this

most people are just too stupid and/or uninterested to become great programmers
>>
>>55571919
>>55571887
sucks but it's true
normalfags just don't have the ability to concentrate hard enough for long enough, day in, day out
>>
What it's called in OO when an object keeps the characteristics of some bigger class?
>>
>>55571887
looks like there might be a chance for me
>>
>>55571665
While you're preaching about trig dumbass HS dropouts shit out Unity games like crazy and get Steam releases raking in dat dough.
>>
mman i'm so bad at this shit
>>
>>55571987
inheritance
>>
>>55571996
making a half decent unity game, one that makes major money, still takes effort
>>
>>55570480
except C doesn't have functions attached to structs so what you said earlier is bullshit
>>
>>55572085
Say it again.

void foo_init();
void foo_shutdown();

typedef struct {
void (*init) (void);
void (*shutdown) (void);
} foo;

int main()
{
foo f;
f.init = foo_init;
f.shutdown = foo_shutdown;

return 0;
}
>>
>>55572085
not him, but you are 100% retarded
>>
>>55572085
>C doesn't have functions attached to structs
u wot m8
Thread replies: 255
Thread images: 30

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.