/dpt/ - Daily Programming Thread

What are you working on, Sup Forums?

Previous Thread:

Other urls found in this thread:

sprylang.org/
ntrs.nasa.gov/archive/nasa/casi.ntrs.nasa.gov/19660017566.pdf
chapel-lang.org/
stackoverflow.com/questions/155609/difference-between-a-method-and-a-function/155655#155655
gist.github.com/aphirst/e21ff1a5360ae3b8cdc93ec4914f8ecd
youtube.com/watch?v=rX0ItVEVjHc
twitter.com/SFWRedditImages

>c++ is the greatest language of all time

why is the image a photo of an average lookings woman in her early 30s

I just came across this language:
sprylang.org/

It's really pretty neat. Basically Smalltalk meets REBOL.

If it's not true then why c++ is so popular?

>javascript

why is this error?

>miss meeting with my group for my software engineering class because of the flu
>check back in the next day
>"yeah we're writing an android app in C"

Here's a scan of an original NASA specification for a Fortran IV program. Full of formulas and flow charts.

ntrs.nasa.gov/archive/nasa/casi.ntrs.nasa.gov/19660017566.pdf

Wrong double quotes, you nigger.

Idk man but the lack of any indentation there is beyond disgusting

lmao you nigger just use the replace method

...

Who distributed high performance parallel comping here?
chapel-lang.org/

what does this image have to do with programming?

I have no idea what programming is or does sorry.

i'm sick today Sup Forums :(

Ladder logic is programming

gute besserung mein neger

I wonder if kids and noobs were introduced to pure functional programming first and only used that for quite a while, and then tried to learn something like C or Java, if that would be really difficult for them?

It's more like her mid thirties.

it didnt even work
im still learning so didnt wanna use shortcuts

use a non meme language

I am trying to understand the difference between a function and a method and I fell on this post : stackoverflow.com/questions/155609/difference-between-a-method-and-a-function/155655#155655

But I am not sure if I truly understand the second point :
"A method is able to operate on data that is contained within the class (remembering that an object is an instance of a class - the class is the definition, the object is an instance of that data)."

Doesn't it mean that a method has access to variables contained within the global scope + the class scope, or am I understanding something wrong ?

That's right.
A procedure (a function as C may call it) has access to variables in global scope.
A static method can access variables in global and class scope.
An instance method can access variables in global, class and object scope.

Strings are immutable (you can change them) also don't use keywords (finish) as variables pls

a method has specific semantics to break the encapsulation of the instance it's bound to.

i thought they were the same thing just 2 different names

>(you can change them)
can't

What is that supposed to mean? I don't quite understand.

A method can access private and protected members. These are encapsulated implementation details that do not constitute part of the class's interface.

>a method has specific semantics to break the encapsulation of the instance it's bound to.
This is a bizarre way to put it. The method doesn't break encapsulation (unless it returns a reference to your object's private parts or something equally stupid). The implementation of the method is a part of the class definition. It's like saying that your liver has specific semantics to invade your body.

class Foo
{
private a;
}

// method
Foo::geta()
{
return self.a // break encapsulation
}

// procedure
foo_geta(Foo f)
{
return f.a // error, can't break encapsulation
}


also, oop is not necessary done through classes.

so what if i store it in another variable and change it and then returns that?

and is there a text editor that warms me if a variable im using is a keyword?

im just using notepad atm cuz someone told me not to use fancy text editors that autocomplete shit and i wont lean that waay

The method implementation is part of the class definition. The syntactic quirks of C++ are irrelevant.

How is this necessarily breaking encapsulation? What if the private variable directly represents some property of the object that is useful to users of the object, such as the size of a list?

Now if you're returning a reference/pointer to private data, that's another problem entirely.

(You)

That's not just C++, that's any language with a "private" access specifier.

You have brain damage. The method implementation is a part of the class definition. Even if you spread this definition over 500 files and put unrelated crap in them. This is not up for debate.

