/dpt/ - Daily Programming Thread

prev: What are you working on, Sup Forums?

Other urls found in this thread:

github.com/murarth/rusti
stackoverflow.com/questions/1641957/is-an-array-name-a-pointer
tiobe.com/tiobe-index/
github.com/yegor256/eo
twitter.com/AnonBabble

i only write binary, everything else if for retards

Impressive isn't it

First week of coding school and I already feel I'm in way over my head. We've only covered html, css and bootstrap. Next week we start JS. I'm reviewing everything at my own pace and still have homework to do. I'm enrolled at Epicodus in Portland btw.

Fuck off

Has gatekeeper-kun been unbanned?

>t. rustlet

I should really get back to my Free Software projects.

Whom are you quoting?

Regular friday stuff.

@63541376
a rustlet

DOOD, what language can i learn that will get me the most 3d poonanny?

Are there any okay-ish editors for Java that don't come with 30GB of bloat?

can rust print hello world without making a new file?

>are there any editors for poojeetlang that don't come with poo
lol

Netbeans

You mean does it have a REPL? No, but why would it need one?

github.com/murarth/rusti

>t. webshitter

well i meant just running ad-hoc code since it is the rust OS

>there are brainlets in those threads who believe C arrays and pointers are the same thing

Does Linux let you run C code without a compiler?

how are they different?

nevermind lad.

But arrays are pointers to their first element

Pointers don't contain space information.
stackoverflow.com/questions/1641957/is-an-array-name-a-pointer

>Legacy arrays
>Aware of length outside the scope

>arrays are pointers to their first element

Arrays are contiguous sequences of identically sized elements in memory. Pointers to arrays are another thing and are typically how you manipulate arrays.

int* arr0 = {0,1,2,3};
*(arr0+0) == 0

I never understood the sweetieposting, is it just to piss people off or what?

>implicit conversion

some thot on twitter that calls everyone sweetie
and yeah its just to piss people off

tiobe.com/tiobe-index/
do you see rust listed here?
>0.698%
that is right, far lower that JS, a language that makes Getting Shit Done possible. now I ask you, what is the percentage you see there?
>2.972%
The only reason python (another meme language) is above it is due sysadmin plebs that can't learn php and academia using it. Fuck off with your meme language.

>some thot
Don't insult this lady.

>just look at how many pajeets use my lang!

Rust and JavaScript are not in the same criteria.

JavaScript is a scripting language, Rust is a general purpose. There are things that JavaScript just can't do while Rust can.

>Getting shit done
What exactly do you want to do?

//file1.c
int array[] = {0, 1, 2, 3};
//file2.c
#include

extern int *array;

int main()
{
printf("%d\n", array[0]);
}

if she breath she a thot

>a language that makes Getting Shit Done possible
About a month later in prduction

How do you call a window within a callback function? I'm using the FLTK toolkit from c++ to perform this.
I already have my classes and callback set up. I have manged to close one already using hide() but I don't know what to do to open another window. show() doesn't work for me.
struct window_one:Grahph_lib::Window
//code is typed here
struct window_two:Grahph_lib::Window
//code is type here
window_one::cb_next_window(Address, Address pw)
{
reference_to(pw).next_window();
reference_to(pw).show();

}
void splash_screen::next_window()
{
hide();

}
#include "GUI.h"

int main ()
try
{
window_one win(...);
return gui_main(); // an “infinite loop”
window_two win2(...);
return gui_main();
}

>javascript is only 10 times slower than C
That's not bad at all for an interpreted scripting language

Why the fuck people didn't realized that array is a collection of allocated memory on the stack,
and the representation of the memory is the pointer pointed to the 0-th location of the memory,
while pointer is only something to point to other thing.

int main()
{
int a;
int * p = &a;
}

if array == pointer, then p in the code above is an array.

