[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
/dpt/ - Daily Programming Thread
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 255
Thread images: 25
File: 1461226306431.gif (48 KB, 2034x1491) Image search: [Google]
1461226306431.gif
48 KB, 2034x1491
Previous thread: >>54776509

What are you working on, /g/?
>>
File: 1462399412449.jpg (410 KB, 876x2350) Image search: [Google]
1462399412449.jpg
410 KB, 876x2350
First for F*
>>
>>54784736
give an example usage of a factory
>>
>>54784749
your mom
>>
>>54784729
F* is pretty cool

I wonder if a merge between Ocaml and F# can happen
>>
>>54784773
I want a merge between F# and D
>>
python shitters are terrible """"""""programmers""""""""
>>
Reminder that Rust is the best language and everything else is a sad joke by comparison.
>>
>dependent types automatically make a language good for systems programming even if it's still garbage collected
Who started this meme?
>>
File: 1462920404834.png (1 MB, 1000x1400) Image search: [Google]
1462920404834.png
1 MB, 1000x1400
>No himegoto

Shit thread.
>>
>>54784822
KILL YOURSELF FALSE FLAGGING RETARD FAG SHILL
>>
>>54784717
Im making a chat program that connects to a centralized server
>>
File: trop.png (1 MB, 1280x720) Image search: [Google]
trop.png
1 MB, 1280x720
>>54784761
not an argument

>>54784822
This 3bh
>>
>>54784850
kill yourself
>>
>>54784834
cool
make sure to market it to the normies as some new technology (aka front end to irc)
>>
>>54784858
no thank you x
>>
>>54784866
FUCK YOU YOU'RE A FUCKING PATHETIC PIECE OF SHIT YOUR LIFE IS SHIT
>>
>>54784820
Who are you quoting?
>>
>>54784866
*kiss lick wet heart emoji*
>>
>>54784794
and_then is literally just writing >>= with lambdas in Haskell instead of using comprehensions or do notation. So no, Rust doesn't have a satisfying equivalent.

It has try! for Option and Result but it's not using the fact that they're monads to work.
>>
>>54784871
>being baited this easily
Are you 12 or something?
>>
>>54784860
Yes, i just need a logo and name ;^)


The point is to just make a really simple protocol that is easy to code clients for, and have a server that anyone may connect to.
>>
>>54784927
>le epin bait xD
get a life kid
>>
File: haiyai.png (3 MB, 1757x2398) Image search: [Google]
haiyai.png
3 MB, 1757x2398
>>54784936
>get a life kid
>>
>>54784925
And while do notation may have been designed around the IO monad, it's useful for far more. It's okay to like a language while admitting it has faults.
>>
>>54784931
Literally what is websockets with socket.io....
>>
>>54784877
People who talk about Idris. It's neat, but it's just Haskell with dependent types.
>>
>>54784925
Do notation is literally the default mode.
x;
y
is the same thing as haskell's
do x
y
Hakelltards on suicide watch yet again.
>>
>>54784996
You have a severely limited "understanding" of monads.
>>
>>54785016
The suicide hotline is ready for you. Don't do it, just call them!
>>
Learn me a haskell
Learn you a haskell
For a few more monads
real good
>>
>>54784996
haskell:

x <- asfgf
y <- f asjkfi
asf x, y

asfgf >>= (\x -> asjkfi >>= (\y -> asf x, y))
>>
>>54785099
equivalent to

[ asf x, y | x <- asfgf, y <- f asjkfi ]
>>
>>54784717

trying to compile this program that is supposed to allow me to flash an ARM microcontroller

I don't really know what exactly it's supposed to do, Adafruit just linked to it as a Linux alternative to the popular NXP "Flash Magic"

what the fuck does this mean when I try to compile it?


nate@nate-Aspire-V5-571:~/Desktop/lpc$ make -f Makefile clean all
rm -f adprog.o lpcprog.o lpcterm.o lpc21isp
gcc -Wall -static -c -o adprog.o adprog.c
gcc -Wall -static -c -o lpcprog.o lpcprog.c
gcc -Wall -static -c -o lpcterm.o lpcterm.c
gcc -Wall -static -o lpc21isp lpc21isp.c adprog.o lpcprog.o lpcterm.o

>>
>>54785117
Those are just the compilation commands that the makefile is running. It's successful.
>>
>>54785136

so... how do I run it?
>>
>>54785117
>-static
>with -c
ebin
>>
>>54785117

