[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

/dpt/ - Daily Programming Thread

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 342
Thread images: 33

File: Kakyusei_and_SP_Disk_1690.png (19KB, 480x288px) Image search: [Google]
Kakyusei_and_SP_Disk_1690.png
19KB, 480x288px
What are you working on, /g/?

Old thread: >>58618092
>>
>>58621095
First for D
>>
Fist for OOP.
>>
File: FPBP.png (136KB, 850x252px) Image search: [Google]
FPBP.png
136KB, 850x252px
What did he mean by this?
>>
>>58621108
they might be in Lisp but not in C. there should be a space in between if and the conditional.
>>
>>58621140
Why, will you not be able to tell that it's an if statement if people don't do this?
>>
>>58621134
first post bait post
>>
>>58621159
it's good style and practice.
>>
>>58621002
>>58621116
>Visual Basic Studio
There is no such thing. This, and other things you are saying are indicating a complete inability to follow basic instruction or read what's on your screen.

I'm not the anon you're responding to, but this post makes you either look extremely retarded, or shows that you are certainly trolling.

Unfortunately, Poe's Law doesn't allow any confirmation either way, and so we'll just have to call you a faggot and move on.

C# is a great language, Visual Studio is a great IDE, and Azure is a godsend for anyone who understands the value of not having to fuck with your own hardware. That being said, these are tools meant for productivity and ease-of-management in a business environment. I suppose I can understand how it can be a bit overwhelming for someone starting out.

I recommend this book posted here if you want to try again and pay attention to what you're doing: >>58619740

In reference to Mono:
http://www.mono-project.com/
http://www.monodevelop.com/
>>
>>58621095
Making a WoW bot for the lulz

Progress is slow because Windows IPC debugging a shit
>>
Hex > Binary > Decimal >>>>>>>>>>>>>>>> Octal
>>
>>58621233
>integer bases
>>
>>58621191
>Windows [...] a shit

Correct
>>
>>58621169
Is there a retard-friendly way to start learning Azure without paying?
>>
>>58621240
There's different kinds of bases?
Are you sure you're not just assuming these bases can't have radix points for whatever reason?
>>
>>58621280
https://en.wikipedia.org/wiki/Golden_ratio_base
>>
Javascript is the future
>>
>>58621292
got it.
>>
>>58621306
the future is bleak
>>
>>58621306
Web assembly will rekt all js babbies
>>
>>58621306
fp is the future
>>
File: 1484890619870.png (169KB, 310x325px) Image search: [Google]
1484890619870.png
169KB, 310x325px
>What are you working on, /g/?

Trying to decide if I should go back to school as an old fag to get my meme degree, or if I should fore go it and spend the next few months trying to be marketable enough to get a programming job.
>>
>>58621277
https://azure.microsoft.com/en-us/pricing/member-offers/vs-dev-essentials/

$25/month credit for a year, easily enough to play around and learn.

I do believe you will need to put a credit card on file, but it is impossible for a charge to actually occur unless you specifically tell it to go over that $25/month.

Free Azure training (there are good C# courses here, too): https://mva.microsoft.com/en-us/training-courses/microsoft-azure-fundamentals-8391

The biggest reason I love Azure, is that everything has .NET SDKs to manage functionality and pull information. For example, I can use (read: abuse) the Azure Data Factory ETL services with C# code locally on my machine, which means I don't have to dick around with the GUI and I can create datasets/pipelines programmatically based on my databases.

Unfortunately, I believe anyone here would have a hard time seeing Azure's value until they're really in the industry to some degree, and have live data and users to control and work with.
>>
>>58621095
Fuck you for using an anime image
>>
File: 1483096754173.jpg (277KB, 1058x1139px) Image search: [Google]
1483096754173.jpg
277KB, 1058x1139px
>>58621002 here

So what is the least shitty version of VBS, if I'm literally forced to suck Microsoft cock to code in C#?

Again, I'm an idiot. I just want something that will work, on not-great hardware running (ugh) Windows 10.
>>
>>58621385
Always go for the degree.
>>
First for a .NET life of corporate dreariness
>>
>>58621412
>VBS
What are you referring to here? Again, there is no such thing as "Visual Basic Studio".

>I just want something that will work, on not-great hardware running (ugh) Windows 10.
Visual Studio will be fine for this.

There isn't much resource overhead while running the application.

See >>58621169
>>
>>58621412
>Again, I'm an idiot.
You shouldn't be programming, then.
>>
File: 1484475414126.gif (2MB, 235x177px) Image search: [Google]
1484475414126.gif
2MB, 235x177px
>>58621169
>>58621412

>>Visual Basic Studio
>There is no such thing. This, and other things you are saying are indicating a complete inability to follow basic instruction or read what's on your screen.
I'm just getting the branding for all this shit mixed up. There WAS a thing called Visual Basic. Alright, it's called Visual Studio. Got it.

What is the least shitty, free version of VS? The last time I installed this, at anons recommendation, it was 8GB. Which seems pretty fucking huge.
>>
>>58621425

But I'm broke and practically 30. It's a lot harder to work up the morale when you're not 18.
>>
File: 1477593056129.jpg (12KB, 400x400px) Image search: [Google]
1477593056129.jpg
12KB, 400x400px
>>58621499
Are you a cute trap?
>>
>>58621499
>I'm broke
Question answered, nay?
>>
>>58621516
>practically 30
>cute trap
don't get your hopes high
>>
>>58621492
>There WAS a thing called Visual Basic. Alright, it's called Visual Studio.
No, Visual Basic is a programming language. There is still a thing called "Visual Basic", and it is a language that also works with .NET. You can use Visual Studio to develop in many different language, including Visual Basic (VB), C#, C++, C, F#, and others depending on plugins you want to install.

>What is the least shitty, free version of VS?
VS Community 2015:
https://go.microsoft.com/fwlink/?LinkId=691978&clcid=0x409

8GB includes many versions of .NET and their SDKs, as well as tools to develop other types of applications. With the new VS2017 release, they're cutting down on the filesize if you require less tools.

If you'd like to try the new VS2017 release-candidate, you can get it here:
https://www.visualstudio.com/vs/visual-studio-2017-rc/
>>
>>58621538
idc gimme da puss puss
>>
>>58621274
Honestly, I've grown to accept the WinAPI. It does what it's supposed to do and is well documented and feels sort of comfy. It's just that debugging it and using it without 5 layers of newer frameworks can be a real pain.
>>
WebAssembly is enabled by default in Chrome.

Wew.

https://www.chromestatus.com/feature/5453022515691520

Beginning of the end for JavaScript?
>>
A script to batch rename my pirated TV shows to a more human-readable format, fetching the episode names if not provided.
>>
>>58621516
I'm not going to take hormones and live in your jail-bed

>>58621524
I could be worse than broke if I take out loans.
>>
>>58621621
>I'm not going to take hormones and live in your jail-bed
Oh holy fuck I had forgotten about that picture, and now I remember that picture(s?).
>>
>>58621602
クライスト
I don't want an OS in my browser
>>
>>58621633
http://bellard.org/jslinux/
>>
>>58621621
>I could be worse
But wouldn't you rather be better by taking out a job?
>>
>>58621602
Why the fuck can I never find any example code for wasm
I just want to know what it looks like
>>
>>58621657
>But wouldn't you rather be better by taking out a job?

I'm not sure I understand what you're asking. I'm saying there's no guarantee of work after I graduate. My people skills are a little shitty, so I might just be permanently unemployable and it's hard as fuck to get ride of student loan debt unless you have a career.
>>
>>58621306
asm.js is the present. WASM is the future. JS is deprecated.
>>
>>58621602
>57
Need for it to trickle down to stable now.
>>
> tfw your language becomes unparseable with only a single token lookahead

feels shit desu
>>
>>58621621
Always go for the meme degree. That stupid piece of paper is a long term investment.
I know countless of freelancher that dropped out of school and jumped into the mobile bubble. Now they're stuck doing shitty projects because no company wants them.
>>
>>58621140
they aren't in lisp
> being so ignorant you don't know how while and if are implemented
> also not knowing that lisp generally has the same strictness semantics as C and therefore you can't implement while or if as functions
>>
>>58621836
>Now they're stuck doing shitty projects because no company wants them.

Yeah, I kinda where I'm stuck now which is why I wanted to go back. I just have this gut feeling that the tech bubble is going to pop again about the time I get out.
>>
I want to get the MD5sum of a chunk of flash memory going through it byte by byte but I keep getting a crash at runtime.
const unsigned char *partition_address = 0x0010000
unsigned int partition_length = 0x0100000;
unsigned char local_bin[16];

mbedtls_md5_context ctx;
mbedtls_md5_init( &ctx );
mbedtls_md5_starts( &ctx );
for (int i=0;i<partition_length;i++){
mbedtls_md5_update( &ctx, partition_address+i, 1);
}
mbedtls_md5_finish( &ctx, local_bin );
mbedtls_md5_free( &ctx );


Following the backtrace leads me to 274 of the MD5 lib I'm using but I just don't get what I'm doing wrong here.
void mbedtls_md5_update( mbedtls_md5_context *ctx, const unsigned char *input, size_t ilen ){
...
274 memcpy( (void *) (ctx->buffer + left), input, ilen );
...
}

Could someone point out how I'm being retarded?
>>
hey guys help a noob out in c#

assume i created a client class, a car class and an inspections class (pretty much only has a cost inside). the client class has a car array, and the car class has an inspections array.

i want to calculate total costs of inspections by client and in total. my main question is where do i put the functions and what needs to "enter" them.

i have this function in the client class
        public float CostsByClient()
{
float total = 0;
for (int i = 0; i < nCars; i++)
{
for (int j = 0; j < cars[i].totInspections; j++)
{
total += cars[i].inspections[j].cost;
}
}
return total;
}


now for calculating the total cost of all clients, i declared an array of clients on program.cs, like this:

        static public float TotalCost (Client[] clients)
{
float tot = 0;
for (int i = 0; i < clients.Length; i++)
{
if (clients[i] != null)
{
tot += clients[i].CostsByClient();
}
}
return tot;
}


why do i have to make it static? should i just put that code on program.cs and not make it into a function?
>>
>>58621886
The tech bubble as a whole won't pop anytime soon. There's too much going on.
I do think native app development will grind to a halt very soon. Most companies cannot/won't afford two code bases practically doing the same thing. You can already see companies moving to web based apps or using something like Xamarin. Which sucks, because that's where I'm in.
>>
>>58621940
This is in c btw.
>>
>>58621976
Because it doesn't change anything in the class internally.
>>
File: octave.png (276KB, 1920x1080px) Image search: [Google]
octave.png
276KB, 1920x1080px
i managed to finish all my numerical math problems with octave.
feels good!

but gotta say that the compatibility to matlab is pretty underwhelming.
still very nice to improve your math skills

/blog
>>
Larry Wall's top 5 languages are JS, Java, Haskell, C and a scripting language (Perl, Python, Ruby).
What does this list make you to think?
>>
>>58622106
He has shit taste.
>>
>>58622048
alright thanks, so im guessing its fine to set it as static and it should work.

another thing, i created a ListInfo method on my clients class that lists all their shit and it is also supposed to print their total inspection cost. so if i just do

Console.WriteLine("Total inspection cost: " + CostsByClient());


inside ListInfo would it be fine? both CostsByClient and ListInfo are in the clients class.
>>
>>58622106
The guy tries so hard to be diverse that he should move to Sweden.
>>
rate my nyaa.se torrent searcher script
https://github.com/w1c/etc/blob/master/nyaa
>>
>>58621677
I'll see if I can compile something. Not sure if there is an objdump-like tool or if it's string or what. I'll have to see for myself.
>>
>>58622106
>JS, Java, Python | Ruby | Perl
Is his idea that you should learn some shit languages and some good languages?
>>
>>58621597
winapi + wtl is pretty much all you need.
>>
Which ml language implementation should I choose if I want to
compile to android
easy ffi
no GIL
>>
>>58622106
That he should be gassed.
>>
>>58621677
https://github.com/WebAssembly/design/blob/master/TextFormat.md#linear-bytecode
>>
>>58622106
>top 5

It's "Top five that you should know about". Big difference.

https://www.youtube.com/watch?v=LR8fQiskYII
>>
>>58622153
I think his idea is you should know how to handle all instruments, so you could be put under different conditions and being able to drive out the situtaion successfully.

>>58622198
My bad, sorry.
>>
File: anal beads.png (12KB, 777x155px) Image search: [Google]
anal beads.png
12KB, 777x155px
>>58621976
>i want to calculate total costs of inspections by client and in total
You should be using LINQ for this, and it's very very easy.

Without seeing your class definitions, I'll assume it's something like this:
var costByClient = clients.Select(client => 
new
{
Client = client.Name,
TotalCost = client.Cars.SelectMany(car => car.Inspections.Select(i => i.Cost)).Sum()
});

var totalCost = costByClient.Select(x => x.TotalCost).Sum();

costByClient
.ToList()
.ForEach(x => WriteLine($"Total for {x.Client} is {x.TotalCost}"));

WriteLine("Total cost is " + totalCost);



Here's my classes:
class Client
{
public string Name{ get; set; }
public List<Car> Cars { get; set; }
}
class Car
{
public string Color { get; set; }
public List<Inspection> Inspections { get; set; }
}
class Inspection
{
public double Cost { get; set; }
}
>>
>>58622263
Also, let's all pretend I used
decimal 
instead of double there, because we all know that you should always use decimal for money.
>>
>>58622304
but think of the pennies we can siphon off, man
>>
>>58622122
Yeah it should work just fine.
>>
thoughts on Kotlin?
>>
CPP

How do I get this map of functions to work in a loop, executing each one)?

std::map<std::string, std::string(CommandHelp::*)()> helpTexts;


helpTexts[CommandName::ABILITY]        = &CommandHelp::Ability;
helpTexts[CommandName::BUILD] = &CommandHelp::Build


msg = (commandHelp.*this->helpTexts[arguments])();
>>
>>58622344

Literally who?
>>
>>58622344
>100% interoperable with Java™
saved my self the trouble.
>>
>>58622324
ty
>>58622263
thats kinda cool, i really should get started on learning linq, thanks anon.
>>
>>58622344
if Scala is Java in 15 years, Kotlin is Java in 5.
desu Ceylon has a lot more interesting and 'new' ideas in it, but Kotlin is much safer to migrate to.
>>
>>58622344
Java sprinkled with memes.
>>
>>58622320

>theoretical product costs 30 cents, or 0.3 dollars
>price stored as 0.3
>insert 3 dimes (0.1 each)
>machine tries to pay out an infinitesimal amount of cash as change
>>
>>58622354
What do you mean?
>>
>>58621940
Maybe it's a library bug. Try increasing the chunk size to 4 or 8 and see if it works.

Otherwise I don't know. Maybe something wrong with your offsets?
>>
>>58622010
no shit
>>
>>58622429
>program machine to wire off that small amount of change into a swiss bank account
>become rich

It's like you hate money :^)
>>
>>58622429
>what is an office space reference

also your scenario wouldn't exactly happen with doubles, you'll get 0.999~=1.0 (or the dual of it) more likely than trending towards infinity like some zeta function

but yes, decimals should always be used when it comes to figures that _need_ to balance correctly (i.e money or # of pictures of your waifu)
>>
File: IMG_5947.jpg (83KB, 1280x720px) Image search: [Google]
IMG_5947.jpg
83KB, 1280x720px
>>58621606
Where are you getting your episode names from? Was planning to do this myself sometime.
>>
In my MVC project (PHP), I have a BookController. I need to be able to display the following:
1. a user specified card
2. all cards within a category (thriller, romance, etc)
3. all cards

Do I implement a different action method within BookController for every action, or do I create a single action 'View' which performs some logic and then update the model accordingly?
>>
Java is pure.
>>
>>58622548
Pure shit
>>
>>58622516
or hackers, or superman III
>>
>>58622557
doesnt matter as long as it is pure
>>
>>58622569
>pure
java gets CRUSHED every night
>>
>>58622569
>thank_you_master.jpg
>>
I just finished Ashita no Joe 2

I cried
>>
File: d20-icon-5.png (9KB, 316x316px) Image search: [Google]
d20-icon-5.png
9KB, 316x316px
Trying to decide what I want my first solo project to be. Always have done projects for school but never on my own. I'm thinking a text based RPG in C++, mainly because I'm not familiar enough with the language as I was python or the web languages. Thoughts?
>>
>>58622675
Be a man and do it in C!
>>
>>58622675
maze generator with ai
>>
>>58621095
What's this image from? It is cool
>>
>>58622675
Write the game script first of all.
>>
>>58621499
It is pretty hard to work up the morale to become employable through self-teaching. It might be a good idea to become a webdev codemonkey and then use that job to fund parttime college.

A degree in computer engineering is the best option though.
>>
>>58622715
https://pragprog.com/book/jbmaze/mazes-for-programmers
>>
>What are you working on, /g/?
website
>>
>>58622745
>parttime

I really don't want to be possibly over 35 when I graduate.

>computer engineering

I have no interest in developing hardware, and I already know more than enough about hardware to work on software. Is there any other reason to do that over CS?
>>
#include <string>
#include <map>

struct cmd_help
{
std::string
ability()
{}

std::string
build()
{}
};

int
main()
{
auto texts = std::map<std::string, std::string(cmd_help::*)()>{};
texts["ability"] = &cmd_help::ability;
texts["build"] = &cmd_help::build;

auto cmd = cmd_help{};

for (const auto& text: texts) {
(cmd.*text.second)();
}

return 0;
}
>>
File: 1384055602310.jpg (103KB, 979x1191px) Image search: [Google]
1384055602310.jpg
103KB, 979x1191px
I'm doing an assignment in MIPS, but I have just about zero knowledge of the language so I'm using a reference sheet to hold my hand. I got it to read in the values, store them, and subtract B from A, but my answer always comes out negative. Why is this?
>>
>>58623023
Ops, forgot to mention >>58622354.
>>
>>58623024
I hate to ask this, but are you sure your operand order is correct?
>>
>>58623024
MIPS is made up of nand gates. Therefore, remember to invert your output before printing.
>>
>>58623127
>remember to invert your output before printing
I do not know what this means.
>>
File: commstruction.png (20KB, 1262x266px) Image search: [Google]
commstruction.png
20KB, 1262x266px
Hey fellas, I'm getting into programming and using the Feynman Technique to learn some of the more basic concepts. With that said I have one question:

Is there a difference between a "command" and an "instruction"?

The finnish course I'm going through (pic related) labels them commands but browsing wikipedia seems to indicate they're called instructions.

In essence I'm trying to figure out how to properly label what the pic's definition is referring to.
>>
Quick I need idea for my bachelors thesis.
>>
Is it possible to emulate 2 android phones that are in close proximity of each other in android studio?
>>
>>58623145
in this case no, they're the same
>>
>>58623146
write a to-do app
>>
>>58623176
For university not coding bootcamp.
>>
>>58623169
Any common situations I should know about where they could be differentiated?
>>
>>58623064
I messed around and found the winning order of operands, so thank you for bringing this to my attention. Shit got a little confusing when I started moving values to different addresses.
>>
>>58623199
not really
i'd say 'command' implies something more personal or at least high level than 'instruction', but that's really just a word game

neither command nor instruction are really technical words, they pretty much mean what they say
>>
>>58623199

Not him, but they are used interchangeably for some things. I've noticed command used more for more higher-level stuff, instructions for lower level. It would be odd to hear someone call what you first posted an instruction. Similarly, low level machine code is almost always an instruction, not a command.

That's more an idiom than definition, though.
>>
>>58623230
>>58623241
Thanks anons!
>>
>>58623196
What's the difference?
>>
File: 1428171156305.png (262KB, 1996x1572px) Image search: [Google]
1428171156305.png
262KB, 1996x1572px
>>58623023
>>58623038

thanks!
>>
>>58623127
Kek
>>
>>58623145
technically thats a method

(you'll hear method, function and procedure more than command and instruction when you're working at that abstract level. depending on the age of the material you might also hear routine, subroutine, subprogram. at that abstract level, command generally will refer to a command-pattern (but we're going into OOP design patterns here (by being pedantic)). )

but for method, functions and procedures:
methods are usually 'actions' done on things (using `println` on the 'in' object)
functions are generally not tied to an existing object (ex:
int sum(a,b) { return a+b; }
)
and procedures are usually things that mutate state and don't return values
>>
>>58623292
and because I forgot to add in a conclusion:
it doesn't really matter. a C guy will call everything a function, a Java guy will almost always say method in formal language and probably function because of how ubiquitous it is. while a ada/pascla guy will use procedures/subprograms

these terms are generally associated with the programming paradigm you're using. procedural -> procedural and function. object-oriented -> methods because they are function thats use a receiver to determine how to dispatch the message
>>
File: browser_.webm (3MB, 1920x1080px) Image search: [Google]
browser_.webm
3MB, 1920x1080px
>>
>>58623351
C - procedure
Haskell - function
>>
>>58623424
C - Subroutine
>>
File: 2017-01-23-223117_755x299_scrot.png (23KB, 755x299px) Image search: [Google]
2017-01-23-223117_755x299_scrot.png
23KB, 755x299px
I work on this shit
>>
>>58623424
>>58623459
>>58623292
subprogram you fucking inbreds
>>
>>58623467
What fucking language uses the word subprogram?
>>
File: Instruction1.png (3KB, 506x24px) Image search: [Google]
Instruction1.png
3KB, 506x24px
>>58623169
>>58623230
>>58623241
>>58623292
>>58623351

Is this accurate?
>>
>>58623492
fine
LABEL
if your gonna be pedantitic
>>
File: instruction.png (18KB, 587x243px) Image search: [Google]
instruction.png
18KB, 587x243px
>>58623504
yes
>>
>>58622456
Library is from a ARM mbed TLS: https://github.com/ARMmbed/mbedtls/blob/master/library/md5.c

So it should be fine. I'm just completely at a loss.
>>
give me basic assignment to do in C++
>>
>>58623574
chip8 emulator
>>
>>58623463
thats pretty neat. do you handle smoothing if you had like, say, a -6 in a sea of 1s? or will it look like a very steep hole?

also, source?
>>
>>58623504
Better said would be "A program is a set of instructions that tell the computer what to do." The program isn't what does it. Probably picky, but you're triggering my autism.
>>
>>58623574
a basic music/video player.
a basic gif/webm viewer.

project euler
>>
>>58623593
more like its 'a set of coded instructions' (unless you're writing machine code. otherwise you'll be using mnemonic decoding)
>>
>>58623574
Encryption program
>>
>>58623146
>bachelor's thesis
What? Are you at an Ivy League or a time traveler from 1964?
>>
>>58623593
If you had to describe what an instruction (in this compsci sense) is to a 5th grader in one sentence, what would it say?
>>
>>58623634

i'll give you ROT13 encryption.
its the best I can do
>>
>>58623650
Just slap a xor on it and it'll already be better
>>
>>58623639
A string of numbers that describe how a computer is to perform a single step of a complex program. Adding two numbers is an example of a common instruction available on a processor.
>>
>>58621119
what IS oop?

inb4 artificial college example
>>
>>58623639
"an instruction"
>>
File: 1469360145535.png (226KB, 450x450px) Image search: [Google]
1469360145535.png
226KB, 450x450px
>My kernel has 3 separate and unrelated printing facilities
>printk - C++ streams oriented, deprecated
>kprintf - C style printf oriented, deprecated
>kprint - printf style polymorphic function object with additional functionality, current

I can't seem to make up my mind and stick to it, and my kernel uses all 3.
>>
>>58623639
..an instruction
like when you're taking a test and the teacher (aka, the instructor) tells you to read the instructions before beginning. its a set of orders/rules/commands to follow during the event

the window needs to be cleaned. we have bob here.
>you should get the bucket
>you should fill the bucket with water and soap
>you should take the bucket to the windows
>you should clean windows by scrubbing them from top to bottom
>repeat this for each window.

thus an example of a program for bob cleaning the windows.
>>
>>58623639

instruction: a step in what I want the computer to do in the end.
>>
>>58623696
It's not like anybody uses your shit, just write a regex to eliminate the first two.
>>
>>58623696
does your print do fprint and sprint?
if not, you need more. there's like 8 in linux :)
>>
>>58623635
I had one
>>
>>58623726
You mean kprint? it's polymorphic. So you just subclass it's baseclass and override it's putChar if you want the chars to go somewhere else.
I'll create the variants when the need arises.
>>
File: 2017-01-23-225509_797x597_scrot.png (101KB, 797x597px) Image search: [Google]
2017-01-23-225509_797x597_scrot.png
101KB, 797x597px
>>58623588
Yes it works with negative number it also works with colors.
Sorry for source, it's a school project and my fucking name/mail is on all my files.
>>
>>58623739
Well both CS and EE here have Senior Design projects. It's less about theory and more about building a practical design. The EE is 3 semesters long and the CS is 1 semester long.

This is what my team is doing.
http://www.robonation.org/competition/roboboat
>>
File: Instruction6.png (4KB, 699x18px) Image search: [Google]
Instruction6.png
4KB, 699x18px
Instruction bros

Is this better?
>>
>>58623832
All engineering has that, some do both.
>>
File: 1485164940116.gif (4MB, 422x418px) Image search: [Google]
1485164940116.gif
4MB, 422x418px
>>58623840
>>
>>58623840
sure, but why distinguish between a computer and a person? people have free will and ca choose not to obey (your) authority. a computer can and will only do what its told to do.

(why not just define instruction (or use a simpler word like order?)?)
ex: "An instruction is an order a computer must follow."
>>
>>58623902
cuck
>>
>>58623891
Well we have to do a design paper. Don't think that it's comparable. It's a glorified design review, which usually means it's like 150+ pages. Have to write it this semester. Not looking forward to it.
>>
>>58623930
That's not too bad actually. I'm clocking out on my lessons for the day but I'll refine these definitions in the future
>>
>>58623930
>must follow

I'd use the word "execute" as that has more meaning in the field, but also works in plain English.

English: carry out or put into effect (a plan, order, or course of action).
CS: carry out an instruction or program.
>>
>>58624004
there is literally nothing CS about any of these words, you can get by perfectly well with the proper English definition
>>
>>58623978
and in most programming languages you don't write/use instructions directly. instead you use logic and your compiler/interpreter turns it into instructions for the computer. only "close to the metal" languages like assembler use instructions (and directly writing machine code (which is the literal instructions the processor understands))

an analogy--
logic is to instructions like formula are to algorithms.
former is an abstract sequence of how to do it, the later is a sequence of what to do
>>
>>58623930
>An instruction is an order a computer must follow.
This implies that there are orders that computers can choose to follow.
>>
how do i make netbeans more aesthetic this thing looks like shit
>>
what sounds better

>it was a 3-month contract
or
>I wrote a script that did 75% of my job for me four times faster than a human employee
>>
>>58624055
how does it do it? the context is that only instructions exist, no other forms of orders. (context was elided because we were discussing a single line in the middle of a paragraph)
>>
>>58624073
I get the feeling there is an option 3 if this is going on a resume.

"Developed tools that increased efficiency by 400%" or something.
>>
File: 1445814580280.gif (2MB, 320x240px) Image search: [Google]
1445814580280.gif
2MB, 320x240px
>>58624077
>>58624055

I'm starting to think that programming has ruined our brains with years of bug hunting and now we feel compelled to scrutinize tediously over (in this case mostly useless) minutiae.
>>
>>58624178
Do you "issue orders" to your calculator?
Why would you "issue orders" to a computer, which is just a really elaborate calculator?
>>
>>58624200
Actually, a calculator is just a primitive computer.
>>
0-4 program
5-8 squats
9- reread sicp
>>
>>58624217
Chads get out
>>
>>58624229
i'm actually a trap
>>
>>58624200
Yes, you do
>>
>>58624242
i bet you don't even have programming socks
>>
>>58624200
you don't shout at your calculator? you must've been boring in class.

but with calculators, you're still using abstracted logic from the processor. even in RPN calculators you're still removed from doing this for a simple addition/sum of 2 numbers:
(lets go with a mos 8502 'cause thats whats used in the latest hp 35s)
#8500 21 00 80
#8503 7e
#8504 23
#8505 66
#8506 32 03 80
#5809 76
; input =>
#8000 26
#8001 62
; result =>
#8003 88

instead you do + 38 98 and you get 138 on the stack
>>
>>58621334
When? In the year 2117? Even asm.js still depends on javascript to run.

>>58621723
How the hell do you even use asm.js? You use something like emscripten that gives tou 5MB of javascript for a single line of code print statement?
>>
>>58624294
>something like emscripten that gives tou 5MB of javascript for a single line of code print statement?
But that's literally not true.
>>
we need a javascript virtual machine
>>
>>58624290
shit, 136. fat fingered
>>
>>58624315
i think you've confused need with not want
>>
>>58624294
Basically, you have to compile all of your libraries through the emcc compiler which is a clang frontend, and that opens up a whole world of problems.

It's also not worth it at all unless you're writing games because there's absolutely no way to manipulate the DOM through asm.js or webassembly.
>>
>>58624315
No we don't
>>
>>58624294
>asm.js

asm.js is not wasm. asm.js is sort of proto wasm implemented in js, but it will be phased out in favor of wasm, a true binary solution to the same problem.
>>
>>58624315
No, wasm is essentially a virtual machine. What we need to do is strip js out of the browser and just run it on top of wasm. That way we can finally rid ourselves of netscape's sin.
>>
>>58624350
PSA: Your post is full of shit, you have no idea what you're talking about
>>
>>58623151
no one?
>>
>>58624386
What is wrong about it?
>>
>>58624350
even WASM itself says it's not replacing or altering javascript....

Also the whole point of web assembly is that it's not a virtual machine for speed. It's sandboxed native code.
>>
>>58624423
>even WASM itself says it's not replacing or altering javascript....
Is there anything wasm can't do that js can do?
>>
>>58624442
Yes. Be included in every currently deployed web browser.
>>
WASM will lead to nefarious shit like DRM in web pages to prevent content scraping, enforce ads and embedded bitcoin miners "to support the site :)".

Blocking WASM code will become the new adblocking.
>>
>>58621385
Go for the CS degree desu. Look for scholarships, shit I think you can even still join the military and they will pay for it. I am not saying you can't learn this shit on your own, but a real teachers help a shit ton, along with other benefits and connections made in engineering schools.
>>
>>58624407
1) WASM isn't a VM, it's a language intended to be distributed in a binary format, that will be run on existing Javascript VMs (e.g. Turbofan/V8, SpiderMonkey)
2) JS can already run outside of the browser, see Node.js et al.
3) Running JS on top of WASM makes no sense, they target the same VM, it doesn't mean anything to have one running on top of the other.
4) Javascript is not going away.
>>
>>58624451
Obviously, but that's a temporary advantage. If js has no other advantages then it will hopefully be replaced over time.
>>
>>58624423
>even WASM itself says it's not replacing or altering javascript....

I didn't claim it aiming to replace it. That's why I said "should", not "are", you illiterate mong.

>Also the whole point of web assembly is that it's not a virtual machine for speed.

Who said anything about speed?

> It's sandboxed native code.

Exactly. You run the javascript interpreter in that sand box. The only reason to do this is for legacy compatibility.
>>
>>58624423
well, technically one of the goals is to be faster at certain things than javascript.

it'll be faster to load data (faster parsing) and have more efficient memory profiles (efficient use of the stack machine).

the safety/sandbox stuff is mostly what was worked on in PNaCL

>>58624480
this
>>
>>58624331
>there's absolutely no way to manipulate the DOM through asm.js or webassembly
Bullshit https://github.com/tcr/rust-webplatform
>>
>>58624480
>WASM isn't a VM

wasm is the instruction set for a virtual machine. So no, not technically, but you should know what I mean.

>2) JS can already run outside of the browser, see Node.js et al.

