[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: 17
File: dpt.png (389 KB, 934x1000) Image search: [Google]
dpt.png
389 KB, 934x1000
What are you working on, /g/?
>>
first for python :D
>>
My erection
>>
What's your favorite git hosting service /dpt/?
>>
Pi has a finite number of digits.
>>
Reminder: OCaml is your god. OCaml is your salvation.
>>
>>52564337
Alright m8, keep up the pretence. It's pretty clear that you're an idiot.
>>
>>52564419
The fact that you've never compared by address is clear sign you've never worked with any serious code
>>
File: LOL.png (157 KB, 642x834) Image search: [Google]
LOL.png
157 KB, 642x834
>>
>>52564414
>/sci/
>>
File: k.jpg (154 KB, 604x900) Image search: [Google]
k.jpg
154 KB, 604x900
What's your favourite programming language, /dpt/?
>>
>>52564419
OK pajeet.
>>
How can I declare the types of scoped constants in haskell?

Has-type notation doesn't seem to work inside a function.
>>
>>52564437
>feminist
>funny
pick one
>>
File: 1452960196836.jpg (54 KB, 418x359) Image search: [Google]
1452960196836.jpg
54 KB, 418x359
>>52564437
not this again
>>
>>52564439
I really like Go. That said, I'm starting to get more and more annoyed by those fucking error checks the more I use it.
>>
>>52564439
based php
>>
>>52564419
lol this is ridiculous. Are you aware, assembly, the most fundamental language that isn't machinecode has compare instructions all over the place?
>>
>>52564467
Go: all the flaws of C without any of its benefits, none of erlang's benefits beside channels. Add a set of custom flaws to the mix, and you have yourself a Go.
>>
>>52564437
Man this shit sure triggers me

>>52564360
Lazily learning functional programming at a corporate internship where I baaaaaarley get any work

Life's gud
>>
>>52564419
In a game, if you want to see if the item/enemy you're targeting is the same item/enemy something or someone else is targeting, you would compare by address. Comparing references should NOT automatically compare the values of the thing they're pointing to. That is idiotic and will leave people wondering why their code doesn't work. To say comparing by value is the only important way to compare 2 things is clear sign you've only ever dealt with small scripts
>>
rate my bubblesort
void bubblesort(unsigned *arr, unsigned size)
{
while (!is_sorted(arr, size))
{
unsigned i;
for (i = 0; i < size - 1; i++)
{
int state = compare(arr[i], arr[i+1]);
if (state > 0)
swap(arr+i, arr+i+1);
else
continue;
}
}
}
>>
>>52564514
>barley
I oat to report you for this.
>>
>>52564525
Presumably, is_sorted is doing a full array traversal on each iteration, making this algorithm O(n!) in time complexity instead of the usual O(n2).

So it's fucked.
>>
File: juu.gif (992 KB, 500x376) Image search: [Google]
juu.gif
992 KB, 500x376
>tfw people call me a noob for using Ubuntu

I don't want to spend an hour setting everything up in Arch, ok?
>>
>>52564510
There're some neat features in Go like a GC, reflection, goroutines, channels, easy cross compilation and a static compiled ABI.
It's a shame that they made some horrible mistakes by not using generics (muh generic dynamic array) and a proper way of handling errors.
>>
>>52564390
My vps
>>
>>52564582
noob
>>
>>52564582
It's faster to have a working arch than a working buntu.
>>
>>52564525
Now do it using recursion.
>>
>>52564565
is_sorted() returns 0 as soon as it finds an unsorted pair
worst case is it goes through the whole array without a hitch and returns 1.
>>
>>52564582
ubuntu is fine, just don't use unity
>>
>>52564611
Ok, mate.
>>
>>52564443
Anybody?
>>
>>52564609
>worst case is it goes through the whole array without a hitch and returns 1.

Hence why that step is O(n)
>>
>>52564439
haskell :3
>>
>>52564609
You could count how permutation you do each pass. If it's zero your list is sorted.
>>
>>52564656
>>52564647
what's a better way to do it then?
int is_sorted(unsigned *arr, unsigned size)
{
int sorted = 1;
unsigned i;
for (i = 0; i < size - 1; i++)
{
int state = compare(arr[i], arr[i+1]);
if (state > 0)
return 0;
}
return sorted;
>>
How does this logic check out for a the Farmer, Wolf, Goat, Cabbage problem?

farmer = 8
wolf = 4
goat = 2
cabbage =1

        virtual bool isGoalState(){
return (state & 8 && state & 4 && state & 2 && state & 1);
}

virtual int* succStates(){
int *states = new int[8];
int i = 0;

if(!(state & 8)){
//farmer is west
if(( (state & 4) || (state & 2) ) && ( (state & 2) || (state & 1) )){
states[i] = state + 8;
i++;
}

if(!(state & 4) && !(!(state & 2) && !(state & 1))){
//wolf is west
states[i] = state + 12;
i++;
}
if(!(state & 2)){
//goat is west
states[i] = state + 10;
i++;
}
if(!(state & 1) && !(!(state & 4) && !(state & 2))){
//cabbage is west
states[i] = state + 9;
i++;
}
}
>>
>>52564680
I left some code out

        virtual int* succStates(){
int *states = new int[8];
int i = 0;

if(!(state & 8)){
//farmer is west
if(( (state & 4) || (state & 2) ) && ( (state & 2) || (state & 1) )){
states[i] = state + 8;
i++;
}

if(!(state & 4) && !(!(state & 2) && !(state & 1))){
//wolf is west
states[i] = state + 12;
i++;
}
if(!(state & 2)){
//goat is west
states[i] = state + 10;
i++;
}
if(!(state & 1) && !(!(state & 4) && !(state & 2))){
//cabbage is west
states[i] = state + 9;
i++;
}
}

if(state & 8){
//farmer is east
if(( !(state & 4) || !(state & 2) ) && ( !(state & 2) || !(state & 1) )){
states[i] = state - 8;
i++;
}

if(state & 4 && !(state & 2 && state & 1)){
//wolf is east
states[i] = state - 12;
i++;
}
if(state & 2){
//goat is east
states[i] = state - 10;
i++;
}
if(state & 1 && !(state & 4 && state & 2)){
//cabbage is east
states[i] = state - 9;
i++;
}
}

while(i < 8){
states[i] = -1;
i++;
}

return states;
}
>>
>>52564439
It's Idris now I guess, but it's nowhere near production ready at this point, so I'd have to go with OCaml for getting actual work done and Scheme as a close second.
>>
>>52564609
void bubblesort(uint32_t *arr, size_t size)
{
int sorted;
int state;
size_t i;

do {
sorted = TRUE;

for (i = 0; i < size; ++i) {
state = compare(arr[i], arr[i+1]);
if (state > 0) {
swap(&arr[i], &arr[i+1]);
sorted = FALSE;
}
}
} while (!sorted)
}
>>
>>52564676
void bubblesort(unsigned *arr, unsigned size)
{
int n = 1;
while (n)
{
n = 0;
unsigned i;
for (i = 0; i < size - 1; i++)
{
int state = compare(arr[i], arr[i+1]);
if (state > 0)
swap(arr+i, arr+i+1);
++n;
else
continue;
}
}
}
>>
>>52564676
Don't use that function at all. You know bubbles sort is done when it goes through the whole list without swapping.
>>
>>52564676
template <class d>
void swap(d& one, d& two)
{
d d;
d = one;
one = two;
two = d;
}

//Works with Arrays and Vectors
template <class d>
void bubblesort(d &temp, int n)
{
bool sorted = false;
int i = 0, j = 1;

while (!sorted) {
sorted = true;
for (i = 0; i < n - j; i++) {
if (temp[i] > temp[i + 1]) {
swap(temp[i], temp[i + 1]);
sorted = false;
}
}
j++;
}
}
>>
>>52564680
If you're going to do binary comparisons, then use the notation. Your code looks a mess
>>
>>52564713
I guess this would be better with a do-while, but you get the point
>>
>>52564733
are you talking about bit shifting? You can't do bit shifts if trying to change the bits the way I am.
>>
>>52564694
>>52564694
virtual int* succStates() {
int *states = new int[8];
int i = 0;

if (!(state & 8)) {
//farmer is west
if (( (state & 4) || (state & 2) ) && ( (state & 2) || (state & 1) ))
states[++i] = state + 8;
//wolf is west
if (!(state & 4) && !(!(state & 2) && !(state & 1)))
states[++i] = state + 12;
//goat is west
if (!(state & 2))
states[++i] = state + 10;
//cabbage is west
if (!(state & 1) && !(!(state & 4) && !(state & 2)))
states[++i] = state + 9;
}

if (state & 8) {
//farmer is east
if (( !(state & 4) || !(state & 2) ) && ( !(state & 2) || !(state & 1) ))
states[++i] = state - 8;
//wolf is east
if (state & 4 && !(state & 2 && state & 1))
states[++i] = state - 12;
//goat is east
if (state & 2)
states[++i] = state - 10;
//cabbage is east
if (state & 1 && !(state & 4 && state & 2))
states[++i] = state - 9;
}

while (i < 8)
states[++i] = -1;

return states;
}
>>
>>52564766
I'm talking about using binary notation rather than 8 4 2 1
>>
>>52564482

How useful is it to learn Assembly. I took a systems class at my school and I hated it, but mostly had to do with professor being a dildo. I took the second level and I loved it, but it was mostly C stuff and the prof was really good (hard assignments but gave good lectures and helped students along the way without giving out answers).
>>
>>52564588
>no dynamic libraries
This is enough to stay the fuck away from go
>muh return-value errors
And this should kill any remaining supporters.
>>
>>52564467
I want to try it out, but have no idea what I could make with it that is useful and that doesn't need third-party frameworks.

Same with C actually, I have wanted to play with it, but I don't want to just make shitty tutorial programs.
>>
>>52564792
I don't think that will make that big of a difference. How hard is it to visualize 8, 4, 2, 1 in bits
>>
Threadly reminder that you should not refer to the act of programming as coding. It is improper and makes you look like a 16 year old

You are a programmer, not a coder

Software Alchemist is GOAT
Developer is okay
Magician is okay
Software Magus is okay
Software Engineer is okay
Software Architect is okay
Code Guru is okay


Archmage is reserved for only the most senior of programmers

Writing in HTML and CSS is not programming, therefore it should be referred to as designing
>>
>>52564713
won't this terminate on the first loop regardless of what happens?
>>
>>52564796
Essentially useless outside of writing compilers and vulnerability analysis.
>>
>>52564810
Doesn't matter what you think. You had 2 choices and you chose the shit one
>>
>>52564819
I generally refer to myself as a Datamancer, due to the nature of my work.
>>
>>52564819
here's your reply lonely looser
>>
>>52564809
Most folk use Go for network heavy programs.
Maybe some crawler stuff.
>>
>>52564819
If it's not Computer Magus, it might as well be called Rajesh.
>>
File: 1443657082930.jpg (65 KB, 567x561) Image search: [Google]
1443657082930.jpg
65 KB, 567x561
>>52564819
>>
>>52564824
How so? If any swaps occur, n will be a nonzero number by the time it reaches the top of the while loop again
>>
>>52564680
>( (state & 4) || (state & 2) ) && ( (state & 2) || (state & 1) )
can be collapsed to:

(state & 6) && (state & 3)

>!(!(state & 2)
what's with the double negation?
might have made sense if you needed to force to be exactly 0 or 1, but since you're just testing the 'truthiness' of it it's not needed.
>>
>>52564826
It's actually better because I don't need to use a different data type
>>
>>52564437
I was with her until she said white man. Now I realise women in the workplace are the enemy.
>>
>>52564846
I've seen it mentioned, yeah. Still have no idea what I'd do with that kind of stuff in my free time, but I guess it's a starting point.
>>
>>52564877
6 | 3 == 7
so it could be further reduced to (state & 7)
>>
>>52564439
Forth for the pure enjoyment of playing around in it (especially implementing it from scratch without even an OS or kernel).
C for getting practical things done.
>>
>>52564588
>reflection
Not as awesome as you think. In fact type erasure and reflection are the shittiest way to make type generic code. AND the programmer has to do that unsafe shit by himself instead of the implementation handling it for him. Go is somehow worse than Java in that regard. They better add reification soon or I'm going to shoot myself.
>>
>>52564903
The only people who use Go are those who enjoy 2k lines of backtraces that actually don't say anything when a connection closes unexpectedly.
>>
>>52564912
>C
>getting practical things done
Choose exactly one.
>>
>>52564894
You don't have to use a different data type for binary, what the fuck are you on?
>>
>>52564909
>6 | 3 == 7
>so it could be further reduced to (state & 7)
No, that would be: (state & 6) || (state & 3)
which would fire if any of the lowest for bits was set.
(state & 4) || (state & 2) ) && ( (state & 2) || (state & 1)
means he wants either of the two upper bits AND either of the two lower bits, which is only 4 total combinations out of the 15 possible from 4 bits (yours would accept all 15 combinations).
>>
>>52564923
I choose both.
>>
>>52564916
It's always good to know what hipsters are using, even if it's shit.
It could even get good in a few years.
>>
>>52564819
> I'm a code slinger
> My main language of choice is Hypertext Markup Language and Cascading Style Sheets, or HTML plus CSS as I've taken to calling it.
>>
>>52564986
>It could even get good in a few years.
Not while pike's at the helm.
>>
>>52564914
True, reflection is used in places where generics could've been a better solution. The interface{} is a dirty hack imo.
Why is it so hard to make a decent programming language senpai? C++ is std::ugly, C# is the pet of MS and D is too obscure.
>>
>>52564923
You can get practical things done if you aren't an idiot.
>>
>>52564925
How do you use bit notation? The only way I see is to use a new type or use c++14 which I can't.
>>
>>52564858
Well I guess that's a better way of putting it.
Thanks anon!
>>
>>52565017
So what are you doing here?
>>
So does anybody have any idea why this code isn't working?
main ∷  IO ()
from ∷ String → [Int]

from = map fromEnum

main = do
print "Enter message: "
message ← readLn
print "Enter shift number: "
n ← readLn
print $ map toEnum∘(+n)∘from message
>>
>>52565011
literally 0b for bit and 0x for hex
>>
>>52565010
Yeah, like hello world, and fizzbuzz, and high/low, and even, if you're an expert, perhaps heads or tails! What a fantastic language!
Now if you'll excuse me, I have real work to do, which involves performing expensive computations across 27 machines of 4 GPUs each.
>>
>>52565011
Congrats, you're clinically retarded!
>>
>>52565026
No problem, I'd just recommend rewriting it as a do-while and putting
int n = 0;

inside the do-while. It's much cleaner that way
>>
>>52565031
>→
>←
>∘
>>
>>52565079
Ignore the graphical-syntax sugar, it's there for readability.
>>
>>52565048
>Now if you'll excuse me, I have real work to do, which involves performing expensive computations across 27 machines of 4 GPUs each.
How about 16 000 machines, each with two xeons and three xeon phis for a total of ~3 million compute cores?
It's running on a platform written in C.
>>
Think I'll go watch anime.

Any suggestions?
>>
>>52565048
I'd say the Linux kernel is pretty practical :^)
>>
>>52565104
Dagashi Kashi is bretty gud.
>>
>>52565104
C and Python or Ruby
>>
>>52565001
Go has a good base: sane OOP, good GC, excellent routine scheduler and features, but the designers decided that compiler complexity outside of those areas is not acceptable and made the rest of the language shitty. I'm sure if someone forked Go and made 'Good' that it would be God's chosen language.

For right now, C++ is ugly and complicated, but feature-wise I think it's very good for a systems language.
>>
how do i set up dlna on linux?
>>
>>52565074
I tested both on an array of size 214748364 and their performance is nearly identical.
>is_sorted
real    0m0.410s
user 0m0.340s
sys 0m0.076s


>while (n)
real    0m0.414s
user 0m0.340s
sys 0m0.076s
>>
>>52564529
not this shit a grain
>>
>>52565169
sudo apt-get install minidlna
>>
>>52564819
Code monkeys who glorify their shitty webdev jobs with those titles make me sick. I know someone who calls himself "Code Whisperer", after teaching himself basic Web languages and memeshit like node.js.

And "software engineer" is reserved for actual engineers.
>>
>>52565031
define 'isnt working'
>>
>>52565171
With an actual randomly generated array?
>>
>>52565189
engineers are held liable if their creations collapse and kill people

software engineers aren't, because they're not really engineers
>>
way to write a lua function out inside a table?
>>
>>52565201
let me try that

i was just sorting garbage in memory
>>
>>52565193
It throws compile errors no matter how I phrase it.
The code as posted gives:
Couldn't match expected type 'a0 -> [Int]' with actual type '[Int]'
Possible cause: 'from' is applied to too many arguments
In the second argument of '(.)', namely 'from message'
In the second argument of '(.)', namely '(+ n) . from message'
>>
>>52565149
Go devs are completely autistic about compile time. Adding things like generics increase compile time and that's a no-no.
Another thing I find missing is a file scope for defining constants.
>>
>>52565218
Like this?
{function(x, y) return x + y end, function(x, y) return x - y end, ... }
>>
>>52565232
Here you go - the from function was tripping you up.
Prelude> map (toEnum . (+1) . fromEnum) "asdf" :: String
"bteg"
>>
>>52565210
Whatever you say, code monkey. If software engineers were the same as your kind, they wouldn't get higher starting salaries than other engineering fields.
>>
>>52564588
Generics are not a big deal for people writing actual programs because you simply don't care about making things generic.
For reusable libraries generics can be nice, but for libraries you can use code generation to stamp out the versions you need (you can bake it into the build/fetch part since you need to do at least that one extra step for getting 3rd party libs anyway).
>>
>>52565316
this, put parenthesis around those functions separated by dots
>>
>>52565246
D's generics don't slow it's compilation down. In fact, I'm pretty sure DMD compiles faster than Go's reference compiler.
>>
>>52565103
>cpu
I laughed
>task that isn't strongly bandwidth-bottlenecked
You're hilarious!
>C
I bet it's python, but you call it C because cpython is written in C! Top C-uck!
>>
>>52565115
The amount of vulnerabilities it has is very practical indeed :^) All thanks to C :^)
>>
>>52565149
>Go
>sane OOP
>features
>let alone good features
>let alone excellent features
>good GC
This is what gotards actually believe
>>
>>52565347
My biggest problem is the lack of a generic resizeable array. Writing programs, not libraries, rarely benefit from generics unless you're a Java developer.
>>
>>52565375
it's not even a contest, dmd literally blows everything else out of the water.
>>
File: java-c performance.jpg (205 KB, 1181x792) Image search: [Google]
java-c performance.jpg
205 KB, 1181x792
Why is C slower?
>>
>>52565316
I understand what this code is doing, but I can't seem to work it into what I already have.
main = do
print "Enter message: "
message ← readLn
print "Enter shift number: "
n ← readLn
--print $ map toEnum∘(+n) $ from message
print $ map ((toEnum)∘(+ n)∘(fromEnum)) message


Results in literally pages worth of errors
>>
>>52565276
I see, i'd like to do something like this:

table = { 
x,
y,
run = function()
print( x, y )
end
}


but it gives me the attempt to index a nil value error
>>
>>52565399
The lack of OOP functionality makes it sane. Java style OOP is batshit insane.
>>
>>52565437
>Java style OOP is batshit insane.

In what way?
>>
>>52565427
gcc -O3 -march=native
>>
>>52565427
>sublime turd
>UNREGISTERED
C is only as fast as you are in the head.
>>
>>52565427
try gcc -O3

Also, you're counting startup time of the C binary, including library loading, whereas you're not doing it in the Java one.
>>
>>52565201
> while(!is_sorted)
time ./bubblesort 
214748 ints allocated!
sorted!

real 2m6.845s
user 2m5.588s
sys 0m0.128s


>while (n)
time ./bubblesort 
214748 ints allocated!
sorted!

real 2m8.223s
user 2m8.084s
sys 0m0.004s
>>
>>52565445
teh boilerplate m8
>>
>>52565437
>java is the only oop language in the wooorld !111
Gonoreah, everyone!
>>
>>52565427
You're not using equivalent timing methods
>>
>>52564819
What about 'Analyst'?
>>
>>52565377
>I laughed
You're laughing at the most powerful computer in the world?
Do you even know what Xeon Phi's are?
>task that isn't strongly bandwidth-bottlenecked
Which is why you need a good scheduler, written in C.
>I bet it's python
No, it's a few million lines of C.
>>
>>52565210
Depends on the country meight.
>>
>>52565386
No piece of software is going to be free from vulnerabilities, and that most definitely doesn't make it impractical.
How much am I willing to bet you are using Windows, which is also written in C?
>>
>>52565445
Inheritance is rarely useful. The fact you can use interfaces combined with inheriting another class is pantsu on head stupid. Composition and proper design solves most of those cases. Everything is a method.
>>
>>52565001
Haskell
>>
>>52565489
Xeon Phi's are actually kind of crappy... but agree that C rocks.
>>
>>52565503
>lol fuck inheritance muh gomposishun

Filtered.
>>
>>52565429
That's just Haskell being Haskell
you gotta learn to understand those error messages
>>
>>52565064
sounds like you need to release some tension. Go jerk off to some hentai because I'm assuming you don't have a girlfriend with a neckbeard like that.
>>
>>52564360

Java related question: what is a good module to use for image manipulation, stuff like cropping, resizing, and editing photos?
>>
>>52565489
I'm laughing my ass off. You're so desperate it's so cute! Be sure to inform yourself before posting though. Making yourself look twice the fool you are is not doing yourself any service.
>>
>>52565559
java.nio
>>
>>52565499
Windows is written in C++ because C is THE vulnerable language. Name one non-shit language that supports buffer overruns, use after free, and double free as FEATURES. You literally can't.
>>
>>52565575
The kernel is C
>>
>>52565539
It's true what they say, the tears of retards are a most delectable delicacy.
>>
>>52565528
Inheritance is useful when you're dealing with a deep hierarchy like UI widgets and entities for game development. Using inheritance for the sake of tweaking the way a class works, is stupid.
>>
>>52565520
>Xeon Phi's are actually kind of crappy
They are way more power efficient compared to GPUs, and keeping power usage down is one of the main priorities when scaling to the petaflops range.
>>
>>52565322
oh look another eng major with buyers remorse
>>
>>52565584
>backpedaling
>>
>>52565594

I agree with you now, but that's not what you said initially.
>>
>>52565429
>No instance for (Read a0) arising from a use of ‘readLn’
>The type variable ‘a0’ is ambiguous
>No instance for (Enum a0) arising from a use of ‘fromEnum’
>The type variable ‘a0’ is ambiguous
The compiler cannot infer the types in this case. You need to add type signatures.
main = do
print "Enter message: "
message <- readLn :: IO String
print "Enter shift number: "
n <- readLn :: IO Int
print $ (map (toEnum . (+ n) . fromEnum) message :: String)
>>
File: 1451080352324.jpg (57 KB, 576x436) Image search: [Google]
1451080352324.jpg
57 KB, 576x436
>>52564582
>being on the bleeding edge after a month
>>
>>52565607
Not the guy you were replying to, just pointing out that you're wrong. The kernel usually defines the language the OS is written in.
>>
>>52564588
error values make user errors the default (in go you handle programming errors with panics)
exceptions make programming errors the default
i personally prefer the first, although some syntactic sugar for forwarding might have been nice
essentially, error values as monad (when implementing this one has to make sure that it is immediatly obvious when reading some function's code which function can return an error and which can't, and this is pretty damn hard to do in an imperative lang)
>>
>>52565562
>this amount of projection and delusion
a few dozen gpus is consumer tier, people can run that in their garage.
>>
>>52565488
Analyzing is not the same as programming.
>>
>>52565598
>powerefficiency
>mattering
>compared to performance
Keep playing with your toys. Any realworld task would take over a year to complete on your magical cpu utopia machine. There's a reason everyone with an ounce of seriousness is using GPUs.
>>
>>52565631
I spend most of my time writing programs.
>>
>>52565629
>google is consumer-tier
OK bro.
>>
>>52565503

>inheritance is rarely useful

- Design of GUI APIs makes extensive use of inheritance. Impractical to subclass a graphical component using composition.
- Wrappers around core behaviour (e.g., inherit from list and make it fire events when elements are added) are easier done with inheritance.

These two are just common use cases where composition is not too useful.
>>
>>52565575
JFYI, C++ has all of those amazing "features" it inherited from C as well.

Windows is written in C. The C++ features that they support are pretty much limited to what you would get from a C API anyways, and are also entirely accessible from C.
>>
File: 1451141337349.jpg (45 KB, 716x717) Image search: [Google]
1451141337349.jpg
45 KB, 716x717
>>52564819
>Code Guru is okay
>moonrunechan/baroo\ baroo/mfw.jpg
>>
>>52565608
Poor wording on my side.
My point is that inheritance is usually not necessary and makes your code more complex than it should be.
>>
>>52565680
In many cases GADTs are a much better solution than inheritance.
>>
>>52565456
>dislikes sublime text
>then hates him that he hasn't bought it
I think you're the one fucked in the head
>>
File: 1381681214198.jpg (171 KB, 1000x600) Image search: [Google]
1381681214198.jpg
171 KB, 1000x600
>>52565607
You don't know what that means.

>>52565435
x and y are nil, that's why. You don't need to declare fields in Lua table. What you are doing is making a list where index 1 is x (which if undefined is nil) and index 2 is nil, and field run is a function. Lua tables don't support 'this', which seems like what you are trying to do.

>>52565399
>pic related
>>
>>52565594
>>52565608
Overriding is shit for "deep hierarchies".
Inheritance without overriding is what Go's type embedding is.
>>
>>52565575
>Windows is written in C++
u wot?
Windows NT is written in straight C, and the WinAPI is C as well. Most of the MS apps and whatnot are written in C++ but using the WinAPi which is itself C, so it's barely any different.
>>
>>52565664
The butthurt is amazing! Keep it coming please.
>>
>>52565702
okay, that's all I needed to know

not a deal breaker

thanks
>>
>>52565702
Gofags, everyone!
>>
>>52565611
message <- readLn :: IO String
doesn't actually work though, because it apparently looks for a binding to message (causing an error when said binding obviously doesn't exist).
>>
>>52565713
Wrong.
>>
>>52565456
>sublime turd
>probably a vimtard
>not using magnetized needles to flip bits in the hard drive
>>
>>52565752
Thanks for coming to /dpt/ today, you made a difference!
>>
>>52565721
>>52565752
You're not even trying anymore
>>
>>52565627
>although some syntactic sugar for forwarding might have been nice
Exactly. Java has the throws keyword. It would be nice for Go to have something similar.
>>
>>52565771
>>52565752
Samefag.
>>
>>52565635
>powerefficiency
>mattering
It's pretty much the number one engineering priority when designing big data centers.
Why do you think northern Sweden and Finland has become such attractive targets for data centers? Cheap electricity and good cooling.

When you run a home made GPU setup in your home, sure you go maximum performance, but you can not viably scale that beyond maybe a 100 teraflops.

>Any realworld task would take over a year to complete on your magical cpu utopia machine.
These "cpu toys" are literally several orders of magnitude more powerful than your little "eXtreme g4ming GPU H0M3 CLUSTER".
>>
>>52565752
https://msdn.microsoft.com/en-us/library/bb384843.aspx
>The Win32 API (also known as the Windows API) is a C-based framework for creating Windows applications.
>>
>>52565644
The people who write job listings don't necessarily know the difference.
See http://programmers.stackexchange.com/questions/140561/
>>
File: Screenshot_2016-01-22_14-59-02.png (7 KB, 337x105) Image search: [Google]
Screenshot_2016-01-22_14-59-02.png
7 KB, 337x105
>>52565779
>you tried
>>
Low quality bait.
>>
>>52565792
>I get all my computer science information through The Guardian
t. you
>>
>>52565793
I'm sorry you're retarded, but actually I'm not sorry.
>>
File: grid.gif (73 KB, 791x1024) Image search: [Google]
grid.gif
73 KB, 791x1024
fuck
I have 16k gps locations (long and lat) on a map(one state), there is same distance between each point. On the map it looks like a big grid 4k * 4k gps locations.

Now for a given gps location I have to find 4 gps location that make smalles square around given location 2 * 2 from 16k * 16k gps location.
I have a text file with 16k location but they are not in order.

Each gps point it made of lat and log and I have no idea how should I search, first find nears long, then lat? but how to find other points?
>>
Guys guys we are supposed to be friendly here since we are interested in the same stuff.
GROUP HUG !
>>
>>52565773
throws works with exceptions, exceptions make programming errors the default (the "throw" operation is costly because you need the stack trace, and it's often generated redundantly or even way too deep into the call stack)
"throws" causes the exact issue i mentioned: you cannot distuingish properly between functions that return errors and functions that don't anymore.
this means that you have to traverse the call tree all the time and read documentation just to find out which functions may actually cause errors.
>>
>>52565851
Go back to /mlp/ faggot.
>>
>>52565845
You also have white dots where lines intersect.
>>
>>52565852
Not sure if retarded or just pre-
>go programmer
Oh.
>>
File: Selection_071.png (54 KB, 574x184) Image search: [Google]
Selection_071.png
54 KB, 574x184
Well I changed 'readLn' to 'getLine' and suddenly all my problems went away.
Huh.

Well either way I'm not complaining, as I finally got my shitty and broken Caesarian Shifter completed. Pic related is the beauty of clean Haskell.
>>
>>52565845
Build an R-tree.
>>
>>52565851
We don't like the same stuff.

Lots of people here like Go, Python and JavaScript.

They're terrible languages.
>>
>>52565824
>I get all my computer science information from linustechtips
t. you
>>
>>52565869
You just need a human touch.
Its ok anon, /hug
>>
File: Python.png (214 KB, 473x444) Image search: [Google]
Python.png
214 KB, 473x444
Can /dpt/ tell me about Python? I am new to Programming and I want to learn Python for my first language, as I have heard that Python is the best language for beginners. Any tips for a newbie programmer?
>>
>>52565895
No, I actually do that stuff I mentioned for a living. Nice projecting though.
>>
>>52565893
Python is used in top tier info sec and pentesting (also pure good old hacking).
>>
>>52565902
It's shit and will teach you really bad practices for later on.
Start with C++.
>>
>>52565902
http://haskellbook.com/
>>
>>52565916
Not sure if this is bait or not. Isn't C++ A Horrible language to learn for beginners?

>>52565921
Fuck off.
>>
>>52565902
>An interpreted language best for beginners.
Where the fuck did you hear that?
>>
>>52565913
And?

It's still a shit language.
>>
>>52565913
Is it really? I'm going into infosec, so would it be a good idea to learn it for that?
>>
>>52565916
This.
>>
>>52565936
Says...you? A literal nobody?
>>
>>52565931
The internet.

>>52565936
If Python is a bad language for beginners, what language is good for newbies then?

>>52565945
I cant tell if I am being trolled or not.
>>
>>52565564

thanks
>>
>>52565929
The python beginner is bait. Plain as goddamn day. As are the majority of the responses.

/dpt/ is fucking retarded at times.
>>
>>52565929
You'll be a better programmer in almost every language in mainstream use, including Python, if you learn Haskell.
>>
>>52565957
Pascal.
>>
>>52565929
>Not sure if this is bait or not. Isn't C++ A Horrible language to learn for beginners?
Not at all. It was my first language.
The problem with Python and other 'popular' first programming languages (such as Visual Basic or Java) is that they're really, really abstracted, so you're not actually learning how to program, you're just learning how to program in that specific language.
C++ is close enough to the hardware that you actually learn how the computer handles things, which means you can better apply that knowledge later when you're actually doing higher level work in C# or whatnot.

Also it's still one of the most used languages out there.
>>
>>52565969
The only retard is whoever falls for the python meme.
>>
>>52565974
what the fuck did you do to 4chan
>>
>>52565957
ML
>>
>>52565971
>>52565969

So then if Python is low quality bait, what language is good for beginners?

>>52565978
Is C good enough?
>>
>>52565984
Says a literal NEET nobody.
>>
>>52565748
test
"Enter message: "
"Help"
"Enter shift number: "
2
"Jgnr"

Works for me. I'm guessing you didn't realize that readLine needs "'s to parse a string. Here you go, this is what I think you want, using getLine over readLine and putStrLn over print (we can also drop the type annotations):
test = do
print "Enter message: "
message <- getLine
print "Enter shift number: "
n <- read . getLine
putStrLn $ map (toEnum . (+ n) . fromEnum) message

"Enter message: "
asdf
"Enter shift number: "
3
dvgi
>>
>>52565902
Depends on what you want to do later. If you just want to learn to program something and be able to automate simple things, do Python. Can do machine learning, maths, web development and other fancy things that are in the mouth of everybody now.

However, if you want to be a programmer and learn serious programming, start with C. Understand what's going on, what's a compiler, how does memory work, etc. Then move on to something "enterprisey", such as Java, C++ or C#, to learn OOP design. Then go to Haskell and learn a bit of functional programming and paradigms (you will not use Haskell for anything, but some ideas in it are actually pretty nice and will improve your code in other languages). Now you're a programmer and can learn whichever language you want.
>>
>>52565984
WAY too obvious jackass.
>>
>>52565957
OCaml.
>>
>>52565999
Haskell

ML in a pinch

C is good to know but doesn't give you the same sort of transferable skills
>>
>>52565999
C is good, but honestly a little TOO low level. It's so barebones that it lacks some features that essentially every other programming language has, such as a 'string' datatype (yes you can easily replicate strings in C, but a beginner may not realize this) or whatnot.
>>
>>52565852
I'm not into functional programming, so I won't touch the monad subject.
>you cannot distuingish properly between functions that return errors and functions that don't anymore.
From a debugging perspective, that's a big problem. It can be solved by adding logs or using a debugger.
Otherwise, why would you care who threw the exception? Let's say you catch a SocketException. Why would you care who threw the exception? You most likely want to revert all your actions and notify the user that something went wrong while networking.
>>
>>52566006
Sorry, THIS is what you want:
main = do
print "Enter message: "
message <- getLine
print "Enter shift number: "
n <- readLn
putStrLn $ map (toEnum . (+ n) . fromEnum) message
>>
>>52566005
Keep projecting. I bet you like C.
>>
>>52566009
>/g/,ladies and gentlemen
this is seriously worse board than /pol/ and all homosexual boards
>>
>>52565954
The point of an anonymous imageboard is that its users are anonymous

Also it doesn't matter who says it, Python is shit, enjoy your GIL, shitty type system, and whinging about having to change code in order to migrate to 3.x
>>
>>52565911
>No, I actually do that stuff I mentioned for a living.
hohoho
The fact that you don't think C is used for super computing was a dead giveaway.
>>
>>52566034
I bet you stash your own cum in little jars around your pc,putting little name stickers of your favorite ponies on them and taking sip every time you shitpost on 4chan.
>>
>>52566049
kill yourself clueless neet, give your parents a break
>>
So, /dpt/ is pretty much telling me that every single programming language is shit?

Well fuck.

I just wanted to know what the best language for beginners was ;_;
>>
>>52566067
The fact that you think people do HPC in software is a dead giveaway that you get your information from The Guardian or other tabloid-tier outlets.
>>
>>52566091
guido pls
>>
>>52566098
start with java, then learn C++ if you want to get more autistic

https://docs.oracle.com/javase/tutorial/
>>
>>52566098
>So, /dpt/ is pretty much telling me that every single programming language is shit?
That's /g/ for you.
Having a problem? Your fault for not doing the exact same thing as every other anon 100% of the time.
>>
>>52566098
Any of them is just fine. Just don't think ONLY one of them will teach you enough for more than fizzbuzz.
>>
>>52566098
serves you well when you are trying to get serious info on a fucking 4chan.
>>
>>52566098
OCaml.
>>
>>52566133
Lesson learned.
>>
>>52566098
Haskell
>>
>>52565635
>>52565792
doesn't it depend on the specific task which is more efficient out of CPU vs GPU?
>>
you are all scumbag cynical imbeciles
>>
>>52566167
spoiler: yes. Almost every task is GPU these days but some workloads (usually static operations performed on very large amounts of data, as opposed to dynamic operations done data-chunks at a time, in particular those where synchronizing is expensive) can benefit from using large cpu farms instead.
>>
>>52566098
Just pick any high level language. It really doesn't matter.
Python is a nice language for a beginner. C# and Java are also good languages.
>>
>>52566039

thanks for your thoughtful argument
>>
>>52565929
>Isn't C++ A Horrible language to learn for beginners?
Only if you believe the memers who say starting with C++ will ruin you for life.
>>
>>52566189
Thanks, Anon.
>>
>>52565174
I like your wheat
>>
>>52566189
>Python is a nice language for a beginner.
It's only really good for getting used to basic control flow constructs.
>>
>>52565999
Java is pretty damn good for begginers bro.

In the end, it's more important your skills about programming and stuff like recurssion, divide and conquer, data structure, logic than what language you use.

only autist think language really matters.

>inb4 some retard answer
you know the language doesn't matter faggots, you could literally write an OS in javascript retards.
>>
>>52566204
python is absolutely fucking disgusting i'm not kidding. please just learn java or C#

https://en.wikipedia.org/wiki/Duck_typing#Criticism
http://programmers.stackexchange.com/questions/15468/what-are-the-drawbacks-of-python
http://software-carpentry.org/blog/2012/02/why-not-use-python.html
Thread replies: 255
Thread images: 17

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.