More specifically it uses statically linked dependencies (but i don't see it linking any outside libs) and names the resulting executable lpc2lisp. The first command makes sure that any pre-cached object files are removed before compiling in case you have no clobber set (meaning preventing a program from overwriting an already existing file).
>>
>>54785099
rust:
x = asfgf();
y = f(asjkfi())();
asf(x, y);

asfgf().and_then(|x| asfkfi().and_then(|y| asf(x, y)))

>>54785112
Equivalent to
asfgf().iter().zip(f(asjkfi())).map(|(x, y)| asf(x, y));
>>
>>54785190
no, not equivalent because in haskell that works with any monad
>>
>>54785162
Have you tried killing yourself yet? It would increase the average IQ on Earth by at least 5 points.
>>
>>54785202
So does it in rust. Don't kill yourself just yet alright? The suicide hotline people are there for you.
>>
>>54785203
where's the love anon
>>
>>54785203

r-rude
>>
>>54785220
>implying Rust can do that transformation
>>
>>54785220
you just said
>Equivalent to
>asfgf().iter().zip(f(asjkfi())).map(|(x, y)| asf(x, y));

so it doesn't work for any monad because not every monad has zip
>>
>>54785190
There's more to monads than just IO.
>>
>>54785244
Every iter has zip, retard. It's literally the same thing. Every iter has zip because of the way traits work.

>>54785262
>backpedaling at the speed of light
>>
>>54785284
I'm not backpedaling, I've been saying that all along. You seem to think that do notation is equivalent to just writing imperative code, but that only applies if you're talking about IO which is essentially just sequencing operations with arbitrary effects.
>>
>>54785284
look, i said that this
>>54785112
is equivalent to this
>>54785099
and now you're saying it's not that at all in rust

also HO functions are nice but do syntax & comprehensions for monads is much fucking nicer and the point of the argument
>>
>>54785330
It is equivalent and you should move your butthurt over to ##haskell
>>
/dpt/-chan, dai suki~

>>54784749
// Animal factory
Animal newAnimal (string animalName)
{
if ("Pig" == animalName)
return new Pig(); // Pig is private
else if ("Dog" == animalName)
return new Dog(); // Dog is private
}


// User can have a pig and a dog without knowing these types.
Animal pig = newAnimal("Pig");
Animal dog = newAnimal("Dog");
>>
>>54784962
>what is websockets with socket.io
web shit
>>
>>54784729
the c one is a bit innacurate m8ey
>>
>>54785348
let newAnimal = function
| "Pig" -> new pig ()
| "Dog" -> new dog ()
>>
>>54785391
>using a string instead of an enum
>>
>>54785399
reading from a file
>>
>>54785410
separation of concerns
>>
>>54785399
an enum does mean a new type which add complexity
>>
>>54785419
?
>>
>>54785356
And?
>>
>>54785428
The factory doesn't give a shit about I/O, so it shouldn't take a string. Converting the string to the enum (and providing an appropriate error) is something that should be done elsewhere.
>>
>>54785399
>>54785427
Adding an enum defeats the purpose because they 're already subtypes
Read what I replied to
>>
>>54785444
>elsewhere
What do you mean elsewhere?
When did I say where it is?
There's literally no good justification for why the given factory is better than that
>>
File: Capture.png (4 KB, 324x154) Image search: [Google]
Capture.png
4 KB, 324x154
how do i go from this to getting all of the matched groups in an array?
>>
Hey guys, so I have these 2 modules that implement a plugin API (in C). The hosting application (everything running in the same address space) can pass messages from one module to another in the form of text strings. I'd like to use a more efficient communication method between my modules, so I figured I'd send from one module to the other a pointer to a function which they can later use as an alternative means of communication. The question is: how do I pass the address of the callback from one module to another using the text messaging interface and doing it in a standard, portable manner?
>>
>>54785444
factory is about eliminating type complexity in favor of interface complexity. with an enum, you still have to create a new type that you will have to maintain which ruins the purpose of a factory.
>>
>>54785462
>>54785533
I guess so. In that case, I would ensure that the factory isn't a partial function by returning
'animal option
or something.
>>
>>54785543
or the null object pattern.
>>
Hey /g/
I'm currently developing a chip-8 with SDL (may seem a bit 'much' but SDL is easy to use) and I've currently hit a wall.

I'm trying to implement this instruction:
Dxyn - DRW Vx, Vy, nibble
Display n-byte sprite starting at memory location I at (Vx, Vy), set VF = collision.

The interpreter reads n bytes from memory, starting at the address stored in I. These bytes are then displayed as sprites on screen at coordinates (Vx, Vy).
Sprites are XORed onto the existing screen. If this causes any pixels to be erased, VF is set to 1, otherwise it is set to 0.
If the sprite is positioned so part of it is outside the coordinates of the display, it wraps around to the opposite side of the screen.
See instruction 8xy3 for more information on XOR, and section 2.4, Display, for more information on the Chip-8 screen and sprites.

(http://devernay.free.fr/hacks/chip8/C8TECH10.HTM)

The problem is, I can't just manipulate the pixels directly since I'm scaling the screen

The function I have is slow, but it works in unit tests. I'm looking to see if there are any alternatives to just storing a separate set of pixels for this DRW function to use as a set of ints then just using bit shifts to get which pixels I should xor?
thx
>>
>>54785571
Which is a horrible, horrible alternative especially if you're already in a functional language.
>>
File: 1231231231.jpg (2 KB, 125x92) Image search: [Google]
1231231231.jpg
2 KB, 125x92
>>54785571
>null
>ever
>>
I think I'm too retarded for programming.
>>
>>54785582
>>54785583
i don't see how the language being functional or not is relevant at all, you only need ADTs for the null object pattern which has nothing to do with a null reference. it's time for /dpt/ to learn what is and how to abstraction.
>>
>>54785639
Literally just use an option type
>>
>>54785639
What is the "null object pattern", to you?
>>
>>54785626
You are probably using some low level garbage like C# or Java

Learn it with Haskell and enjoy programming

I cringe at the interview questions which ask some inane question about Java, c#, etc, which never happens in Haskell or another functional langauge. Since it wasn't made in the 70s
>>
>>54785651
>low level
>Java
these webshits should just leave /g/ forever
>>
File: haskell.png (12 KB, 225x321) Image search: [Google]
haskell.png
12 KB, 225x321
>>54785651
>which never happens in Haskell or another functional langauge
because you do literally nothing useful
>>
>>54785678
The Haskell runtime runs it, the Haskell code just rearranges pure functions
>>
>>54785669
>>low level
>not greentexting C#
kys
>>
>>54785669
Java is low level when you compare it to Haskell
>>
>>54785650
https://en.wikipedia.org/wiki/Null_Object_pattern#Java

an object with no side effects where the purpose actually is to replace a null reference.
>>
>>54785720
Why the everloving fuck would you use this when you can use option?
>>
>>54785731
kill yourself
>>
File: 1421680731602.jpg (157 KB, 500x500) Image search: [Google]
1421680731602.jpg
157 KB, 500x500
>>54785651
>garbage like C#
>>
>>54784773
yes, but not through F*. It could come around the same time as 1ML and be a joint effort between Microsoft and INRIA to stay relevant. Or maybe INRIA or Microsoft will just start "copying" features from each other in upcoming languages releases. I think that's more likely to happen from INRIA because Microsoft has already strayed away from it a ton in ways that would be hard to recover from (object system completely different, namespaces AND modules, etc.), so OCaml would introduce computation expressions, units of measure, quoted syntax, etc.
>>54784729
I like F* a lot, but I think its use cases are pretty limited when compared to other dependently typed languages
>>54784986
I don't think it has anything to do with systems programming but I still prefer it to Haskell
>>54785720
nigga wtf
>>
File: 1451346645505.gif (1 MB, 268x274) Image search: [Google]
1451346645505.gif
1 MB, 268x274
>>54785748
>>
>>54785579
here's the function in question
please don't laugh (pretty please)
void DRW_func(int n1, int n2, int nibble) { // since we have a scale we can't just XOR the sprite onto our drawing surface.
gObject* found = findGraphic(nibble); // findGraphic searches the graphic list for the address cpu.I. If found, returns the pointer
// if not, the address at cpu.I in the program is read for upto nibble bytes and pointer to the created graphic is returned.
int intersects = 0;
int x = cpu.v[n1], y = cpu.v[n2];
int posX = x/32, ofsX = x%32;

for (size_t i = 0; i < found->size; i++) {
// YES I KNOW THIS WON'T WRAP AROUND CORRECTLY YET. THAT'S NOT IMPORTANT RIGHT NOW
//tempRow just gets the pixel data we want.
unsigned int tempRow = (pixels[(y*2)+posX] << ofsX) | ((unsigned int)(pixels[(y*2)+posX+1] & (((int)0xFFFFFFFF << (8-ofsX)))) >> (8-ofsX));
if (tempRow & found->data[i]) {
intersects = 1;
}

unsigned int pixResult = tempRow ^ found->data[i];
pixels[(y*2)+posX] = (pixResult >> ofsX) | (pixels[(y*2)+posX] & ((int)0xFFFFFFFF << ofsX));
pixels[(y*2)+posX+1] = pixResult & ((unsigned int)0xFFFFFFFF >> (8-ofsX));
}

cpu.v[0xF] = intersects;
redraw();
}


I was using chars up until now, realized how stupid that was and so I switched to ints like 30 seconds ago but you get the idea.
Is there a faster way to implement this DRW function?
>>
>>54785750
pajeet pls
.net is ass
>>
File: haskelel2.jpg (745 KB, 1920x1080) Image search: [Google]
haskelel2.jpg
745 KB, 1920x1080
i want FP fags and python shitters to leave
>>
>>54785786
ignore the
(int)0xFFFFFFFF
please. That cast obviously doesn't belong
>>
>>54785731
you still have to check your options ! options are like null references but safer since the check is unavoidable. null objects completly avoid the need to check.

maybe(Animal) a = newAnimal(...);
if ( some(a) )
Animal aa = a.unpack();
aa.sound();


vs

Animal a = newAnimal(...);
aa.sound();


no, seriously, buy a book on design pattern and abstraction techniques, there nothing more important in programming.
>>
>>54785788
>.net is ass

It's great, though.
>>
File: 1421976784932.jpg (183 KB, 407x441) Image search: [Google]
1421976784932.jpg
183 KB, 407x441
>>54785800
>benis dd | comp xd = drop 2 dd
>>
>finally find out the address where Qemu ARM64 adds PCI devices
>the VGA PCI device doesn't assign a memory address to the BAR's so I can write to framebuffer
I feel like shooting shit up
>>
>>54785836
A maybe type is literally an option type you dumbass
>if >unpack
Just a more verbose, less safe version of this:

a |> Option.bind (fun a -> a.sound())
>>
>>54785836
>returning a "default" instead of explicitly making it an error to be handled
It may seem harmless there, but what if the class in question has a method that needs to return something useful? Return another default? Make another null object for the returned type?

It's not a good solution, it's literally a hack.
>>
So my Python project suddenly started throwing an error saying "cannot set attribute", something related to tuple attributes, it didn't happen before so I guess it has to do with updating Python version from 3.4 to 3.5 or so, what gives? Why would a minor version break compatibility?
>>
>>54785888
>he still hasn't realized
>>
>>54785880
>>54785871
>A maybe type is literally an option type you dumbass
i know, lel, the code is option vs null object.

heavy thunderstorm happening here. soz but i have to shut down the computah. bye.
>>
>>54785750
Use F# for .NET
>>
>>54785626
become a web / python developer
>>
>>54785909
>F#
even more disgusting than C#
>>
>>54785786
>>54785822
someone please respond
>>
>>54785898
That Python a shit? Yeah I know but there's no better alternative for rapid prototyping with such a large library support. There's Lua and Ruby I guess but Lua isn't suited outside of embedded engines IMO and Ruby is even worse than Python.
>>
>>54785922
Hello Pajeet
>>
>>54785899
Option type: add a new value to represent "null" in a safe way. In a non-shit language, you can easily pattern match and use combinators like map.
Null object: hijack a value to represent "null", change all operations accordingly.

Why you would ever use the latter when the first is available is beyond me.
>>
>>54785909 >>54785932
I love F# and shill it more than anyone else in /dpt/ but it makes slow as fuck programs

Even fparsec told people not to use computation expressions because they're significantly slower
>>
>>54785935
Curse of C
>>
>>54785948
F#edoras BTFO
>>
>>54785948
It's a good thing F# allows you to use imperative with OO then!

Which still works better than c# since you can use other features which are free
>>
>>54785935
Also, Rust is really great at this. If you have an Option over a reference or pointer, it simply uses null as None and non-null as Some. So there's no run-time overhead, and it's good with references especially because you can't otherwise introduce null.
>>
>>54785983
>F#
>C# with even more shit tacked on to it
>good
>>
>>54785983
It's still fucking slow, and if you're gonna do imperative there's no point in using F#
>>
>>54786012
? Options? Discriminated unions? Easy parallelism? Pattern match? None of these have impacted performance

No point to use C#
>>
>>54786004
You sound confused, C# is more verbose
>>
quick question
I have a visual studio 2015 enterprise licence (because of dreamspark program for students)

If I go to another pc which has installed enterprise edition and I login in VS with my MS account will I be able to use all the features?
>>
>>54786141
>le verbosity boogeyman
it comes at a huge expense of having countless ridiculous meme features
>>
File: 1441726869029.jpg (46 KB, 456x488) Image search: [Google]
1441726869029.jpg
46 KB, 456x488
Reading:
>Will ethnic minority voters decide EU vote?
>http://www.bbc.co.uk/news/uk-politics-eu-referendum-36384912

To see how immigrants will fuck up the UK's only chance to get out of the EU. Then I see this:

>Aftab Chughtai says "If it was fair and went all round the world, we could get the best people; computer programmers from India, nurses and doctors from Commonwealth countries where they speak our language and share our law. By staying in the EU, we don't have control of that."

>best people
>computer programmers from India
>mfw
>>
>>54786210
>meme features
not an argument
>>
>>54785521
Send help soon!
>>
>>54786269
kys
>>
File: 1461185606861.png (392 KB, 832x832) Image search: [Google]
1461185606861.png
392 KB, 832x832
>>54786213

I hope leave wins.
>>
>>54786280
this
>>
>>54785427
It reduces runtime latency and checks for the validity of the type at compile-time.
>>
>>54786131
I never said use C#, and a lot of those DO impact performance
>>
>>54786280
we all do
>>
>>54785626
This anon here. Should I learn all functions by heart or just writing what I want and search in the documentation the function which I need and someday I would remember all functions?
>>
>>54786280
I hope the EU falls apart if Britain leaves, but that's being a bit too optimistic
>>
How's my Java babby's first prime number sieve?

public static ArrayList<Integer> generatePrimes(int limit) {
ArrayList<Integer> primes = new ArrayList<>(limit);

for (Integer i = 2; i <= limit; i++) {
primes.add(i);
}

for (Integer n = 2; n <= limit; n++) {
if (primes.contains(n)) {
for (Integer mul = n + n; mul <= limit; mul += n) {
primes.remove(mul);
}
}
}

return primes;
}
>>
>>54786493
Can become better, it suffers on big numbers, Pajeet.
>>
>>54786493
how does it feel that this would be much shorter and easier on fucking C?
>>
>>54786493
p. inefficient, you know you don't have to check evens?
>>
>>54786454

If only we could all be so lucky.
>>
>>54786493
Instead of adding everything and removing, you should be selectively adding based on the contents up to that point.
>>
>>54786523
You're more than welcome to outclass my Pajeet-tier code.
>>
>>54786553
Huh, I didn't think of that. Thanks for the tip. I'll go try to do just that.
>>
>>54786592
Also, as >>54786532 said, you can "bake" the evens out of your loop.
>>
>>54785446
I hate how 4chan has become. Used to be people who had no clue would shut the fuck up. Of course, if they didn't know much but where convinced of a fact, they'd still post. But that was good. Now, people who literally have no clue just shitpost their untruth as if it were the word of god and they were an expert on the topic. If anyone dare to talk back, they're the ones who are ignorant!
>>
>>54785751
>joint effort between Microsoft and INRIA to stay relevant
I think you mean Microsoft Research. MSR and INRIA are both most relevant with no end of their relevance in sight, so I don't see why they would create a new language "to stay relevant".
>>
Is there a way to get some basic statistics about your executable in Visual Studio ? Like how long it takes to execute, amount of memory used, etc.
>>
>>54786554
meh, I'd rather shitpost and hit on traps
>>
Why wouldn't locations in memory store more than one byte?
>>
>>54786745
Because it would take more than one cycle to read an instruction then.
>>
>>54786745
Because you touch yourself at night.
>>
File: 1420500175412.jpg (438 KB, 900x2134) Image search: [Google]
1420500175412.jpg
438 KB, 900x2134
is this picture up to date? would you add/change something?
>>
>>54786822
>design patterns
>>
>>54786704
Not familiar with it but VS should have something like that. Try searching for "profiler".
>>
>>54786760
Isn't the entire point of 64-bit processors their ability to read 8 bytes at a time?
>>
>>54786880
No, you fucking retard.
>>
>>54786745
why would they
>>
>>54786912
Idk, that's why I was asking
>>
>>54786745
It's not about the "size" of "locations". It's about what you can address, which in most cases is any byte.
>>
File: programming_in_ada_2012.jpg (21 KB, 260x338) Image search: [Google]
programming_in_ada_2012.jpg
21 KB, 260x338
>>54786822
LYAH is meme shit. Since there's already another Haskell book listed, kick it out and replace with pic related.
>>
Hello all, I'm looking to learn some C# with no prior programming experience, to do some basic game modding for a game I've been very into for about a year now.

Not the most noble of ambitions, I know, but help me out /g/.

Checking out the wiki, I found "Accelerated C#" but as is that's a bit above my head, and it recommends starting with understanding C++ first. Problem; the wiki recommends C++ for everyone, the download is broken, the torrent isn't seeded, and the Gentooman library doesn't have that book either (atleast, not under C++ programming section)

So my question is, what beginner C++ resources would your recommend to someone with no prior experience programming, and what books would you recommend as followups?

Sorry if the question is a little broad.
Also posting anime, I hear you guys like that around here.
>>
>>54787091
Ivor Horton's Learn C++
>>
>>54787091
http://lmgtfy.com/?q=c%2B%2B+tutorial
>>
File: gauss.png (26 KB, 1454x290) Image search: [Google]
gauss.png
26 KB, 1454x290
I'm trying to generate a gauss filter but I'm not sure what I'm doing wrong.
The kernel should sum up to 1 but it's coming up short.

public class Gauss {

public static double[][] generateKernel(double sigma, int radius){
int l = radius*2 + 1;
double[][] kernel = new double[l][l];

double a = 1.0/(2 * Math.PI * sigma * sigma);
double b, sqrA, sqrB;

for (int i = 1; i <= kernel.length; i++) {
for (int j = 1; j <= kernel.length; j++) {

sqrA = (i - (radius + 1)) * (i - (radius + 1));
sqrB = (j - (radius + 1)) * (j - (radius + 1));
b = -((sqrA + sqrB)/(2 * sigma * sigma));
kernel[i-1][j-1] = a * Math.pow(Math.E, b);
}
}

//testing
double sum = 0;
for (int i = 0; i < kernel.length; i++) {
for (int j = 0; j < kernel.length; j++) {
sum += kernel[i][j];
}
}
return kernel;
}

public static void main(String[] args) {
Gauss.generateKernel(1.4, 2);

}
}


Can someone give me a hint on how to fix this?
>>
>>54787091
Listen to me carefully and trust me since im a computer engineering grad student. I have actually done what you're trying to do.

1. Don't listen to /g/, most people have no real world experience in developing software
2. Don't start with C/C++
3. Start with Python and use it until you understand the basics like methods (dont OOP yet), then move on to C#
4. The fastest and best way to actually learn programming is to take a uni course AND studying programming on your spare time as well
5. C++ is a clusterfuck, not beginner friendly, you wont need the extra performance if you can't even code


Good luck anon
>>
>>54785651
>I cringe at the interview questions which ask some out-of-my-reach question about languages useful in real-life environments
>>
>>54786822
It's slightly out of date. (I'm the guy who updated it btw.)
>>
>>54787203
>don't start with C++
>start with python

Your degree is worthless.
>>
Which CI methodology are you applying to your projects?
>>
There is no reason to use tabs in the current year unless you're working on a codebase that already uses tabs for indentation.
>>
>>54787203
kys
>>
>>54787335
XP is the only right answer
>>
>>54787343
Why should I use spaces instead of tabs for indentation?
>>
>>54787333
>he thinks uni is about learning a programming language
top kek
>>
>>54787343
KYS
>>
>>54787343
>hit this button 4 times instead of using this button that'll do it for you
Yeah, nah
>>
>>54787357
People that learn Python are scarred coders for life.
>>
>>54787348
Because one day you'll have to edit a file with notepad.
>>
File: 1464203119912.jpg (30 KB, 367x390) Image search: [Google]
1464203119912.jpg
30 KB, 367x390
>>54787187
>using imprecise arithmetic
>expecting precise results
>>
>>54787370
Forgot to say: People who write code with notepad need not reply.
>>
>>54787331
there's no python on the list I see.
>>
>>54787379
Oh, will I?
>>
>>54787388
What would you recommend?
>>
>>54787370
>hit tab once and you get 4 spaces
Yeah, nah
>>
>>54787377
>coders
Rajeeet please leave /g/
>>
>>54787389
Oh you can't code outside of your comfort zone? Do you really think you're a coder?
>>
>>54787379
>>54787389
I actually do if I need to make a few quick changes to a Powershell script at work
>>54787397
werks on my machine
>>
>>54787347
I mean, how do you handle it? For example, preparing a Github -> Travis -> Bintray life cycle for Java libraries.
>>
>>54787203
This.
In my uni they start with C++ the first course, it's fun to see half the students repeat.

That said you should learn C++ anyway, you understand everything else much better if you know C++.
>>
>>54787395
I have no idea about programming, I'm afraid I can't help you on this task
>>
>>54787416
Does windows not come with a proper code editor in the current year?
>>
>>54787187
Why did you define a, b, sqrA and sqrtB? They are not saving any multiplications.
Also, don't ever use Math.pow ( Math.E, b ). There's a highly optimized function specifically for this, Math.exp (b).

Anyway, how short does it come up?
>>
>>54787439
I said quick changes, otherwise I use Powershell ISE for more involved shit
>>
>>54784717
A social network.

Been having trouble getting the signup system done, though. Was fucking around with one of the queries for like an hour.

>Then I realized I added a '$' in an array index, so I was trying to insert a null into a non-null data column...
>>
>>54787436
That's what you get for using Python.
>>
>>54787423
I totally agree with you about that everyone should learn C++ at some point.

But I think that learning how to think like a programmer and logically is the most important in the beginning instead of fiddling around with syntax errors
>>
>>54787449
Why use the worst tool at hand for quick changes?
>>
>>54787475
Because it literally doesn't matter what I use at that point
>>
>>54787459
I do not use python, I have no idea of writting code. I don't use any language. but I'll probably start with python
>>
>>54787486
not him, but why are you in this thread, then?
>>
>>54787444
>Why did you define a, b, sqrA and sqrtB? They are not saving any multiplications.
Oh yeah, it's just so I can read it better for now. I'll clean it up when I get this working.

>There's a highly optimized function specifically for this, Math.exp (b).
Ah thanks. I'll use that.

>Anyway, how short does it come up?
I'm getting just under 0.87
>>
>>54787379
Tabs working on notepad... check.
Automatic spaces working on notepad... failed.

There is no reason to use spaces over tabs, with tabs you can adjust space and it's only one click to insert AND delete, and you can't have indentation inconsistences.
>>
>>54787498

Sometimes I ask general questions, other I just read the discussions and try to learn something.

that's how I get to know some languages, wich ones seems to be more important or widespread (C, C++). Some days I understand some little thing, other times I understand nothing
>>
>>54787528
int main(int argc, char** args){printf("Yeah, you should really pick up a book, mate. \nTry a \"For Dummies\" one off Amazon for Kindle.\n");return 0;}


Also, that coding style was absolutely disgusting, lmao.
Quick question: Anyone in here actually write code like that above? I occasionally inline my blocks if they're short.
>>
File: integ.png (22 KB, 487x324) Image search: [Google]
integ.png
22 KB, 487x324
Just a simple integration function block:

(* This function block implements integration over time. *)

(*Check reset value and assign output*)
Q := not(R1);

(*On reset, assign initial value to output*)
if (R1 = true) then
out_val := X_0;

(*On run, compute integral*)
elsif (RUN = true) then
cycle_time := TIME_TO_REAL(CYCLE);

out_val := out_val + cycle_time * XIN;

end_if;

(*assign output value*)
XOUT := out_val;
>>
Pic highly related


#include <stdio.h>

int main(void){
int y;

do{
printf("How many y's did she type? ");
scanf("%d", &y);
} while(y < 0);

printf("meaning: ");

switch(y){
case 0:
printf("\"he\"; pronoun; used to refer to a man, boy, or male animal previously mentioned or easily identified.");
break;
case 1:
printf("friends");
break;
case 2:
printf("I think I like you");
break;
case 3:
printf("Take the hint, dumbass");
break;
case 4:
printf("let's fuck");
break;
default:
printf("I'm drunk");
break;
}

return 0;
}

>>
File: heyyy-1.jpg (50 KB, 550x290) Image search: [Google]
heyyy-1.jpg
50 KB, 550x290
>>54787627
>>
>>54787580
Code structure should be consistent.
>>
>>54787580
I have a lot of books already, the problem is that I'm confused. People say that the best code depends on what you want to do with it. and then start raging about some language being superior to others. at this point, I get lost because I can't understand a thing.

I want to learn how to use the terminal, then I'll probably go with R or python. R because it seems pretty good for statistics, and Python because everything I read tells it's a easy language.
>>
>>54787637
Here's a protip: don't browse /dpt/ if your'e trying to learn programming. It should really be called /dtprst/ for daily tangentially programming related shitposting thread. Make your own threads or post in others if you want to learn. (or even better just use reddit)
>>
>>54787468
Python tries so hard to be a simple special snowflake that it actually makes shit more confusing IMO. The basics of C++ / Java / C# / etc are the same. No need to go full retard and learn Python or BASIC or whatever.
>>
>>54787203
>Don't listen to /g/
Guess I won't be listening to you then~

>>54787121
Will check that out

>>54787128
>Book = Tutorial
lmao
Also I guess there's no need for /g/ made recommendation charts and so on to exist at all since Google is such a great resource (you're a faggot btw).
>>
class newChat:
def initiate(self, threadName, proxy):