>In C++, safety is achieved by careful personal discipline, and is very easy to get wrong. In Rust, safety is the default.
Talk about pajeet language!
>There are things that JavaScript just can't do
Like another operating system? Nobody needs that shit anymore when there are millions, perhaps billions of devices ready to execute whatever app written in JS. Arguing over either one is a scripting language or a "general purpose" language is irrelevant, for both achieves the ends that matters - making peoples lives easier.
Not my fault if you choose to do it the hard way though, guess that is the problem one faces with a long neckbeard.

Can someone explain to me what the fuck a stack is?

It's when you put something on top of something else.

Forgot pic
Enjoy your meme languages nobody uses.

google LIFO

>billions of devices ready to execute whatever app written in JS.
They aren't. Embedded development is no where near JS' territory. Furthermore considering what a piece of shit the language is, and how slow it is no big production would ever touch javascript for their internal heavy lifting jobs.

>Arguing over either one is a scripting language or a "general purpose" language is irrelevant,
It is, JavaScript is literally a scripting language.

You haven't answered what program exactly do you want to create though.

Imagine pancakes.
You make a bunch of them and put them on top of each other.
Now, you want a pancake in the middle because it is the perfect pancake or whatever.
Since this is a stack of pancakes you have to eat all of them in order until you get to that perfect pancake.
So basically in a stack you can access only the last thing you put in it.

>In C++, safety is achieved by careful personal discipline, and is very easy to get wrong. In Rust, safety is the default.
wtf I love Rust now!

Why can't I just slide the perfect pancake out from the middle of the stack?

Because you can only see the top of the pancake stack.

But I know there are pancakes underneath it because I just put all the pancakes in the stack. Why can't I just slide one out from underneath whether I can see it or not?

The stack will fall over burning your shit up.
Look, this is a shitty analogy.
The thing is in a stack you can only either put or take something from the top of it.

have you ever try to slide a pancake out from the middle of the stack without touching other pancake around it?

So i'm currently working on a GUI driven game for my class that is basically like mine sweeper only you walk by clicking buttons. The problem i'm having is I can't get the grid size to update from my action listener. Any advice?

didn't you play Magic the Gathering?

>They aren't. Embedded development is no where near JS' territory.
Oh what a shocker! Nobody uses browsers in their phones! Besides, technology is supposed to lessen the costs of the market, not to appeal to the common memelord argument "COMPUTERS ARE FAAAAAAAAAAAAAAST", memory prices has been rising, silicon too, cannot afford to waste memory on garbage collectors, let the consumers process the unimportant bits!
(and mine us bitcoins too)
>It is, JavaScript is literally a scripting language.
Irrelevant when one seeks to Get Shit Done e.g. sales and marketing, while you are still trying to write yet another shitty ftp client.

keep making more vague posts without any code.

Did you know Daruma Otoshi?
Stack is basically that. If you want to knock something in the middle, you need a proper skill to do that, otherwise it will just falling apart.

Im not that far in my wizard training yet

I know that you push and pop things, but I get confused when people talk about stack/heap, stack smashes and other problems with putting things on the stack. Like why is using recursion really bad in some cases?

>The thing is in a stack you can only either put or take something from the top of it.
That's sounds stupidly restrictive. Why would I use that for anything when I could just use a data structure that lets me take anything from anywhere in it?

>technology is supposed to lessen the costs of the market,
Exactly. JavaScript does not do that. It's costly, inefficient and does no such thing better than other languages.

yes I realized I was a faggot

String text = input.getText();
int newGrid = Integer.parseInt(text);

if(event.getSource() == newGame)
{
def = newGrid;
mainPanel.validate();
mainPanel.repaint();
}
so the def is supposed to change another variable that controls the grid size but nothing happens

Did you put your text inside a code block inside another code block?

this is inside a private action listener method and the def int goes to the public class that holds the main information. I'm very new to this if you couldn't tell

get out, newfag

Because generally you want your data structures to be as restrictive, fast, and lightweight as possible.