So? Not important here.

>3) Running JS on top of WASM makes no sense, they target the same VM, it doesn't mean anything to have one running on top of the other.

It means you can remove the code from the browser's codebase and just include it as a dependency as you could with any language going forward.


You think so small.
>>
>>58624483
It has existing libraries and extensive frameworks. It's also over 20 years old and is well supported and stable.

Javascript used for doing simple things and not heavy lifting is great because it's fast to test and deploy. For code that needs CPU cycles I imagine you just create a WASM module and call it in javascript so you don't have to scrap your libraries, workflow, or codebase.
>>
>>58624534
>wasm is the instruction set for a virtual machine. So no, not technically, but you should know what I mean.
It's a bit more than that, but roughly, yes.

>So? Not important here.
>It means you can remove the code from the browser's codebase and just include it as a dependency as you could with any language going forward.

I don't think you understand how wrong you are, there's no point trying to talk to you.

>You think so small.
You make too many assumptions, and then you say a lot of crap without knowing what you're talking about.

For example, you don't know me, and very little of what you say about WASM makes any sense.
>>
>>58624576
>I don't think you understand how wrong you are, there's no point trying to talk to you.

You can include a C runtime and it runs. You can include a Lua runtime and it runs. What would make javascript any different?


>there's no point trying to talk to you.