because a method, contrary to a procedure, has 'self' to which encapsulation doesn't apply.

objects are not necessary defined by a class (prototype, closure, message).

im using mallocy linked lists with allocated cstrings in them in a 2k microcontroller and no one can stop me!!!!

>look mom i posted it again haha!

>objects are not necessary defined by a class (prototype, closure, message).
This is completely irrelevant. You don't understand what encapsulation is, or what breaking encapsulation means. Please don't spew your absolutely delusional nonsense in front of beginners.

using up all those 2k could stop you

>This is completely irrelevant.
its relevant since your definition involve class level scoping which make it unsuitable for the general concept of method.

>You don't understand what encapsulation
encapsulation is giving accessibility rules to attributes but a method breaks those rules; it doesn't care if a attribute has been declared as private or not, it has specific semantics to ignore encapsulation.

this is PLT 101.

whenever it uses more than 256 bytes i just busyloop until the master slurps up the data
havent noticed any encroaching memory fragmentation yet
maybe ill replace it with a ringbuffer lol

I have seen some functions which when they need to turn off or on some options like

Blah(bool light, bool output, bool shit)

then instead of using a bunch of bool parameters like that they like use some weird shit and save it into 1 something like

1

a bitmask?

You can get notepad++ which has some features (like syntax highlighting) but doesn't autocomplete everything for you.

You can change your input string into an array, then change your character and retransform it into a new string.

var input = "abcdefg";
var myarray = input.split(""); // creates an array from your string
myarray[0] = "A"; // you change whatever you want
myarray[6] = "G";
var newstring = myarray.join(""); // creates a string from an array

>your definition involve class level scoping which make it unsuitable for the general concept of method
I wasn't giving you any definitions. I was pointing out to you the irrefutable fact that method implementations are part of the class definition (assuming class-based OOP) so it's fairly self-evident that their mere existence doesn't break encapsulation as you claim.

>encapsulation is giving accessibility rules to attributes but a method breaks those rules
No, you fucking retard. You don't understand what encapsulation means, so naturally you don't understand what does or does not break encapsulation. The bottom line is that you should shut your hole and stop poisoning the minds of beginners with your delusions.

Bitflags

What are the best short courses/ qualifications you can get for under a couple of thousand bucks? - things that are worth putting on your cv.

I was thinking ISTQB/ Linux Foundation Certified System Administrator (LFCS) /

but how does it work, that shit is even more confusing than magnets

>was supposed to be writing a C compiler
>pushed it off to the last second
>it's due tomorrow

its alot more obvious if you write out the numbers in binary format like 0x00000010
means it only activates the second to last flag
while 0x11111111 activates all the flags

>tfw to stupid too write c compiler

So let's say i wan't to set a 3rd zero from the left to 1 to use instead of a bool, how do i set it and then read it in an IF ?

I finally derusted my Python(2) skills and wrote a tool for my custom surfaces which imports them, extrudes them, and outputs them into industry standard CAD.

gist.github.com/aphirst/e21ff1a5360ae3b8cdc93ec4914f8ecd

Think of an integer as an array of bool, by using binary operators we can treat it like one.
#define set(a,i) a|(1

Let's say we have a byte. A byte has 8 bits: 00000000
Now we can store information/a bool in every bit. We have option1 which is set on the first bit and option2 which is set on the second bit, etc.

If we want to set option 1 and option 3 then our byte looks like this: 00000101

You can manipulate individual bits with bitwise operations

#define get(a,i) a&(1

And what if i need more than 8 bits?

unsigned long or something
unsigned long long

A byte is an 8-bit integer. There are usually 8, 16, 32 and 64-bit integers.

Use a larger type. You have uint_8/16/32/64 so more than enough.

>more than 8 bits

Why would anyone ever need more than 8 bits?

It is for game development, isn't it?

Ok, huh... Can you dumb it down a bit please ? I'm new to programming.