>using recursion really bad in some cases
Your CPU has a bunch of things called registers - those are little memory things that describe it's state. When you recurse you need to save that state somewhere. Pretty much the best way is to push those values on a stack somewhere in memory, this only thing you need to describe state is pointer to the top of stack, now since the stack is actually located in memory if you recurse too much you fill it up and can actually clash with memory allocated by your program for other things, which is bad.

Can anyone explain pic related to me? I might just be a brainlet

stack in the memory basically:
|s-5|s-4|s-3|s-2|s-1|s-0|

s is the stack pointer of the current scope, and s-x is the location of object in the memory address.

then you have a recursive function:
char rec(char in)
{
if (in)
{
return rec(in-1);
}
else
{
return 1;
}
}

when calling the rec() function, the computer will push another memory as the return address,
then push another value as the passed parameter, then move the stack pointer to the return address of the function, and act as a new scope.
If we following the address list on the above, then the return address will be s-6 and, and the passed parameter will be located in s-7.
after that, the stack pointer got decremented to srec = s-6, and all the function care was only the new srec stack pointer.
When the function recursing, similar action was done, and hence will increase the stack size in no time.

of course this is a huge simplification, since the instruction need more information to function properly, such as the original location of
the stack pointer before the function was called.

What exactly do you need clarified?

>generally you want your data structures to be as restrictive
That's retarded. Why would I want to be able to do less with a tool?
>fast, and lightweight
How is it any faster to arbitrarily restrict a data structure from being able to use a simple feature?

explain why cactus is elegant:
>it require tons of vertex to display the thorn
>practically a fractal object since when growing could create new arm indefinitely
>require less amount of water

While being, undeniably, adopted by the people all over the world, present in every operating system that matters, it is everywhere, rustlet. Do you have any idea of the processing power that gives you, combined?
ASSembly can't give you that.
C can't give you that.
Rust can't give you that.
No meme language can give you that, brainlet.

Why does every run return a different number? I swear to god my brainlet can't process why it would go wrong, the code seems pretty normal to me

threads do shit concurrently
in that example price.mul(2) and the price is printed at the same time
So you can't predict whether it will print the price before or after its multiplied by two
I believe this is called a race condition

i fucking love bread

Well, that's threading for you.
Things happen in no particular order.
Unless you take steps to sync them, reading and writing data is unpredictable.

>Why would I want to be able to do less with a tool?
Why would you want to make and maintain tool that does much, much more than it needs to?
>How is it any faster to arbitrarily restrict a data structure from being able to use a simple feature?
Stacks are usually implemented on dye.

pajeet, my son

>>/fit/

see figure 1: cactus

How is Idris better than Haskell?

So, if I got that right,each print will either be 30.20, 60.20, or 60.40?

Why do you mix Russian text and English book?

>While being, undeniably, adopted by the people all over the world,
That's because Javascript has been published before Rust came out.

I don't know the book in question but assumed it was a joke, judging only by "TL;DR" part.

dep types
totality checking
better syntax
not fragmented
a good type system
no extension wankery

30.20 or 60.40, not sure where you're getting 60.20 from

I have no clue, found that pic on another Sup Forums thread

There is no guarantee at which order single instructions in different threads will execute in.
Suppose a function has 3 lines of code, and you launch threads A, B, and C in that order, to run that function.

Just because you launched A first, doesn't mean A is guaranteed to be the first to run line 1. Furthermore, even if it is, that still doesn't guarantee that A will be the first to run line 2, etc.

because one of the threads could multiply the dollars, then the other one prints, then the first one multiplies the cents

Watch YT videos on every subject you're currently studying and google anything you dont understand. GL

and most importantly, it's not lazy by default*

too bad, sucks to be (You)

That's the call stack, not the stack data structure. CPUs have a baked in notion of function (subroutine) calls that use the stack to keep track of parameters and local variables.

>That's retarded. Why would I want to be able to do less with a tool?
Yeah, fuck abstractions let's write everything in ring-0 assembly.

xDD

It's serious (but is still a joke), but it seems to be abandoned.
github.com/yegor256/eo