Previous thread: What are you working on, Sup Forums?
/dpt/ - Daily Programming Thread
first for coroutines
First for chapel does parallelism way better than Go.
first for goroutines are shit, coroutines were better.
TWO SCOOPS
GEE BILLY! TWO SCOOPS?
...
DAHNALD, THE SCOOPS, GIVE THEM TO ME
Thanks, but I do wish they were a bit more like a c-like language.
Finally got to chapter 4 in K&R, the reverse polish calculator exercises are a bitch
you don't have to do every exercise you know. some are way harder than others on purpose
Give me a project to work on, I've got absolutely no idea what to do
computer-aided suicide
that's called Rust and no thanks
>that's called Rust
Anyone has picture with list of programming tasks? I remember there used to be numbered list posted.
better-dpt-roll.github.io
don't roll in these threads
thanks
Comfiest graphics library ?
opengl
For C++ I use SFML
depends the language
simple video game with 3d graphics
::::DDDDD
So, I wonder why the Java compiler tells me I am not allowed to do this.
public class Kreiszahl_pi{
public static void main(String args[]){
//This should be a formula to approximate pi up to five digits after 0
double pi = 3;
double a=1;
double b=2;
double c=3;
double nikalantha1=0;
for (double i = 1; i javac .\Kreiszahl_pi.java
.\Kreiszahl_pi.java:10: error: ';' expected
nilakantha1 =+ 4(a+i)*(b+i)*(c+i);
^
.\Kreiszahl_pi.java:10: error: not a statement
nilakantha1 =+ 4(a+i)*(b+i)*(c+i);
^
.\Kreiszahl_pi.java:10: error: ';' expected
nilakantha1 =+ 4(a+i)*(b+i)*(c+i);
^
.\Kreiszahl_pi.java:10: error: not a statement
nilakantha1 =+ 4(a+i)*(b+i)*(c+i);
^
.\Kreiszahl_pi.java:10: error: ';' expected
nilakantha1 =+ 4(a+i)*(b+i)*(c+i);
^
.\Kreiszahl_pi.java:10: error: not a statement
nilakantha1 =+ 4(a+i)*(b+i)*(c+i);
^
.\Kreiszahl_pi.java:10: error: ';' expected
nilakantha1 =+ 4(a+i)*(b+i)*(c+i);
^
7 errors
PS C:\Users\thora\Documents\Uni\Übungsblatt4>
+= not =+
None of you are successful programmers. You simply spend your time posting here in a programming language dick-waving contest. Nobody cares that you find Go easy, or Java simple, or Rust safe, or Haskell clever, or Lisp elegant. None of you is ever going to finish making anything in any language. I have hundreds of thousands of lines of working C and C++ in production behind me, more useful than anything any of you will ever make. Dogpile me like a bunch of triggered furries all you want, it won't change the truth. You're just a bunch of losers!
Help! I can't stop formatting my code, going full autistic mode. I have to make sure everything is aligned in columns. Should I seek treatment? Is it some sort of OCD? It literally causes an irritation.
>4(a+i)
must be 4*(a+i), there's no implicit multiplication by juxtaposition in Java, nor in most programming languages.
it's not even easier to read, if anything it's harder
still the same error :/
Okay, solved the issue.
Man I am thankful there is a site like Sup Forums.
Are there any books/guides how to make code beautiful, easy-to-read? Examples of such code?
>C++
>beautiful
just write it normally and learn to appreciate it
yeah man here's the guide: don't
add a bunch of
spaces between
............................your
............................words
g_tetris
javac's messages aren't very friendly, yeah. I think I can crack them open for yall tho:
nilakantha1 = +4; that's how the compiler is seeing it. +4 is just 4, and this would mean assigning 4 to nilakantha1 even tho that's not what you meant, so the syntax error's not there, and nilakantha1 += 4; also triggers it. Now from the compiler's pov, the assignment statement is finished, and there's an expression juxtaposed to it for no reason, so it complains you should have ended the statement after the 4, and then states that even if you did, the following statement would still make no sense. Also Sup Forums is eating the leading spaces on your pasted error messages so wrap them in next time thx.
These aren't words though, they are symbols in a formal language. Try again.
Is there a less retarded way to do this?
Making a clock with ncurses
"object oriented" programs with deep or wide inheritance hierarchies are more often than not shitty and unmaintainable.
What's the best way to learn python?
you forgot "my" at the start of your sentence.
>Scala author proposes indentation based syntax
ugh, fucking why
What I learnt in a span of time:
Comment your code.
If you think that you will really forget what your code will do, comment it.
Indent and space your code
if your code is inside a loop, or in a function or whatever, then make it look like so to denote that they are inside.
FUNCTION START:
code
FUNCTION END.
and
FUNCTION START
CODE
CODE
CODE
FUNCTION END.
Something like that.
TRy to make it look easy on your eyes.
Give variables and permutations MEANINGS.
Don't just go args1 args2 and shit.
You will be seriously killed or doxxed with snuffporn and no employer wants to do anything with you.
For an example, I am using the nikalantha algorithm in my code to approximate pi.
it is alternating inbetween + and minus, so I have divided the nilakantha algorithm into 2 functions called nilakantha 1 and 2.
Let it make sense to you even after you are done with your code.
>falling for the scala meme
Function start:
code
Function end
Function start
code
code
code
Function end.
Damn
Store the textmaps in a separate file and xxd -i them at build time? would avoid the "",'s but it's not that retarded IMHO.
yeah I'd prefer having everything packed in the executable
I see. xxd doesn't create 2-dimensional arrays though, so it's going to be nontrivial if you do it. You could get exactly this source code without writing it like so if you put all the textmaps in a text file, then ran sed 's/.\+/"&",/' on it. Dunno if you prefer that.
What's the best site/resource for a crash course in C++? I haven't used it in a few years and now I can't remember shit for it but I might be using it for my next job
cppreference.com
Found a game I started when I was a kid using Java. The whole game is in the main method though and it's extremely bloated.
I could post the semi-working code if anybody's interested
Do it, it's always a laugh.
rate my improved screenfetch
github.com
thank you but bash is obsolete now
I have a C++ question regarding design patterns (visitor here) with unique pointers. Here is an example of what I would like to do using dynamic dispatch
#include
#include
class Visitor;
class Base
{
public:
Base() { }
virtual ~Base() { }
virtual void accept(Visitor& v) = 0;
};
class BaseImpl;
class BaseImplDeriv;
class Visitor
{
public:
virtual void visit(BaseImpl& b) = 0;
virtual void visit(BaseImplDeriv& d) = 0;
};
class BaseImpl : public Base
{
public:
BaseImpl() {}
virtual ~BaseImpl() { }
virtual void accept(Visitor& v) { v.visit(*this); }
};
class BaseImplDeriv : public BaseImpl
{
public:
BaseImplDeriv() {}
virtual ~BaseImplDeriv() { }
virtual void accept(Visitor& v) { v.visit(*this); }
};
class VisitorImpl : public Visitor
{
public:
virtual void visit(BaseImpl& b) override
{
std::cout
#include
#include
#include
#include
#include
int main() {
srand(time(0)*getpid());
int pagesize = getpagesize();
int offset = ((unsigned long) main)%pagesize;
unsigned char* page = ((unsigned char*) main) - offset;
if (mprotect(page, pagesize, PROT_READ|PROT_WRITE|PROT_EXEC) != -1) {
int i; for (;;) {
i = rand()%(pagesize - offset) + offset;
printf("%d: %x ", i - offset, page[i]);
page[i] = rand();
printf("=> %x\n", page[i]); }}
return 0; }
>not doing every exercise in k&r
stop
fucking stop
fUC
KING
S
T
----*
[segmentation fault]
Here. I realized in was proceeding in the wrong order like a retard. The call should be
b->accept(v);
instead of
v.visit(*b);
Alright so the story is that I started making a text based game based of the universe of Fallout 1, then I got bored and abandoned it. Then after New Vegas came out I started working on it again, changing all the skills and stuff and then abandoned it again. This isn't the original but it's only slightly modified.
Function overloads are resolved statically at compile time.
which language allows me to have two scoops of ice cream?
Rate my basename
import std.stdio;
void main(string[] args)
{
foreach (arg; args[1..$])
{
ulong last_slash_index = 0;
foreach(index, character; arg.dup.reverse)
{
if (character == '/')
{
last_slash_index = arg.length - index;
}
}
arg[last_slash_index..$].writeln;
}
}
Thanks, I fixed it. Here is what I assume would be the correct usage of such a pattern in C++.
#include
#include
class Visitor;
class Base
{
public:
Base() { }
virtual ~Base() { }
virtual void accept(Visitor& v) = 0;
};
class BaseImpl;
class BaseImplDeriv;
class Visitor
{
public:
virtual void visit(BaseImpl& b) = 0;
virtual void visit(BaseImplDeriv& d) = 0;
};
class BaseImpl : public Base
{
public:
BaseImpl() {}
virtual ~BaseImpl() { }
virtual void accept(Visitor& v) { v.visit(*this); }
};
class BaseImplDeriv : public BaseImpl
{
public:
BaseImplDeriv() {}
virtual ~BaseImplDeriv() { }
virtual void accept(Visitor& v) { v.visit(*this); }
};
class VisitorImpl : public Visitor
{
public:
VisitorImpl(Base& b) { b.accept(*this); }
virtual ~VisitorImpl() { }
virtual void visit(BaseImpl& b) override
{
std::cout
sepples was a mistake
I love it when something goes right in the end.
Thanks again for your help dpt.
Now I can calculate pi on my code
"OOP design patterns" were a mistake
any language, but you're better off doing it object-oriented
c++:
template class scoop;
class ice_cream {};
template class scoop {};
scoop two_scoops_of_ice_cream[2];
lisp:
(defstruct scoop (t))
(defstruct ice-cream ())
(defun scoop-of-ice-cream ()
(make-scoop (function make-ice-cream)))
(defun two-scoops-of-ice-cream ()
(mapcar (function funcall)
(make-list 2 :initial-element (function scoop-of-ice-cream))))
It's plain to see which one is cleaner.
shit my lisp was wrong i forgot the slot name
fixed:
(defstruct scoop (t))
(defstruct ice-cream ())
(defun scoop-of-ice-cream ()
(make-scoop :t (function make-ice-cream)))
(defun two-scoops-of-ice-cream ()
(mapcar (function funcall)
(make-list 2 :initial-element (function scoop-of-ice-cream))))
Literally nothing wrong with that.
>/dpt/
>working
wew meme lad reddit normie
make a Sup Forums bot that reads data, about something. Maybe about the most frequently used words in each thread, then have it plot it into a graph. Basically graph Sup Forums data, id like to see something nice
>meme lad
hoply fupck
I have a hard time learning arrays.
I need to learn java, too. which I already am doing.
What's a step by step information on arrays?
Like, literal baby's intro to arrays to wizardhood?
>#shittypoetry
It's a list of something.
String[] someWords = {"First", "Second, "Third"};
// start counting at 0. This prints "First"
System.out.println(someWords[0]);
If you don't get it then programming isn't for you.
>DIS OB
GUALIDY BREAD :DDDDDDDDDDD
yeah, but ho do they apply for 2d rooms?
How do they apply to anything else?
Why does it work? I don't know, maybe I just don't know how to use it?
Contextualise your questions plz
2d rooms? What do you mean. Are you talking about 2d arrays? Those are just 2 arrays. IF YOU DONT UNDERSTAND ARRAYS, DONT DO 2D ARRAYS YET. Learn how normal arrays work and 2d will be easy
youtube.com
>yeah, but ho do they apply for 2d rooms?
you can use array of arrays to store tiled 2d structures
Fucking hell ncurses is THE fucking cancer
Try linear algebra on KahnAcademy
An array is like a shelf, it has so many spaces (length) of a certain size (type) and you can put things in each space.
One way to look at a 2D array is an array of arrays, in other words a shelf with smaller dividers in each space.
sup /dpt/
what is the fastest or at least most simple algorythm to sort a 3D network layout of nodes and links? something that avoids colisions to make it visually pleasing i guess. im looking at force directed algorythms which are extremely precise but at the cost of performance
I read the yellow book for C#, wrote some 20 programs, what do I do now? What are pointers? Which is better, WinForms or WPF? Where do I go for further learning?
>What are pointers?
if you want to really know, go learn C.
btw, a more "Java" version of that picture would have all the subscripts (the parts in square brackets [ ]) less by one, as Java follows the convention of 0-indexing (the first element is subscript [0]).
The lisp is cleaner.
Your brain needs purged if you think any lisp is clean looking.
>The lisp is cleaner.
REEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
It's certainly better looking than any c++.
>but this mud is cleaner than this poo pile
UWP. Do you really want to make windows desktop apps though?
Whether or not both are shit is irrelevant to me. Just saying the lisp looks better is all.
is there a better library than ncurses to control console output?
template class scoop;
class ice_cream {};
class poo {};
template class scoop {};
scoop cplusplus;
poo java;
scoop lisp[256];
Is it too late to learn android development?