Same here :\ I though they only could be applied to the objects which are members of the class and... thats pretty much it..

Isn't an instance method and a static method the same thing ?

Not even that desu. If you watch any cppcon videos of game developers, you can just FEEL that they fucking hate c++ and their code uses only the C subset.

Not everyone is an ambitionless loser who his contempt with scraps a true man always desires a bit more than an inferior beta cuck male

I have no idea what you just said but it sounds to me like the ramblings of a virgin

retardo

C++, as a whole, is awful for game development. Gamedevs use it as a glorified C with basic templates, namespaces and operator overloading for vectors.

ignore this guy because he is retarded

He's right. Modern game engines are now data oriented, no more object oriented.

Good. C with templates, namespaces and (sane, arithmetic only) operator overloading is the only valid way to write C++.

Im working on a java project and im still really new to this so im stuck

I have a class that has a variable called token (int).

I have to create multiple instances of said class and print out all the token values from each one.
I know I can just go into main and do a for loop but how can I make a method inside the class to take all of them and print their token values?

What the fuck indie blog post did you read that load of bullshit on?

hasklol:
kebabToSnake = map (\x -> if x == '-' then '_' else x)

It needs to be a static method. You need a static field which is a list of all the tokens. Every constructor should add the object to the static field.

Note that doing this will cause the garbage collector to no longer collect tokens.

woah, a sensible post, in my /dpt/??

youtube.com/watch?v=rX0ItVEVjHc

Data-oriented doesn't mean you're using C++ as C. Generally when it comes to video games it means you're using C++ to build the engine then feeding scripts (aka data) into a built-in interpreter to control aspects of the game logic.

would it just be easier to initialize each object inside of an arraylist instead of on their own

and then just use the getToken method on each one inside the arraylist?

not him but all the aaa engines are moving to data oriented because of multi threading and cache load optimization.

object oriented

entity1 = object{ life, origins, ...}
entity2 = object{ life, origins, ...}
entity3 = object{ life, origins, ...}
...

data oriented

life = array{enity1, entiti2, entity3, ...}
origins = array{enity1, entiti2, entity3, ...}
...

you are confusing data oriented with data-driven.

>just going off the title
Watch the video and he'll be dropping comments on how his indie game shop uses C++.

>keeping objects in an array means it's not object oriented

Confirmed retarded as fuck. That's also a microoptimization to improve cache usage applied in certain systems after profiling shows that optimization is needed. Guess what, you sacrifice abstractions for low level performance optimizations in every language when needed, it doesn't effect your overall design.

Hey, what program language should I learn if:
I use GNU/Linux
I took a Java basics class for high school
I like free software

There's no objects in data oriented design you retard. There's no virtual anything, no inheritance, no polymorphism, and most importantly no messages.

>I know I can just go into main and do a for loop
Why is this not sufficient?

Why do you want to learn it ?

So i can code myself a GF

To eventually get a job in the future, I'll probably learn more languages later so it doesn't necessarily need to be the best one for a workplace, just one as a starting point

this isn't me btw

im submitting it for my SE class (201) and we're taught not to have any methods inside main (as much as possible).

I ended up using an arraylist of the object and overwriting the toString to instead output the token number and it works great.

this isnt me btw

This is not a micro optimization at all. it has consequences on the whole architecture of your game engine. Data oriented allows modules to work independently. For example, the collision module only cares about the arrays holding all the positions and hitboxes. A data oriented engine would necessary rely on components.

The engine developer from naughty dog explains this well in his book (but he calls that object-centric view vs property-centric view)

Stop that.

Python is a good starting language.
It's used in FOSS. It's not difficult to find a job with it.
And there is plenty of IA modules to code your self a chatbot.

If you get the basics down you can implement ELIZA in maybe 40-150 lines of code (depending on the language). I believe in you user, you can do it!

Python is a terrible starting language. C is a much better start where one is forced to understand what they are doing.