[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: 323
Thread images: 20

What are you working on, /g/?

Previous thread: >>61852783
>>
>>61861536
gamecopyworld crashes my webcrawler for wiby.me. Hangs to oblivion. Need to fix asap.
>>
>>61861563
Add a timeout?
>>
I took a course on Matlab for my major. As a first coding language it was pretty hard, but I eventually got the hang of it (sorta).

I want to get into learning C++, since what I plan on doing later on is robotics. What should be the next language I learn in order to ease into it? I was told by this one guy that I should go for python, then C+, then C++. Any opinions?
>>
>>61861589
What major?

I am economics and we are learning SQL.
>>
>>61861536
What language should I learn as a beginner that will help me the most in Network Administration?
>>
>>61861618
mechanical engineering. For us, matlab is the only one we need to know
>>
>>61861589
>C+
>>
>>61861645
bash/powershell depending on platform focus (or both) and python
>>
>>61861536
>The only three programing languages you'll ever need to know
Unless you're actually looking to get a programming job, then you may want to find a language people actually use. I guess that doesn't matter, since half of you faggots are NEETS anyways.
>>
I can now parse this protobuf code into a big ugly ast structure.
syntax = "proto3";
package racket.protobuf.json;
option gay_as_hell = 1;

message JSON {

message Array {
repeated JSON elem = 0 [packed = true];
}

message Table {
map<string, JSON> dict = 0;
}

oneof data {
string text = 0;
double number = 1;
bool boolean = 2;
Array array = 3;
Table table = 4;
}
}


Next I need to write the "compiler" which does scope resolution, imports, and interprets options. Then I need to actually figure out how it's going to integrate into Racket, which I have some ideas for. I don't think I'm going to have it actually generate Racket sources, since I can just have it generate structs or classes at expansion time.

>>61861589
For robotics the C++ you'll do will probably be 90% just C, without using any of the real C++-y features.
>>
>>61861671
>>The only three programing languages you'll ever need to know
Who said this?
>>
>>61861664
meant C#
>>
>>61861678
It's the OP people pic you retard
>>
>>61861694
It doesn't say that though.
>>
>>61861649
matlab data is such a pain to work with from any other language
>>
@61861702 kill yourself
>>
File: Blind Motherfucker.jpg (13KB, 592x111px) Image search: [Google]
Blind Motherfucker.jpg
13KB, 592x111px
>>61861702
>>
>>61861816
>@
why?
>>
Why must GLEW have such shit documentation?
>>
>>61861822
>need
vs
>need to know
>>
>>61861834
Retarded jp wannabe memesters aren't worthy of my You.
>>
>>61861834
No (you)'s
>>
>>61861844
>arguing over semantics
>>
>>61861866
Welcome to /dpt/, enjoy your stay.
>>
>>61861666
>>61861711
>>61861822
>>61861844
>>61861855
>>61861866
wew
>>
>>61861844
>implying that's not what was being implied
>Implying there's any difference beyond semantics
>>
File: 1437797527274.jpg (13KB, 400x169px) Image search: [Google]
1437797527274.jpg
13KB, 400x169px
I'm trying to create a Menu class, that takes a variable amount of Options (basically strings) as constructor arguments.
I'm pretty new to using templates in general, and this variadic template + constructor delegation is something I just barely managed to put together:

Menu() = default;

template<class String, class... T2>
Menu(String option, T2... rest) : Menu(rest...)
{
options.Add(option);
}


I'd now like to have a function called after the last option has been added/the above constructor has been called for the last time.
How would I go about doing that?
>>
>>61861866
>being wrong
>>
>>61861982
>
>>
>>61861866
>>61861920
Semantics are extremely important in programming.
>>
>>61861992
But it's less important in the English language, unless you're dealing with retards.
>>
>>61861645
Perl.
>>
>>61861950
>How would I go about doing that?
learning C++
>>
>>61861838
What's is the issue?
>>
File: 1435606670791.jpg (102KB, 515x495px) Image search: [Google]
1435606670791.jpg
102KB, 515x495px
>>61862066
cheers
>>
>>61861536
who the fuck made OP image i want to strangle them
>>
>web development
>backend/scripting

not necessary
the only languages one needs to know are scheme and haskell
>>
>>61861666
>>61862048
thanks
>>
File: 122416779957.png (18KB, 1024x768px) Image search: [Google]
122416779957.png
18KB, 1024x768px
>>61861950
>>61862087
Figured it out. The default constructor is the terminating constructor for the recursion.
>>
Working through an Algorithms Book in C.

Dumb question: Is there a way to add generic ADT's? For example, if I'm implementing a Linked List, do I need to know beforehand what the 'elementType' will be?

Example:
void Delete(ElementType X, List L);

Do I need to define ElementType somewhere? Or is there some way to make my list work with any arbitrary type?
>>
thinking of switching my field of study. currently in networking and tech support but i want to switch to programming.

pink slashes represent credits i already got from my first two semesters and green boxes are what i would still need to earn in the new program.

does this curriculum seem useful?
>>
>>61862278
>introduction to UNIX/Linux and the internet
Wat
>>
>>61862275
C does not have generics. You'll either have to used void* and casts, or switch to C++ and use templates.
>>
>>61862278
Why would they teach sepples and then Java?
>>
>>61862294
maybe its how not to get viruses 101?
>>
>>61862278
It starts nice, but gets worse every semester.
>>
>>61862278
Stuff with slashes is dogshit useless to developers but I guess it's good you got it out of the way.

Courses which have "OO" or "object oriented" in their title are pretty much bullshit but you need them to communicate with other people who were sold on the same bullshit.

Intro to prog is good, web programming stuff is pretty hit or miss, you kinda need to know SQL so I guess that's good even if they're dogshit boring classes.

Pretty much the litmus test for "is this course bullshit" is how much programming is going to be involved. Ask your instructor. If there are large projects and you're expected to be writing code for every session then that's something that will get you somewhere.
>>
>>61862294
>>61862312
>>61862317
>>61862328
i guess what i want to know is if i can get a job with this shit and weather or not its a good foundation to build up on.

would like to one day build my own app or web service and the self learning route has me kind of lost.

>>61862328
>Stuff with slashes is dogshit useless to developers but I guess it's good you got it out of the way
i just got them out of the way now because almost every other program requires them and i was still unsure weather i wanted to switch or not. so yeah i just got them over and done with so i could focus on the important shit.
>>
>>61862302
Not uncommon in older programs focused on turning out professional devs. Java has won in the OO space but it had to displace C++ to get
there. It's impossible to talk about its design without making refrence to C++, historically "Java for C++ Programmers" makes a lot of sense
>>
>>61861536
Dude, the Idris PHP backend was literally a joke. Might as well promote the Whitespace backend.

There's also no web server available. The whole web dev story is still extremely immature and mostly relegated to the front end.

I'm hoping to help improve on the situation but right now Idris is not something you would really promote as a web dev platform.
>>
>>61862347
If that's the kind of stuff you wanna do then go for it. Once you have a degree, you shouldn't have any problems finding a job as long as you know your shit.
>>
>>61862347
>i guess what i want to know is if i can get a job with this shit
The job thing depends a lot on on what country/region you're in. Broadly web development is pretty hot at the moment and OOP is the incumbent programming paradigm so the courses seem pretty well geared to that. In the US anything short of a BS is scoffed at a bit (I assume this is a description of an associates program?) but a good portfolio and good interviewing can make up for it. After your first job or two your education matters a lot less, "foot in the door" and all that.

>and weather or not its a good foundation to build up on
It's not too bad. A little dated but very few people get good at programming from their coursework, with work outside the classroom on your own projects it's a reasonable curriculum.
>>
>>61862405
its actually a diploma because its only 2 years. need to take a 4 year program to get a degree in canada and anything 2 or 3 years is the equivalent of a US associates degree.

tldr im 29 and im going to be 30 later this year and i need a career i can make money on because im tired of derping around as a rent a cop.

>>61862440
good to know. i want a foundation that has some merit with employers that also allows me to start messing with my own projects. i have app ideas but i doubt i will be able to fulfil them if i have to rely on paying people with my shitty slave wages.
>>
>>61861950
I can see you don't care about performance here but beware that recursing variadic templates is the fastest way to fuck up compiler optimizations.
>>
>>61861536
Shen is a total mess. They think having a Touring complete type system is a good thing.
>>
>>61862278
This looks like a very typical curriculum.
Note that /dpt/ and software development in general is very split on 'what's the best way'. Your program seems to lie with the idea that OOP is a good high level paradigm. You can certainly do worse. I may disagree with the approach but for finding a job I'm sure its good.
>>
>>61862610
>having a Touring complete type system is a good thing
I don't know much about shen but honestly that sounds kinda cool. Maybe it ends up in a situation like with C++ templates where it's slow and a footgun but really powerful but I'm not sure I mind that. I'm also not convinced it has to be slow.
>>
>>61862275
You can do generics with macros if you really want.

#define DELETE_DEFINITION(elem_type, list_type) \
void list_type##_delete(elem_type e, list_type *l) \
{ \
/* do something */ \
}

/* Now define the function for a type */
DELETE_DEFINITION(some_type, some_list_type);
>>
>>61862655
Oh god. That looks like a can of worms I don't want to get into.

I'll just use a simple type then.
>>
>>61861536
#include <stdio.h>

int main(){

int c = 5, d;
d = ++c + ++c + ++c + ++c + ++c + ++c + ++c + ++c + ++c + ++c + ++c + ++c;

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

return 0;

}


How much is d?
>>
>>61862814
https://en.wikipedia.org/wiki/Sequence_point
>>
>>61862814
139, although those operations could be undefined.
>>
>>61862278
>american cs course
>not a single math or algorithms class
Now I can understand /sci/s oppinion on it
>>
>>61862814
6+7+8+9+10+1=41
But there is a semicolon missing so its value is propably undefined
>>
>>61862867
technically its strictly a programming course.
>>
>>61862312
At our uni we didn't have pure languge courses, they always had an overarching theme, and used a language to learn about the given theme.
First semeseter: we learned basic programming, algorithms and data structures, used c
Secdon semeser: learned aboud oop, used c++
Third semesete: learned about dealing with bigger codebases, using libraries exetensively, guis, used java
Forth semeser: patterns, dev cycles, other bullshit, used c#
>>
why is 'the little schemer' so underrated
it's great
>>
>>61861645
bash/powershell/python
>>
>>61861536
so just lisp?
>>
>>61862907
gross
>>
>>61862950
yeah
>>
>>61862907
*code monkey academy
Fify

>>61862946
Because it's not conventional
>>
Clojure is amazing!
>>
>>61863031
it's a lisp, of course it is
>>
>>61861589
>Log in to your MathWorks Account
>>
>>61863031
wrong
>>
>tfw to tired from work to work on my hip sideproject
>all I want after work is to get drunk and watch braindead shows
how do you guys do it
>>
>>61863414
These threads are full of NEETs thats how.
>>
>>61863414
by being übermenschen
>>
>>61863043
Clojure is not a LISP
>>
File: LISP INDEED.png (33KB, 437x202px) Image search: [Google]
LISP INDEED.png
33KB, 437x202px
>>61863457
>
>>
>>61863468
>implying wikipedia is a reliable source of accurate information
lmao @ u
>>
>>61863414
I only try and do a little bit each night after work. It's pretty hard all the time and I don't really mind having a few days off here and there. A little bit each night adds up after a while. If you don't really want to work on side projects then I wouldn't go out of your way to. Life is life and programming is only one aspect of it.

My take is that I try to spend a little bit of every night doing something that I can look back in a few months and see tangible progress. Whether it be running, learning a language or a side-project. That gives me a good motivator.
>>
File: RIGHT ON THEIR FUCKING WEBSITE.png (30KB, 609x381px) Image search: [Google]
RIGHT ON THEIR FUCKING WEBSITE.png
30KB, 609x381px
>>61863477
>
>>
>>61863494
>if I write on my website that my not-homoiconic language is a LISP then it will become true
>>
File: Ive got all night buddy.png (20KB, 421x140px) Image search: [Google]
Ive got all night buddy.png
20KB, 421x140px
>>61863519
>
>>
>>61863519
lithp
>>
>>61863540
see >>61863477
>>
File: ALREADY HAVE YOU COVERED.png (40KB, 334x431px) Image search: [Google]
ALREADY HAVE YOU COVERED.png
40KB, 334x431px
>>61863549
>
>>
>arguing with Lisplets
>>
>>61863654
lithp
>>
>>61861950
Just take an std::initializer_list. Jesus.
>>
>>61863568
You're hopeless. Have fun writing Clojure "macros"!
>>
>>61862814
UB
>>
>>61863685
ur a faggo
>>
what kind of jobs could someone with knowledge of c orogramming in linux get?
>>
>>61863710
unemployment
>>
>>61863705
that's rich coming from a jvm fuccboi
>>
>>61863720
take that back
;~;
>>
File: avarage shen programmer.png (921KB, 1681x1036px) Image search: [Google]
avarage shen programmer.png
921KB, 1681x1036px
>>61861536
>>
>>61863801
Shen will lose its only programmer soon.
>>
>>61863801
she (n.)

she (noun)
>>
>>
>>61863868
The funniest part of that is Lisp's wasn't even deemed functional or complete.
>>
Just finished programming snake, working through old arcade games for fun. Currently working on tetris, just finished handling rotations in 2D array like a matrix.
>>
>>61861536
I have to finish my internship rapport about an Odoo modules who manage docker.
After what I have to finaly how to properly develop in C for an exam.
> Yes I can dev in C.
Also I have to learn how to speak english for an other exam, as you see, I'm fucked.
>>
>>61863909
>can
>can't
english exam in comming
>>
>>61863909
>After what I have to finaly how to properly develop
Go open your English book again, Hans.
>>
>>61861536
>>61863801
>>61863835
Why do autists insist on badly reinventing Common Lisp over and over again? If the historical cruft bothers you so much, push for an ANSI standard revision. It's due for one anyway.
>>
I'm looking for a new job.
Pure Java isn't possible with my experience, so I'm aiming for a position as a full stack developer.
>>
>>61863868
Lisp has the lowest development time, so I'll go with that.
>>
>>61864110
> a language built for modding itself for new flavors
>wahh why do people keep using it for its intended purpose
kill yourself
>>
>>61864136
>> a language built for modding itself for new flavors
Making a shitty homegrown dialect with Ruby-tier performance and no libraries is the opposite of this.
>>
I'm going to try to create a Tower of Hanoi console game in C++. I've only taken a C++ intro course at a community college. Looking for some guidance.
>>
>>61864180
I never said it was productive or good.
Lisp should have died in the 60s
>>
>>61864187
>Lisp should have died in the 60s
Explain?
>>
>>61864201
It has no real uses.
It was a product of the time in the early days of CS.
No dynamic languages should even exist desu.
>>
>>61864184

- Use ncurses or if you want even simpler, print the entire state of the towers at each iteration.

- Ask the user for two numbers between 1 and 3, indicating what disk to move to which tower.

- After use input, check if the disk movement is valid, if not ask for input again. If it was, check if the last tower is full and if so they won.

Just start and see where you get to first.
>>
>>61861649
>what is python and fortran?

during my mech eng masters we went through all three
>>
I have read LYAH and the wikibook. Now I want to get some hands on experience. Is HackerRank any good for that?
>>
>>61864219
This.
Lisp was the only functional langauge back in the days.
>>
>>61864264
Just do all the roll projects that interest you.
>>
>>61864219
>It was a product of the time in the early days of CS.
No, Lisp was ahead of it's time. Literally. A major cause of its unpopularity was performance, since no one wanted to buy a Lisp Machine. Nowadays a mature implementation will be about as fast as Go or C#.
>No dynamic languages should even exist desu.
Generally, yes, but Lisp is dynamic for good reasons, mainly its metaprogramming. SBCL will catch potential issues from the type system anyway.
>>
>>61864332
>SBCL will catch potential issues from the type system anyway.
Does it go as far as preventing any run-time errors?
>, Lisp was ahead of it's time.
Thats not really saying much considering it was 1959.
>Nowadays a mature implementation will be about as fast as Go or C#.
I'd like to see that actually.
>>
>>61864264
write an interpreter for a custom language
>>
>>61864332
its
>>
>>61864355
>Does it go as far as preventing any run-time errors?
No. But static analysis isn't even close to worth losing the flexibility that defines Lisp.
>Thats not really saying much considering it was 1959.
In my defense, web browsers and OO have also caused language design to regress for the last few decades. The only reason Python is useful is because the oriented part of its OO is optional for idiomatic code.
>I'd like to see that actually.
http://benchmarksgame.alioth.debian.org/
>>
>>61864481
>slower in everything but pi
What are you trying to prove here lad?
>>
>>61864507
>>slower in everything but pi
Only by a bit, while being far more expressive and easy to work with. Keep in mind that these are toy benchmarks with no bearing on real world performance, and that SBCL is a full fledged compiler that can produce static binaries that initialize quickly.
Lisp isn't literally a divine miracle, of course, but to say it's a bad language is asinine.
>>
>>61864602
>but to say it's a bad language is asinine.
It has no niche though. Idris or Haskell are more powerful and offer more expressive power.

Lisp to me will always be a toylang.
>>
Are there any good tutorials (preferably with exercises) that exist for ES6 or ES7? I want to learn proper javascript practices without just reading through the entire spec
>>
>>61864644
>>>/g/wdg
>>
>>61864612
>Lisp to me will always be a toylang.
They said the same thing about Haskell. Not that I think it'll actually happen with Lisp though, people are superstitious and its reputation has long since been cemented as that weird AI thing.
>>
>>61864720
Can you really blame people though?
Lisp is one of the oldest langs still in use today and it hasnt evolved much because of purists.
And Clojure (which to me is the most relevant Lisp) is moving to a type system.
>>
Why don't all programs support unicode? Also games?
>>
Guys /wdg/ is laughing at us again!
>>
>>61864737
>hasnt evolved much
Will common lisp hasn't, but racket is quite modern
>>
>>61864737
Not him, but Racket also has a type system. It's ugly af though.
>>
>>61864810
>>61864816
Yeah Racket is alright, but I just dont think a type system can be added after the language is made and work nicely.
>>
opinions on scala?
>>
>>61864853
needlessly complex pile of poo
>>
>>61864853
https://www.youtube.com/watch?v=4jh94gowim0
>>
>>61864886
>fat bald guy wearing flip flops
And who might he be?
>>
>>61864816
>It's ugly af though.
compared to what?
>>
>>61864911
The ex-largest contributor to scala.
>>
>>61864737
>Lisp is one of the oldest langs still in use today and it hasnt evolved much because of purists.
Isn't this basically >le current year logic? Lisp isn't implementation defined. You can take it in all sorts of directions without ruining it, and many people have. Hy is a good example (that doesn't reinvent the wheel).
>And Clojure (which to me is the most relevant Lisp) is moving to a type system.
Is this not evolution?
That said, I looked up Clojure types and a lot of the posts about them seem to be people admitting that static typing was a lot of extra work for no real benefit since they were writing correct code anyway.
>>
>>61864916
#lang typed/racket
(struct None ())
(struct (a) Some ([v : a]))

(define-type (Opt a) (U None (Some a)))

(: find (-> Number (Listof Number) (Opt Number)))
(define (find v l)
(cond [(null? l) (None)]
[(= v (car l)) (Some v)]
[else (find v (cdr l))]))

It just looks ugly, but I find Lisp in general ugly.
>>
Why the fuck is python so fractured?

>pip
>virtualenv
>cheese shop
>easy make
>pypy
>learn python 2, fuck 3
>learn python 3, fuck 2
>>
>>61864944
i said compared to what? what you posted here is not uglier than c++ or haskell
>>
>>61864946
Because it's one of the most popular programming languages
>>
@61861816 @realDonaldTrump OMG tiffany look what he said #sorude #omg
>>
>>61864946
>>cheese shop
>>easy make
for what reason
>>
Julia is what lisps should look like imho. Have homoiconicity by representing code as S-expressions allowing macros capable of arbitrary AST transformations, but have some actual syntax and sugar on top of it. You can have the full power of macros without limiting yourself to pure lisp syntax.

The other aspect of it is that it should be designed for a particular real world application where it outperforms all existing options. In Julia's case that is scientific computing, since it basically deprecates Matlab.
>>
>>61865000

A flakey old open source library called GDAL.

I'm guessing it will be mostly python 2 for compatibility. The lists of instructions and forum posts of people getting it to work with 3.5 and 3.6 and whatnot look real involved and involve building from source
>>
>>61865004
>Julia
designed by people who have no clue about PLT.
>>
>>61862814
Similar question
i=0
return i++ + i-- - ++i + --i

What is the output?
>>
>>61864823
The entire point of Lisp is that you can bolt shit onto it without it being messy and inconsistent. Racket is just Scheme with shit bolted on, but it works out nicely for them.
And it is true that CL lacks any type safety features in the official spec, but some implementations do have them. SBCL tends to yell at you if you do anything unsafe.
>>
>>61865082
Yet its type system is better than many that I've seen from people who have worked with types in their whole career. It meshes beautifully with dynamic dispatch, and is powerful enough to let you build things like GADT's.
>>
>>61865111
from a glance it seems youre just trying to be sneaky with cancelling increments and decrements out so possibly still 0
>>
>>61865111
can we please stop posting dumb sequence point questions
>>
>>61861536

None of these langs have any libraries. Worse than useless.
>>
File: Screenshot_2017-08-12-19-24-18.png (190KB, 2560x1600px) Image search: [Google]
Screenshot_2017-08-12-19-24-18.png
190KB, 2560x1600px
>>61865169
Works on my machine
>>
>>61865215
>I'm hopeless if I cant just plug shit into functions already made for me
Hello code artisan.
>>
>>61865231
>reinventing the wheel
>>
>>61865221
Undefined behavior is undefined behavior. Regardless of whether the result on your particular machine gives a result that makes some sense.
>>
>>61865234
there is no wheel
>>
>>61864853
I like it, you can do most of the things you can do in haskell thanks to libraries like cats, and fs2 is great for processing data.
>>
>>61865234
>>61865265
https://www.youtube.com/watch?v=dYwaRrLldgI
>>
>>61865265
just like you don't have a job
>>
>>61865294
only what you bring
>>
>>61862643
Turing-complete type systems have the problem that a type derivation could enter an infinite loop and the compiler would hang. Though examples of this arguably aren't common, you're still playing with fire.
>>
>>61865294
But code monkeys aka programmers who actually have jobs, only use existing librariea to make anything
>>
File: 1402816941229.jpg (35KB, 696x785px) Image search: [Google]
1402816941229.jpg
35KB, 696x785px
Has anyone on here ever sold some of their software?
>>
Trying to learn Python but I'm an unorganized fuck. Always end up with no time or lo procrastinating
>>
>>61863868
Haskell is to kawaii for its own good.
>>
Behold, an ancient relic from the stonage called C++
>>
>>61865352
>globals
absolutely gross
>>
>>61865323
>implying I ever finnished any even remotely longer project
>>
>>61865352
rate my haskell code

pi2 = 3.14159
-- there's already a pi in prelude
avogadro = 6.0221413e23
my_gravity = 9.2
>>
>>61865372
Why do GC'd langugae fags try to fit in?
>>
>>61865362
globals are fine if they aren't mutable (and in some other cases in general)
>>
>>61865382
>I like playing with fire
>>
>>61865382
holy shit, this is fucking embarassing

>the code is as clean as possible, compared to C++ which is a complete fucking mess

g-gced language!!! non-overlapping magisteria!!!
>>
>>61865387
>globals are fine
they are not.
Terrible habit that encourages spaghetti code.
>>
What easier for a C# developer to grok in a weekend?

Python or C

Either way I have to get over the ducktyping weirdness or learn pointers and stuff I guess. I've used both before but only at a basic level
>>
>>61865406
No, seriously. Do you expect GC'd language to be taken seriously? Especially in comparison to C++? Especially a GC'd language that's called Haskell?
>>
>>61865419
keep manually allocating your own grave
>>
>>61865416
python
>>
>>61865407
na, you're wrong

how in your opinion would you for expose a set of constants in a library, then?
>>
>>61865426
RAII, no need for manual allocation
>>
>>61865419
Functional programming languages are the only ones with an excuse to have GC.
>>
>>61865436
>automatically allocated languages trying to come to the manual table
did you expect to be taken seriously?
>>
>>61865440
No, the only excuse would be to actually have a decent and comparable performance, which haskell lacks
>>
>>61865444
Yes, I don't use GC
>>
>>61865416
C

Pointers aren't hard to grasp, just always check if they're NULL or not before doing anything with them because you're not gonna get a stack trace when they explode
>>
>>61865433
modules solve this problem because everything is in its right place.
>>
>>61865452
ohhh big baby doesnt use his GC!!! he uses automatic now!! maybe one day he'll use manual like an adult
>>
>>61865452
If your time has no value then I understand why you enjoy managing your own memory. The rest of us prefer to use the right tool for the job and actually build stuff and solve problems. Use C when its the right tool for the job.
>>
>>61865463
You sound very upset. Why don't you go back to your hand-held baby REPL and those fizzbuzz scripts
>>
>>61865456
i think i'm coming from a different perspective of global here. don't disagree with you here on the module level
>>
I've still never seen /g/ post anything where a GC would actively impede them.
>>
>>61865453

So its C# but without a NullReferenceException to cover your ass?

That doesn't sound so bad.
>>
>>61865465
sorry i don't talk to little toddlers still using their RAII training wheels
>>
>>61865463
>>61865477
>Hasklet getting TRIGGERED
lmao
>>
>>61865473
C# is all OOP, C doesn't have OOP at all.
>>
>>61865485
it's satire of you
so you are only revealing that you were triggered

you are mad that C++ is such an AWFUL FUCKING LANGUAGE, like seriously it and Java set back programming by decades, and your only excuse is "b-b-but GC" - a non fucking argument, that can be turned upon you by pointing out """modern C++""" doesn't use manual memory, it uses automatically managed memory.
even rust uses automatic memory, what's your point?
because the language doesn't always use automatic memory that its superiority is unimportant?
>>
>>61865485
>>61865502
i mean this is literally what you are complaining about

my_gravity = 9.2


that's all it took to set you off
because you know that C++ is really awful at this

this code doesn't even really use GC
>>
>>61865473

It's not really that simple, for instance C lacks a lot of modern comforts such as generics and you have to manually allocate and free memory. Memory management is the biggest source of errors, for instance use after free which might not cause a segfault (until it suddenly does)

It's also not OOP, so you have to use a procedural style. You can pass function pointers to do stuff like partial application and emulate HOF, but honestly you don't want to do this in C. Also beware of preprocessor magic, it's a surefire way to inflict misery on yourself.
>>
>>61865502
My point is, Haskell is not a competitor of C++. GC'd language are much easier to deal with and have cleaner syntax. However if you really want a GC'd language to compare with C++ try D. And if you want a non-GC language to compare try Rust. Haskell is like on par with C#
>>
>>61865510
You do realize that's not the problem, right? It's about the retarded include system redundancy C++ suffers from
>>
>>61865528
A lot of people don't use C++ for performance, they use it because it's popular.
Hopefully C++ will die a quick and painful death and nobody will ever talk about it ever again.
>>
Learn Java
>>
>>61865473
Oh dear, no. No exceptions, no namespaces, no classes, manual allocation of everything, the list goes on.
>>
>>61865544
Unfortunately, C++ will probably never die.
>>
>>61865555
>Exceptions
>Classes
undesirable
>>
>>61865568
Exceptions are actually helpful for tracking down bugs.
>>
>>61865573
there's a monad for that
>>
>>61865488

I know that, but in C# you already need to be aware of pass by reference (objects) vs pass by value (primitives and structs) so pointers are just another layer on top of that.

>>61865518
>you have to manually allocate and free memory

You still have the stack for locally scoped variables though right? I think I'm happier having to do more than have something like python which is just loads of magic and smoke & mirrors.

Just a matter of if I can learn enough basics in a couple days. It's only for algorithms and data stuff, not big heavy programs
>>
>>61865555

I wasn't talking literally.

Just that you already have pass by reference and null checks everywhere in C#.
>>
>>61865582
Do monads give you a stack trace?
>>
>>61865602
use WriterT
>>
>>61865568
Who said anything about them being desirable?
>>
>>61865587
C is pure, everything is pass by value and all reference usage is explicit with pointers. I love it, it's so clean unlike C# with its ref struct bollocks.

Yes you have the stack, use it a lot.
>>
>>61865602
>>61865611
or something halfway between that and ExceptT so that you keep the accumulated log up to the exception
the order of transformers matters in this case

effect fags btfo
>>
>>61865587
You do have the stack. With C you know what you get, for better or worse. I prefer it to python, but I also think it is surrounded by a massive cargo cult unable to admit that it has some deep flaws and should only be used in a few specific scenarios. It's fun to write though, that's probably why people are so attached to it.
>>
>>61865617
>C is pure
wew lad
>>
>>61865633
Regarding semantics of value and reference, yes it is.
>>
>>61865633
I want to protect those semantics.
>>
File: 1379865298577.jpg (90KB, 397x400px) Image search: [Google]
1379865298577.jpg
90KB, 397x400px
>>61865369
I'm mildly disappointed
>>
Should I learn RUBY to add to my skillset? It seems a lot of devops (puppet, chef) rely on Ruby Enginners.

Here's the languages I know so far: C, Go, Python, Javascript

And please, recommend me one Functional Language that's not a meme
>>
>>61866352
>that's not a meme
gonna need your own special definition of that, chief.

And no, Ruby is trash.
>>
>>61866387
Fine,
something used in production and has a decent and active community and package ecosystem
>>
>>61866420
Then Clojure, or Haskell.
>>
>>61866420
>something used in production and has a decent and active community and package ecosystem

clojure
scala
F#
>>
>>61866352
You only have learned trash programming languages for now. Please learn a lisp asap.
>>
>>61866352
Learn basic ruby, yes.
Functional language: Haskell/Scala or pick one that is moderately popular that looks interesting to you.
>>
>>61866352
Scala for the JVM or F# for the CLR.
>>
>memory safe
>lazy
>monanism
This is the worst timeline for language shitters.
>>
>>61866522
lazy by default is TRASH.
Optional laziness is the way to go.
>>
>>61866515
what a shitty reason to chose a pl.
>>
Do I really need more than Powershell or bash for scripting?
>>
>>61865369
kek. even dat 82yo woman does better than you

http://www.bbc.com/news/av/world-asia-40852480/japan-s-golden-coder-making-games-apps-aged-82
https://angular2-hn.firebaseapp.com/item/14995333
>>
>>61866537
It's not if you're already familiar with one of those two.
>>
>>61866566
java api ≠ jvm
.net ≠ clr
>>
>>61866438
Been interested in Haskell

>>61866459
>scala

Isn't that High-level pajeet lang?

>>61866473
Nty stallman

>>61866507
+1 Haskell

Okay boys, Im getting into Hasklel, hopefully I didn't get memed
>>
>>61866585
>hopefully I didn't get memed
Keep in mind Haskell was the Rust before Rust, it has its fair share of issues and plenty of quirks.
>>
>>61866584
Those two language provide good interop between those you mentioned.
>>
>>61866602
It must be mature by now though.

Look forward to doing some execises on Haskell.

Maybe I will write a simple tictactoe with a haskell backend and vue js front end
>>
>>61866602
If you have spare cash for books,
I have Real World Haskell and LYAH and they're both pretty good.
>>
>>61866757
>cash

any reason Why I cant find a free copy of them?

Thanks for the reccs anyhow.
>>
>>61866757
>spending cash on either of those
>>
>>61865617
I never understood why in C they used:
int *ptr;
int **ptrptr = &ptr;
int val = *ptr;

Instead of the following:
int *ptr;
int **ptrptr = *ptr;
int value = &ptr;

The second one just looks more sane to me.
>>
void Main()
{
int LEN = 2000000;
Stopwatch sw = new Stopwatch();
var a = new double[LEN];
var b = Enumerable.Repeat(0.0, LEN).ToList();
double c = 0;

sw.Restart();
for (int i = 0; i < LEN; i++)
{
c += a[i];
}

sw.Stop();

Console.WriteLine("Array. {0}.", sw.ElapsedTicks);

sw.Restart();
for (int i = 0; i < LEN; i++)
{
c += b[i];
}

sw.Stop();

Console.WriteLine("List. {0}.", sw.ElapsedTicks);
}


Array. 12037.
List. 6794.

Why is the list faster?
>>
>>61866816
Look at the bytecode.
>>
>>61866814
Declaration follows use. *ptr yields an int.
>>
Testing out unicode on Windows and I realised you could mess up text with superscript/subscript. So I wrote a small joke program that runs silently in the background waiting for a task manager window to spawn. Took a day to write.
>>
>>61866842
But what would ptr without the * yield to than?
>>
>>61867034
You're not supposed to think about it.
>>
>>61861536
school fag from earlier.

was looking into coding bootcamps and just wanted to know what you thought about just self teaching myself their curriculum?

the beauty of this is that it acts as a guideline and if i try to self learn i can still work full time.
>>
>>61867369
bootcamps are a scam and regularly place incompetent people into jobs they shouldnt have.
>>
What am I doing wrong here? It breaks on linker stage for some reason

class Horse : public Animal {
public:
Horse();
~Horse();
float feet_amount;
static Horse* horse_instance;
static Horse* GetHorseInstance() {
return horse_instance;
}
}


Horse::Horse() {
this->feet_amount = 0.3f;
Horse::horse_instance = this;
}


Am I missing something here?
>>
>>61867404
i kind of realized that, but what about following their curriculums at home?
>>
>>61867369
>JavaScript & Node.js
>MongoDB & JSON
>Git, GitHub and that url shortener site
I wouldn't follow that course as all of the concepts specified are to be avoided.
>>
>>61867426
self-teaching is the way to go along with all the free MIT courses and stuff out there.
>>
What is the best way to initialize an array of objects in Java? I have the following:

MyClass[] arr = new MyClass[3];
arr[0] = new MyClass(...parameters...);
arr[1] = new MyClass(...parameters...);
arr[2] = new MyClass(...parameters...);


However arr is actually much larger (e.g. 500 elements) and a for loop is useless because the parameters of each class instance are unique and must be hardcoded. In C/C++ I would write something like this:

MyStruct arr[3] = {{...parameters...},
{...parameters...},
{...parameters...}};


But it seems Java is lacking this syntax.
>>
>>61867455
Store the initialization parameters in a config file or something, then read them one instance at a time and construct the instance and add it to the collection.
>>
>>61867421
Yes, static member variables must have definitions in cpp files.
>>
>>61867433
i just want to learn some stuff that is still current in the industry. what do?

>>61867445
know any good guides or ebooks for total noobs?
im interested in web development and making web apps. possibly evolve that into stand alone apps much much further down the road.
>>
>>61867578
>im interested in web development and making web apps.
If you want to avoid JS (unless you want to actually get a job in it) then pick one of the thousand languages that can compile to JS.
I dont do much webdev myself so youre better off looking at /wdg/
>>
do any /g/ents know how to work with homomorphic encryption and/or blockchain development?
>>
>>61867593
>one of the thousand languages that can compile to JS.
I've heard good things about PureScript
>>
>>61867555
Thanks mane <3
>>
>>61867604
go away memer
>>
>>61865453
>Pointers aren't hard to grasp
Then is why is every critical system vulnerability always something to do with pointer handling?
>>
>>61867100
I always just find it confusing that type identifiers are part of the name and not the type. In some places in c they talk about the types "int" and "int *" while in other places they talk about "int (*ptr)" and "int value".
>>
>>61867625

no really, I'm asking for a friend
>>
Reading old code when...
for i=1,self.ruleSet.samplesPerSpawn do
self:insertSample(
self.ruleSet.ClassOfSample(
self.ruleSet.ClassOfSample.mutate(
self.ruleSet.ClassOfSample.cross(
father.weights,
mother.weights,
self.ruleSet.functionRandom
),
self.ruleSet.functionRandom
),
self:randomizePosition()
)
)
end

Where did I go wrong? That's probably worst thing I have ever made (not really).
>>
>>61867659
keep your bubbles to yourself
>>
>>61867653
I agree. As soon as you have to name the type (e.g. in a cast) things turn to shit.
>>
>>61867555
Inline variables are a thing now.
>>
In C++, I want to allocate a 2d array of objects, read a file, then construct each object in that 2d array. Is it better to call new to construct the 2d array, or malloc since I'm calling the constructor later?
>>
>>61867670

can I blow them in ur bum my man?
>>
>>61867690
auto* ptr = ::operator new(sizeof(int) * 1024);
>>
>>61867763
is this still in english?
>>
>>61867778
What do you mean, Anon. :(
>>
best place to learn programming in my opinion:
https://painlessprogramming.blogspot.hr/
>>
>>61867519
Is there a way to do this with JSON? Something like the libraries in Python for parsing JSON to dicts and other collections.
>>
>>61867813
shant be clicking your blogspot
>>
>>61867813
go away shill

if learning programming seems easy, then you're probably not learning
>>
>>61867787
nothing sorry
>>
>>61867814
Probably. I don't know Python or its libraries
>>
File: bait-but-also-true.png (17KB, 522x384px) Image search: [Google]
bait-but-also-true.png
17KB, 522x384px
Reminder
>>
Working on a android app in xamarin that does audio mixing, where you can record and audio files and apply effects to them to try to create new music. Ionly need to do now the encoding part and effects
>>
Do you GDB?
https://www.youtube.com/watch?v=PorfLSr3DDI
>>
>>61867956
print debugging 4 life, desu.
>>
>>61867927
But Python allows for a very fast development while still offering quite decent performance. Vast majority of software could be rewritten in Python and there will be no performance loss (maybe even improvement).
>>
>>61867927
>when you download someone else's OC and save it and then someone else downloads it from you posting it
sasuga
>>
>>61867956
I have written debugging scripts for gdb. Wish the Python bindings were more mature desu.
>>
Having a lot of trouble with this programming assignment. It's a grid of bears and fish moving around, bears eat fish if they are on the same tile. As someone recommended yesterday, I overhauled it so that every tile in the grid has an array of occupants. The problem i'm having is with moving them around now, I need to add them to the new tile and remove them from the old one but I can't move them while iterating through the tile. how should I do this?
>>
>>61867763
Hi, original question asker: I'm kind of new to C++ (but not programming). Can you explain this a bit?
>>
>>61867990
Python allows you to write buggy code very quickly indeed.
>>
I have a decent amount of programming experience (C++, Python, Haskell, various Lisps, etc.), but have decided that I want to get into kernel programming. Since I've never used plain C, I decided to write a string container as an exercise. Can anyone tell if there's anything I'm doing here that is not the typical C way of doing things? Any advice would be good. In particular, I'm wondering if my string_new and string_append functions should return pointers-to-string.

string.h
#pragma once

typedef struct string {
const char* cc_str;
const unsigned len;
} string;

unsigned cc_str_len(const char* cc_str);

string string_new(const char* raw_str);
unsigned string_len(const string str);
char string_at(const string str, unsigned i);
string string_append(const string str0, const string str1);


string.c
#include "string.h"
#include <stdlib.h>

unsigned cc_str_len(const char* cc_str)
{
unsigned len;
for (int i = 0; /* */; ++i) {
if (cc_str[i] == '\0')
return len;
else
++len;
}
}

string string_new(const char* raw_str)
{
unsigned len = cc_str_len(raw_str);
string newstr = (string){raw_str, len};
return newstr;
}

unsigned string_len(const string str) /* useless? */
{
return str.len;
}

char string_at(const string str, unsigned i)
{
return str.cc_str[i];
}

string string_append(const string str0, const string str1)
{
unsigned len0 = string_len(str0);
unsigned len1 = string_len(str1);
char* new_cc_str = malloc((len0 + len1) * sizeof(char));

for (int i = 0; i < len0; ++i)
new_cc_str[i] = string_at(str0, i);

for (int i = len0; i < len1; ++i)
new_cc_str[i] = string_at(str1, i - len0);

string new_str = (string){new_cc_str, len0 + len1};
return new_str;
}
>>
>>61867990
https://benchmarksgame.alioth.debian.org/u64q/python.html
Yeah, Python's performance is pretty dismal.
>>
>>61868012
Use two grids
Clear B
Put the next state of A in B
Resolve tile participants in B
Swap A and B
>>
>>61868041
What part is confusing you? Do you know malloc?
>>
>>61868172
I know malloc, but I don't know what
::operator
means.
>>
>quit smoking
>don't stand up and stretch anymore at smoke breaks
>be more productive but scared of hemorrhoids
life is cruel all around

Reminder to stretch
>>
>>61867956

This seems pretty archaic compared to Visual Studio. Can't these Linux guys make a good IDE (i.e. editor, code manager, help system, debugger). The trace ability functionality is cool though.
>>
>>61868229
>smoking
>>/b/
>>
>>61868196
::operator new
is all one thing.
:: is used for namespace resolution,
Foo::bar
means the bar symbol in the Foo namespace or class,etc.. By omitting the lhs, :: resolves to the global namespace rather than any
operator new
that might be shadowing it in a more local scope.
And by using
operator new
instead of simply new, that means a direct call to the allocator which takes an argument of chars just like malloc.
>>
New thread: >>61868339
>>
>>61868077
Woah, a dynamic language is slower than a compiled one, and in a bunch of unrealistic silly tests to boot!
>>
>>61868363
pythonista sure is upset
>>
>>61868363
reeeeeee
>>
>>61868066
>Can anyone tell if there's anything I'm doing here that is not the typical C way of doing things?

from what I think I know:
>check the value of malloc
>sizeof(char) is going to be 1 so you can leave it out

as for string_append and returning pointers to strings the current way means you can't do something like
a = string_append(a, b);

because of a memory leak but in the other way you could do
string_append(&a, b)
>>
>>61868727
>&
that doesn't exist in C and it's also not pure
>>
>>61868786
>>61868727

to clarify, when I say it's not pure, I mean modifying an existing value instead of returning a copy is generally a bad way to do things
>>
>>61868323
What's the advantage of this over malloc?
>>
>>61868862
a block allocated with malloc must be released with a call to free. A block allocated with new or operator new must be released with a call to delete.
So I guess it's a consistency thing? It's the only advantage I can think of.
>>
>>61868883
So it allocates it just the same as malloc, but allows me to use delete, and doesn't call a constructor needlessly, leaving me to be able to call another constructor later on (after reading a file)? This is perfect, thanks a lot!
>>
>>61868786
& does exist in C it's just you are thinking I'm using it in the C++ way. And I try to write pure functions myself but in C I'm less strict about doing so
>>
>>61868960
You can call a constructor at a later point with placement new.
new (ptr) Obj(arg); // Constructs an Obj with argument arg at *ptr.
Doesn't allocate, just calls the ctor.

The pointer to the whole block you allocate with operator new will be of type void*, and when you delete this pointer no destructors will be called. If you want to call destructors, you can do it explicitly on each member of the array which you are certain exists.
ptr->~Obj();


If all this seems like a lot of work, it's because it is. You may prefer.to use a std::vector. You can reserve storage for a large number of objects in advance with std::vector::reserve while keeping the logical size of the array 0. Then you can construct objects in the vector with zero allocation cost at a later time.
Thread posts: 323
Thread images: 20


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