"I'm gonna take my ball and go home"

>You make too many assumptions

Pot calling the kettle black


>very little of what you say about WASM makes any sense.

And yet you can't actually point those things out. Odd.
>>
>>58624534
wasm is slated to run outside of the browser too

as for removing code from, say, firefox. do you know how the interface works in firefox? the entire frontend uses javascript and xul now. redoing all of that, plus removing ionmonkey, and then rewriting odinmonkey (the optimization module that interfaces ionmonkey to asm.js and soon wasm) then porting ionmonkey back to wasm then making wasm work correctly with e10s (mainly with the chrome part).. yeah np. lets just remove javascript.

perhaps if servo doesn't fit well within firefox, a new browser could be design to use wasm as the interaction agent but it'd probably not happen in firefox. mozilla has bigger issues with maintaining their multi-decade, multi-standard old C++ then dealing with some reactionists who hate javascript because reasons.

unrelated, Eichs dream of Lisp in the browser is partially coming true though. :)
feels so good that they are using s-expr for the IR. shame its not m-expr though.
>>
>>58624666
>as for removing code from, say, firefox. do you know how the interface works in firefox? the entire frontend uses javascript and xul now. redoing all of that, plus removing ionmonkey, and then rewriting odinmonkey (the optimization module that interfaces ionmonkey to asm.js and soon wasm) then porting ionmonkey back to wasm then making wasm work correctly with e10s (mainly with the chrome part).. yeah np. lets just remove javascript.

