[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: 317
Thread images: 32

File: Sparc-logo.svg.png (76KB, 2000x1012px) Image search: [Google]
Sparc-logo.svg.png
76KB, 2000x1012px
Previous thread: >>56644004

What are you working on, /g/?
>>
finished my first C program, you give ti a chess board and it determines the best anithcess move

at first forgot to free memory in the alpha beta search and had to reboot computer because memory ran out
>>
How the fuck does ipv4 work?
Seriously who invented this autism
>>
>write C
>make mistake
>shutdown computer
>>
>>56650183
?
>>
>>56650195
THE MEMORY'S ALL FUCKED NOW
>>
>>56650195
he's obviously writing a bootloader
>>
>>56650203
What ancient piece of shit OS are you using?
>>
>>56650217
>not installing Gentoo into ram and having to reinstall everytime something overflows
SHIGGY DIGGY
>>
>write C
>confuse "if (c == true)" with "if (c)"
>delete filesystem
>>
>>56650252
Do you even know how computers fucking work?
>>
>>56650268
Do you?
>>
>>56650268
I literally have built computers in minecraft
Watch who youre talking to kiddo
>>
>>56650253
There's no true in C unless you use some shitty header like stdbool.h but then that's your own fucking fault.
>>
>>56650293
>>56650290
c
>>
>>56650303
>shitty
>C standard
pick both and only both
>>
>>56650293
Well apparently you don't because you don't understand something as simple as paging and memory protection.
It doesn't fucking matter if you installed Gentoo on a RAM disk, a segfault is only going to potentially fuck up the address space of the process that caused the segfault, which is gone now because the kernel killed it.
>>
>>56650344
What if a have a really early version of Gentoo without proctection though?
>>
>>56649402
It's a behavior that is well defined by the language specification and actually does make sense.

Please see
http://www.ecma-international.org/ecma-262/7.0/index.html#sec-toboolean
and
http://www.ecma-international.org/ecma-262/7.0/index.html#sec-logical-not-operator
and
http://www.ecma-international.org/ecma-262/7.0/index.html#sec-abstract-equality-comparison

Don't try to badmouth Javascript when it's obvious that you never read anything about PLT.
>>
>>56650370
I'm being rused now aren't I.
>>
>>56650370
>putting an OS into your drive without using protection
your computer is a slut
>>
>>56650396
>I literally have built computers in minecraft
>Watch who youre talking to kiddo
hmm
>>
>>56650405
?
It's entirely possible to build computers in minecraft using redstone.
>>
>>56650413
Could we make a compiler that compiles code to redstone?
>>
>>56650293
Minecraft computers don't deal with paging and virtual memory addresses, so that explains why you don't know how it works. Please don't act like a fool though by saying that you know everything because you built an APU in Minecraft.
>>
>>56650293
Could we in the esteemed company of...

The Great Autismo??
>>
>>56650293
>>>/v/ you fucking manchild
>>
>>56650452
If you reverse engineered the format minecraft maps are stored in, then I don't see why we couldn't.
>>
File: 2016-09-17 10-08-57.webm (92KB, 1280x720px) Image search: [Google]
2016-09-17 10-08-57.webm
92KB, 1280x720px
>>56650075
spending 2 weeks with a language just to check out its basic syntax and practices gave some insight as to why for example C# does some stuff that it does.

You obviously can't learn 6 languages in one year. Well actually by know I'd say I don't really look at programming as "Learning C#" or "Learning X language" anymore. Its more about just practicing doing stuff.

I'm only a year in right now but the most valuable part of learning the syntax of a language is being able to read more types of code to see what people are doing.

Then again I'm just some shitter that wants to make games and is currently working on the meme of making my own terminal game engine so I can make hipster modern-esc UI within the terminal. I'm working on adding dropdown menus.
>>
File: 32 Bytes auf autism.png (1MB, 1680x987px) Image search: [Google]
32 Bytes auf autism.png
1MB, 1680x987px
>>56650413
Yes I know and that wasnt a lie pic related
But they cant get complicated enough to have memory protection, paging etc.
So the whole thing was supposed to sound like someone talking out of his ass
>>
File: 1453656893900.png (1021KB, 870x717px) Image search: [Google]
1453656893900.png
1021KB, 870x717px
>2016
>he hasn't rewrote the TempleOS kernel in NAND gates
get out kiddo
>>
>>56650507
Don't just go assuming things.
Of course I have.
>>
>>56650475
Redstone can make NAND gates, which means that a redstone computer can be turing complete.
>>
Is it possible to download just the Visual Studio compiler without the shitty IDE.
>>
>>56650520
Yeah but minecraft is a piece of shit written in awful java code
The game afaik stops processing redstone past a certain range and starts lagging super hard
>>
>>56650532
That was supposed to be a ? not a .
>>
>>56650532
why not just use the GCC? and yes you can from here http://landinghub.visualstudio.com/visual-cpp-build-tools
>>
>>56650549
Redstone is turing complete
The VM it runs in (Minecraft) just isn't able to process it when the contraptions get big enough.
>>
>>56650532
Which one?
>>
>>56650532
Yeah, they're called Visual Studio build tools. Alternatively, you can use MSYS2 to get GCC.
>>
>>56650573
Yes I know thats exactly what I was talking about
Someone building a computer in minecraft couldnt possibly have implemented paging and memory protection
>>
>>56650573
turing complete doesn't mean what you think.
>>
Can someone post the latest programming challenges picture?
>>
>>56650612
Could you please pinpoint the mistake I made in my replies?
>>
Lads I have a domain name, weeaboo.net coming up for renewal.

Do you think it's worth renewing or should I just give it up since I don't use it?
>>
0:30: Trying to find a way to bind $scope variables to the template...
>>
Most I can write in is commandline lol
>>
File: 1469323138359.png (1021KB, 3840x2160px) Image search: [Google]
1469323138359.png
1021KB, 3840x2160px
>>56650625
Not sure if it's the latest but here is one
>>
File: 1432414681439.png (378KB, 1450x1080px) Image search: [Google]
1432414681439.png
378KB, 1450x1080px
>>56650641
>>56650651

0:33 Dumping challenges for anon instead of figuring out binding.
>>
File: prog1.png (244KB, 1920x1080px) Image search: [Google]
prog1.png
244KB, 1920x1080px
>>56650675

0:34 - realizing anon already posted an updated version
>>
>>56650638
I own a bunch of stupid domain names and renew them, and you should too. Maybe we can have a stupid domain name party.
>>
>>56650213
is that the indian version of fizzbuzz?
>>
>>56650691
>>56650675
>>56650651
Ty senpai
>>
>>56650651
>>56650675
>>56650691
ive done majority of these and can do vast majority of these, the rest id have to read about

am i programmer
>>
>>56650736
no

you need a programming license
>>
>>56650744
what
>>
File: 20160917_Game_GameMaker_iOS.png (7KB, 1136x640px) Image search: [Google]
20160917_Game_GameMaker_iOS.png
7KB, 1136x640px
Using Game Maker Studio. This is programming, hopefully one of you here have experience with GameMaker.

I want to draw a view (as a surface) onto another view, and draw stuff on the latter view as well. I am making this game with iOS in mind.

Pic related is what I am getting, I think I am close, but not entirely there.

I made an object called game_draw, and on the create event:
surf = -1;

scale_ios = 3;

if !surface_exists(surf)
{
surf = surface_create(view_wview[0], view_hview[0]);
view_surface_id[0] = surf;
}

on the end step event: (this is the only way the camera will work for me at the moment)
/*  center the camera on the player */
view_xview[0] = -(view_wview[0]/2) + objPlayer.x;
view_yview[0] = -(view_hview[0]/2) + objPlayer.y;

/* so that the camera works */
view_xview[1] = view_xview[0];
view_yview[1] = view_yview[0];

on the draw begin event:
if view_current = 0 
{
if surface_exists(surf)
{
surface_set_target(surf);
}
}

on the draw end event:
if view_current = 1 
{
surface_reset_target();

game_w = view_wview[0] * scale_ios;
game_h = view_hview[0] * scale_ios;
game_x = display_get_gui_width()/2 - game_w/2;
game_y = 0;

if surface_exists(surf)
{
draw_surface_stretched(surf, game_x, game_y, game_w, game_h);
}
}


I do not think I am doing things correctly, and I tried drawing something onto view 1 (the larger view) and it didn't show, but if I put it somewhere like 0,0 then it shows up in view 0 (the smaller view you see the game on right now) scaled.

Any ideas?
>>
>>56650757
>Not having the official Oracleâ„¢ Javaâ„¢ Programmer license
>>
File: 1465681123914.gif (1001KB, 640x480px) Image search: [Google]
1465681123914.gif
1001KB, 640x480px
>>56650757
>he forgot to collect his programming license
bahaha enjoy doing CS again from the beginning
>>
>>56650532
Yes. But why would you? The IDE is the best part of MSVS.
>>
>>56650764
>Using Game Maker Studio.
>>>/vg/agdg
>>
>>56650802
the
 tag doesn't exist there
>>
>>56650802
>Using a computer with a operating system pre-installed instead of writing your own

kys
>>
ive been meaning to ask something connected to what this guy is asking>>56650764

if you dont really need an entire game maker studio, do you just use a gui window and fill it with the functionality you need to make such games?

or do you use some other type of window?
>>
File: big kek.gif (1MB, 245x280px) Image search: [Google]
big kek.gif
1MB, 245x280px
>>56650818
>rolling your own crypto
>>
>>56650372
>it does actually make sense when you learn a giant table by heart
no
we know that it isn't arbitrary
we know that it's well specified
it's still shit
>>
>>56650770
>>56650778
>That feel when they tried to ceremonially give me my programming license before i was formally done with my education, so i didn't attend the ceremony so they threw it away and now i'm done i can't collect it.
>>
>>56650818
>Not building your own computer
>>>v
>>
>>56650811
works for me, search for agdg yourself then.

>>56650818
>kys
/agdg/ has a lot more people with experience in game maker studio, thats why I send him there.
Are you so retarded that you just imply every cross-board link is an insult?
>>
Are there any printable characters that get sorted after all the alphanumeric?

I need something to tag a few files to make them appear grouped at the bottom of the file list.
>>
>3GB for a sub-par compiler
What the FUCK does Visual CPP Build Tools come with? It's literally just the compiler and it's bigger than an Arch Linux installation with GUI and gcc
>>
>>56650612
well theoretically redstone can be used to simulate a turing machine and can kind of be seen as a "set of data manipulation rules" if you take the mental gymnastics far enough
>>
>>56650882
>every cross-board link is an insult?
To be fair, this IS 4chan.
>>
File: banter.gif (2MB, 500x209px) Image search: [Google]
banter.gif
2MB, 500x209px
>>56650882
>/agdg/ has a lot more people with experience in game maker studio
I see what you did there
>>
>>56650918
thanks for the heads up
>>
>>56650900
make an array containing printable characters
sort it
find out
>>
>>56650900
You could prefix them all with ZZZ or some shit
>>
File: 1442422965851.gif (607KB, 800x792px) Image search: [Google]
1442422965851.gif
607KB, 800x792px
>>56650641
>>56650675

0:55 Manged to bind a single variable to scope. Apparently:

public fooNum: number = 42; 


is valid syntax for binding properties to the template. Everything said use "this", and now it doesn't seem to work. Much confuse, wow. Next step - bind object to template and get props / run methods on event.
>>
>>56650842
It does make sense if you have a minimum of PLT knowledge.

Boolean("0") returning false would only make sense if the semantics would be the same as Boolean(Number("0")) but that would be completely retarded since a string can be empty and doesn't necessary represent a number (what about Boolean(Number("Java")) )
>>
>>56650638
Renew it, or at least sell it. It sounds like it could be worth something, as far as domain names go.
>>
File: 11I0i.jpg (20KB, 329x213px) Image search: [Google]
11I0i.jpg
20KB, 329x213px
>>56651214
It makes sense, but it still leads to highly unintuitive looking code and bugs. Thats why it's shit.

pic isn;t good simply because it's in the spec.
>>
>>56650100
OK, please advise me on how best to go about this:

>Learnt C at Uni. Pretty good at it.
>Learnt Java at Uni, basics at most. Not great with OO
>Want to learn iOS/Android dev

I keep starting then stopping tutorials. I got fairly far through some iOS ones, but then real life stopped me and now its been a few months.

What should I do? Should I read K&R to restart learning my C as its been a few years since I've seriously done it.

Or should I focus on learning OO in some way?

I should I just focus on the iOS tutorials and take that steep learning curve?
>>
>>56650833
what?
>>
Do any of you know any book/course on C++ similar to "Learn C the hard way" or http://www.buildyourownlisp.com/ ?
>>
torrent/download link for K&R? Not a noob, but not programmed in C for at least 18 months now
>>
File: cyberpunk.gif (2MB, 750x750px) Image search: [Google]
cyberpunk.gif
2MB, 750x750px
>>56651020

I finally managed to figure out the stupid Angular2/Typescript syntax for binding actual objects to scope:

export class SimpleComponent {

public fooNumber: number = 5;
public anon: Person = new Person(1, 'Anon');

}

export class Person {

id: number;
name: string;

constructor(id: number, name:string){
this.id = id;
this.name = name;
}

}


wew lad, learning web libraries can really cause an existential crisis
>>
>>56651458
>Not great with OO
>Or should I focus on learning OO in some way?

OO is trash
>>
>>56651635

>01:36*
>>
>>56651640
Well please advise me on how best to work towards my goal of app development
>>
>>56651656
?
>>
>>56651680
Just learn objective-C and iOS SDK and Java and Android SDK respectively.
>>
>>56651680

Don't listen to that faggot. If you want a job and you aren't an absolutely genius, learn C# or Java, preferably C#.

I am: >>56651635

P.S. Even front end/mobile is going OO now. Code snippet very related.
>>
>>56650507
>hasn't rewrote
*rewritten :^)))))))))
>>
>>56651711
The market is narrow for C# mobile app development.

