[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: 333
Thread images: 28

File: 1499219864464.jpg (47KB, 612x767px) Image search: [Google]
1499219864464.jpg
47KB, 612x767px
Previous thread: >>61252761

What are you working on, /g/?
>>
unit tests are retarded
>>
>>61257769
IRC for Kotlin.
>>
Golang reporting in
>>
>>61257769
dumb frogposter
>>
nth for arguing with someone without defining key terms in the discussion
>>
>>61257740
This is actually what happens:
// /person/[:id]
public class Person {
public List<House> Houses {get; set;}
public List<Car> Cars {get; set;}
}
// /person/:id/cars
public class PersonCars {
public List<Car> Cars {get; set;}
}
// /person/:id/houses
public class PersonHouses {
public List<House> Houses {get; set;}
}

These are just the simple ones but /person/:id/core actually has multiple fields that I know have to repeat.
>>
>>61257841
What the fuck, stop. You're doing it wrong.
>>
>>61257802
thanks for the input NEET
>>
>>61257841
Sorry dude you fucked up somewhere.
>>
>>61257864
if you can write a proper test, you can write a proper function in the first place.

a lot of problems are too big to test with a catch-all unit tests, you would have to do a proof instead of a unit test.
>>
>>61257869
>>61257856
Well I can't change the api as it isn't mine. But do tell me how to do fix it if you weren't talking about what the api returns.
>>
>>61257902
You don't have to create a class for every possible JSON format. Deserialize into the logical components of what you're pulling from.

It's hard to help you without more information. Are you just pulling this data from an API and trying to use it in your application? Because you can
muhPerson.Cars = JsonConvert.DeserializeObject<List<Car>>(rawJsonFromApi);
>>
>>61257769
learning assembly
>>
>>61257937
No it's just that if I scrape "/person/4" it will give me something like:
{"Id":4,"Name":"name","Age":35,"Houses":[{"address":"addr"},{"address":"addr2"}],"Cars":[{"brand":"Subaru"}] 

Depending on the situation you don't really want to get everything and only a small part of the person. So I can scrape "/person/4/houses", "/person/4/cars" and "/person/4/core" which will give me:
{"Houses":[{"address":"addr"},{"address":"addr2"}]}
{"Cars":[{"brand":"Subaru"}]}
{"Id":4,"Name":"name","Age":35}

It would have been nice to only having to define all of the fields in my classes once and just be able to include all of those small parts into the person class.
>>
>>61257815
I don't know Java but aren't you supposed to do Program.SuckMy...?
Since it's declared as a static member function you'd have to access it as a class member. But you don't need an object to pass it.

That's my slim understanding of public static/whatever equivalent in 'oop' languages from when I touched them maybe 10 years ago.
>>
>>61257802
They're good for making sure pajeet doesn't fuck up your code.
As for practical error catching they're not that useful.

You usually don't need help with the cases unit tests can cover anyway.
>>
>>61258191
correct
>>
>>61258143
You don't learn assembly, you program with it.
You learn javascript because it makes no sense.
>>
File: bath face.jpg (54KB, 379x436px) Image search: [Google]
bath face.jpg
54KB, 379x436px
>>61257769
>statically-typed, compiled Scheme

find a flaw
literally the best of every world: safe, performant, expressive
>>
>>61258286
>statically typed scheme
How? What point? Either a function is defined for an argument, or it isn't.
>>
File: sicp.jpg (10KB, 290x215px) Image search: [Google]
sicp.jpg
10KB, 290x215px
>>61258286
>>61258319

I'm doing the same thing except in CL, there's more available libraries and the lisp vm is just being used as an intermediate/compiler langauge

remember ANSI Common Lisp is the industry standard LISP!

>>61258319
formal verification and auto proofs
>>
>>61258218
Weird how they're arguing. It's not bound to an object it just needs scope resolution.
>>
>>61258286
>performant
Meaningless word. Also I doubt it's true if what you meant was efficient, by common performance standards.
>>
>>61258286
>no reader macros
>no unhygienic macros
>not Common Lisp so lacks libraries and is not compatitble with any standardized language
>>
>>61257802
No it isn't. Actually try working in a large project instead of your shitty 100 LoC scripts
>>
>>61258333
Strongly typed scheme or lisp sounds very terse and unpleasant. What I like about lisp and scheme is that all data structures are all fundamentally lists, with a few primitive defined functions. Everything else can be derived from this (except for things like IO).

>>61258358
>>61258191
I'm not sure why people think scope resolution somehow affects the logical semantics of a static method. If you call a namespace a class, and that class happens to hold a bunch of static methods, what you've created is a namespace with functions as members. Not really any difference than std:: in C++. You're just strong arming C# a bit, but it doesn't really matter.
>>
>>61258394
t. webfag
>>
>>61258380
Most Schemes do have unhygenic macros though. It's just not necessary in most cases.

You should avoid metaprogramming whenever possible anyway.
>>
File: 1406007819880.png (148KB, 300x300px) Image search: [Google]
1406007819880.png
148KB, 300x300px
>>61257769
I have decided that webdev languages (HTML, CSS, Java, JavaScript, etc) belong in the trash and I'd rather be fucking unemployed than work another shitty webdev contract. My professors and job advisors all scammed me by selling me on getting into webdev, and I fell for the meme.
Thus, I am teaching myself how to be an honest, intelligent, hardworking American systems programmer by learning assembly, C, C++, C#, and the .NET framework.
Right now I'm just starting with C and reading The C Programming Language 2nd Edition (H&K), next is getting into assembly.
>>
>>61258424
Is that the best you can do?
>>
>>61258433
>C++
>C#
"Intelligent"

Can't believe I share this thread with brainlets like these
>>
>>61257769
uninstalling octave and installing matlab
>>
>>61258446
You can leave anytime.
>>
>>61258462
No, you should go back to your shitty webdev thread. It's meant for containing single digit brainlets such as yourself
>>
>>61258395

dynamic typing is technically strongly typed programming that hides it from you through inference
>>
>>61258433
You will never make it. Mark my words.
>>
>>61258474
If you seriously are one of those fucking blowhards that think C is the only language in the universe worth a shit, then you need to find a rope and hang yourself.
>>
>>61258395
Scheme is typed whether you realize it or not.
Better to annotate it to catch a shite tonne of errors and increase performance.
>>
>>61258428
>You should avoid metaprogramming whenever possible anyway.
Sure but you can't avoid it. And if you don't have good tools for it you might as well program in blub language.
>>
>>61258488
Did I ever say so, brainlet?
>>
>>61258504
Ok. Scheme has more tools for metaprogramming than Lisp does. Classic unhygenic macros and syntax-rules.
>>
>>61258428
>avoid metaprogramming where possible
It's always possible to avoid. You're saying never to do it here. But I suspect that's not what you mean.
Be more specific?
>>
>>61258482
Explain.
>>
In c++, do you use "\n" or endl to print a newline? Is one of these more acceptable?
>>
>>61258519
>not implementing hygienic macros with unhygienic macros
Scheme is shit and unhygienic macros are in it are not standized.
>>
>>61258479
How so? I think I know what you mean, and I think you're incorrect, but I'd rather not assume.

>>61258500
It is typed, but the type system does not get in your way. Annotation just makes shit harder to read.
>>
>>61258539
\n
Because C++ had issues with endl and we should never ever move past that.
>>
>>61258520
The beauty of Lisps is in their unambiguous homoiconic syntax. If you're creating clever new syntax that breaks from this mold, you're causing trouble.

I'm just saying in 5 years of Scheming I'm not sure I ever ran into a situation where a macro saved the day.
>>
File: sicp.jpg (108KB, 600x600px) Image search: [Google]
sicp.jpg
108KB, 600x600px
>>61258547

your objects/values are being passed around as tagged memory and get inferred when parsed
>>
>>61258547
Type systems aren't getting in your way. They're saving you from trouble down the road. What's more is that type signatures are essentially self-documenting. I write them in comments in languages that don't have them, just to keep track of what functions do.
>>
>>61258588
If I write a function that is defined for all inputs for which car and cdr are defined (any list), I shouldn't have to explain that the compiler/reader.

>>61258576
That does not have anything to do with Scheme programming. Leave the implementation details to the implementations.
>>
>>61258567
are you retarded?

endl is fine, it's just slow to write big fies because it flushes the buffer every time, but sometimes that's what you want
>>
>>61258509
Not him but you never provided any arguments why you thought they were unintelligent languages, not providing arguments for your statement is something unintelligent people tend to do.
tl;dr cuck/retard
>>
>>61258646
>do stupid inefficient shit
It's never sensible to have that kind of behavior embedded in what's supposed to be just a simple output.
Using endl is for brainlets. If you absolutely love streams just do your output and then do std::flush instead. The normal case isn't to flush on newline. If you want these kind of silly behaviors go to some scripting language shit.
You shouldn't use C++ if you find flushing all the time acceptable behavior.
>>
>>61258622
(: function-name ((list-of any) -> any)))

wowwwwwww
>>
>>61258622
>If I write a function that is defined for all inputs for which car and cdr are defined (any list), I shouldn't have to explain that the compiler/reader.

f [] = a
f (x:xs) = b
-- a, b have the same type

the compiler can infer
>>
>>61258695
to see what you print out instantaneously is *expected* behavior, that's why std::endl is used everywhere in programs
it only becomes an issue when you write big files
>>
>>61258261
I have 2 reference manuals open so I'm not sure how little learning is required here anon.
>>
>>61258746
Wow, Haskell with parenthesis
>>>/trash/

>>61258767
For what purpose?
>>
>>61258770
or many smaller files
the point is that if you don't output a shitton of lines when writing speed becomes an issue then std::endl is fine
>>
>>61258286
Literally Clojure + clojure.typed
>>
>>61258784
>haskell invented type signatures
do you kiss your mother with that brain?
>>
>>61258801
except without a fucking JVM
>>
>>61258801
>literally clojure
clojure is not even a lisp.
>>
>>61258827
explain this pls
>>
>>61258622
What's the car and cdr of the empty list?
>>
>>61258826
> implying the JVM is bad
>>
>>61258810
>haskell is not the most widely used strongly typed functional language

>>61258837
Depends on the implementation, in some they're undefined, for others they return the empty list.
>>
>>61258770
If that's expected behavior then use std::flush
Why should that be linked to newline at all then? If that's expected behavior just flush at every character even.

Linking it to newline is just retarded.
>it only becomes an issue when writing big files
It becomes an issue when you put any sort of demand on the output.

I'm sure you wouldn't accept this in other circumstances. What if your network sockets arbitrarily flushed when you pass it certain characters?
>>61258799
Yes if you literally don't care about the program do whatever you like. Just do whatever. But why are you using C++ then? Use a better language for development speed. You're using C++ because you have requirements that makes it helpful.
Output is one of those things you can't take lightly.
>>
>>61258837
empty list
>>
>>61258172
>It would have been nice to only having to define all of the fields in my classes once and just be able to include all of those small parts into the person class.

I think you're beyond helping; you have this fucked up idea that there's no way to do exactly what you're asking for, when there is.
>>
>>61258890
Do explain to me how it should be done.
>>
>>61258837
errors.

>>61258863
>therefore anything with typing is haskell
bulletproof logic
>>
>>61258864
>Linking it to newline is just retarded.
no you're retarded
>>
>>61258934
Motivate why linking it to newline is wise.
Motivate why not setting it as standard to have users consciously flush their output in a language that's supposed to be efficient.

Or be quiet.
>>
>>61258926
You apparently have this:
public class PersonHouses {
public List<House> Houses {get; set;}
}


This is unnecessary. It is not needed. If you want a list of House, then use a
List<House>
.

I'm still not certain why you think you need those classes. You can deserialize directly into
List<House>
and use that however you see fit. If you can show me some of your code where you use these unnecessary classes, I can provide more insight. It's nearly impossible to make recommendations without you telling me what you're actually trying to do.
>>
>>61258873
>>
>>61259008
in real language like Common Lisp.
Nobody cares about your 1GB/s garbage generation.
>>
>>61259008
please use safeHead
>>
>>61259019
why would you want the car of an empty list to be another empty list?
you do realize how harmful that can be right?

once again, errors are your friend
>>
>>61259019
>>
>>61257769
dumb not anime poster
>>
>>61259043
nil is the same thing as '() which is empty list. Dumb faggot.
>>
>>61259067
I never implied it wasn't.

I'd rather have the Haskell error than the CL valid response though.
>>
How it should be
>>
>>61259082
How'd you get this, senpai?
>>
>>61259082
yeah anybody using clojure should just leave.
>>
>>61259100
it's chicken scheme, not CL
>>
>>61258428
Metaprogramming is in my soul.
>>
>>61259104
Cool. Having a browse through the docs now.
>>
>>61259077
>he'd rather his program crash than not
>>
>>61259134
Silently failing is much deadlier than the alternative.
>>
>>61259117
metaprogramming is a tool for crippled languages
>>
>>61259149
I hope you don't write code for pacemakers.
>>61259150
>he has to work around his language instead of making it work for him
>>
>>61259134
If my function is
[a] -> a

I don't want a list.
>>
>>61259149
>well defined behavior
>silently failing
It's not failing if it's doing what it's supposed. Haskell crashes just fuck you.
>>
File: 1474228831420.jpg (319KB, 1600x1064px) Image search: [Google]
1474228831420.jpg
319KB, 1600x1064px
>tfw still NO interesting summer project
why even live?
>>
>>61259187
> an Exception means a crash
There is something called 'error handling', you know.
>>
>>61259175
>work around his language
That's what metaprogramming is
In good languages you just do regular programming
>>
>>61259206
Just let your errors quietly accumulate bro, nothing can go wrong.
>>
>>61259206
exceptions were mistake, dumb faggot.
>>
can anyone post the latest programming challenges? I've done 3 so far, looking for the next one
>>
>>61259212
This is wrong.
>>
i dont know if this is the correct place, but I'll ask here anyway.
In grade 11, I completed ~10 chapters of programming : principles and practises of c++ ( its a basics programming book). Grade 12 was hectic for me, so I didn't touch the book.
I'm joining college this year. Should I reread the first 10 chapters again? I really don't want to do that, but I don't think I remember each and every detail. Or should I just resume from chapter 11 and will all those things i forgot just come back to me?
^apologies for my sri lankan english
>>
>>61259196
Fuck you faggot
get out of here with your lack of creativity
>>
Yo in some IDEs when you write parenthesis or quotations it auto writes the end parenthesis/quotation, is there a way to move the cursor after the end symbol without using the right arrow key? It's out of the way.

Specifically I'm using vscode.
>>
>>61259222
Error handling, which was the focus, was not.
>>
>>61259272
You are an error. Handle yourself.
>>
>>61258988
I am scraping this api for data I want to use for myself, one of the valid endpoints are:
...
/person/[:id]
/person/:id/core
/person/:id/pets
/person/:id/cars
/person/:id/houses
/person/:id/belongings
...

Calling "/person/4 with a valid id will give you back an object with a lot of fields.
Calling any of the other/person/:id/{name} endpoints will give you back an object with specific parts of the same person object as I sometimes don't really need to get all of the data but just specific parts for example all the houses the person owns.
So if I scrape "/person/4/houses" it will give me back
{"Houses": [{"address":"addr"},{"address":"addr2"}]}

instead of:
[{"address":"addr"},{"address":"addr2"}]

So I can't directly do
JsonConvert.DeserializeObject<List<House>>(text);

as I am actually getting back an object and not a List. and I should say that I give all of those classes an interface and those parts that use the Person, PersonHouses or PersonCore can be passed to the correct functions and still function. It's just that I need to write down the same properties 3 times for the interface, Person and Person{name} which is a bit annoying.
>>
>>61259134
>>
>>61259133
It takes on the best qualities of lots of languages imhotep
Scheme in general has less warts and saner behavior than Lisp (cdr of '() fails, only #f is false) but Chicken specifically has unhygenic Lisp macros, static typing, C FFI, pattern matching, list comprehensions, regex, and more
>>
>>61259293
Just what are you trying to prove here, pencil dick?
>>
>>61259308
That Haskell has saner default behaviour with empty lists, and that, if necessary, handling the associated error is trivial.
>>
>>61259320
If it had saner default behavior, it would use that instead of head. But it doesn't, so your argument is meaningless and a waste of space.
>>
>>61259224
feels batman
>>
>>61259363
Whatever, man.

The head of an empty list isn't a list though.
>>
>>61259293
(defun fn (lst)
(car lst))

(fn '())
;; returns nil
(fn '(1 2 3))
;; returns 1

Wow lisp won again.
>>
>>61259379
The head of an empty list isn't an exception, lol.
>>
>>61259376
>>61259224
here you go nigger
better-dpt-roll.github.io
>>
>>61259408
Go post your dumb roll threads to >>>/b/
>>
>>61259417
fuck off faggot this website was made so people stop rolling, kill yourself
>>
>>61259395
Except 'nil' is an empty list.
>>
>>61259430
It is also false, and ⊥.
>>
>>61259403
It should be, that's the point.

You're asking the computer to do an impossible task - it *should* complain to you.
>>
>>61259445
>trying remove element from nothing should crash rather than return nothing
dumb haskell poster
>>
>>61258214
Kill yourself as soon as possible
>>
>>61259442
As the Chicken Lisp guy pointed out, it shouldn't be. Nil, false and bottom should not, imo, be an empty list.
>>
>>61259226
Templates are an example of how retarded metaprogramming is.
>>
>>61259458
> computer, perform this impossibility
> ok, here's a valid response you will have a harder time debugging

No, the computer should definitely produce an error.
>>
>>61259458
>Empty list is nothing
Dumb lisposter
>>
>>61259417
>>61259408
thanks niggas
>>
>>61259494
Correction: templates are retarded. Metaprogramming is not.
>>
>>61259494
No templates are an example of metaprogramming facilities that makes metaprogramming look bad.

Templates should definitively not be used for metaprogramming.
>>
>>61259494
>templates
You're out of your element Donny.
>>
>>61259232
Just start from the beginning again and if you remember parts of it, just skip those parts. It's better to know the beginner parts well because the first programming class you take in college will not be very difficult, especially if you have any prior knowledge.
>>
>>61259497
>exceptions
>how computers should work
faggot
>>
>>61259494
TMP is shit, even C++ recognised that and introduced constexpr
>>
>>61259523
>errors = exceptions
>>
>>61259509
>>61259513
>>61259519
>>61259531
Templates are an example of metaprogramming.
Even if they had a saner implementation, since they are glorified macros, they would STILL be retarded.
>>
haskell is unironically shit
>>
>>61259551
>template metaprogramming represents all of metaprogramming
>>
>>61259523
Errors can be handled. Would you rather have the red flag-waving of a manageable exception, or for it produce a silent valid result?

A matter of taste, I suppose. I'd prefer the former.
>>
>>61259571
Fuck off, I don't want reddit stink around me.
>>
>>61259568
I am fucking telling you that this is a perfect example of a crippled language that uses metaprogramming as a work around, since that's what metaprogramming is about.
>>
>>61259561
Pretty cool, actually.

Currently thinking about implementing some bioinformatics, protein folding shit in it.
>>
>>61259583
>C++ is crippled and uses metaprogramming, therefore, all languages that use metaprogramming are likewise crippled
>>
What's the equivalent of lists in C ?
>>
>>61259551
>even if they had saner implementation
They're wrong in concept.
If you never do metaprogramming how can you even comment on it.
>glorified macros
Indeed. Partly why they're terrible.
>>
>>61259622
linked lists
>>
>>61259622
Equivalent of lists from where?
You write your own datastructures in C. Or use external libraries.
>>
>>61259625
>macros are bad
>partly why they're terrible
because metaprogramming is bad

>>61259607
"Hahahaha, he hasn't given me an example for every single metaprogramming feature my favourite language uses therefore metaprogramming is not retarded!"
>>
>>61259622
Linked lists or arrays.
>>
>>61259649
>too retarded to understand the fallacious nature of sweeping generalizations
>>
>>61259622
a struct that contains the data at the current node and a pointer to the next node

>>61259561
haskell is shit because its laziness makes it difficult to reason about performance and its syntax is too clever for its own good
it's not shit because of static typing and the head of a list returning an exception
>>
>>61259649
>because metaprogramming is bad
I was gonna type out some inb4 but I thought you might come up with a sane reply. You don't use metaprogramming and have impressions from metaprogramming that's macros and C++ templates.
It's pointless to argue with you.
>>
>>61259670
>sweeping generalisations
Thanks for confirming that you're retarded, now that you've made this complaint I don't need to engage with you at all.

>>61259675
What do you use metaprogramming for?
Here are the accepted replies:
>i want to embed a programming language in my program and don't want to write it myself
Nothing else is coming to mind.
>>
>>61259700
t. brainlet
>>
>>61259671
One can often explicitly state that something must be run non-lazily, with $! as function applicator.

There was some talk of strict function annotations, but not yet.
>>
>>61259768
you can use {-# LANGUAGE Strict #-} to make a module strict
>>
>>61258433
>(H&K)
>>
>>61259622
dynamically create a new array when you need to add a new element
>>
>>61259622
c doesn't have a list type. c doesn't even have a string type.
>>
main = print (head [1,2,3])

head the_list =
if the_list `is` empty
then Nothing
else Just (the first_element (from the_list))

the = id
first_element (x:xs) = x
from = id
(is) = (==)
empty = []

Why is Haskell so perfect?
>>
>>61260230
>it's another "look how concise this trivial thing is" example

We all know Haskell becomes an unreadable mess when you try to do any serious work with it.
>>
>>61260230
the = id
first_element (x:xs) = x
from = id
(is) = (==)
empty = []

This is mindbogglingly unintuitive syntax.
>>
>>61260261
>>61260272
I like writing code that reads like english. I usually take an english sentence then write constructs to make it do what it says.
>>
>>61260272
the only part of this i accept as unintuitive syntax is the list syntax (x:xs) and []
>>
>>61260308
Don't get me wrong, I'm with you on that. I love C#'s extension methods for that very reason.

Haskell is still a shit.
>>
>>61260320
wrong
>>
>>61260308
Then you'd LOVE COBOL.
>>
>>61260320
>a = b
>c = d
>e = f
>g = h
>i = j

>this syntax is impossible to understand to the typical C# programmer - what does = even mean?
>>
>>61260342
What even is this post? What are you trying to say?
>>
>>61258961
>Motivate why linking it to newline is wise.
What else? The output consists of lines.

>Motivate why not setting it as standard to have users consciously flush their output in a language that's supposed to be efficient.
Oh so you didn't know this about endl and blame your ignorance on the language?
But now you know so use it appropriately.
>>
I have found true enlighenment
ask me anything
>>
>>61260399
How was reading The Little Schemer?
>>
>>61260399
how do I program in prolog?
>>
>>61260399
flat or round?
>>
>>61260412
I haven't read it

>>61260417
I don't know, I've been meaning to learn the language as well

>>61260419
Flat or round what?
>>
>>61260470
>I haven't read it
Ahh, I believed you when you said you'd found true enlightenment. Keep looking friend.
>>
>>61260372
>you didn't know
I knew.
>blame your ignorance on the language
Well I can see how some might. But that's not a big issue. The issue is having implicit actions taking place. It's terribly ugly.
>the output consists of lines
So? Why is a line the unit of data you want to push? Buffered output has no reason to flush immediately normally the normal case is that you write out a few lines and then flush. Flushing per line is a very odd case as you'd find if you've written anything but basic programs.
Shit even fizzbuzz should probably not flush every line so there we have something on your level as an example.

Flushing at newline is as arbitrarily as any other character. You could flush on whitespace just as well. Or any character. If you think newlines are special then you're just not a senior programmer.
>>
Whats the point of using a set over a dictionary or list?
>>
>>61260555
>dictionary
cleaner interface (many set implementations are backed by dicts)
>list
O(1) contains, guaranteed to only have 1 of each element
>>
>>61260555
A set is a dictionary with only keys, no values.
A set is a list without duplicates, and depending on implementation without order.
>>
>>61260470
breasts
>>
File: 2giphy.gif (108KB, 500x298px) Image search: [Google]
2giphy.gif
108KB, 500x298px
So far I've only ever used Java and C++ for school assignments, but I noticed a lot of the grad students in IT have Pycharm installed, and a PhD student told me he has to model a lot of algorithms and test them with a program.
If python is the way to go should I learn 2.7 or 3 now?
>>
>Try to use Rust
>Can't even implement a basic flood fill
Phew, never thought I could suck that much at a programming language.
>>
>>61260618
Python 2 is a dead end.
>>
>>61260618
Algorithms are algorithms, my man. They can be implemented in LaTeX, if you want. Language is irrelevant.

But 3.
>>
How does anyone find time to work on personal projects and a portfolio? By the time I get home and have dinner it's nearly time for bed and on weekends I try to balance friends and hobbies
>>
>>61260660
>FRIENDS
>>
>>61260618
I dont like python. A lot of people in academia got memed into learning it. If you've ever tried to maintain someone else's python code, you'll realize why python sucks. If you're gonna fall for the meme, learn 3.
>>
>>61260660
By not caring about my actual job, and leaving that shit as soon as possible.
>>
>>61260660
>job
>friends
l-m-a-o
>>
>>61260643
I sort of assumed that, but thank you for the validation
>>61260645
I get that, but I'm making an assumption that there's some sort of uniformity among grad students because Python seems so common. For instance my gf took a computer imaging class and when she went to the TA for help the TA practically told her "don't come back until you've re-written your program in Python".

>>61260731
I guess that explains my reply above this one. What's weird is my school doesn't offer Python at all yet everyone post undergrad uses it.
>>
>>61260767
Then that TA is shit and should be sacked.

If he/she is worth his/her salt, then they should know multiple languages inside-out.

TAs are an American thing, right? I don't know how well educated one is meant to be; they're not a thing in Britain.
>>
>>61260803
TA was a PhD student and the class is the exact course material for undergraduate and masters, except undergrads get a curve. So yeah I agree that's unacceptable, but I guess when you're hard up for TAs people like that pop up.
>>
>>61260767
Python is a cargo cult in academia. Most academics want to learn as little programing as possible so they do what everyone else does, which is Python. They dont know why they use Python but they do and everyone they know does so it has to be the best choice.

>>61260803
A TA (teacher's assistant) is just a grad student usually.
>>
>>61258571
You can make object oriented programming easier with macros to generate constructor procedures. The alternative would be eval or something truely frightening.
>>
>>61260872
I once heard it described that everyone learns Python in academia because of all the built in libraries and tools.
Why make your own functions when you can import or something like that. The dude who told me that could be biased and insisted anything Python can do, C++ can do better.
>>
>>61260633
That's because rust is overengineered shit
>>
Currently learning how to use OpenGL directly on a SDL window
F U N
U
N
>>
>>61260927
That's part of it too -- since academics use python they write libraries that target python. Then people need to use python to use those libraries. A lot of data science libraries (numpy, scipy, pandas) and machine learning libraries (scikit-learn, tensorflow) were first written in Python. These libraries quickly became memes in their relevant fields and anyone who wanted to join those fields was instructed to learn them.

C++ replacing python (and vice versa) is a pipe dream. Academics do not want to do manual memory management.
>>
File: 1498880859035.jpg (303KB, 598x714px) Image search: [Google]
1498880859035.jpg
303KB, 598x714px
>glDrawElementsInstancedBaseVertexBaseInstance
>>
File: 1-141029214102.jpg (45KB, 640x480px) Image search: [Google]
1-141029214102.jpg
45KB, 640x480px
still working on my 3d lolicon mmorpg, what do you think about my new 3d model?
>>
>>61261036
it gets even worse because those fields themselves are memes
>>
>>61261205
Thanks, I just got promoted.
>>
>>61261205
it has tits and it doesn't have a penis
>>
>>61257802
>Spec defined as code
>Automated regression checking
>Can refactor code without worrying about whether or not something has broken
How are they bad again?
>>
>>61261221
noted in the bug tracker, will only have tiny tits and a penis
>>
File: v&.png (35KB, 475x122px) Image search: [Google]
v&.png
35KB, 475x122px
>>61261205
>>
>>61261221
>doesn't have a penis
It always does anon-chan, it's just not big enough.
>>
>>61257802
They're retarded when they're non-existent and you need to refactor a multi-million dollar project that also lacks documentation. Kys neet faggot
>>
>>61257802
how else do you know if your code works?
>>
>>61261182
I use a call to glDrawArraysInstancedBaseInstance in my code. I would have used glDrawElementsInstancedBaseVerexBaseInstance if I could have but primitive restart is a huge performance hit for some unknown reason.
>>
>>61261253
>anon-chan
anon-kun for you
>>
>>61261268
what about degenerate triangles
>>
>>61261264
>Writing code that doesn't work
Just don't do that. Easy.
>>
>>61261225
>Can refactor code without worrying about whether or not something has broken
This is how. False sense of security.

I'm not him and I'd say overall they're good though.
>>
>>61261287
anon-seeeenpaaaai
>>
how exactly does a mysql database work?
is it basically like a file?

what's a table exactly
>>
>>61261316
loli chan :3
>>
>>61261292
No reason to bother then. Only reason I had to use gldrawelements was to decrease vram usage. But both primitive restart and referencing verts nonlinearly dropped fps from 120 to 90 for PR and 80 for nonlinear vertex ordering.

Degenerate triangles would still put me slightly ahead on v ram usage but would significantly hurt performance as I'm limited by the vertex and geometry shaders.
>>
>>61261370
>vertex ordering
Vertex referencing I mean.

Polite sage.
>>
File: 1493010991317.png (47KB, 600x800px) Image search: [Google]
1493010991317.png
47KB, 600x800px
I miss 2010-2012 era /dpt/
I miss the Yuki OP
>>
>>61261404
what was it like anon
>>
>>61261404
post it
>>
>>61261268
>glDrawArraysInstancedBaseInstance

Couldn't you use a single VBO for everything with this?
>>
>>61261448
2 vbos. That's what I do. One vbo for model data and one vbo for instance data.
>>
File: 1356472093046.png (389KB, 934x1000px) Image search: [Google]
1356472093046.png
389KB, 934x1000px
>>61261425
no arguing over unrelated shit like anime on an anime website
no reddit

>>61261432
are you serious? this was the op image of every /dpt/ until like 2015 when reddit invaded after gamergate/fappening/trump
>>
>>61261471
it gets pretty boring desu anon
are you the one guy who constantly uses it
>>
>tfw still NO summer programming project
should I just hand myself already?
>>
>>61261485
I don't make the thread. I can't bring myself to come here anymore.
>>
>>61261487
make a discord spambot
>>
>>61261492
There's one guy who constantly uses yuki
It needs to be mixed up at least a bit
Obviously anime OP is better but the same OP is not
>>
>>61261487
You should start a project or examine why you have not done so? Do you not actually like programming? Are you scared of failing or not writing good enough code? Is everything you want to do too overwhelming? Be honest with me anon; I know what it feels like to be into something I have lost interest in.
>>
>>61261471
it's shitty fanart, doesn't even look like the anime
>>
>>61261509
The OP being "boring" is not relevant. All interesting discussion in the thread should be of one's daily programming. The OP should be consistent and as uncontroversial as possible by using the same OP image and maybe containing an FAQ or link section.
>>
>>61261521
No I like programming I just have no idea what to do. School project can be shitty but a least I've got a project
>>
>>61261541
I think it's very relevant.
>>
>>61261471
>no one used to argue about anime
>starts an argument about anime
fuck you
>>
>>61261552
Most obvious and maybe boring is to make a video game. You could also just start working through books like TAOCP or I guess since we're here SICP. Research an algorithm or field of study that interests you. You don't need to make enterprise level software. To be honest, having an implementation of something as simple as Kruskal's algorithm on your github will set you apart from most CS grads.

>>61261569
I stated a fact; you are the one starting an argument.
>>
>>61261612
>Kruskal's algorithm
This looks interesting, I'll look into it.
I've got a github with my implementation of Huffman algorithm that I decided to make after our professor talked about it in class. Works well but could use some fixing.
To you have any other algorithm I could look into? I've already done A* for a small game and changed to algo to work with entities that needed more than one tile
>>
>>61261682
If you're interested in Kruskal's algorithm, you might also be interested in the application of Kruskal's algorithm in maze generation. Check out other graph stuff too like Breadth/Depth First Search, Dijkstra's algorithm or Floyd's algorithm. (All of those can be used to generate or solve mazes as well)
>>
>>61258837
empty list isn't a thing in lisp
nil is an atom, and because of convenience, it's car and cdr is itself,
>>
File: scr.png (221KB, 1680x1050px) Image search: [Google]
scr.png
221KB, 1680x1050px
/dpt/-chan, daisuki~

>>61257769
>What are you working on, /g/?

Exploring the darkest comers of Racket
>>
>>61261879
dumb daisukiposter
>>
>>61260341
give me an example pls
>>
>>61261879
>le reddit challenge
you have to go back
>>
File: shitty_code.jpg (252KB, 1062x896px) Image search: [Google]
shitty_code.jpg
252KB, 1062x896px
R8 the shittiest rock-paper-scissors program ever. Never used python before, so its shittier than shit
>>
>>61261913
dumb poster
>>
File: rust.jpg (212KB, 727x822px) Image search: [Google]
rust.jpg
212KB, 727x822px
Anybody else enjoying Rust?
>>
>>61261933
>That elsif chain
Just stop. Get some help. Buy a book.
>>
>>61261969
kys yourself faggot :^)
>>
>>61261971
thx bby
>>
C function naming convention, how do you do it?
Working on a game engine, and can't decide whether to name functions as
>create_texture
or
>texture_create
>>
>>61261969
Is that how you make bombs now?
>>
>>61262002
texture
>>
>>61262002
create_texture of course
>>
>>61262037
You wouldn't want your bomb to segfault
>>
>>61262037
Rust guarantees that the bomb can only explode in an unmuslim block
>>
File: 1493349104583.jpg (80KB, 512x512px) Image search: [Google]
1493349104583.jpg
80KB, 512x512px
Teleworking from home on a network monitoring contract written in C with light Python scripting. /comfy/
>>
>>61262002
the general convention is object_action, for ex SSL_Init or gtk_window, follow that
>>
https://nogenerics.info/
>>
>>61262103
kek
>>
>>61262103
lmao
>>
>>61262103
wew
>>
File: 1495682575669.gif (1MB, 211x203px) Image search: [Google]
1495682575669.gif
1MB, 211x203px
>>61262103
God damn, did not expect that.
Who ever did this, deserves a medal.
>>
>>61262103
:^)
>>
>>61262002
Most autocompletion users would appreciate texture_create
But frankly that's their fault for having dumb ass editors who don't make this shit convenient for them.
I'm fine with either. I imagine you might want texture_create just because of these people though. It's more common as well.
>>
>>61261933
I fixed it for you
class Move(IntEnum):
ROCK = 0
PAPER = 1
SCISSORS = 2

class Player:
global name, move

def winner(a, b):
if a.move == b.move:
return None
elif a.move == (b.move - 1) % 3:
return b
elif a.move == (b.move + 1) % 3:
return a
def announce_move(a):
return a.name + " chose " + a.move + "."
def _play(self):
winner = winner(self.players[0], self.players[1])
announcement = announce_move(self.players[0]) + " " + announce_move(self.players[1])
if winner == None:
announcement += " DRAW."
else:
announcement += winner.name + " WINS"
>>
>>61262172
well that went into my drawing reference folder really quickly
>>
>rust had ternaries but removed them
wow
>>
>>61262258
>IntEnum
>need a class to specify that the enum is an int
https://nogenerics.info/
>>
>>61261933
>>61262258
This shit is giving be PTSD from my time as a "Intro to OOP" TA at Uni.
God damn that was a painful semester.
>>
>>61262336
its amazing how bad beginners are at designing OOP software
it truly is a meme
>>
>>61262258
>
class Player:
global name, move


jesus fucking christ
>>
>>61262336
I'm not trying to do MUH OOHPS

I just wanted to demonstrate how that fuckhuge if/elseif chain could be reduced.
>>
>>61262258
still too many operations
>>
>>61262366
It's OOP. Don't question OOP.
>>
>>61261933
those comments... anon...
>>
If you were to build platform which would let users to run search / browse and execute programs easily without installing them how would you design it?
How to share and where to go get it?
How execute the program in sandboxed enviroment?
How to handle possible networking the application might need to do to access remote databases and such?
>>
>>61262392
How would you do it with less complexity then?
>>
File: rustle.webm (119KB, 848x480px) Image search: [Google]
rustle.webm
119KB, 848x480px
>>61262416
https://bitbucket.org/snippets/Tetsumi/RXko/rock-paper-scissor
>>
File: 1469401832154.jpg (50KB, 500x500px) Image search: [Google]
1469401832154.jpg
50KB, 500x500px
would lisp make a good first language? I'm not looking for a programming job, I just want to learn
>>
>>61262460
it's quite unlike most languages, I feel like it takes a different (somewhat more mathematical than simply logical) mindset
>>
>>61262400
>>>/g/wdg

This is not the thread for web dev.
>>
>>61261552
recode ls with all its options, you'll learn about unix-like system internals
>>
>>61262460
no because after you learn it all the rest languages will feel like shit.
>>
>>61262002
had a quick look at my /usr/include
thing_create was definitely more prevalent that create_thing, but I also got a lot along the lines of libraryname_subsystemname_create_thing or libraryname_thing_create_description.
>>
File: 1435778390206.jpg (56KB, 280x400px) Image search: [Google]
1435778390206.jpg
56KB, 280x400px
>>61262451
>draw and scissor are never referenced
>>
>>61262258
def winner(a, b):
d = {"T": None, "W": a, "L": b}
return d["TWLLTWWLT"[a.move * 3 + b.move]]
>>
>>61262460
lisp is the only programming language that has been approved by Richard M. Stallman (PhD)
>>
File: 1329526177731.png (46KB, 651x436px) Image search: [Google]
1329526177731.png
46KB, 651x436px
>>61262451
>https://bitbucket.org/snippets/Tetsumi/RXko/rock-paper-scissor
Fuck me, that is genius.
>>
>>61262451
I can simplify this code.
print("paper")
>>
>>61262472
Excuse me then. Thank you for your guidance!
>>
>>61262451
what purpose does the draw variable serve?
>>
>>61262502
And Java
>>
>>61262566
>He doesn't always pick draw when playing rock paper scissors
>>
File: emb.webm (175KB, 1920x1080px) Image search: [Google]
emb.webm
175KB, 1920x1080px
>>61262483
please don't bully

>>61262535
webm

>>61262566
the order is important. draw must be 0 in both the possible inputs and the possible outputs
>>
New thread when? :3
>>
>>61262734
Copy-paste this thread into a text document, there you go, the next /dpt/ thread.
>>
>>61262777
>not visualizing the thread with BI tools
>>
>>61259430
No it's not.
>>
>>61258433
It's a good choice desu. Though it's much harder to break into that industry, you gotta be a 10xer no screwing around.

>>61258446
Spotted the haskell shitter.

>>61258482
m8 I've trained people with no prior programming experience to do exactly what he described. Most just don't have it in them, but those people are usually the flippant types who can't be serious about anything. I think what he said he's doing/going to do is proof that he is serious and can probably do it.
>>
>>61262628
>the order is important. draw must be 0 in both the possible inputs and the possible outputs

the draw variable is never referenced. the list contains strings.
>>
>>61262808
One more word out of you and I'll fucking "draw" my dick out and fuck you're anus.
>>
>>61262460
Do it, it's very comfy.
>>
>>61262808
i'm pretty sure you don't understand your own code. try to run it without the draw = 0 line.
>>
>>61260613
Round, obviously.
>>
I need to implement a priority queue on some data structure for my project. I know how to do it but in C there is no template so do I have to re-write the code everytime I need to use a priority queue?
>>
>>61262884
use macros, I guess
>>
>>61262905
Yeah but I'm wondering if there is a better way. I was thinking of using void*
>>
>>61262884
void *
>>
>>61262884
>C
https://nogenerics.info/
>>
>>61262856 meant for >>61262830
>>
>+300
We need a new thread now!
>>
I made this C function that should return a "true" boolean value if a number is found from an array, "false" otherwise.

bool 
Search(const int a[], int n, int key) {
int i = 0;
int * p;
bool is_found = false;

for (p = a; p < (a + n); p++) {
if (*p == key) {
is_found = true;
puts("Found it!");
}
++i;
}

if (!is_found) {
puts("It wasn't found...");
}

return is_found;
}


It seems to work, but I get the following compiler warning and I cannot understand why.

search_haystack.c: In function ‘Search’:
search_haystack.c:58:16: warning: assignment discards ‘const’ qualifier from pointer target type [enabled by default]
for (p = a; p < (a + n); p++) {
^
>>
>>61263078
int const *p
>>
>>61263078
*a is const, *p is not while a = p -> you are breaking the type system.
>>
>>61263078
>return a "true" boolean value
that is the longest way to say "returns true" i have read in a long time.
>>
>>61263098
>>61263105
That's it, the errors are gone. I tried with both "const int *p" and "int const *p" and both seem to suppress the warning. Thanks!

>>61263127
Sorry, I am not very familiar with the vocabulary.
>>
File: HoneyView3_2017-07-07_16-27-19.png (303KB, 423x423px) Image search: [Google]
HoneyView3_2017-07-07_16-27-19.png
303KB, 423x423px
>>61263078
it goes through the whole thing even if it finds the number on the first iteration
>>
>>61263176
>Sorry, I am not very familiar with the vocabulary.
it's not a problem, just found it funny! enjoy programming.
>>
>>61262884
Use void * ,size of and a function pointer for determining priority. Take a look at qsort for guidance.
>>
/!\ A L E R T /!\

New thread

>>61263402
>>61263402 >>61263402
>>61263402 >>61263402 >>61263402
>>61263402 >>61263402
>>61263402

/!\ A L E R T /!\
>>
>>61262471
>>61262479
>>61262502
>>61262841
what's a good resource to start learning lisp? this site?

http://learnlispthehardway.org/
>>
>>61263414
SICP. It's got a free online version too if you are a filthy tree hugger.
>>
>>61263177
You're right, I added a break; in the loop so that it should stop if the number is found.

By the way, this exercise is from "C Programming - A Modern Approach", ex. 7, chapter 12 (Pointers and arrays).

Here is the complete code:
https://pastebin.com/tieG4cdH
>>
>>61263441
even though sicp is about scheme?
>>
>>61263455
You didn't specify common lisp. Lisp can refer to common, emacs, clojure, or scheme. Scheme's the best though and emacs the worst.
>>
>>61263509
isn't scheme quite limited compared to common? all of my information is from a cursory google so I'm not sure
>>
>>61263576
Not at all. And if you really need something, all good scheme compilers have a FFI to C ABI's. Common lisp series spread a lot of misinfo and half truths.

I'd use chicken or guile.
Thread posts: 333
Thread images: 28


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