I'm talking in the abstract, not firefox, a specific implementation. Up until now there was no way to make a browser without javascript tied clear to the core, even if you made it from scratch, as too much of the web needs it. But if wasm gets adopted you could.


See, this is what I mean when I say small-minded. It's as if you have no idea what theoretical means.
>>
Is nightcore good music for programming to?
>>
>>58624831
There's no objective answer, it depends on what kind of person you are.

                                                                                                                                                And you're probably an insecure faggot weeb if you listen to nightcore
>>
>>58624666
>servo
Begone, SJW shill
>>
>>58624849
I'm happily married with kids, and I don't have any particular fancy for Japanese culture beyond their cars being reliable.
>>
>>58624865
They aren't, you need to buy German cars and get a better tastes in music
>>
File: das auto.gif (3MB, 360x360px) Image search: [Google]
das auto.gif
3MB, 360x360px
>>58624873
>2011+6
>still falling for le german engineering meme
>>
>>58624873
Let me guess, I should listen to whatever garbage MTV is playing?

German cars are kinda meh.
>>
>>58624741
yet, to go from being small minded to large? minded you need to slowly progress.

I was pointing out roadblocks in the progression. It has seemed that you have an idea where the exit for the highway is, but nothing about the highway.

And "javascript tied to the core"? Javascript isn't coupled with the "core" of Firefox (the core of Gecko to be more exact). It was during the first releases of SpiderMonkey. By the time TraceMonkey and JaegerMonkey and now IonMonkey has came around they use IPC for communicating with the VMs. They had been isolated from the "core" years ago when they started to add in sandboxing and the redesign of the VMs to compete with Chrome's V8 (Crankshaft, not the Strongtalk-based V8). Infact, since SpiderMonkey you can build it outside of Gecko (for using it in a node.js-like environment.). But yes, *Monkey is tied to XUL and XPCOM, but those aren't the "core" of the browser.

