Previous thread: What are you working on, Sup Forums?
/dpt/ - Daily Programming Thread
unit tests are retarded
IRC for Kotlin.
Golang reporting in
dumb frogposter
nth for arguing with someone without defining key terms in the discussion
This is actually what happens:
// /person/[:id]
public class Person {
public List Houses {get; set;}
public List Cars {get; set;}
}
// /person/:id/cars
public class PersonCars {
public List Cars {get; set;}
}
// /person/:id/houses
public class PersonHouses {
public List Houses {get; set;}
}
These are just the simple ones but /person/:id/core actually has multiple fields that I know have to repeat.
What the fuck, stop. You're doing it wrong.
thanks for the input NEET
Sorry dude you fucked up somewhere.
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.
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.
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(rawJsonFromApi);
learning assembly
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.
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.
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.
correct
You don't learn assembly, you program with it.
You learn javascript because it makes no sense.
>statically-typed, compiled Scheme
find a flaw
literally the best of every world: safe, performant, expressive
>statically typed scheme
How? What point? Either a function is defined for an argument, or it isn't.
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!
formal verification and auto proofs
Weird how they're arguing. It's not bound to an object it just needs scope resolution.
>performant
Meaningless word. Also I doubt it's true if what you meant was efficient, by common performance standards.
>no reader macros
>no unhygienic macros
>not Common Lisp so lacks libraries and is not compatitble with any standardized language
No it isn't. Actually try working in a large project instead of your shitty 100 LoC scripts
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).
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.
t. webfag
Most Schemes do have unhygenic macros though. It's just not necessary in most cases.
You should avoid metaprogramming whenever possible anyway.
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.
Is that the best you can do?
>C++
>C#
"Intelligent"
Can't believe I share this thread with brainlets like these
uninstalling octave and installing matlab
You can leave anytime.
No, you should go back to your shitty webdev thread. It's meant for containing single digit brainlets such as yourself
dynamic typing is technically strongly typed programming that hides it from you through inference
You will never make it. Mark my words.
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.
Scheme is typed whether you realize it or not.
Better to annotate it to catch a shite tonne of errors and increase performance.
>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.
Did I ever say so, brainlet?
Ok. Scheme has more tools for metaprogramming than Lisp does. Classic unhygenic macros and syntax-rules.
>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?
Explain.
In c++, do you use "\n" or endl to print a newline? Is one of these more acceptable?
>not implementing hygienic macros with unhygienic macros
Scheme is shit and unhygienic macros are in it are not standized.
How so? I think I know what you mean, and I think you're incorrect, but I'd rather not assume.
It is typed, but the type system does not get in your way. Annotation just makes shit harder to read.
\n
Because C++ had issues with endl and we should never ever move past that.
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.
your objects/values are being passed around as tagged memory and get inferred when parsed
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.
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.
That does not have anything to do with Scheme programming. Leave the implementation details to the implementations.
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
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
>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.
(: function-name ((list-of any) -> any)))
wowwwwwww
>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
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
I have 2 reference manuals open so I'm not sure how little learning is required here user.
Wow, Haskell with parenthesis
For what purpose?
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
Literally Clojure + clojure.typed
>haskell invented type signatures
do you kiss your mother with that brain?
except without a fucking JVM
>literally clojure
clojure is not even a lisp.
explain this pls
What's the car and cdr of the empty list?
> implying the JVM is bad
>haskell is not the most widely used strongly typed functional language
Depends on the implementation, in some they're undefined, for others they return the empty list.
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?
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.
empty list
>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.
Do explain to me how it should be done.
errors.
>therefore anything with typing is haskell
bulletproof logic
>Linking it to newline is just retarded.
no you're retarded
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.
You apparently have this:
public class PersonHouses {
public List Houses {get; set;}
}
This is unnecessary. It is not needed. If you want a list of House, then use a List.
I'm still not certain why you think you need those classes. You can deserialize directly into List 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.
...
in real language like Common Lisp.
Nobody cares about your 1GB/s garbage generation.
please use safeHead
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
...
dumb not anime poster
nil is the same thing as '() which is empty list. Dumb faggot.
I never implied it wasn't.
I'd rather have the Haskell error than the CL valid response though.
How it should be
How'd you get this, senpai?
yeah anybody using clojure should just leave.
it's chicken scheme, not CL
Metaprogramming is in my soul.
Cool. Having a browse through the docs now.
>he'd rather his program crash than not
Silently failing is much deadlier than the alternative.
metaprogramming is a tool for crippled languages
I hope you don't write code for pacemakers.
>he has to work around his language instead of making it work for him
If my function is
[a] -> a
I don't want a list.
>well defined behavior
>silently failing
It's not failing if it's doing what it's supposed. Haskell crashes just fuck you.
>tfw still NO interesting summer project
why even live?
> an Exception means a crash
There is something called 'error handling', you know.
>work around his language
That's what metaprogramming is
In good languages you just do regular programming