threading.Thread(target=chatOne.initiate('thread one: '))

TypeError: request() got an unexpected keyword argument 'proxy'

Anyone know what I'm doing wrong?
>>
>>54787580
I inline conditionals and even loops every time I can (as long as they are 1 instruction only), also function definitions if they are on the header.
Also most times I do this:
if (n==0) return doSomething();
if (n==1) return doSomethingElse();
if (n==2) return doSomething(b);
>>
>>54787520
Tabs are 8 spaces long on notepad
>>
>>54787622
What is that diagram?
>>
>>54787668
I mean,
threading.Thread(target=chatOne.initiate('thread one: ', proxy))

I've tried a million other ways, Not sure why it's so difficult, never done it with classes before.
>>
>>54787634
I know, but if it's just like an if-else, where each one only does a return or something, I switch from
if(){
//things
}else{
//other stuff
}


to something like
if(){stuff}
else{other stuff}


>>54787637
Well, they are right that the best code depends on what you're doing, but only a few languages, specifically web and shell (or Visual BASIC, if you decide to learn that for whatever reason...), can only be used in certain environments. Most other languages can be used pretty liberally.

My goto languages are C/C++ for system-related code, C++ or Java for games (Java if it's web), and PHP + JS for regular web.

And I use AutoHotKey for macros.
>>
>>54787662
I estimate you will give up on C++ before tomorrow
>>
>>54787686
Yeah, yeah! That's what I was talking about:
>>54787716
>>
>>54787520
>There is no reason to use spaces over tabs, with tabs you can adjust space and it's only one click to insert AND delete, and you can't have indentation inconsistences.

Except that you can't control how tabs are displayed in every IDE, browser or application, while spaces usually keep the same rough proportions (a space has the same size, or similar, to any character).
>>
>>54787662
http://it-ebooks.info/
>>
>>54787723
Nahh if he is really interested on it he can last a week.
>>
Project euler number 5, this language is pretty cool

isnorem x y
| y == 1 = True
| x `mod` y /= 0 = False
| otherwise = isnorem x (y-1)

norem = [x | x <- [20,40..], isnorem x 20]

main = print $ norem !! 0


I am really bad at naming variables
>>
>>54787696
It's a graphical representation of the function block. It contains the code I wrote.
>>
>>54787091
C++ for Dummies, 6-in-1.
OR
Beginning Programming with C++
>>
>>54787753

Everybody should just use full-width tabs. Problem solved.
>>
>>54787379
no you don't and it still works fine with notepad just that they're 8 wide
>>
>>54787803
Not that Anon, but you're right... Why IS Notepad tabs so wide?
>>
>>54787764
A list comprehension is pretty overkill for that. Use filter instead, and consider switching around the arguments in
isnorem
so you can write this:
norem = filter $ isnorem 20
>>
What makes this insertion sort (I made this)
(define (insert x lst)
(if (null? lst)
(list x)
(let ((y (car lst))
(ys (cdr lst)))
(if (<= x y)
(cons x lst)
(cons y (insert x ys))))))

(define (insertion-sort lst)
(if (null? lst)
'()
(insert (car lst)
(insertion-sort (cdr lst)))))

So much slower than this sort
(define (insert x lst)
(if (null? lst)
(list x)
(let ((y (car lst))
(ys (cdr lst)))
(if (<= x y)
(cons x lst)
(cons y (insert x ys))))))

(define (insertion-sort lst)
(if (null? lst)
'()
(insert (car lst)
(insertion-sort (cdr lst)))))

?
>>
>>54787820
I forgot filter existed, thanks

Don't you have to then write out the type for isnorem, which is less clean than just passing both arguments?
>>
>>54787821
Wait, I fucked up pretty hard
(define (remove-i lst index)
(define (rindex oldlst newlst iteration)
(if (= iteration index)
(append newlst (cdr oldlst))
(rindex (cdr oldlst)
(append newlst (list (car oldlst)))
(+ iteration 1))))
(rindex lst '() 0))
(define (insertionsort arg)
(define (iterkeys key before after)
(cond ((null? before) (append (list key) after))
((< key (last before))
(iterkeys key
(remove-i before (- (length before) 1))
(append (list (last before)) after)))
(else (append before (list key) after))))
(define (iter key before after)
(cond ((null? before) (iterkeys key after '()))
(else (iter (car before)
(cdr before)
(iterkeys key after '())))))
(if (< (length arg) 2)
arg
(iter (list-ref arg 1) (cddr arg) (list (car arg)))))

This is the one I wrote for the first one
>>
>>54787842
Nope, it'll still be inferred.
>>
>>54787847
Firstly, I was looking at that like "Where the FUCK is the ONE instruction difference here?!"

I was like "These are COMPLETELY identical, what am I MISSING?!"

Secondly, what language is that?
>>
>>54787891
Yeah, like I said, I fucked up; actual first one is here >>54787847
Language is MIT Scheme
>>
File: 1459871451056.jpg (7 KB, 230x215) Image search: [Google]
1459871451056.jpg
7 KB, 230x215
>>54787651
>tfw /dpt/ is not DPT anymore
>>
>>54787847
A big thing I can glean from that mess is that you're using lots of append calls. Appending A to B is O(n) in the length of A.
>>
>look in freezer
>find Trader Joe's Orange Chicken and Fried Rice
It's gonna be a good lunch today boys
>>
>>54787906
yeah, no I got that part about fucking up.

heh, I've never seen that before.
It looks WAY too syntactical for me.
>>
>>54787779
It isn't matlab or something like that?

>>54787816
Because tabs are 8 spaces and are not used for indentation, but for quick and dirty alignment code.
>>
>>54787939
Retard land is that way >>>/reddit/
>>
>>54787917
Sorry, in the length of B. Still, it's not cheap.
>>
>>54787939
You know... I vaguely remember a grade school teacher telling me not to use tabs for indentation...

I thought they were just being a dick.
>>
>>54787939
Tabs are used for indentation and NOT alignment you fucking retard.
>>
>>54787945
back to >>>/prog/
>>
What should I use nowadays if i need performance?
Rust? Go?
Or stick to C/C++?
>>
>>54788050
Rust, unless you need a library without bindings yet and you don't want to write them yourself.
>>
File: Screenshot_2016-05-28_21-51-21.png (33 KB, 915x249) Image search: [Google]
Screenshot_2016-05-28_21-51-21.png
33 KB, 915x249
Writing yet another binary serialization library
>>
>>54788068
would you mind to elaborate?
why exactly is rust better than, say, C++?
>>
>>54788050
C++14
>>
>>54788050
Rust. Go is rather slow (not python-slow at least), and is as easy and comfortable to use as C, i.e. it's suitable for precisely no applications. Also, it has a forced GC.
C as usual is the wrong choice for the job, no matter what the job is.
C++ is a good choice on account of its maturity and speed but not much else.
>>
>>54788093
It's well-designed, has good type inference, and you can actually rely on its guarantees.
>>
File: Gentoo.png (7 KB, 720x400) Image search: [Google]
Gentoo.png
7 KB, 720x400
http://tour.dlang.org/

This is p. cool
>>
>>54788095
>still no modules
>templates are shit
>reflection is shit
>tons of boilerplate
>>
>>54788050
C++, if you REALLY need performance. Go if ~2 times slower than C++ and the occasional single digit millisecond GC pause is fine. Rust is far too thin on available libraries at the moment, in my opinion.
>>
>>54788093
Rust is significantly cleaner, supports much higher-level constructs, ensures no memory-related bug can possibly exist in your program at compile time, doesn't need a runtime, is extremely small if you use libcore instead of the whole libstd, and performs really well (it has roughly the same performance as C++ with clang). In the real world, you can compare e.g. leaf with caffe. Caffe is massive, built by hundreds of engineers, in C++, and is mature. Leaf is just starting, developed by a dozen engineers, and written in rust. Leaf still manages to be faster on the featureset that it shares with caffe.
>>
HOW DO I FIND THE LOCATION OF THE TMP DIRECTORY GCC IS USING

HOW DO I DELETE IT

HOW DO I MAKE IT USE A DIFFERENT DIRECTORY
>>
>>54788148
I find rust has more meaningful libraries than go right now, e.g. go might have 10 libraries for the same useless task whereas rust has just a couple libraries for each task, and each library is more complete and meaningful, such as "a binary tree library" v.s. "a tree library which includes binary and non-binary trees, self-balancing and dumb trees".
>>
>>54788142
I may not be able refute your arguments, but IMBO C++ is the best option here.
>>
This is valid C++ code.
%:include <iostream>

int main(int argc, char *argv<::>)
<%
if (argc > 1 and argv<:1:> not_eq NULL) <%
std::cout << "Hello, " << argv<:1:> << '\n';
%>
%>
Thread replies: 255
Thread images: 25

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

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.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.