Though Xamarin is based af
>>
>>56651711
I have a job already. But want to learn this in my spare time.

There is thoughts that work are going to send us on a C# training course soon, to standardise the way all our tools are written. So would prefer to not learn that for now.

How would you suggest i learn OO? Is there a good guide or something to work through?
>>
File: javascript trash.jpg (103KB, 1024x576px) Image search: [Google]
javascript trash.jpg
103KB, 1024x576px
>"0" equal to false
>acts like true on conditional expressions
>>
>>56651736

Most large companies use C#/Java in general. Xamarin IS awesome, especially now that Microsoft bought it and made it free.

>>56651740

I don't know of any AMAZING books desu. I read "C# in a Nutshell, the Definitive Reference". Honestly, just go through something like this first though:

http://www.tutorialspoint.com/csharp/

it should be a breeze, but will give you a basis.

P.S. I know you asked about Java, but I don't know it (in fact, had to try very hard to avoid it recently).
>>
>>56651748
That has led directly to some hellish bugs in days gone by... Fuck JS. Fuck people who think weak/dynamic typing is ever a fucking good idea.
>>
File: CBpxF32WEAAFVUm.png (442KB, 600x900px) Image search: [Google]
CBpxF32WEAAFVUm.png
442KB, 600x900px
Why do so many engineers prefer Ruby to Python?