(I don't really know the internals of Chrome -- only Firefox)

>>58624856
who said I was shilling for Rust? it seems like you got triggered. do you need to start a hugbox, snowflake? I was pointing out Mozilla's current projects regarding their browsers, thats all.
>>
>>58624917
If I learn Rust will I become an SJW?
>>
>>58624942
you'll become a shit programmer
>>
>>58624917
>who said I was shilling for Rust?
The #1 reason people talk about it is to increase awareness of it. The people doing this are SJWs looking for leverage to use for political gain among programmers.

The #2 reason people talk about it is to tear it apart for being worthless and unusable. Anyone who actually tries it will do this.

It is safe to assume that anyone talking about it without doing a #2 is instead doing a #1.
>>
>>58624977
Isn't that the same thing?

I guess not, I guess all SJWs are shit programmers, but not all shit programmers are SJWs

>>58624990
Couldn't we fork Rust to improve it in both aspects?
>>
>>58625010
What would be the point? It doesn't add anything we're missing.
>>
@58624990
(You)
>>
>>58625019
I think we need a better C++, and that seemed to be what Rust was aiming to be. C++ can't ever remove major features because of its need to remain backwards compatible.
>>
SJW has nothing to do with the qualities of the Rust language

there's no bullshit in CS
>>
>>58624917
>seriously arguing over the meaning of the word core

I meant it was not possible to remove because it is a required piece. That's pretty "core".

I don't frankly give a fuck about how firefox is put together internally. It matters not one fucking wink to my original rant, as again, this is an abstract idea, not "how to do this in firefox in a practical way". I said we "should" do it In the same way you say "We should invade Canada" or "we should gas all the jews". But you had to go full sperglord on me by thinking this the mailing list for firefox. Well here's a news flash it's a god damn chan.

Good lord, you are such an insufferable, faggot.

>(I don't really know the internals of Chrome -- only Firefox)

What is it with that community that breads people like you? It's like cult where they worship autism.
>>
>>58625048
C++ will always be the best C++.
>>
File: breading.jpg (208KB, 1000x667px) Image search: [Google]
breading.jpg
208KB, 1000x667px
>>58625058
>What is it with that community that breads people like you?
>breads
>>
File: 1484576314915.jpg (48KB, 616x600px) Image search: [Google]
1484576314915.jpg
48KB, 616x600px
Do you also feel that there's a conspiracy aimed at destroying certain languages before they have a chance to take off? Like Julia, Rust, etc.

Like something happens to the lead devs, they get hired elsewhere or suddenly become disinterested. Or the whole project is targeted, being discredited by online trolls.

It's very suspicious.
>>
>>58625094
It's a good thing in many cases, anon. Most new languages don't bring anything worthwhile to the table.

Take Rust as an example. No support for HKTs, and there probably never will be. Why? There's no good reason for them not to have designed them in from the start, but they didn't, so it's just another useless language with many man-hours poured into it.
>>
>>58625094
You need therapy
>>
>>58625094
There is no conspiracy. These languages are actually garbage. Competent developers can see through the lies of the corporate interests that shill them everywhere.
>>
File: s4dTtBy.jpg (86KB, 384x313px) Image search: [Google]
s4dTtBy.jpg
86KB, 384x313px
>>58625091
That's what you get when I can't be arsed to proof-read my rants.
>>
>>58624942
no, you'll become an SJW if you want to crusade for social contracts for people whom you view as inferior and can't stand up for themselves. the downtrodden are specifics, but SJWs group entire categories into their authoritarian fantasies.

(rust = sjw because they have ruby fags, a code of conduct and their PR guy is the stereotypical internet SJW. but this applies to many languages 'cause of their power grab to get their CoCs in everyone's mouth)

>>58624990
why not just use facts? all reals no feels here. mozilla is putting a lot of time into rust, and specifically servo 'cause they believe in dogfooding. they've already replaced some of their shittily written C++ libraries with them in Rust. so, pointing out that one of the open-ended goals is to get Servo push people into refactoring Gecko into many small specific parts, instead of one massive thing.

this has actually started to work 'cause Quantum has been accepted and is coming on nicely. (although Quantum will be written in Rust -- Quantum is a renderer, a compositor, a css engine, a dom engine that is 'massively parallel' and everything is GPU accelerated.

w/r/t: #1 and #2.
#1 what they (firefox) are doing is interesting and finally they are cleaning up those many years of technical debt. maybe we'll finally have a firefox without memory leaks. but if you view SJWs as a threat, I can see shunning and FUDing anything from Mozilla (and Google, and any other big tech company)

#2 servo is just a test bed, not meant to actually be a replacement.

>>58625058
if you can't handle criticism and deem any critic an insufferable faggot, then you should probably stop being such an insufferable faggot. I agree with you on the noble idea of using wasm as a universal VM -- but you should know the technical problems in making that happen.

re firefox v chrome: both of these browsers are an order of magnitude more lines of code than the linux kernel. (I'm not "pro" firefox, but I am anti-chrome / botnet)
>>
>>58625094
I wanted to like Rust, but they just keep doing stupid shit. The feature creep is going to make C++ look sane.
>>
>>58625094
no conspiracy here
>>
>>58625189
I wouldn't mind feature creep if it were good features, like many GHC extensions are, but it isn't.
>>
>>58625094
I see no problems with Julia, anon.
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     I don't see Julia at all, though.
>>
>>58625180
So: fork Rust, remove the CoC, tell the SJWs to go jump in a lake?
>>
>>58625189
C++ has fatal design flaws. STL should be uniformly rewritten from scratch, there's no other option.
>>
>>58625094
rust's lead dev left because his pet language was getting subverted into something that had the aim of being practical. not an experiment in lattice-like structures for maintaining ownership graphs and semantics.

it stopped being a fun project for Graydon Hoare to explore discrete and computational mathematics, and more of a manager role in helping shape the language for real-world use.

the sjw's came on about 9 months after he stepped down (which was already a year+ after he basically stopped working on the language)
>>
>>58625237
C++ should remove old language (mis)features. Nailing more and more legs onto a dog still won't make it a functional octopus.
>>
>>58625180
>re firefox v chrome: both of these browsers are an order of magnitude more lines of code than the linux kernel. (I'm not "pro" firefox, but I am anti-chrome / botnet)

Again you're arguing from practicality like a total autist. The only argument you're winning is one for euthanasia of the retarded.
>>
>>58625122
>there probably never will be
I'm not so sure about this, but it will still be a while. Though I agree they should have been in from day one, there's really no excuse. The designers are obviously pretty well versed in type theory from their adaptation of linear types for RAII and regions for borrowing.
>>
>>58625180
Actually, Chrome, Firefox and Linux are all 15-20M lines of code.
>>
>>58625231
Careful. He'll argue with you for 30 minutes about why that's not feasible in practice.
>>
>>58625272
how is that even arguing? should I tell you how presto works? I'm just giving you facts. you seem to take offense at anyone questioning your ideas. or do you just enjoy using chrome?

I do know quite a bit about v8 up until the strongtalk/hotspot/sun guys left to work on go and dart. but I can't go into detail how it integrates with chromium. so if you're interested in the process of making javascript dogshit slow to being rather fast I can detail that.

>>58625330
oh, I haven't ran cloc on the kernel since before 3.11 for workgroups. but for chrome, that # doesn't include chromium os (which technically is under the umbrella ..so I guess I was artificiality inflating the number) and all the support libraries around chrome (and the like 1500+ projects).

at any rate they are massive projects

>>58625331
you must be truly autistic if you can't recognize a discussion over an argument. or a woman
>>
>>58621095

In Java, can you have queues (and other data structures with generics) with different sub-classes?

e.g. You have the Token class with the sub-classes
Operator
and Number. There is a
 queue<T extends Token>tokens
. Can you add
Operator
and Number objects to tokens, or can you only add Token objects?
>>
>>58625431
You can add an instance of any subclass of Token to a Queue<Token>. <T extends U> is something different, and it restricts what types can be used for the generic parameter (so that methods of U can be called on objects of T even though you don't know what T is exactly).
>>
>>58625422
I assumed you were adding lines of code facts to say that making a browser is impractical.

>you seem to take offense at anyone questioning your ideas.

You realize that I'm only bitching at you, right? It's not even that you, as you put it "questioning my ideas" (questioning usually involves questions for the record), it's just the way you think. I don't like you as a person.

>>58625422
>Argument
>noun
>a reason or set of reasons given with the aim of persuading others that an action or idea is right or wrong.

Dumb ass.
>>
>>58625465

Hmm, that make sense, although Eclipse is still freaking out about, asking if I want to typecast it.
>>
>>58625578
Post code.
>>
>>58625578
>>58625595
To be more clear about <T extends U> that's part of the generic class/method definition. Not when it's being used.

For example, if you made a class Foo<T extends Token>, you could have a Foo<Operator> and a Foo<Number> but not a Foo<Object>.
>>
How do i do this /g/, i want to press a Button and after click to change the background and after second click to change to default. My method works, i click and unclick a button correctly, but if i want to click another button i have to do it 2 times, to set the correct bool

wat do

        bool isPressed = true;

private void ButtonClick(object sender, RoutedEventArgs e)
{
Button _btn = sender as Button;
if (isPressed )
{
_btn.Background = Brushes.Aqua;
txtBox.Focus();
isPressed = false;
}
else
{
_btn.ClearValue(Button.BackgroundProperty);
txtBox.Focus();
isPressed = true;
}
>>
>>58625595

I'm just writing the code now, so it's really unfinished. I've removed the part that I don think are relevant.

public class Tokenizer<Token> {

...

public Queue<Token> tokenize(String exp) {
Queue<Token> tokens = new LinkedList<Token>();
int index = 0;

while (index < exp.length()) {
if (isDigit(exp.charAt(index))) {
int lastDigit = index;

// Stuff that will increment lastDigit.

NumericToken nextNumb = new NumericToken(exp.substring(index, lastDigit), mode);

tokens.add(nextNumb);
}
>>
Business Idea: Never use antiquated 3-part for loops again!
>>
>>58625679
>public class Tokenizer<Token>
You have a class called Token and a generic parameter called Token. The parameter probably shadows the class, and because it's unrestricted there's no guarantee that a NumericToken is a Token (replace Token with T in your code to see what I mean).
>>
>>58625739
wrong thread lad
>>
>>58625745

Yeah, it seems to work. Thanks.
>>
>>58625739
>>58625766
all me
>>
I'm good at multiple languages including c++ but I still don't know what the fuck an iterator is
>>
>>58625801
it's a thing that walks through a linear data structure for you

you're not good at c++ if you don't know this
>>
>>58625801
"good at"
>>
>>58625801
>I'm good at multiple languages including c++ but I still don't know what the fuck an iterator is

An object that can iterate over an collection of items, I think. Like a foreach loop, but with some more complication, I'm guessing. I'm not too clear on them myself.
>>
>>58625818

I understand how to increment a pointer sizeof(x) times
>>
>>58625636
Help please, i know there is some shortcut for this that only people that studied real university know about
>>
>>58625870
> sizeof(x) times

an int is ~4 bytes nigga
>>
>rust
>/pol/acks are crying because of code of conducts
yet again, SHAN'T
while the rust coc is a bit baroque and heavy handed compared to my second favourite coc, the python/psf coc (first being none at all ofc) it doesn't stop me using the language and i've only ever had good interactions with the rust community and #rust-beginners. that said, don't act like a bellend and you'll be fine.
the anti-mozilla trope on this board is out of control and has transcended logic and reason. the new mozilla logo was immediately branded as "SJW" even though it was literally just a new fucking logo design. FUD like
>mozilla wants to rid the web of white males
>mozilla wouldn't hire you because you're a white male
is commonplace and absolutely stupid shit like >sjw mozilla want to point out the localisation of the internet
jfc
>>
>>58625801
Think of a for loop. You've got the initialization, the condition, and the so-called "afterthought".
for (int i = 0; i < n; i++) {
cout << a[i] << endl;
}

Iterators abstract this. The initialization is obtaining an iterator to a place in a data structure. The condition may include comparing two iterators, and in some environments the iterator itself can tell you if it's finished or not (if so, you stop using it). The afterthought is a method of the iterator that moves the iterator to the next position. You dereference the iterator itself to get the current element.
You can "run" a typical iterator using a for loop, but it isn't necessary, and there are more advanced iterators that are bidirectional, aren't sequential, etc. This is where things get interesting.
// it = it.next() can be done with it++
for (auto it = a.begin(); it != a.end(); it = it.next()) {
cout << *it << endl;
}

// equivalent to the new
for (auto x : a) {
cout << x << endl;
}
>>
>>58625974

sounds gay
>>
>>58626093
Iterators make efficiently iterating through a linked list easy. They also make it safe to remove elements from a collection while iterating through it, though you can't do that with the for each syntax. Also if a collection implements an iterator and operations like begin, end, etc. it can work with lots of generic algorithms (meaning, of course, that it's easier for YOU to write an algorithm that supports many collection types).
>>
>>58625636
why not use multiple isPressed variables?

or in a less shitty way:
    public class ChangableButton : Button {
private bool _isPressed;

public Brush BackgroundColor { get; set; }

protected override void OnClick() {
_isPressed = !_isPressed;
if (_isPressed) {
Background = BackgroundColor;
}
else {
ClearValue(BackgroundProperty);
}

base.OnClick();
}
}


subclass button so the OnClick does it in a reusable fashion.

(just change the buttons BackgroundColor to the color you want to change it to)
>>
File: 1482509991723.jpg (181KB, 750x750px) Image search: [Google]
1482509991723.jpg
181KB, 750x750px
I am learning C and I just came upon ''bit fields and bitwise operators''

Is it normal if this is too abstract and doesn't make any sense? Holy shit

Also can anybody recommend me something to get better at using data structures? pls respond
>>
Good people of /g/, I started learning Swift 3 days ago. It's my first programming language, and you guys helped me 2 days ago with a nested function (Idk if that guy remembers).

Anyway, could people good at Swift help me understand these 3 statements (they come right after each other):

>“Functions are actually a special case of closures: blocks of code that can be called later.”
Who is he referring to after the colon?
But closures can also be called later. You can give them a name and type when you inizialize them ( you can do that if I understood correctly, even if Idk why you would yet but it's not the topic), and call them later in another statement.
>“The code in a closure has access to things like variables and functions that were available in the scope where the closure was created, even if the closure is in a different scope when it is executed—you saw an example of this already with nested functions.
Could you please make me an example of "scope"? And an example of "scope at creation" and "scope at execution"?
Also, didnt he just say that function are special because they can be called later? But now he says that closures can be also created and then executed in a different scope, just like functions.
>“You can write a closure without a name by surrounding code with braces ({}).”
Again, you "can", but also can give a closure a name? Even inline? while passing her as an argument?

I know these are a lot of questions. Just bear with me anons please. You helped me a lot before.
>>
>>58626202
If it feels too abstract, just get 8 coins and set them in a row in front of you.
>>
>>58626202
learn binary plebeian. you won't understand bitwise operators until you learn how binary actually works.
>>
>>58626202
>Is it normal if this is too abstract and doesn't make any sense? Holy shit

Any competent book will give you tiny examples to illustrate their purpose and shed light.

They're basically leftover from the days where you had to optimize absolutely everything with memory management.
>>
>>58626202
think of each number in its binary representation.
>>
>>58625636
https://en.wikipedia.org/wiki/State_pattern
>>
>>58626247
>>58626236
>>58626232

Alright alright, what about data structures. I feel like they are very important and should probably try my hardest to get good at them.
>>
>>58626202
https://youtube.com/watch?v=vpjhJJQLPq4
>>
>>58626278
just have everything be a hashmap, that's why python does
>>
File: udy1nj7i27ae6xzzsa1a.jpg (28KB, 620x470px) Image search: [Google]
udy1nj7i27ae6xzzsa1a.jpg
28KB, 620x470px
>>58626278
Just use hashmaps for everything.
>>
>>58626278
It really depends on what you need to do. You're gonna have to familiarize yourself with a number of different data structures before you can get a feel for what'll be the right fit for your situation.
>>
>>58626278
>what about data structures. I feel like they are very important and should probably try my hardest to get good at them
Yes, they are probably one of the most important things in programming.
There are entire books dedicated to learning about data structures.

>>58626285
>>58626302
That's an incredibly shitty and stupid attitude to have. Hashmaps are not good at everything.
They really fall apart when they need to be resized often.
>>
>>58626278
structs come naturally when you need to group two bits of information together. more complicated stuff like trees and linked lists are a bit more involved
>>
>>58626226
>Who is he referring to after the colon?
>But closures can also be called later. You can give them a name and type when you inizialize them ( you can do that if I understood correctly, even if Idk why you would yet but it's not the topic), and call them later in another statement.
A block of code can use local variables declared outside it, but the code is executed in place. A closure is a block of code, potentially capturing local variables, that's wrapped up into a value that you can pass around and call at your leisure. It's a weird explanation but I guess it makes sense.

>Could you please make me an example of "scope"? And an example of "scope at creation" and "scope at execution"?
Scope is a measure of what local variables are available to you, more or less. Scope at creation refers to the scope in which the closure is created with the lambda expression (anonymous function). Scope at execution refers to the scope where the closure is called. Some local variables may be available when making the closure but not when calling it, but everything still works (because the closure copies the variables).

>Again, you "can", but also can give a closure a name? Even inline? while passing her as an argument?
I don't use Swift but I imagine you can simply assign a closure to a variable.
>>
>>58626320
>That's an incredibly shitty and stupid attitude to have. Hashmaps are not good at everything.
Yeah, well, that's just, like, your opinion, man.
>>
>>58626320
>They really fall apart when they need to be resized often.
just make 'em really big then that way you dont have to resize
>>
does anyone prefer to not actually read tons of book or watch youtube tutorial vids for learning how to program? once you get the basic shit down then its best to be thrown into a project IMO. If you get stuck on something then look it up. Much better way to learn too because youre working on real life projects.
>>
>>58626341
t. Pajeet
>>
>>58626340
Ok, if you're fine with wasting a shitload of memory, how do you efficiently traverse a hashmap in order?
>>
File: 1485135642832.jpg (246KB, 400x800px) Image search: [Google]
1485135642832.jpg
246KB, 400x800px
>>58626341
>I don't like reading books
>I can still be a good programmer, right guise?
>>
>>58626356
Hashmaps are not ordered.
>>
>>58626356
maintain a doubly-linked list of keys and iterate in that order
>>
>>58626341
I don't read programming books and I'm a senior developer. I get praised on the quality of my code.

I mostly learn from documentation and articles. I've read maybe 3 programming books total in my life.
>>
>>58626373
I know. That's why I asked.
If you're using hashmaps for absolutely everything, how do you propose that we have ordered data structures?
>>
>>58626385
Use naturals as keys. O(1) lookup time, muthafuckaaa
>>
>>58626382
>>58626390
What if I want to insert an element into the middle of that data structure?
>>
>>58626226
uh, I don't really know swift syntax but closures are in many different languages.

#1 he's saying you can "save" a function to a variable, that it doesn't run until you invoke it with ().
(this'll all be in a fake language)
var sum = int func(a+b) { return a+b }
// that sum function didn't run here

var answer = foo(1,2)
// now it ran and answer should be 3


#2: Scope is .. think of looking through binoculars and you can only see stuff straight ahead while your peripheral vision is blacked out. So, variables live in scopes (function level, module level, global, etc). He's saying closures take a copy (of the reference) of things that were in scope and will use them when you invoke the function.

var c = 42
var sum = int func(a,b) { return a+b+c }

func bar() {
var answer = sum(1,2)
// because c was in 'scope' when you declared the sum closure
// it made a copy of 'c' (basically)
// so answer won't be 3 this time, but rather 45
}

// but
func baz() {
var avg = int avg(a,b) {
var hello = "world";
return a+b/2
}
// hello isn't in scope here
// so if you were to make another closure, it'd only see things at its own scope level
}


#3: I'm not sure how to answer this. Basically you don't need to assign closures to variables, but rather you can pass them around like numbers or strings or what have you.

int test(sum func(a,b) int, a, b) {
return sum(a,b)
}

var answer = test(int func(a,b) { return a+b }, 1, 2)
// this will pass a sum closure (unnamed) to our test function, and the numbers 1.2
// and predictably our answer will be 3



sorry I couldn't use swift in the examples, I don't own a mac so no interest in learning it. and the gnustep swift stuff doesn't appeal to me.
>>
>>58626403
you're unsure of how to keep a linked list in order?
>>
>>58626403
Just do it. Hashmaps work for everything.
>>
>>58626328
Thank you. I understood everything you said.
I just need somebody who knows Swift to confirm my doubts about it.
The theory you explained is very clear. Now I need somebody to reply those questions to tell me if I can do something or not.
>>
>>58626417
I want to do it efficiently. Better than O(n).
>>
>>58626341
If every software developer read the 2005 books about software vulns specially overflows than we didn't had so many overflows anymore.
Books have content that lots of devs should apply today but doesn't happen always ( 90% of the time )
There are lots of other examples for this.
>>
>>58626341
"""""""real life projects""""""" don't mean shit if you go in haphazard and ignorant.

I hate nu-devs.
>>
>>58626463
Better waste days reading books filled with stuff you're not gonna use, and not complete any projects.

How come only like 5% of you ever show off any of your projects? The majority of you don't do any actual programming.
>>
>>58626432
also maintain a heap too
>>
>>58626474
But we're supposed to be using hashmaps for absolutely everything.
You keep bringing in these other data structures.
>>
Right now what are your top 3 programming languages?
>>
>>58626473
>where is your project
Jesus christ, I thought /dpt/ was beyond the same bullshit of /agdg/.

But having the complete knowledge is better than stopping to google basic functions and syntax every two minutes. Or scouring SO for code to paste.
>>
>>58626490
the important thing is the interface, the implementation will never be known to the users and can be improved at a later date
>>
>>58626497
D, Haskell, [undefined]
>>
>>58626500
That's what it boils down to. There are no "theoretical programming" jobs. You either can apply your knowledge to real life problems or you might as well not be a programmer at all.
>>
>>58626516
You're so dense it hurts, enjoy your shitty web dev startups.
>>
>>58626518
But Forth uses a stack.
>>
>>58626533
>t. jobless pajeet
>>
>>58626542
Exactly. When was the last time anyone wrote anything in Forth?
>>
>>58626405
Ok, except the different syntax:
>#1 he's saying you can "save" a function to a variable, that it doesn't run until you invoke it with ().
So why are functions a special case of closures because they can be called? You can do exaclty the same with closures (what you did in your example).
What I mean is, he wants to highlight a difference between closures and functions, but actually this difference can disappear if the developer wants to.
>#2
the var hello is not in scope because it's in another func so the closure cant access it, correct?
>#3
This was mostly a question about syntax.
Again, thank you so much for the help.
Just wished somebody knew Swift to explain me my syntax doubts.
>>
>>58626473
But I do use the stuff I read in books
>>
>>58626552
>>58626516
>>58626473
>>58626341
You need to go back to /wdg/, /vg/agdg/ or whatever shithole you came from.
Non-CS scum trying to masquerade as programmers makes me sick.
>>
>>58626575
I have a degree and I'm a senior software design engineer.

What are you though?
>>
>>58626592
Mickey Mouse.
>>
>>58626592
Wrong my friend, you are an anon. and so am i.
>>
>>58626592
>a degree
In what? From where?
You probably have an """IT""" degree from some random place nobody has heard of.
>>
my teammates are acting like it's impossible to get webpages and a database running on their localhost. i'm on linux using lamp, they're on mostly windows and one on mac. the mac guy keeps saying we should pay for a "real" web server. what do
>>
>>58626608
Nope, Computer Science from one of the best technical universities.

Doesn't matter since we're all anonymous here. You guys are arrogant as fuck for nodevs.
>>
>>58626575

oh look its a faggot elitist who never goes outside

sure you might be a top tier programmer but you're still a faggot. Programming is not THAT hard, thats why they ask you fucking fizz buzz on interviews.
>>
>>58626624
>nodevs
Fuck off to >>>/vg/agdg
Your kind is not welcome here.
>>
>>58626634
Why not? We're all developers. I don't like /agdg/ because they're mostly newbies.
>>
File: 1477349339216.jpg (31KB, 638x540px) Image search: [Google]
1477349339216.jpg
31KB, 638x540px
>>58626624
>nodevs
are you from aggydaggy?
>>
How viable are real time ray tracers now
>>
File: java-vs-haskell.png (102KB, 2435x913px) Image search: [Google]
java-vs-haskell.png
102KB, 2435x913px
neurons in overdrive
>>
>>58626566
closures "close over" their environment (they capture the current state / variables when they are created), functions don't do that. (the CS terms for this is binding, more specifically late binding)

re #2: its not in scope because functions create their own scope, and they reside in something else's scope. you can access things from above your scope, but not below it.
>>
New thread:
>>58626687
>>58626687
>>58626687
>>
>>58621169
>visual studio is a good ide
what planet are you fucking on?
>>
>>58626240
>They're basically leftover from the days where you had to optimize absolutely everything with memory management.
As someone doing evil bit shift nonsense at work, I'd just like to say those days are still very much with us.
Thread posts: 342
Thread images: 33


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
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.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.