I mainly use python (Data analyst), but from the little bit of ruby I've dealt with, it seems a lot more cluttered than python, and a bit less intuitive.

What's the reason it tends to be preferred?
>>
>>56651787
Yeah, but few use Xamarin for app development compared to Objective-C/Java.
>>
>>56651808
Swift is the future anon. Put down Objective-C.
>>
>>56651810
Yes, it's the future. Not the present. Have fun getting an iOS job with only Swift and not knowing Objective-C well.
>>
>>56651748
>>56651788

Stop making shit up guys, you are as bad as the OO anon. Proofs:

https://plnkr.co/edit/zkrJ5aQ8kf6zyHMKjxBF?p=preview

if (0 || callAnonAFag()  ){}


Obviously it acts FALSY.

I am: >>56651635

01:50: Arguing with faggots instead of studying.

>>56651808

As far as I know, that's true, so no arguments there.
>>
>>56651795
>Why do so many engineers prefer Ruby to Python?
Because they're gay.
>>
>>56651820
DESU, I really can't imagine me learning Objective-C (or even Swift for that matter) to a high enough standard to get a real job with it.

I expect to make a few apps for myself and have a small portfolio, and then use that to get contract jobs from the likes of freelance websites, rather than corporates.
>>
File: 1445715648881.png (50KB, 580x572px) Image search: [Google]
1445715648881.png
50KB, 580x572px
>It's a "I overload operator() to do everything" codebase
>>
>>56651846
>to a high enough standard to get a real job with it.
It's really not that hard. Most iOS dev's are horrifyingly shit. People often think programmers jobs must be these amazing professionals, but most of them aren't. Their mostly glorified script kiddies who think they must be experts because of their paychecks.
>>
I want to know 2 file locations which I don't want to pass to my program every time I run it.
I keep the paths in a file that its path I #define and it does what i want but it feels very shitty way.
Basically, is there a way to keep the location known to a program after it has shutdown and rerun without passing it every time (pass once and keep until it's changed) and without being specified at compile time.
I'm using c.
>>
>>56651884
post code
>>
>>56651895
paths.txt
>>
>>56651888

>Their mostly glorified script kiddies who think they must be experts because of their paychecks.

Trips of truth despite
>their
>>
>>56651888
Well, I can do my best and learn hard. For me I'll be learning Swift. If that rules me out of iOS dev jobs from a corporate point of view, so be it.

I didn't get the stuff I was learning about MVC and MVVM (same thing?), so really struggling. That's why I was wondering if it was worth learning OO first, before jumping into stuff about Swift.
>>
>>56651935
Yes, thats what I do but the path of the paths.txt is still a #define. Btw i don't want it to be in the current directory, I want it to be able to be anywhere

The more i think of what i want to do the more I think its not possible.
In other words i want to do this:

int defaultvalue=1

changeDefaultValue(int x){
defaultvalue=x // i want this to carry over to the next time the program is run, so i want x to be the value of the defaultvalue the next time it is run
}

its stupid.
>>
>>56652006
a #define or an argument pass*
>>
>>56651994
>I didn't get the stuff I was learning about MVC and MVVM (same thing?), so really struggling
You may be shocked to find how few devs really understand MVC in the industry. Infact, it's not really that clearly defined in my experience. People seem to have different definitions of it that they accept. MVVM is more clearly defined though. Not too important for iOS dev though.

Swift is OO. It's basically Objective-C with a lot more static typing, better syntax, random things fixed and more functional language features.
>>
>>56650370
You don't.
Even the very first publicly released Linux (0.1) had paging.
>>
>>56650868
>not mining and refining the minerals yourself
>>
>>56652006
I guess I should just go with a certain location like programs do with their config files...
>>
>>56650532
Yes.
Get the WinDDK (for Win7 and earlier) so you can also link against msvcrt.dll and not have to worry about vcredist bloat.
(Still a ~2GB install though)
>>
>>56652081
just do what werks and is simplest
>>
>>56651795
What is that pic saying? C++ is lazy bitch who dreams of doing everything but wont get of her lazy butt to do anything, while C is perfect waifu?
>>
>>56652111
I'll just put the "paths.txt" in a certain location(it can be the home directory which is easily identifiable in any machine) and I will read/modify the paths(the files can be anywhere) when i need too. I guess that's a good way to do it but initially i thought i could have that "paths.txt" anywhere I wanted.
Putting the files in the same directory as the program is being run into would work too put it would be complete fucking shit. I'm looking to find a good way more than making it work, because to make it work is not a problem.
>>
>>56652058
OK, so what book/tutorials/whatever is good for learning OO?

Otherwise I'll brush up on my old C with K&R first
>>
>>56652172
>work too put it would be
but*
>>
2d game in UART with ARM64 assembly
Trying to get the poo emoji work on sakura
>>
>>56652172
wait why cant you just do directory1/directory2/paths.txt
>>
SQL noob here. If I have a table like

student_id | score
1 | 90
1 | 100
2 | 90
2 | 0
2 | 0

how do I find the average score of each student like so:

student_id | average_score
1 | 95
2 | 30
>>
>>56652192
Are you trying to do a chris sawyer?
>>
>>56652211

>I don't google it every time I have to do it at work
>>
updating index?
>>
>>56652226
im making a game where ur pajeet and u must escape evil white men who try to erase ur identity and make u poo in loo
>>
Is this an array or a list? I'm a little confused.

#Python shit
MyThing = []
MyThing.append("thingy")
print(MyThing)
#it's gonna print ['thingy']
>>
>>56652204
Now that you mentioning it i can get the full path of the executable from argv[0], maybe i should just go with ./paths.txt. I didn't want it to be in the directory of the program or being associated with its directory because I thought that if the program would be called from another location i wouldn't be able to find the paths.txt.
>>
>>56652287
it's a list but the python standard calls them arrays
>>
>run "appbuilder build android"
>browser tab with login form opens up
you gotta be shitting me
>>
the reference assemblies for framework .netframework version=v4.5

How do I fix this, I have .Net 4.5 installed. I'm using Xamarin Studio Community on windows 10.
>>
>>56652204
>>56652318
It's in the same principle, you specify a certain location. In the first idea you specify the home directory (or the /etc/ directory) which there are in every machine and in the second you specify the folder of the executable. I think I got to the bottom of this and I have the understanding of how to avoid the file not being found-able.
>>
File: 1468705255112.jpg (370KB, 1280x906px) Image search: [Google]
1468705255112.jpg
370KB, 1280x906px
>02:38
>going to write a service and wrap it up
>>
>>56652420
What's the difference between an array and a list? I don't understand.
>>
>>56652553

A list is generally variable length. An array is a fixed length in many languages. Somehow, this makes it faster to loop over. Also, lists are generally easier to work with, exposing foreach loops and such. Arrays generally want basic for loops.

>02:41
>still shitposting
>>
>>56652595
>Somehow, this makes it faster to loop over
no, this is only true for linked lists (not for array lists)
the foreach example is pointless and only true for languages like java
>>
>>56652750

I am not going to argue with you, since I only know examples from specific languages.
>>
I'm writing a sample web application in Scala for work to convince them to rewrite this main web application in it.

I really like Scala and SBT too so it won't be too bad if they don't want to use it.
>>
>>56652211
You'll probably have to group by student_id and then some sort of aggregator for the group of values.

https://www.postgresql.org/docs/9.5/static/functions-aggregate.html
>>
>>56652595
Arrays and vectors are faster to iterate than a linked list because their memory is contiguous and good for the CPU cache.
>>
>>56652595

What does an array look like compared to my "thingy" list example of appending that String to the list?
>>
>>56653001
you cannot append to an array
an array has a fixed size
>>
So I've graduated and I actually need to find a job, I only did one unit on Java and hardly paid any attention but I have to learn that shit to pass a programming aptitude test on Tuesday. Is Java, A Beginner's Guide the best place to go to cram as much in as possible by then? I've used a bunch of other languages (including oo) so I'm no stranger to programming logic I just need to learn how to do it in Java.
>>
hey guys rate my python
def bootstrap( config:Union[
str,
dict,
os._Environ
] = os.environ ) -> Callable[
[
Union[ Iterable[ str ], Service ],
serve.Verb,
str,
Optional[ bytes ]
],
Optional[ bytes ]
]:
"""Bootstrap the Gumballs environment
Args: <snip>
>>
>>56653124
What do you know, most of the syntax can be assumed from other langauges, but the specifics might get you.
So id skip the beginning of any book to get to the language specific info.
>>
>>56653166
I've completed a comp eng degree so my programming base is decent, mostly from C and Python. I probably just need to drill in any Java-specific terms and class structure. It's online and open book so I don't need to memorize it or anything, just not be completely stumped when I start.
>>
>>56653217
>online and open book.
would any company take this seriously?
completely cheatable.

I started C after java and every rule that applied in java applied in C.
But your problem is, C is simpler than java so you gotta get a grips on OOP.
>>
>>56653256
They claim their system can tell if you cheat, presumably by comparing your code to the database of other completed solutions. No idea how well that system works. I completed a year-long placement writing OOP Python so that shouldn't be too bad either.
>>
How obscure are regular expressions? I know they're usually avoided unless you really need them, but I'm curious how often they actually come up in production
>>
>>56653438
Regular expressions aren't obscure at all.
>I know they're usually avoided unless you really need them
Why would you avoid them? You just shouldn't try to parse non-regular grammars with them (e.g. bracket matching) and you shouldn't to simple substring searches with them (because more efficient algorithms exist for that).
>>
>>56653479
>substring search
Who would do this with anything other than a FSM?
>>
python sucks desu
>>
>>56653499

Why wouldn't you use KMP?
>>
>>56653479
>simple substring searches ...more efficient algorithms for that
example?
>>
>>56653546
I was taught Robin-Karp
>>
>>56653499
>>56653547
https://en.wikipedia.org/wiki/Boyer%E2%80%93Moore_string_search_algorithm
>>
>>56653479
I wonder why all this stuff I read said to avoid them. I figured they would be very useful, that's why I asked.
>>
>>56653643
just consider this
https://swtch.com/~rsc/regexp/regexp1.html
most regex implementations are shit and dangerous
stackoverflow recently had a long downtime because of this
>>
>>56653568

Robin-Karp also works.
>>
>>56653438
I don't use them much in production code, but I use them all the time to write little convenience scripts and find things in the fuckhuge legacy codebase.
>>
>>56653710
We can thank the idiots who disregard computer science theory for that.
Larry Wall is a hack.
>>
im a hack :/
>>
>>56653775

Perl made web programming easy, though. It ushered in this wonderful age of web applications!
>>
>>56653834
so did php
>>
>>56653936

Yes, and PHP is excellent, too.
>>
>>56653948
not funny
>>
>>56653948
comedy requires more than just tragedy to be funny
>>
Trying to learn OpenGL to "graduate" from command-line applications.

I'm starting to read the "OpenGL SuperBible", and I notice that it's focused on OpenGL for Windows. If I'm using XCode on a Mac, would the sample code still work?
>>
>>56654151
>"graduate" from command-line applications
But CLI programs are arguably the most useful.
>>
File: BenderEmbarassment.gif (282KB, 500x370px) Image search: [Google]
BenderEmbarassment.gif
282KB, 500x370px
>>56654173
But I want to draw Conway's Game of Life on a pretty window and make ray tracers, anon!

Unknowingly, I answered my own question.
The "readme" on the source code tells me to use Cmake. (Specifically,
cmake -G "unix Makefiles"
)
>>
>>56654173
He means toy calculators or whatever
>>
https://forum.dlang.org/thread/[email protected]?page=1

>removing semicolons this late into a language's development
>>
>>56654173

Likely the most powerful, too.
>>
>>56654151
Opengl is portable, windowing and context creation is not.
Use SDL or GLFW for those.
>>
So this might sound crazy, but on VS 15 Preview 4, hitting the "start" button doesn't actually start debugging. It'll just flash once (the debug process presumably gets killed) and then it'll just refocus on the editor. It's not doing this every time, either.

It's pissing me the fuck off.

Anybody have a clue?
>>
File: NotSoSmart.png (5KB, 603x136px) Image search: [Google]
NotSoSmart.png
5KB, 603x136px
Is this my IDE telling me my method name is stupid?
>>
>>56654499
Whoops that shouldnt be private.
>>
>>56654478
VS is literally getting worse every update.

All other IDEs suck, expect for Jetbrain IDEs but CLion isn't free.
>>
>>56654478
Install Gentoo
Install emacs
Have fun
>>
>>56654527
vim > emacs

from head to toe
>>
>>56654519

It is if you're a student. It's the best.

>>56654527

I don't want to do that.
>>
I'm implementing Little Man Computer but with the accumulator and program counter as objects just to learn a bit of OOP. How retarded am I?
>>
>>56654629

It could be worse.
>>
>>56654623
>It is if you're a student
No NEET licenses I'm guessing.
>>
>>56654725

Not that I know of, no. That said, you could buy it with your NEETbux.
>>
>>56654629
You can do without, but if you want to practice OOP I don't see the issue.
>>
Why is Pearson so amazing? Why are they literally the best publishers to ever publish computer science textbooks? I love Pearson, thanks Pearson!
>>
do we prefer vc++ or gcc++
>>
>>56654629
That will prepare you well for how OOP is used in the real world.
>>
>>56654954
Neither, because C++ is shit.
>>
>>56654977
idiot
>>
>>56655025
Get some taste, fag.
>>
>>56655273
your right

*installs rust*

heh... gonna make it now...
>>
>>56655288
>*emotes*
I think you should leave.
>>
>>56655341
psht...

nothing personnel kid...
>>
I wanted to answer someone in a thread, but the thread got deleted, so I'll post the code here anyway. How would you improve it, /dpt/?

Here's the problem
>user entres a positive interger
>add up all the number up to this number
>but dont add any number that is a multiple of any of the digits in the number

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

int main()
{
int number; //number
int n=0; //amount of digits
int *a; //array of digits
long sum = 0; //sum

puts("Enter a positive integer\n");
scanf("%d", &number);

a = (int *)malloc(sizeof(int));

for (int i = number; i > 0; i /= 10) {
n++;
a = (int *)realloc(a, n*sizeof(int));

a[n - 1] = i;
if (n > 1) {
a[n - 2] = a[n - 2] - a[n - 1] * 10;
}
}

int condition;
for (int i = 0; i < number; i++) {
condition = 1;
for (int j = 0; j < n; j++) {
if (a[j] == 0) {
if (i % 10 == 0) {
condition = 0;
}
}
else if (i % a[j] == 0) {
condition = 0;
}
}

if (condition) {
sum += i;
}
}

printf("\n%d\n", sum);

free(a);

getchar();
getchar();
return 0;
}
>>
Just tell it to me straight. How shit is my code?
https://github.com/salvadorp2001/Little-Man-Computer-CPP
>>
I asked a question about which lang is more hipsterish, Go vs Node.js, and people here said Go.
but, how is it hipster to select a language because of its good perfomance (and resource management) and ease of use? that's what attracted me to Go, at least...
>>
>>56655570
>doesn't even compile LMC assembly
It's shit
>>
Just finished an implementation of Conway's Game of Life in CLI in C++.

How would I make a graphical implementation now that I have the logic of the program?
>>
>>56655698
port it to piet
>>
>>56655669
It's the numeric one. I'm not gonna waste my time separating the mnemonics.
>>
>>56655491
note that the sum of 1 to n of all integers which are a multiple of k is the k*sum of 1 to floor(n/k), hence you can do this in time which is logarithmic w.r.t to n

ill post a solution soon
>>
>>56655852
km(m+1)/2
where m = floor (n/k)
>>
>>56655852
congrats you can repost what someone else said with different wording
>>
>>56655491
Now with excessive error checking and excessive input validation.
#include <errno.h>
#include <limits.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main()
{
long n;
long sum = 0;
bool digits[10] = {0};

char buffer[32];
char *endptr;

puts("Enter a positive integer\n");
fgets(buffer, sizeof buffer, stdin);

errno = 0;
n = strtol(buffer, &endptr, 10);
if (endptr == buffer || n < 0 || endptr[strspn(endptr, " \t\v\r\n")] != '\0') {
puts("Not a positive integer");
return 1;
} else if (errno == ERANGE) {
puts("Integer is too large");;
return 1;
}

for (int i = n; i > 0; i /= 10)
digits[i % 10] = true;

for (int i = 0; i < n; ++i) {
bool cond = true;

for (int j = 1; j < 10; ++j)
if (digits[j] && i % j == 0) {
cond = false;
break;
}

if (cond) {
if (LONG_MAX - i > sum) {
puts("Integer overflow");
return 1;
}

sum += i;
}
}

printf("\n%ld\n", sum);
}
>>
>>56656184
oops. >>56656022
>>
File: Windows 98-2016-09-17-22-33-46.png (28KB, 1920x1080px) Image search: [Google]
Windows 98-2016-09-17-22-33-46.png
28KB, 1920x1080px
Truly this is how it was meant to be done.
>>
>>56649825
I think any decent language should manage this. Because comparisons to true can be made into inverse comparisons to false.
Using true as a value? Well you shouldn't, should be undefined.
>>
>>56656218
>>56655491
here.
#include <cstdio>

int main()
{
bool hasDigit[10]; // just ignore indices 0,1
unsigned n, sum;
printf("Enter a positive number: ");
scanf("%d", &n);
unsigned temp = n;
for(unsigned i = 0; i < 10; ++i){
hasDigit[i] = false;
}
while(temp){
hasDigit[temp%10] = true;
temp /= 10;
}
// if we subtract this digit, all multiples have already been subtracted
for(unsigned i = 2; i < 5; ++i){
if(hasDigit[i]){
for(unsigned j = i<<1; j < 10; j += i){
hasDigit[j] = false;
}
}
}

sum = n*(n+1)/2;
for(unsigned i = 2; i < 10; ++i){
if(hasDigit[i]){
sum -= (i*(n/i)*((n/i)+1))>>1;
}
}
printf("Sum: %d\n", sum);
}


im sure if you spent some time you could improve it even more
>>
>>56656396
You could have just installed Gentoo
>>
>>56649825
Neither should be allowed by the type system.
>>
File: 1446332888264.png (711KB, 1600x2162px) Image search: [Google]
1446332888264.png
711KB, 1600x2162px
>>56656440
>#include <cstdio>
>>
>>56656457
I'm sure your parents are really proud of you. What isn't there to be proud of? An autist whos incapable of socializing, undeserving of being loved by anyone, and so he substitutes it with childrens cartoons for love and lust.

You're a real winner buddy. End yourself.
>>
File: 1457188223998-2.png (65KB, 194x200px) Image search: [Google]
1457188223998-2.png
65KB, 194x200px
>>56656510
please tell me that this is a pasta and you didn't write this yourself
>>
File: 1452635429762.jpg (67KB, 416x508px) Image search: [Google]
1452635429762.jpg
67KB, 416x508px
>>56656510
Why are you even here?
>>
>>56656445

This is more fun. BGI is great.
>>
File: rude.png (767KB, 1600x2162px) Image search: [Google]
rude.png
767KB, 1600x2162px
>>56656457
Anon please be more friendly.
>>
>>56656440
nice. what is the purpose of the bit shifts?

> for(unsigned j = i<<1;
> sum -= (i*(n/i)*((n/i)+1))>>1;
>>
>>56656440
>
i*(n/i)*((n/i)+1)

Isn't this just
>
n*((n/i)+1)
>>
>>56656608
I assume he's one of -those- types who thinks he always needs to replace /2 and *2 with shifts
>>
>>56656650
iff n%i == 0, then its equivalent. otherwise, the integer division rounds down

>>56656608
just division/multiplication. desu you can safely replace it with the respective div/mult operations b/c any decent compiler will do a strength reduction
>>
>>56656691
>>56656703
>b/c any decent compiler will do a strength reduction
>I assume he's one of -those- types who thinks he always needs to replace /2 and *2 with shifts
Why? It's only potentially slower on modern CPU's?
Am I missing something here?
>>
>>56656818
youre right, using * or / is only potentially slower on modern cpus when compared to a shift op. its not a point people really care about because modern compilers will almost, if not always, reduce it to a shift op.

desu i think hes just getting autistic over it, but autists gonna autist
>>
>>56655491
I forgot to write one information:
>if the digit is 0, dont add any number that is a multiple of 10.

>>56656440
I guess it could be done like this, right?

bool hasDigit[11];

// [...]

if (hasDigit[0]) hasDigit[10]=true;

// if we subtract this digit, all multiples have already been subtracted
for(unsigned i = 2; i <= 5; ++i){
if(hasDigit[i]){
for(unsigned j = i<<1; j <= 10; j += i){
hasDigit[j] = false;
}
}
}

sum = n*(n+1)/2;
for(unsigned i = 2; i <= 10; ++i){
if(hasDigit[i]){
sum -= (i*(n/i)*((n/i)+1))>>1;
}
}

// [...]
>>
>>56656880
>using * or / is only potentially slower on modern cpus when compared to a shift op.
That's not what I said.
The throughput is lower but the latency is 0.5 on sandybridge for instance compared to an integer mul or div which is higher throughput but 1 latency.
Meaning it's (shift) slower (since a result can't be recieved in half a cycle).

I don't get how someone could conclude that a shift would be faster from that.
And if compilers make that conversion all the time and not just for funsies when it doesn't matter then that's horrible. Now I have to look at all my muls and divs anon. Thanks -.-
>>
File: 1457387542235-0.png (27KB, 200x133px) Image search: [Google]
1457387542235-0.png
27KB, 200x133px
>imperative
>>
>>56656931
Well there's no fast functional alternatives anon.
>>
>>56656898
>if the digit is 0, dont add any number that is a multiple of 10.
If thats the case, all you need to do is add this.
    // .....
sum = n*(n+1)/2;
if(hasDigit[0]){
sum -= 10*((n/10)*((n/10)+1))/2;
}
for(unsigned i = 2; i < 10; ++i){
if(hasDigit[i]){
sum -= (i*(n/i)*((n/i)+1))>>1;
}
}
// ...
>>
>>56657003
Oops, forgot. change the
if(hasDigit[0]) to if(hasDigit[0] && !hasDigit[5])
>>
>>56657053
and the
&& !hasDigit[2]
>>
>>56657073
o yeah. that too
>>
Hmm so there's actually people who think shifts would be faster than muls and there was any appreciable amount of time where compilers were so crappy that you had to replace it?

Is this like that i++ vs ++i bullshit?

It's like some people don't even write software for computers anymore.
>>
i + 1
>>
File: fun.gif (422KB, 621x460px) Image search: [Google]
fun.gif
422KB, 621x460px
Windows 98 & BGI are so much fun. I'm actually enjoying fucking around.
>>
>>56657177
BGI?
>>
>>56657190

Borland Graphics Interface, which they included with turbo C.
>>
>>56657209
>turbo C
>turbo
sounds like a 90s thing
>>
>>56657209
I just dick around with /dev/fb0.
>>
Wow rude mods, deleting that gCPU thread.
>>
>>56657240

I'm a Windows fag. :^)
>>
File: bepis.gif (88KB, 640x458px) Image search: [Google]
bepis.gif
88KB, 640x458px
Some more fun.
>>
File: (s)OS.png (242B, 47x39px) Image search: [Google]
(s)OS.png
242B, 47x39px
>>56657322
who /botnet/ here
>>
>>56657344

I haven't installed W10 yet, but I'm upgrading soon, and I'll have to.

I'll regret it.
>>
>>56657394
>I'll have to
>I'll regret it
Don't do it.
>>
>>56657394
Isn't free time over?

Are you actually paying for it?

>captcha is LITERALLY 2016
>>
>>56651709
>objective-C

fuck that gross shit, use Swift
>>
what should I learn to make gaems? c# or c++?
>>
>>56657475
Unity uses c#
>>
>>56657431
Swift is a troll language.
>>
>>56657530
I don't want to use an engine. I want to draw pixels directly on the screen.
>>
File: maga.gif (307KB, 611x455px) Image search: [Google]
maga.gif
307KB, 611x455px
Don't forget what to do on November 8th.
>>
>>56654954

g++ or clang++. Never VC++
>>
>>56657560
then c++
>>
>>56657608
I like the inline assembly better in VC++. : \
>>
>>56657608
Whats wrong with VC++?
>>
>>56657560
C++ is the traditional language for low level engine stuff. If you go that route you'll probably want to go with sdl2 or sfml using opengl for actually drawing.

If you go with C# you can also use sfml.net and opentk for drawing.
>>
>>56657322
we know you are a fag, no need to remind us
fag
>>
>>56657656

in all other respects, I am completely heterosexual.
>>
>>56657651
>>56657633
I think you mean C.
Practically all OS interfaces are in C.
>>
gladLoadGLLoader((GLADloadproc) glfwGetProcAddress);

I dunno what to do about the fact that this gives me "undefined reference to 'gladLoadGLLoader' "
>>
>>56657693
Probably link to GLAD.
>>
>>56657698
What, like include it?
>>
>>56657698
Linking improperly would give him a linker error.
>>56657693
Usually you have to set certain flags before including the glad header. Or you just forgot to include it altogether.
>>
>>56657719
Setting flags before including a header?
Weird.
I'd certainly have no clue what to do there.
>>
>>56657719
>set certain flags
Sorry I mean set defines.
>>
>>56657605

Throwing my vote away and voting for the Libertarian candidate, because not knowing what Aleppo is pales in comparison to how horrible the other two candidates are?
>>
>>56657684
If you learn c++ you get c for free.
>>
>>56657649
absolutely nothing
>>
>>56657740
No you don't. And you get a ton of useless knowledge that confuses you.
>>56657728
gladLoadGLLoader is not something which isn't defined normally though. Have you included glad.h?
>>
What is the correct method of launching some process from C on *nix?

fork() followed by exec*()?
>>
>>56657651
well I know a bit of C and I liked C# when I was reading the first chapters of microsoft's step-by-step book.
I really don't know which one I should use.
>>
>>56657756
>No you don't.
How so?
>>
>>56657766
I really don't know which one I should learn*
>>
>>56657768
Learning C++ is simply not the same as learning C.
Especially when you consider the programming practices within the two very different languages.
It's true that if you learn C++ you know most of the syntax of C. But that can be said for tons of languages. Any C-like really.
>>56657766
If you liked C# you can go with that.
>>
>>56657719
Well, "undefined reference" is a linker error.
>>
>>56657756
Yep, it's included.
Not including has it instead say it wasn't declared in this scope.
>>
>>56657796
Yeah you're right. Sorry I shouldn't be giving help when tired.
>>56657805
How are you linking?
>>
>>56657826
#include <loader/glad.h>
>>
>>56657840
That's not linking. That's including a header file.
Linking is when you tell the compiler "here's some library files".
>>
isn't the garbage collector a bad thing?
I mean, with C I can free any mallocated memory I want
>>
>>56657737

I don't want to risk a Clinton presidency.
>>
>>56657860
The problem with garbage collection is that you don't control when and where you allocate or deallocate memory. So yes it's correct that it's bad.

But for any game I see you making it shouldn't really be an issue.

But certainly if you're making a professional AAA game you wouldn't use c# simply for that reason. I'm not sure if you can get manual memory management going in C# in any nice way but that's also an alternative.

If your goal is to be low level I'm afraid you're pretty out of luck because OS's prevent that right now.

handmadehero.org is probably something you'd enjoy though. He technically uses C++ but he uses a subset that's very similar to C.
>>
>>56657858
What's the difference?
>>
File: correctvswrong.png (141KB, 758x674px) Image search: [Google]
correctvswrong.png
141KB, 758x674px
Haven't done much on my Chip-8 compiler for a while. Talked to my programming instructor recently, and he gave me advice that's actually reasonable and helpful. Just finished a very basic implementation of checking the symbol table (only checking so far, verifying code validity).

Errors still print as if on line 0 because I forgot to keep track of each tree node's line in code. Should be an easy fix.
>>
>>56657907
I'm just gonna link you to something. It's a bit to explain.
http://stackoverflow.com/questions/6264249/how-does-the-compilation-linking-process-work
>>
>>56657925
Also I'm not a fan of the stuff the person answering insets. Like the fear of macro's/defines and #includes.
>>
>>56657860
>>56657903
Also Garbage collection is far more efficient now than it used to be. Its performance hit will be negligible in most cases.
>>
>>56657925
That still makes it sound like a linking error is a failure to #include.
>>
>>56657961
It's not really about how much it will hit, it's WHEN that is the question everybody is asking.

I don't have a problem with GC as long as it's not forced on you and the language acknowledges more than half-heartedly that RAII is useful.
>>
>>56657961
GC is a problem for real-time systems

>>56657977
RAII shares some faults with GC
>>
>>56657961
>>56657977
And GC should only be used when your lifetimes really aren't at all straightforward. It's great for copy-on-write semantics, for example, when you don't want reference counting hell.

>>56657986
Like?
>>
>>56657994
Like when your RAII accidentally frees a massive structure
>>
>>56658005
Accidentally?
>>
>>56658009
"accidentally" as in GC "accidentally", i.e. "when i didn't want it to happen"
>>
>>56658015
Maybe in shit languages like C++ where move semantics were an afterthought.
>>
Oh boy
>>
>>56657961
Not for games which care about the stall, they need to be more predictable than GC tends to allow. I'd agree that for non-games without very high requirements garbage collection is quite nice.

But GC is just a more inefficient process overall so it will never beat programmer-managed memory for high-end applications.
>>56657976
Well it isn't. A #include is just a copy paste into a file. The linker takes object files and link them together to a program after compilation.
>>56658019
Both RAII and GC are bad because they're (at least sometimes) unnecessary operations.
RAII is pretty useless because it hides errors you have to deal with.
>>
>>56658038
>RAII is pretty useless because it hides errors you have to deal with.
???
>>
>>56658038
All the other stuff I have without linkers though works perfectly fine.
>>
>>56658060
Anon it's a thing you have to accept exists and will exist.
>>
>>56658072
It seems odd though, that one library needs linking and another doesn't.

Also I have absolutely no idea how one writes a linker.
>>
>>56657865

I honestly think I could be equally disappointed by either candidate.

>>56658005

The great thing about RAII is that it never does anything on accident. It always frees resources in a predictable manner.
>>
>>56658089
>>Also I have absolutely no idea how one writes a linker.
You don't. You tell your compiler using flags where .lib (for example) files are. I don't know what environment you're in so I can't really help you.
>>56658050
If you're writing your code in a way that relies on RAII you're going to have errors that were reliant on it. As RAII should be removed almost in its entirety if you care about performance you've just introduced hidden bugs until late in development. It's not that easy to see how that happens because it's such a small thing that causes issues on a large scale, and when you're doing it you don't necessarily make the connection. But pay attention next time.
RAII is also annoying to do. Could be easier in some languages,
This is also worth looking at.
https://youtu.be/TH9VCN6UkyQ?t=1784
>>
>>56658164
>The great thing about RAII is that it never does anything on accident. It always frees resources in a predictable manner.
>>56658015
>>
>>56658169
There weren't any library files though.
I used http://glad.dav1d.de/ to get the two header files I need.
>>
>>56658207
Maybe you're not compiling glad.c?
See if there's a glad.obj somewhere
>>
>>56658218
There's a glad.c file, but putting it in my lib folder isn't helping.
>>
>>56658247
Could I get to know what compiler you're using or is that secret?
Have you added an include directory (or added a directory to the path environment variable) that points to the folder where include and src (for glad) is located?
>>
>>56658269
CodeBlocks.
I'm new to the IDE, so I don't know how to fix up a naming mistake I made for the include directory a project uses (the root folder is called GLFW even though other things are inside) but I did try having a src folder (with glad.c) alongside my include folder.
>>
>>56658175

But GCs are non-deterministic. You can ALWAYS tell exactly when RAII will manage resources. It may not have been when you wanted the resources to be freed, but it is entirely your fault that it did so.
>>
>>56658381
New thread.
Thread posts: 317
Thread images: 32


[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.